Internal changes

PiperOrigin-RevId: 842727112
This commit is contained in:
Krzysztof Rymski 2025-12-10 07:54:38 -08:00 committed by Copybara-Service
parent 9689fc82f9
commit 64178ace38
2 changed files with 24 additions and 0 deletions

View File

@ -173,8 +173,10 @@ cc_library(
hdrs = ["util/test_util.h"], hdrs = ["util/test_util.h"],
deps = [ deps = [
":basics", ":basics",
":mat",
"@highway//:hwy", "@highway//:hwy",
"@highway//:hwy_test_util", "@highway//:hwy_test_util",
"@highway//:nanobenchmark",
"@highway//:stats", "@highway//:stats",
], ],
) )

View File

@ -21,11 +21,14 @@
#include <algorithm> // std::sort #include <algorithm> // std::sort
#include <cmath> #include <cmath>
#include <iostream>
#include "util/basics.h" // RngStream #include "util/basics.h" // RngStream
#include "util/mat.h"
#include "hwy/base.h" #include "hwy/base.h"
// IWYU pragma: begin_exports // IWYU pragma: begin_exports
#include "hwy/nanobenchmark.h"
#include "hwy/stats.h" #include "hwy/stats.h"
#include "hwy/tests/test_util.h" // RandomState #include "hwy/tests/test_util.h" // RandomState
// IWYU pragma: end_exports // IWYU pragma: end_exports
@ -99,6 +102,25 @@ HWY_INLINE void VerifyGaussian(hwy::Stats& stats) {
HWY_ASSERT(IsNear(3.0, stats.Kurtosis(), 0.3)); HWY_ASSERT(IsNear(3.0, stats.Kurtosis(), 0.3));
} }
template <typename T>
void FillMatPtrT(MatPtrT<T>& 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 <typename T>
void PrintMatPtr(MatPtrT<T> 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 } // namespace gcpp
#endif // THIRD_PARTY_GEMMA_CPP_UTIL_TEST_UTIL_H_ #endif // THIRD_PARTY_GEMMA_CPP_UTIL_TEST_UTIL_H_