Move benchmark_helper to evals/, weights_raw to compression/.

PiperOrigin-RevId: 650155983
This commit is contained in:
Jan Wassenberg 2024-07-08 01:12:28 -07:00 committed by Copybara-Service
parent cdebcc3533
commit cbb67b4ee0
18 changed files with 51 additions and 50 deletions

View File

@ -82,18 +82,6 @@ cc_library(
], ],
) )
cc_library(
name = "weights_raw",
hdrs = ["gemma/weights_raw.h"],
deps = [
":common",
":weights",
"//compression:compress",
"@hwy//:hwy",
"@hwy//:thread_pool",
],
)
cc_library( cc_library(
name = "tokenizer", name = "tokenizer",
srcs = ["gemma/tokenizer.cc"], srcs = ["gemma/tokenizer.cc"],
@ -205,8 +193,8 @@ cc_library(
cc_library( cc_library(
name = "benchmark_helper", name = "benchmark_helper",
srcs = ["gemma/benchmark_helper.cc"], srcs = ["evals/benchmark_helper.cc"],
hdrs = ["gemma/benchmark_helper.h"], hdrs = ["evals/benchmark_helper.h"],
deps = [ deps = [
":app", ":app",
":args", ":args",
@ -369,7 +357,7 @@ cc_library(
":common", ":common",
":gemma_lib", ":gemma_lib",
":prompt", ":prompt",
":weights_raw", "//compression:weights_raw",
], ],
) )
@ -386,8 +374,8 @@ cc_test(
":gemma_lib", ":gemma_lib",
":prompt", ":prompt",
":sampler", ":sampler",
":weights_raw",
"@googletest//:gtest_main", "@googletest//:gtest_main",
"//compression:weights_raw",
], ],
) )
@ -409,8 +397,8 @@ cc_test(
":gemma_lib", ":gemma_lib",
":ops", ":ops",
":sampler", ":sampler",
":weights_raw",
"@googletest//:gtest_main", "@googletest//:gtest_main",
"//compression:weights_raw",
"@hwy//:hwy", "@hwy//:hwy",
"@hwy//:hwy_test_util", "@hwy//:hwy_test_util",
"@hwy//:thread_pool", "@hwy//:thread_pool",

View File

@ -49,6 +49,7 @@ set(SOURCES
compression/sfp.h compression/sfp.h
compression/sfp-inl.h compression/sfp-inl.h
compression/test_util.h compression/test_util.h
compression/weights_raw.h
backprop/activations.h backprop/activations.h
backprop/backward.cc backprop/backward.cc
backprop/backward.h backprop/backward.h
@ -61,11 +62,11 @@ set(SOURCES
backprop/forward_scalar.h backprop/forward_scalar.h
backprop/optimizer.cc backprop/optimizer.cc
backprop/optimizer.h backprop/optimizer.h
evals/benchmark_helper.cc
evals/benchmark_helper.h
evals/cross_entropy.cc evals/cross_entropy.cc
evals/cross_entropy.h evals/cross_entropy.h
gemma/activations.h gemma/activations.h
gemma/benchmark_helper.cc
gemma/benchmark_helper.h
gemma/common.cc gemma/common.cc
gemma/common.h gemma/common.h
gemma/configs.h gemma/configs.h
@ -95,7 +96,6 @@ set(SOURCES
gemma/ops.h gemma/ops.h
gemma/tokenizer.cc gemma/tokenizer.cc
gemma/tokenizer.h gemma/tokenizer.h
gemma/weights_raw.h
gemma/weights.cc gemma/weights.cc
gemma/weights.h gemma/weights.h
util/app.h util/app.h

View File

@ -25,8 +25,8 @@
#include "backprop/activations.h" #include "backprop/activations.h"
#include "backprop/common_scalar.h" #include "backprop/common_scalar.h"
#include "backprop/prompt.h" #include "backprop/prompt.h"
#include "compression/weights_raw.h"
#include "gemma/common.h" // EmbeddingScaling #include "gemma/common.h" // EmbeddingScaling
#include "gemma/weights_raw.h"
namespace gcpp { namespace gcpp {
template<typename T> template<typename T>

View File

@ -32,8 +32,8 @@
#include "backprop/prompt.h" #include "backprop/prompt.h"
#include "backprop/sampler.h" #include "backprop/sampler.h"
#include "backprop/test_util.h" #include "backprop/test_util.h"
#include "compression/weights_raw.h"
#include "gemma/configs.h" #include "gemma/configs.h"
#include "gemma/weights_raw.h"
namespace gcpp { namespace gcpp {

View File

@ -30,8 +30,8 @@
#include "backprop/forward_scalar.h" #include "backprop/forward_scalar.h"
#include "backprop/sampler.h" #include "backprop/sampler.h"
#include "backprop/test_util.h" #include "backprop/test_util.h"
#include "compression/weights_raw.h"
#include "gemma/configs.h" #include "gemma/configs.h"
#include "gemma/weights_raw.h"
#include "hwy/base.h" #include "hwy/base.h"
#include "hwy/contrib/thread_pool/thread_pool.h" #include "hwy/contrib/thread_pool/thread_pool.h"

View File

@ -26,8 +26,8 @@
#include "backprop/activations.h" #include "backprop/activations.h"
#include "backprop/common_scalar.h" #include "backprop/common_scalar.h"
#include "backprop/prompt.h" #include "backprop/prompt.h"
#include "compression/weights_raw.h"
#include "gemma/common.h" // EmbeddingScaling #include "gemma/common.h" // EmbeddingScaling
#include "gemma/weights_raw.h"
namespace gcpp { namespace gcpp {

View File

@ -23,7 +23,7 @@
#include <complex> #include <complex>
#include "gtest/gtest.h" #include "gtest/gtest.h"
#include "gemma/weights_raw.h" #include "compression/weights_raw.h"
namespace gcpp { namespace gcpp {

View File

@ -181,17 +181,28 @@ cc_library(
], ],
) )
cc_library(
name = "weights_raw",
hdrs = ["weights_raw.h"],
deps = [
"//:common",
"//compression:compress",
"@hwy//:hwy",
"@hwy//:thread_pool",
],
)
cc_binary( cc_binary(
name = "compress_weights", name = "compress_weights",
srcs = ["compress_weights.cc"], srcs = ["compress_weights.cc"],
deps = [ deps = [
":compress", ":compress",
":weights_raw",
# Placeholder for internal dep, do not remove., # Placeholder for internal dep, do not remove.,
"//third_party/gemma_cpp:args", "//:args",
"//third_party/gemma_cpp:common", "//:common",
"//third_party/gemma_cpp:gemma_lib", "//:gemma_lib",
"//third_party/gemma_cpp:weights", "//:weights",
"//third_party/gemma_cpp:weights_raw",
"@hwy//:hwy", "@hwy//:hwy",
"@hwy//:nanobenchmark", "@hwy//:nanobenchmark",
"@hwy//:profiler", "@hwy//:profiler",

View File

@ -38,9 +38,9 @@
#include <thread> // NOLINT #include <thread> // NOLINT
#include "compression/io.h" // Path #include "compression/io.h" // Path
#include "compression/weights_raw.h"
#include "gemma/common.h" // Model #include "gemma/common.h" // Model
#include "gemma/weights.h" #include "gemma/weights.h"
#include "gemma/weights_raw.h"
#include "util/args.h" #include "util/args.h"
#include "hwy/base.h" #include "hwy/base.h"
#include "hwy/contrib/thread_pool/thread_pool.h" #include "hwy/contrib/thread_pool/thread_pool.h"

View File

@ -13,14 +13,16 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef THIRD_PARTY_GEMMA_CPP_GEMMA_WEIGHTS_RAW_H_ #ifndef THIRD_PARTY_GEMMA_CPP_COMPRESSION_WEIGHTS_RAW_H_
#define THIRD_PARTY_GEMMA_CPP_GEMMA_WEIGHTS_RAW_H_ #define THIRD_PARTY_GEMMA_CPP_COMPRESSION_WEIGHTS_RAW_H_
// NOTE: this file should only be used by compress_weights; it is currently // Historical note: this was the original f32-only simple on-disk format
// also referenced by backprop, but we plan to remove that. Historical note: // created by convert_weights.py. BlobStore is now the preferred on-disk
// this was the original f32-only simple on-disk format created by a Python // format, and we load that into CompressedWeights.
// export script. BlobStore is now the preferred on-disk format, and we load //
// that into CompressedWeights. // NOTE: this file should only be used by compress_weights. It is currently
// also referenced by backprop because it supports T = std::complex, and
// CompressedWeights might not yet.
#include <random> #include <random>
@ -239,4 +241,4 @@ class WeightsWrapper {
} // namespace gcpp } // namespace gcpp
#endif // THIRD_PARTY_GEMMA_CPP_GEMMA_WEIGHTS_RAW_H_ #endif // THIRD_PARTY_GEMMA_CPP_COMPRESSION_WEIGHTS_RAW_H_

View File

@ -10,8 +10,8 @@
#include <vector> #include <vector>
#include "compression/io.h" // Path #include "compression/io.h" // Path
#include "evals/benchmark_helper.h"
#include "evals/cross_entropy.h" #include "evals/cross_entropy.h"
#include "gemma/benchmark_helper.h"
#include "gemma/common.h" #include "gemma/common.h"
#include "gemma/gemma.h" #include "gemma/gemma.h"
#include "util/args.h" #include "util/args.h"

View File

@ -13,7 +13,7 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
#include <stdio.h> #include <stdio.h>
#include <time.h> #include <time.h>

View File

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
#ifndef THIRD_PARTY_GEMMA_CPP_GEMMA_BENCHMARK_HELPER_H_ #ifndef THIRD_PARTY_GEMMA_CPP_EVALS_BENCHMARK_HELPER_H_
#define THIRD_PARTY_GEMMA_CPP_GEMMA_BENCHMARK_HELPER_H_ #define THIRD_PARTY_GEMMA_CPP_EVALS_BENCHMARK_HELPER_H_
#include <stddef.h> #include <stddef.h>
@ -116,4 +116,4 @@ void ShowHelp(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app);
} // namespace gcpp } // namespace gcpp
#endif // THIRD_PARTY_GEMMA_CPP_GEMMA_BENCHMARK_HELPER_H_ #endif // THIRD_PARTY_GEMMA_CPP_EVALS_BENCHMARK_HELPER_H_

View File

@ -19,7 +19,7 @@
#include <string> #include <string>
#include "benchmark/benchmark.h" #include "benchmark/benchmark.h"
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
namespace gcpp { namespace gcpp {

View File

@ -19,7 +19,7 @@
#include <vector> #include <vector>
#include "compression/io.h" #include "compression/io.h"
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
#include "gemma/gemma.h" // LayersOutputFunc #include "gemma/gemma.h" // LayersOutputFunc
#include "util/args.h" #include "util/args.h"
#include "hwy/base.h" #include "hwy/base.h"

View File

@ -21,7 +21,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
#include "gemma/common.h" #include "gemma/common.h"
#include "hwy/aligned_allocator.h" #include "hwy/aligned_allocator.h"
#include "hwy/tests/hwy_gtest.h" #include "hwy/tests/hwy_gtest.h"

View File

@ -20,7 +20,7 @@
#include <vector> #include <vector>
#include "compression/io.h" // Path #include "compression/io.h" // Path
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
#include "gemma/gemma.h" // Gemma #include "gemma/gemma.h" // Gemma
#include "util/args.h" #include "util/args.h"
#include "hwy/base.h" #include "hwy/base.h"

View File

@ -22,7 +22,7 @@
#include <vector> #include <vector>
// Placeholder for internal header, do not modify. // Placeholder for internal header, do not modify.
#include "gemma/benchmark_helper.h" #include "evals/benchmark_helper.h"
#include "gemma/common.h" #include "gemma/common.h"
#include "gemma/gemma.h" // Gemma #include "gemma/gemma.h" // Gemma
#include "util/app.h" #include "util/app.h"