Skip to content

Commit a16df06

Browse files
author
The gemma.cpp Authors
committed
Toward Bazel support: expose BUILD, add WORKSPACE/MODULE.bazel. Refs google#16
PiperOrigin-RevId: 609734560
1 parent 7c9954d commit a16df06

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

MODULE.bazel

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module(
2+
name = "gemma",
3+
version = "0.1.0",
4+
)
5+
6+
bazel_dep(
7+
name = "rules_license",
8+
version = "0.0.7",
9+
)
10+
11+
bazel_dep(
12+
name = "com_google_sentencepiece",
13+
version = "0.1.96",
14+
)

WORKSPACE

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
workspace(name = "gemma")
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
5+
6+
maybe(
7+
http_archive,
8+
name = "rules_license",
9+
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
10+
urls = [
11+
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
12+
],
13+
)
14+
15+
maybe(
16+
http_archive,
17+
name = "com_google_sentencepiece",
18+
sha256 = "8409b0126ebd62b256c685d5757150cf7fcb2b92a2f2b98efb3f38fc36719754",
19+
strip_prefix = "sentencepiece-0.1.96",
20+
urls = ["https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip"],
21+
build_file = "@//third_party:sentencepiece.bazel",
22+
patches = ["@//third_party:com_google_sentencepiece.patch"],
23+
patch_args = ["-p1"],
24+
)

gemma.cc

+1-3
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#include "hwy/contrib/thread_pool/thread_pool.h"
6363
// copybara:import_next_line:sentencepiece
6464
#include "src/sentencepiece_processor.h"
65-
// #include "third_party/sentencepiece/src/util.h"
6665

6766
namespace gcpp {
6867

@@ -205,8 +204,7 @@ struct Activations {
205204
static constexpr size_t kQKVDim = TConfig::kQKVDim;
206205
static constexpr size_t kHeads = TConfig::kHeads;
207206
static constexpr size_t kKVHeads = TConfig::kKVHeads;
208-
static constexpr size_t kCachePosSize =
209-
TConfig::kLayers * kKVHeads * kQKVDim;
207+
static constexpr size_t kCachePosSize = TConfig::kLayers * kKVHeads * kQKVDim;
210208
static constexpr size_t kCacheLayerSize = kKVHeads * kQKVDim;
211209

212210
std::array<float, kBatchSize * kModelDim> x; // input

gemma.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
#include <string>
2525
#include <vector>
2626

27-
// copybara:import_next_line:gemma_cpp
28-
#include "configs.h" // kSeqLen
2927
// copybara:import_next_line:gemma_cpp
3028
#include "compression/compress.h" // SfpStream/NuqStream
3129
// copybara:import_next_line:gemma_cpp
30+
#include "configs.h" // kSeqLen
31+
// copybara:import_next_line:gemma_cpp
3232
#include "util/args.h" // ArgsBase
3333
#include "hwy/aligned_allocator.h"
3434
#include "hwy/base.h" // hwy::bfloat16_t

0 commit comments

Comments
 (0)