| |
| |
|
|
| load("@rules_license//rules:license.bzl", "license") |
|
|
| package( |
| default_applicable_licenses = [ |
| "//:license", |
| ], |
| default_visibility = ["//visibility:public"], |
| ) |
|
|
| license( |
| name = "license", |
| package_name = "gemma_cpp", |
| ) |
|
|
| |
| licenses(["notice"]) |
|
|
| exports_files(["LICENSE"]) |
|
|
| cc_library( |
| name = "ops", |
| hdrs = ["gemma/ops.h"], |
| deps = [ |
| "//compression:compress", |
| "@hwy//:algo", |
| "@hwy//:dot", |
| "@hwy//:hwy", |
| "@hwy//:math", |
| "@hwy//:matvec", |
| "@hwy//:profiler", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_test( |
| name = "ops_test", |
| size = "small", |
| timeout = "long", |
| srcs = ["gemma/ops_test.cc"], |
| local_defines = ["HWY_IS_TEST"], |
| |
| tags = ["hwy_ops_test"], |
| deps = [ |
| ":ops", |
| "@googletest//:gtest_main", |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:hwy_test_util", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "common", |
| srcs = ["gemma/common.cc"], |
| hdrs = [ |
| "gemma/common.h", |
| "gemma/configs.h", |
| ], |
| deps = [ |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "weights", |
| srcs = ["gemma/weights.cc"], |
| hdrs = ["gemma/weights.h"], |
| deps = [ |
| ":common", |
| "//compression:compress", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:profiler", |
| "@hwy//:stats", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "weights_raw", |
| hdrs = ["gemma/weights_raw.h"], |
| deps = [ |
| ":common", |
| ":weights", |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "gemma_lib", |
| srcs = [ |
| "gemma/gemma.cc", |
| ], |
| hdrs = [ |
| "gemma/activations.h", |
| "gemma/gemma.h", |
| ], |
| textual_hdrs = [ |
| |
| |
| ], |
| deps = [ |
| ":common", |
| ":ops", |
| ":weights", |
| "//compression:compress", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:matvec", |
| "@hwy//:nanobenchmark", |
| "@hwy//:profiler", |
| "@hwy//:thread_pool", |
| "@com_google_sentencepiece//:sentencepiece_processor", |
| ], |
| ) |
|
|
| cc_library( |
| name = "cross_entropy", |
| srcs = ["gemma/cross_entropy.cc"], |
| hdrs = ["gemma/cross_entropy.h"], |
| deps = [ |
| ":common", |
| ":gemma_lib", |
| "@hwy//:hwy", |
| ], |
| ) |
|
|
| cc_library( |
| name = "args", |
| hdrs = ["util/args.h"], |
| deps = [ |
| "//compression:io", |
| "@hwy//:hwy", |
| ], |
| ) |
|
|
| cc_library( |
| name = "app", |
| hdrs = ["util/app.h"], |
| deps = [ |
| ":args", |
| ":common", |
| ":gemma_lib", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| "@hwy//:topology", |
| ], |
| ) |
|
|
| cc_library( |
| name = "benchmark_helper", |
| srcs = ["gemma/benchmark_helper.cc"], |
| hdrs = ["gemma/benchmark_helper.h"], |
| deps = [ |
| ":app", |
| ":args", |
| ":common", |
| ":cross_entropy", |
| ":gemma_lib", |
| |
| "@benchmark//:benchmark", |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:nanobenchmark", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_test( |
| name = "gemma_test", |
| srcs = ["gemma/gemma_test.cc"], |
| |
| tags = [ |
| "local", |
| "manual", |
| "no_tap", |
| ], |
| deps = [ |
| ":app", |
| ":args", |
| ":benchmark_helper", |
| ":common", |
| ":cross_entropy", |
| ":gemma_lib", |
| ":ops", |
| "@googletest//:gtest_main", |
| "//compression:io", |
| "@hwy//:hwy_test_util", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "gemma", |
| srcs = ["gemma/run.cc"], |
| deps = [ |
| ":app", |
| ":args", |
| ":benchmark_helper", |
| ":common", |
| ":gemma_lib", |
| |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:nanobenchmark", |
| "@hwy//:profiler", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "compress_weights", |
| srcs = ["gemma/compress_weights.cc"], |
| deps = [ |
| ":args", |
| ":common", |
| ":gemma_lib", |
| ":weights", |
| ":weights_raw", |
| |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:nanobenchmark", |
| "@hwy//:profiler", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "single_benchmark", |
| srcs = ["gemma/benchmark.cc"], |
| deps = [ |
| ":app", |
| ":args", |
| ":benchmark_helper", |
| ":common", |
| ":cross_entropy", |
| ":gemma_lib", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:nanobenchmark", |
| "@hwy//:thread_pool", |
| "@nlohmann_json//:json", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "benchmarks", |
| srcs = ["gemma/benchmarks.cc"], |
| deps = [ |
| ":benchmark_helper", |
| "@benchmark//:benchmark", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "debug_prompt", |
| srcs = [ |
| "debug_prompt.cc", |
| ], |
| deps = [ |
| ":app", |
| ":args", |
| ":benchmark_helper", |
| ":gemma_lib", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| "@nlohmann_json//:json", |
| ], |
| ) |
|
|
| cc_binary( |
| name = "gemma_mmlu", |
| srcs = ["gemma/run_mmlu.cc"], |
| deps = [ |
| ":app", |
| ":args", |
| ":benchmark_helper", |
| ":gemma_lib", |
| "//compression:io", |
| "@hwy//:hwy", |
| "@hwy//:profiler", |
| "@hwy//:thread_pool", |
| "@nlohmann_json//:json", |
| ], |
| ) |
|
|
| cc_library( |
| name = "prompt", |
| hdrs = ["backprop/prompt.h"], |
| deps = [], |
| ) |
|
|
| cc_library( |
| name = "sampler", |
| hdrs = ["backprop/sampler.h"], |
| deps = [ |
| ":prompt", |
| ], |
| ) |
|
|
| cc_library( |
| name = "backprop", |
| srcs = [ |
| "backprop/backward.cc", |
| "backprop/forward.cc", |
| ], |
| hdrs = [ |
| "backprop/backward.h", |
| "backprop/backward-inl.h", |
| "backprop/forward.h", |
| "backprop/forward-inl.h", |
| ], |
| deps = [ |
| ":common", |
| ":gemma_lib", |
| ":ops", |
| ":prompt", |
| ":weights", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "backprop_scalar", |
| hdrs = [ |
| "backprop/backward_scalar.h", |
| "backprop/common_scalar.h", |
| "backprop/forward_scalar.h", |
| ], |
| deps = [ |
| ":common", |
| ":gemma_lib", |
| ":prompt", |
| ":weights_raw", |
| ], |
| ) |
|
|
| cc_test( |
| name = "backward_scalar_test", |
| size = "large", |
| srcs = [ |
| "backprop/backward_scalar_test.cc", |
| "backprop/test_util.h", |
| ], |
| deps = [ |
| ":backprop_scalar", |
| ":prompt", |
| ":sampler", |
| ":weights_raw", |
| "@googletest//:gtest_main", |
| ], |
| ) |
|
|
| cc_test( |
| name = "backward_test", |
| size = "large", |
| srcs = [ |
| "backprop/backward_test.cc", |
| "backprop/test_util.h", |
| ], |
| deps = [ |
| ":backprop", |
| ":backprop_scalar", |
| ":gemma_lib", |
| ":ops", |
| ":sampler", |
| ":weights_raw", |
| "@googletest//:gtest_main", |
| "@hwy//:hwy", |
| "@hwy//:hwy_test_util", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_library( |
| name = "optimizer", |
| srcs = [ |
| "backprop/optimizer.cc", |
| ], |
| hdrs = [ |
| "backprop/optimizer.h", |
| ], |
| deps = [ |
| ":common", |
| ":weights", |
| "//compression:compress", |
| "@hwy//:hwy", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|
| cc_test( |
| name = "optimize_test", |
| srcs = [ |
| "backprop/optimize_test.cc", |
| ], |
| deps = [ |
| ":backprop", |
| ":common", |
| ":gemma_lib", |
| ":optimizer", |
| ":prompt", |
| ":sampler", |
| ":weights", |
| "@googletest//:gtest_main", |
| "@hwy//:thread_pool", |
| ], |
| ) |
|
|