gemma.cpp/compression/BUILD.bazel

225 lines
4.5 KiB
Python

# Weight compression, I/O and analysis
package(
default_applicable_licenses = [
"//:license", # Placeholder comment, do not modify
],
default_visibility = [
# Placeholder for internal visibility,
"//:__subpackages__", # Placeholder, do not modify
],
)
config_setting(
name = "android",
constraint_values = [
"@platforms//os:android",
],
visibility = ["//visibility:private"],
)
FILE_DEPS = select({
"//conditions:default": [
# Placeholder for io deps, do not remove
],
":android": [],
})
cc_library(
name = "io",
srcs = [
"io.cc",
# Placeholder for io backend, do not remove
],
hdrs = ["io.h"],
deps = [
"@highway//:hwy",
] + FILE_DEPS,
)
cc_library(
name = "blob_store",
srcs = ["blob_store.cc"],
hdrs = ["blob_store.h"],
deps = [
":io",
"@highway//:hwy",
"@highway//:thread_pool",
],
)
cc_library(
name = "distortion",
hdrs = [
"distortion.h",
"shared.h",
],
deps = [
"@highway//:hwy",
"@highway//:stats",
"@highway//hwy/contrib/sort:vqsort",
],
)
cc_test(
name = "distortion_test",
size = "small",
srcs = ["distortion_test.cc"],
deps = [
":distortion",
"@googletest//:gtest_main", # buildcleaner: keep
"//:test_util",
"@highway//:hwy_test_util",
"@highway//:nanobenchmark", # Unpredictable1
],
)
cc_library(
name = "sfp",
hdrs = ["shared.h"],
textual_hdrs = ["sfp-inl.h"],
deps = [
"@highway//:hwy",
],
)
cc_library(
name = "nuq",
hdrs = ["shared.h"],
textual_hdrs = ["nuq-inl.h"],
deps = [
":sfp",
"//:basics",
"@highway//:hwy",
"@highway//hwy/contrib/sort:vqsort",
],
)
cc_library(
name = "test_util",
textual_hdrs = [
"test_util-inl.h",
],
deps = [
":compress",
":distortion",
"@highway//:hwy",
"@highway//:hwy_test_util",
],
)
cc_test(
name = "sfp_test",
size = "small",
srcs = ["sfp_test.cc"],
features = ["fully_static_link"],
linkstatic = True,
local_defines = ["HWY_IS_TEST"],
# for test_suite.
tags = ["hwy_ops_test"],
deps = [
":distortion",
":sfp",
"@googletest//:gtest_main", # buildcleaner: keep
"//:test_util",
"@highway//:hwy",
"@highway//:hwy_test_util",
"@highway//:nanobenchmark",
],
)
cc_test(
name = "nuq_test",
size = "small",
timeout = "long",
srcs = ["nuq_test.cc"],
features = ["fully_static_link"],
linkstatic = True,
local_defines = ["HWY_IS_TEST"],
# for test_suite.
tags = ["hwy_ops_test"],
deps = [
":distortion",
":nuq",
":sfp",
"@googletest//:gtest_main", # buildcleaner: keep
"//:test_util",
"@highway//:hwy",
"@highway//:hwy_test_util",
"@highway//:nanobenchmark",
],
)
cc_library(
name = "compress",
srcs = ["compress.cc"],
hdrs = [
"compress.h",
"shared.h",
],
textual_hdrs = ["compress-inl.h"],
deps = [
":blob_store",
":distortion",
":io",
":nuq",
":sfp",
"@highway//:hwy",
"@highway//:nanobenchmark",
"@highway//:profiler",
"@highway//:stats",
"@highway//:thread_pool",
],
)
cc_test(
name = "compress_test",
size = "small",
timeout = "long",
srcs = ["compress_test.cc"],
features = ["fully_static_link"],
linkstatic = True,
local_defines = ["HWY_IS_TEST"],
# for test_suite.
tags = ["hwy_ops_test"],
deps = [
":compress",
":distortion",
":test_util",
"@googletest//:gtest_main", # buildcleaner: keep
"//:test_util",
"@highway//:hwy",
"@highway//:hwy_test_util",
"@highway//:thread_pool",
],
)
# For internal experimentation
cc_library(
name = "analyze",
textual_hdrs = ["analyze.h"],
deps = [
":nuq",
":sfp",
"@highway//:hwy",
"@highway//:stats",
"@highway//:thread_pool",
"@highway//hwy/contrib/sort:vqsort",
],
)
cc_binary(
name = "compress_weights",
srcs = ["compress_weights.cc"],
deps = [
":compress",
":io",
"//:allocator",
"//:args",
"//:common",
"//:weights",
"@highway//:hwy",
"@highway//:thread_pool",
],
)