mirror of https://github.com/google/gemma.cpp.git
173 lines
3.1 KiB
Python
173 lines
3.1 KiB
Python
# gemma.cpp is a lightweight, standalone C++ inference engine for the Gemma
|
|
# foundation models from Google.
|
|
|
|
load("@rules_license//rules:license.bzl", "license")
|
|
|
|
package(
|
|
default_applicable_licenses = [
|
|
"//:license", # Placeholder comment, do not modify
|
|
],
|
|
default_visibility = ["//visibility:public"],
|
|
)
|
|
|
|
license(
|
|
name = "license",
|
|
package_name = "gemma_cpp",
|
|
)
|
|
|
|
# Dual-licensed Apache 2 and 3-clause BSD.
|
|
licenses(["notice"])
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
cc_library(
|
|
name = "ops",
|
|
hdrs = [
|
|
"ops.h",
|
|
],
|
|
deps = [
|
|
"//compression:compress",
|
|
"@hwy//:algo",
|
|
"@hwy//:dot",
|
|
"@hwy//:hwy",
|
|
"@hwy//:math",
|
|
"@hwy//:matvec",
|
|
"@hwy//:profiler",
|
|
"@hwy//:thread_pool",
|
|
"@hwy//hwy/contrib/sort:vqsort",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "ops_test",
|
|
size = "small",
|
|
srcs = ["ops_test.cc"],
|
|
local_defines = ["HWY_IS_TEST"],
|
|
# for test_suite.
|
|
tags = ["hwy_ops_test"],
|
|
deps = [
|
|
":ops",
|
|
"@googletest//:gtest_main",
|
|
"@hwy//:hwy",
|
|
"@hwy//:hwy_test_util",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "args",
|
|
hdrs = [
|
|
"util/args.h",
|
|
],
|
|
deps = [
|
|
"@hwy//:hwy",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "gemma_lib",
|
|
srcs = [
|
|
"gemma.cc",
|
|
],
|
|
hdrs = [
|
|
"configs.h",
|
|
"gemma.h",
|
|
],
|
|
deps = [
|
|
":args",
|
|
":ops",
|
|
# "//base",
|
|
"//compression:compress",
|
|
"@hwy//:hwy",
|
|
"@hwy//:matvec",
|
|
"@hwy//:nanobenchmark", # timer
|
|
"@hwy//:profiler",
|
|
"@hwy//:thread_pool",
|
|
"@com_google_sentencepiece//:sentencepiece_processor",
|
|
],
|
|
)
|
|
|
|
cc_test(
|
|
name = "gemma_test",
|
|
srcs = ["gemma_test.cc"],
|
|
# Requires model files
|
|
tags = [
|
|
"local",
|
|
"manual",
|
|
"no_tap",
|
|
],
|
|
deps = [
|
|
":args",
|
|
":gemma_lib",
|
|
":ops",
|
|
"@googletest//:gtest_main",
|
|
"@hwy//:hwy_test_util",
|
|
"@hwy//:thread_pool",
|
|
],
|
|
)
|
|
|
|
cc_library(
|
|
name = "app",
|
|
hdrs = [
|
|
"util/app.h",
|
|
],
|
|
deps = [
|
|
":args",
|
|
":gemma_lib",
|
|
"@hwy//:hwy",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "gemma",
|
|
srcs = [
|
|
"run.cc",
|
|
],
|
|
deps = [
|
|
":app",
|
|
":args",
|
|
":gemma_lib",
|
|
# "//base",
|
|
"//compression:compress",
|
|
"@hwy//:hwy",
|
|
"@hwy//:nanobenchmark",
|
|
"@hwy//:profiler",
|
|
"@hwy//:thread_pool",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "compress_weights",
|
|
srcs = [
|
|
"compress_weights.cc",
|
|
],
|
|
deps = [
|
|
":args",
|
|
":gemma_lib",
|
|
# "//base",
|
|
"//compression:compress",
|
|
"@hwy//:hwy",
|
|
"@hwy//:nanobenchmark",
|
|
"@hwy//:profiler",
|
|
"@hwy//:thread_pool",
|
|
],
|
|
)
|
|
|
|
cc_binary(
|
|
name = "benchmark",
|
|
srcs = [
|
|
"benchmark.cc",
|
|
],
|
|
deps = [
|
|
":app",
|
|
":args",
|
|
":gemma_lib",
|
|
# "//base",
|
|
"//compression:compress",
|
|
"@hwy//:hwy",
|
|
"@hwy//:nanobenchmark",
|
|
"@hwy//:profiler",
|
|
"@hwy//:thread_pool",
|
|
"//third_party/json",
|
|
],
|
|
)
|