mirror of https://github.com/google/gemma.cpp.git
parent
9689fc82f9
commit
64178ace38
|
|
@ -173,8 +173,10 @@ cc_library(
|
|||
hdrs = ["util/test_util.h"],
|
||||
deps = [
|
||||
":basics",
|
||||
":mat",
|
||||
"@highway//:hwy",
|
||||
"@highway//:hwy_test_util",
|
||||
"@highway//:nanobenchmark",
|
||||
"@highway//:stats",
|
||||
],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -21,11 +21,14 @@
|
|||
|
||||
#include <algorithm> // std::sort
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
|
||||
#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 <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
|
||||
|
||||
#endif // THIRD_PARTY_GEMMA_CPP_UTIL_TEST_UTIL_H_
|
||||
|
|
|
|||
Loading…
Reference in New Issue