diff options
Diffstat (limited to 'test/quantize_test.cc')
-rw-r--r-- | test/quantize_test.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/test/quantize_test.cc b/test/quantize_test.cc index 83b1d20..3263812 100644 --- a/test/quantize_test.cc +++ b/test/quantize_test.cc @@ -52,45 +52,45 @@ template <class Backend> bool Test(const float *input_unaligned, float quant_mul Backend::Quantize(input.begin(), test.begin(), quant_mult, size); for (std::size_t i = 0; i < size; ++i) { if (IsOff(input[i] * quant_mult, ref[i], test[i])) { - UNSCOPED_INFO("Error at " << i << " from " << input[i] << '*' << quant_mult << '=' << (input[i]*quant_mult) << " ref = " << ref[i] << " test = " << test[i]); + UNSCOPED_INFO("Error at " << i << " from " << input[i] << '*' << quant_mult << '=' << (input[i]*quant_mult) << " ref = " << static_cast<int>(ref[i]) << " test = " << static_cast<int>(test[i])); success = false; } } return success; } -template <class Backend> bool TestMany() { - bool success = true; - float input[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31}; - success &= Test<Backend>(input, 1.0, 32); - success &= Test<Backend>(input, 32.0, 32); - float corners[32] = {-32769, -32768, -32767, -129, -128, -127, -1, 0, 1, 126, 127, 128, 129, 32766, 32768, 32769, -1.9, -1.5, -1.1, -1, -0.9, -0.5, -0.1, 0.0, 0.1, 0.5, 0.9, 1.0, 1.1, 1.5, 1.9, 16056.8}; - success &= Test<Backend>(corners, 1.0, sizeof(corners) / sizeof(float)); - success &= Test<Backend>(corners, -1.0, sizeof(corners) / sizeof(float)); - success &= Test<Backend>(corners, -0.49, sizeof(corners) / sizeof(float)); - return success; +template <class Backend> void TestMany(std::size_t grow) { + float input[33] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32}; + float corners[33] = {-32769, -32768, -32767, -129, -128, -127, -1, 0, 1, 126, 127, 128, 129, 32766, 32768, 32769, -1.9, -1.5, -1.1, -1, -0.9, -0.5, -0.1, 0.0, 0.1, 0.5, 0.9, 1.0, 1.1, 1.5, 1.9, 16056.8, 2.5}; + for (std::size_t len = 0; len <= 33; len += grow) { + CHECK(Test<Backend>(input, 1.0, len)); + CHECK(Test<Backend>(input, 32.0, len)); + CHECK(Test<Backend>(corners, 1.0, len)); + CHECK(Test<Backend>(corners, -1.0, len)); + CHECK(Test<Backend>(corners, -0.49, len)); + } } TEST_CASE ("Quantize SSE2", "[quantize]") { if (kCPU < CPUType::SSE2) return; - CHECK(TestMany<SSE2_16bit>()); + TestMany<SSE2_16bit>(8); } -TEST_CASE ("Quantize SSE3", "[quantize]") { +TEST_CASE ("Quantize SSSE3", "[quantize]") { if (kCPU < CPUType::SSSE3) return; - CHECK(TestMany<SSSE3_8bit>()); + TestMany<SSSE3_8bit>(1); } TEST_CASE ("Quantize AVX2", "[quantize]") { if (kCPU < CPUType::AVX2) return; - CHECK(TestMany<AVX2_8bit>()); - CHECK(TestMany<AVX2_16bit>()); + TestMany<AVX2_8bit>(1); + TestMany<AVX2_16bit>(16); } #ifdef INTGEMM_COMPILER_SUPPORTS_AVX512 TEST_CASE ("Quantize AVX512", "[quantize]") { if (kCPU < CPUType::AVX512BW) return; - CHECK(TestMany<AVX512_8bit>()); - CHECK(TestMany<AVX512_16bit>()); + TestMany<AVX512_8bit>(1); + TestMany<AVX512_16bit>(16); } #endif |