Toward Bazel support: expose BUILD, add WORKSPACE/MODULE.bazel. Refs #16

PiperOrigin-RevId: 609734560
This commit is contained in:
The gemma.cpp Authors 2024-02-23 08:22:48 -08:00
parent 7c9954dea5
commit a16df06cf2
4 changed files with 41 additions and 5 deletions

14
MODULE.bazel Normal file
View File

@ -0,0 +1,14 @@
module(
name = "gemma",
version = "0.1.0",
)
bazel_dep(
name = "rules_license",
version = "0.0.7",
)
bazel_dep(
name = "com_google_sentencepiece",
version = "0.1.96",
)

24
WORKSPACE Normal file
View File

@ -0,0 +1,24 @@
workspace(name = "gemma")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
maybe(
http_archive,
name = "rules_license",
sha256 = "4531deccb913639c30e5c7512a054d5d875698daeb75d8cf90f284375fe7c360",
urls = [
"https://github.com/bazelbuild/rules_license/releases/download/0.0.7/rules_license-0.0.7.tar.gz",
],
)
maybe(
http_archive,
name = "com_google_sentencepiece",
sha256 = "8409b0126ebd62b256c685d5757150cf7fcb2b92a2f2b98efb3f38fc36719754",
strip_prefix = "sentencepiece-0.1.96",
urls = ["https://github.com/google/sentencepiece/archive/refs/tags/v0.1.96.zip"],
build_file = "@//third_party:sentencepiece.bazel",
patches = ["@//third_party:com_google_sentencepiece.patch"],
patch_args = ["-p1"],
)

View File

@ -62,7 +62,6 @@
#include "hwy/contrib/thread_pool/thread_pool.h"
// copybara:import_next_line:sentencepiece
#include "src/sentencepiece_processor.h"
// #include "third_party/sentencepiece/src/util.h"
namespace gcpp {
@ -205,8 +204,7 @@ struct Activations {
static constexpr size_t kQKVDim = TConfig::kQKVDim;
static constexpr size_t kHeads = TConfig::kHeads;
static constexpr size_t kKVHeads = TConfig::kKVHeads;
static constexpr size_t kCachePosSize =
TConfig::kLayers * kKVHeads * kQKVDim;
static constexpr size_t kCachePosSize = TConfig::kLayers * kKVHeads * kQKVDim;
static constexpr size_t kCacheLayerSize = kKVHeads * kQKVDim;
std::array<float, kBatchSize * kModelDim> x; // input

View File

@ -24,11 +24,11 @@
#include <string>
#include <vector>
// copybara:import_next_line:gemma_cpp
#include "configs.h" // kSeqLen
// copybara:import_next_line:gemma_cpp
#include "compression/compress.h" // SfpStream/NuqStream
// copybara:import_next_line:gemma_cpp
#include "configs.h" // kSeqLen
// copybara:import_next_line:gemma_cpp
#include "util/args.h" // ArgsBase
#include "hwy/aligned_allocator.h"
#include "hwy/base.h" // hwy::bfloat16_t