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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -23,7 +23,7 @@
#include <complex>
#include "gtest/gtest.h"
#include "gemma/weights_raw.h"
#include "compression/weights_raw.h"
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(
name = "compress_weights",
srcs = ["compress_weights.cc"],
deps = [
":compress",
":weights_raw",
# Placeholder for internal dep, do not remove.,
"//third_party/gemma_cpp:args",
"//third_party/gemma_cpp:common",
"//third_party/gemma_cpp:gemma_lib",
"//third_party/gemma_cpp:weights",
"//third_party/gemma_cpp:weights_raw",
"//:args",
"//:common",
"//:gemma_lib",
"//:weights",
"@hwy//:hwy",
"@hwy//:nanobenchmark",
"@hwy//:profiler",

View File

@ -38,9 +38,9 @@
#include <thread> // NOLINT
#include "compression/io.h" // Path
#include "compression/weights_raw.h"
#include "gemma/common.h" // Model
#include "gemma/weights.h"
#include "gemma/weights_raw.h"
#include "util/args.h"
#include "hwy/base.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
// limitations under the License.
#ifndef THIRD_PARTY_GEMMA_CPP_GEMMA_WEIGHTS_RAW_H_
#define THIRD_PARTY_GEMMA_CPP_GEMMA_WEIGHTS_RAW_H_
#ifndef THIRD_PARTY_GEMMA_CPP_COMPRESSION_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
// also referenced by backprop, but we plan to remove that. Historical note:
// this was the original f32-only simple on-disk format created by a Python
// export script. BlobStore is now the preferred on-disk format, and we load
// that into CompressedWeights.
// Historical note: this was the original f32-only simple on-disk format
// created by convert_weights.py. 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>
@ -239,4 +241,4 @@ class WeightsWrapper {
} // 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 "compression/io.h" // Path
#include "evals/benchmark_helper.h"
#include "evals/cross_entropy.h"
#include "gemma/benchmark_helper.h"
#include "gemma/common.h"
#include "gemma/gemma.h"
#include "util/args.h"

View File

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

View File

@ -13,8 +13,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef THIRD_PARTY_GEMMA_CPP_GEMMA_BENCHMARK_HELPER_H_
#define THIRD_PARTY_GEMMA_CPP_GEMMA_BENCHMARK_HELPER_H_
#ifndef THIRD_PARTY_GEMMA_CPP_EVALS_BENCHMARK_HELPER_H_
#define THIRD_PARTY_GEMMA_CPP_EVALS_BENCHMARK_HELPER_H_
#include <stddef.h>
@ -116,4 +116,4 @@ void ShowHelp(LoaderArgs& loader, InferenceArgs& inference, AppArgs& app);
} // 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 "benchmark/benchmark.h"
#include "gemma/benchmark_helper.h"
#include "evals/benchmark_helper.h"
namespace gcpp {

View File

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

View File

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

View File

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

View File

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