Skip to content

Commit e4e02a1

Browse files
Ikko Eltociear Ashiminedan-zheng
Ikko Eltociear Ashimine
authored andcommitted
Copybara import of the project:
-- 5c7dbc6 by Ikko Eltociear Ashimine <[email protected]>: Update build.yml dispath -> dispatch COPYBARA_INTEGRATE_REVIEW=google#22 from eltociear:patch-1 5c7dbc6 PiperOrigin-RevId: 609827161
1 parent 7698e3c commit e4e02a1

File tree

4 files changed

+279
-4
lines changed

4 files changed

+279
-4
lines changed

BUILD

+116
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# gemma.cpp is a lightweight, standalone C++ inference engine for the Gemma
2+
# foundation models from Google.
3+
4+
load("@rules_license//rules:license.bzl", "license")
5+
6+
package(
7+
default_applicable_licenses = ["//:license"],
8+
default_visibility = ["//visibility:public"],
9+
)
10+
11+
license(
12+
name = "license",
13+
package_name = "gemma_cpp",
14+
)
15+
16+
# Dual-licensed Apache 2 and 3-clause BSD.
17+
licenses(["notice"])
18+
19+
exports_files(["LICENSE"])
20+
21+
cc_library(
22+
name = "transformer_ops",
23+
hdrs = [
24+
"ops.h",
25+
],
26+
deps = [
27+
"//compression:compress",
28+
# copybara:import_next_line:hwy
29+
"//:algo",
30+
# copybara:import_next_line:hwy
31+
"//:dot",
32+
# copybara:import_next_line:hwy
33+
"//:hwy",
34+
# copybara:import_next_line:hwy
35+
"//:math",
36+
# copybara:import_next_line:hwy
37+
"//:matvec",
38+
# copybara:import_next_line:hwy
39+
"//:profiler",
40+
# copybara:import_next_line:hwy
41+
"//:thread_pool",
42+
"//hwy/contrib/sort:vqsort",
43+
],
44+
)
45+
46+
cc_library(
47+
name = "args",
48+
hdrs = [
49+
"util/args.h",
50+
],
51+
deps = [
52+
# copybara:import_next_line:hwy
53+
"//:hwy",
54+
],
55+
)
56+
57+
cc_library(
58+
name = "app",
59+
hdrs = [
60+
"util/app.h",
61+
],
62+
deps = [
63+
":args",
64+
# copybara:import_next_line:hwy
65+
"//:hwy",
66+
],
67+
)
68+
69+
cc_library(
70+
name = "gemma_lib",
71+
srcs = [
72+
"gemma.cc",
73+
],
74+
hdrs = [
75+
"configs.h",
76+
"gemma.h",
77+
],
78+
deps = [
79+
":args",
80+
":transformer_ops",
81+
"//base",
82+
"//compression:compress",
83+
# copybara:import_next_line:hwy
84+
"//:hwy",
85+
# copybara:import_next_line:hwy
86+
"//:matvec",
87+
# copybara:import_next_line:hwy
88+
"//:nanobenchmark", # timer
89+
# copybara:import_next_line:hwy
90+
"//:profiler",
91+
# copybara:import_next_line:hwy
92+
"//:thread_pool",
93+
":sentencepiece_processor",
94+
],
95+
)
96+
97+
cc_binary(
98+
name = "gemma",
99+
srcs = [
100+
"run.cc",
101+
],
102+
deps = [
103+
":app",
104+
":args",
105+
":gemma_lib",
106+
"//compression:compress",
107+
# copybara:import_next_line:hwy
108+
"//:hwy",
109+
# copybara:import_next_line:hwy
110+
"//:nanobenchmark",
111+
# copybara:import_next_line:hwy
112+
"//:profiler",
113+
# copybara:import_next_line:hwy
114+
"//:thread_pool",
115+
],
116+
)

compression/BUILD

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# Weight compression, I/O and analysis
2+
3+
package(
4+
default_applicable_licenses = ["//third_party/gemma_cpp:license"],
5+
default_visibility = [
6+
"//learning/gemini/prod/contrib/gemini_cpp:__subpackages__",
7+
"//third_party/gemma_cpp:__subpackages__",
8+
],
9+
)
10+
11+
cc_library(
12+
name = "blob_store",
13+
srcs = [
14+
"blob_store.cc",
15+
],
16+
hdrs = [
17+
"blob_store.h",
18+
],
19+
deps = [
20+
# copybara:import_next_line:hwy
21+
"//:hwy",
22+
# copybara:import_next_line:hwy
23+
"//:thread_pool",
24+
],
25+
)
26+
27+
cc_library(
28+
name = "stats",
29+
srcs = [
30+
"stats.cc",
31+
],
32+
hdrs = [
33+
"distortion.h",
34+
"stats.h",
35+
],
36+
deps = [
37+
# copybara:import_next_line:hwy
38+
"//:hwy",
39+
],
40+
)
41+
42+
cc_library(
43+
name = "sfp",
44+
hdrs = [
45+
"sfp.h",
46+
],
47+
textual_hdrs = [
48+
"sfp-inl.h",
49+
],
50+
deps = [
51+
# copybara:import_next_line:hwy
52+
"//:hwy",
53+
],
54+
)
55+
56+
cc_test(
57+
name = "sfp_test",
58+
size = "small",
59+
srcs = ["sfp_test.cc"],
60+
features = ["fully_static_link"],
61+
linkstatic = True,
62+
local_defines = ["HWY_IS_TEST"],
63+
# for test_suite.
64+
tags = ["hwy_ops_test"],
65+
deps = [
66+
":sfp",
67+
":stats",
68+
"//testing/base/public:gunit_main_no_google3",
69+
# copybara:import_next_line:hwy
70+
"//:hwy",
71+
# copybara:import_next_line:hwy
72+
"//:hwy_test_util",
73+
# copybara:import_next_line:hwy
74+
"//:nanobenchmark",
75+
# copybara:import_next_line:hwy
76+
"//:thread_pool",
77+
],
78+
)
79+
80+
cc_library(
81+
name = "nuq",
82+
hdrs = [
83+
"nuq.h",
84+
],
85+
textual_hdrs = [
86+
"nuq-inl.h",
87+
],
88+
deps = [
89+
":sfp",
90+
# copybara:import_next_line:hwy
91+
"//:hwy",
92+
"//third_party/highway/hwy/contrib/sort:vqsort",
93+
],
94+
)
95+
96+
cc_test(
97+
name = "nuq_test",
98+
size = "small",
99+
srcs = ["nuq_test.cc"],
100+
features = ["fully_static_link"],
101+
linkstatic = True,
102+
local_defines = ["HWY_IS_TEST"],
103+
# for test_suite.
104+
tags = ["hwy_ops_test"],
105+
deps = [
106+
":nuq",
107+
":sfp",
108+
":stats",
109+
"//testing/base/public:gunit_main_no_google3",
110+
# copybara:import_next_line:hwy
111+
"//:hwy",
112+
# copybara:import_next_line:hwy
113+
"//:hwy_test_util",
114+
# copybara:import_next_line:hwy
115+
"//:nanobenchmark",
116+
],
117+
)
118+
119+
cc_library(
120+
name = "compress",
121+
hdrs = [
122+
"compress.h",
123+
"nuq.h",
124+
"sfp.h",
125+
],
126+
textual_hdrs = [
127+
"compress-inl.h",
128+
],
129+
deps = [
130+
":blob_store",
131+
":nuq",
132+
":sfp",
133+
":stats",
134+
# copybara:import_next_line:hwy
135+
"//:dot",
136+
# copybara:import_next_line:hwy
137+
"//:hwy",
138+
# copybara:import_next_line:hwy
139+
"//:thread_pool",
140+
],
141+
)
142+
143+
# For internal experimentation
144+
cc_library(
145+
name = "analyze",
146+
textual_hdrs = [
147+
"analyze.h",
148+
],
149+
deps = [
150+
":nuq",
151+
":sfp",
152+
":stats",
153+
# copybara:import_next_line:hwy
154+
"//:hwy",
155+
# copybara:import_next_line:hwy
156+
"//:nanobenchmark", # timer
157+
# copybara:import_next_line:hwy
158+
"//:thread_pool",
159+
"//third_party/highway/hwy/contrib/sort:vqsort",
160+
],
161+
)

gemma.cc

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,7 @@
6060
#include "hwy/aligned_allocator.h"
6161
#include "hwy/base.h"
6262
#include "hwy/contrib/thread_pool/thread_pool.h"
63-
// copybara:import_next_line:sentencepiece
64-
#include "src/sentencepiece_processor.h"
63+
#include "sentencepiece_processor.h"
6564

6665
namespace gcpp {
6766

gemma.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@
3333
#include "hwy/aligned_allocator.h"
3434
#include "hwy/base.h" // hwy::bfloat16_t
3535
#include "hwy/contrib/thread_pool/thread_pool.h"
36-
// copybara:import_next_line:sentencepiece
37-
#include "src/sentencepiece_processor.h"
36+
#include "sentencepiece_processor.h"
3837

3938
namespace gcpp {
4039

0 commit comments

Comments
 (0)