From 2b29f2ad3dcde4eded9cf259def0c1ee32abbb6f Mon Sep 17 00:00:00 2001 From: Jens Elofsson Date: Tue, 14 Jan 2025 13:07:18 +0100 Subject: [PATCH 1/2] Fix data type for argument to std::mt19937 The argument to std::mt19937:s constructor is uint32_t, but the supplied value (the variable "seed") was uint64_t. This has been changed to uint32_t. Signed-off-by: Jens Elofsson --- test/reference/fill.cpp | 16 ++++++++-------- test/reference/fill.hpp | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/test/reference/fill.cpp b/test/reference/fill.cpp index d73c5376..a2252a3d 100644 --- a/test/reference/fill.cpp +++ b/test/reference/fill.cpp @@ -44,7 +44,7 @@ std::vector fill_matrix_raw(size_t height, size_t width, std::function< } template -std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_t seed) { +std::vector fill_matrix_random_raw(size_t height, size_t width, uint32_t seed) { using TDist = std::conditional_t< std::is_floating_point_v, std::uniform_real_distribution, std::uniform_int_distribution>; @@ -55,7 +55,7 @@ std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_ } template <> -std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_t seed) { +std::vector fill_matrix_random_raw(size_t height, size_t width, uint32_t seed) { std::mt19937 rnd(seed); std::uniform_real_distribution dist; @@ -63,7 +63,7 @@ std::vector fill_matrix_random_raw(size_t height, size_t width } template <> -std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_t seed) { +std::vector fill_matrix_random_raw(size_t height, size_t width, uint32_t seed) { std::mt19937 rnd(seed); std::uniform_real_distribution dist; @@ -71,7 +71,7 @@ std::vector fill_matrix_random_raw(size_t height, size_t widt } template <> -std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_t seed) { +std::vector fill_matrix_random_raw(size_t height, size_t width, uint32_t seed) { std::mt19937 rnd(seed); std::uniform_int_distribution dist(-8, 7); @@ -79,7 +79,7 @@ std::vector fill_matrix_random_raw(size_t height, size_t width, u } template <> -std::vector fill_matrix_random_raw(size_t height, size_t width, uint64_t seed) { +std::vector fill_matrix_random_raw(size_t height, size_t width, uint32_t seed) { std::mt19937 rnd(seed); std::uniform_int_distribution dist(0, 15); @@ -88,7 +88,7 @@ std::vector fill_matrix_random_raw(size_t height, size_t width, } // namespace -std::vector fill_matrix_random(size_t height, size_t width, const DataFormat& format, uint64_t seed) { +std::vector fill_matrix_random(size_t height, size_t width, const DataFormat& format, uint32_t seed) { switch (format.pack_format()) { case DataFormat::PackFormat::NONE: switch (format.data_type()) { @@ -119,10 +119,10 @@ std::vector fill_matrix_random(size_t height, size_t width, const DataF } template -std::vector fill_random(size_t length, uint64_t seed) { +std::vector fill_random(size_t length, uint32_t seed) { return fill_matrix_random_raw(1, length, seed); } -template std::vector fill_random(size_t length, uint64_t seed); +template std::vector fill_random(size_t length, uint32_t seed); } // namespace kai::test diff --git a/test/reference/fill.hpp b/test/reference/fill.hpp index 80093952..25846c6c 100644 --- a/test/reference/fill.hpp +++ b/test/reference/fill.hpp @@ -22,7 +22,7 @@ class DataFormat; /// @param[in] seed Random seed. /// /// @return The data buffer for the matrix. -std::vector fill_matrix_random(size_t height, size_t width, const DataFormat& format, uint64_t seed); +std::vector fill_matrix_random(size_t height, size_t width, const DataFormat& format, uint32_t seed); /// Creates a new data buffer filled with random data. /// @@ -33,6 +33,6 @@ std::vector fill_matrix_random(size_t height, size_t width, const DataF /// /// @return The data buffer. template -std::vector fill_random(size_t length, uint64_t seed); +std::vector fill_random(size_t length, uint32_t seed); } // namespace kai::test -- GitLab From 001382593eeb062cf95909c94959f1733775b448 Mon Sep 17 00:00:00 2001 From: Jens Elofsson Date: Tue, 25 Feb 2025 16:41:25 +0100 Subject: [PATCH 2/2] Address review comments Change datatype of callers to fill_random<>() Signed-off-by: Jens Elofsson --- test/tests/matmul_clamp_f32_f32_f32p_test.cpp | 2 +- test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp | 4 ++-- test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp | 8 ++++---- test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp | 4 ++-- test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp | 2 +- test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp index eae21b9b..4ac1f986 100644 --- a/test/tests/matmul_clamp_f32_f32_f32p_test.cpp +++ b/test/tests/matmul_clamp_f32_f32_f32p_test.cpp @@ -71,7 +71,7 @@ TEST_P(MatMulTest_f32_f32_f32p, EndToEnd) // NOLINT(google-readability-avoid-un GTEST_SKIP(); } - constexpr uint64_t seed = 0; + constexpr uint32_t seed = 0; const size_t m = matmul_shape.m; const size_t n = matmul_shape.n; diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp index 90000e97..06b50043 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4c32p_test.cpp @@ -162,7 +162,7 @@ TEST_P(MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, EndToEnd_RHS_nxk) { GTEST_SKIP(); } - constexpr uint64_t seed = 0; + constexpr uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; @@ -296,7 +296,7 @@ TEST_P(MatMulTest_f32_qmatmul_clamp_f32_qai8dxp_qsi4c32p, EndToEnd_RHS_kxn) { GTEST_SKIP(); } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp index c0018dd6..22edc8c1 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi4cxp_test.cpp @@ -280,7 +280,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi4cxp, EndToEnd_RHS_nxk_qsi4cx) { GTEST_SKIP() << "Signed integer input unsupported"; } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; @@ -404,7 +404,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi4cxp, EndToEnd_RHS_nxk_qsu4cx) { GTEST_SKIP(); // Wrong type. This test for NxK } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; @@ -531,7 +531,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi4cxp, EndToEnd_RHS_kxn_qsi4cx) { GTEST_SKIP() << "Signed integer input unsupported"; } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; @@ -659,7 +659,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi4cxp, EndToEnd_RHS_kxn_qsu4cx) { GTEST_SKIP(); // Wrong type. This test for KxN } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; diff --git a/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp b/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp index 4dd69e4b..eab1e6a7 100644 --- a/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_f32_qai8dxp_qsi8cxp_test.cpp @@ -101,7 +101,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi8cxp, EndToEnd_RHS_nxk_qsi8cx) { GTEST_SKIP(); } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; @@ -215,7 +215,7 @@ TEST_P(MatMulTest_f32_qai8dxp_qsi8cxp, EndToEnd_RHS_kxn_qsi8cx) { GTEST_SKIP(); } - const uint64_t seed = 0; + const uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; diff --git a/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp b/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp index ce5c6ebc..b91c1fbc 100644 --- a/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp +++ b/test/tests/matmul_clamp_f32_qsi8d32p_qsi4c32p_test.cpp @@ -167,7 +167,7 @@ TEST_P(MatMulTest_f32_qsi8d32p_qsi4c32p, EndToEnd) { GTEST_SKIP(); } - const std::uint64_t seed = 0; + const std::uint32_t seed = 0; const size_t M = matmul_shape.m; const size_t N = matmul_shape.n; diff --git a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp index eec9d022..1acd19ed 100644 --- a/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp +++ b/test/tests/matmul_clamp_qai8_qai8p_qsi8cxp_test.cpp @@ -185,7 +185,7 @@ const std::array gemv_variants = { }, }; -constexpr uint64_t seed = 0; ///< Random seed used for tests +constexpr uint32_t seed = 0; ///< Random seed used for tests constexpr float output_clamp_rate = 0.1F; ///< Clamping range in ration of output /// Value range -- GitLab