From 64178ace380a88e1070dfac0d8570a540574ad12 Mon Sep 17 00:00:00 2001 From: Krzysztof Rymski Date: Wed, 10 Dec 2025 07:54:38 -0800 Subject: [PATCH] Internal changes PiperOrigin-RevId: 842727112 --- BUILD.bazel | 2 ++ util/test_util.h | 22 ++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/BUILD.bazel b/BUILD.bazel index e4f7d7e..ab04fd3 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -173,8 +173,10 @@ cc_library( hdrs = ["util/test_util.h"], deps = [ ":basics", + ":mat", "@highway//:hwy", "@highway//:hwy_test_util", + "@highway//:nanobenchmark", "@highway//:stats", ], ) diff --git a/util/test_util.h b/util/test_util.h index 32e1e04..f0c37f9 100644 --- a/util/test_util.h +++ b/util/test_util.h @@ -21,11 +21,14 @@ #include // std::sort #include +#include #include "util/basics.h" // RngStream +#include "util/mat.h" #include "hwy/base.h" // IWYU pragma: begin_exports +#include "hwy/nanobenchmark.h" #include "hwy/stats.h" #include "hwy/tests/test_util.h" // RandomState // IWYU pragma: end_exports @@ -99,6 +102,25 @@ HWY_INLINE void VerifyGaussian(hwy::Stats& stats) { HWY_ASSERT(IsNear(3.0, stats.Kurtosis(), 0.3)); } +template +void FillMatPtrT(MatPtrT& mat) { + for (int i = 0; i < mat.Rows(); ++i) { + for (int j = 0; j < mat.Cols(); ++j) { + mat.Row(i)[j] = hwy::Unpredictable1() * 0.01f * (i + j + 1); + } + } +} + +template +void PrintMatPtr(MatPtrT mat) { + for (int i = 0; i < mat.Rows(); ++i) { + for (int j = 0; j < mat.Cols(); ++j) { + std::cerr << mat.Row(i)[j] << " ,"; + } + std::cerr << std::endl; + } +}; + } // namespace gcpp #endif // THIRD_PARTY_GEMMA_CPP_UTIL_TEST_UTIL_H_