From 64888200cbc9e9c287601f23c58b4088cdf51cba Mon Sep 17 00:00:00 2001 From: Young Jin Kim Date: Tue, 29 Sep 2020 17:08:50 -0700 Subject: Fix unit test errors - skip unnecessary acc16 test for VNNI CPUs (#9) --- test/PackedRequantizeAcc16Test.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/test/PackedRequantizeAcc16Test.cc b/test/PackedRequantizeAcc16Test.cc index 8978150..147d60f 100644 --- a/test/PackedRequantizeAcc16Test.cc +++ b/test/PackedRequantizeAcc16Test.cc @@ -4,6 +4,7 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. */ +#include #include #include #include @@ -97,6 +98,12 @@ static vector> GetShapes_() { * accumulation. Output processing: requantization -> nothing */ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, Test) { + cpuinfo_initialize(); + if (fbgemmHasAvx512VnniSupport()) { + // No need to use acc16 if VNNI is available + return; + } + vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; bool test_ld; @@ -338,6 +345,12 @@ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, Test) { * accumulation. Output processing: spmdm -> requantization -> nothing */ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, SpMDMTest) { + cpuinfo_initialize(); + if (fbgemmHasAvx512VnniSupport()) { + // No need to use acc16 if VNNI is available + return; + } + vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; bool test_ld; @@ -664,6 +677,12 @@ TEST_P(fbgemmu8s8acc16WithQuantGranularityTest, SpMDMTest) { * accumulation. Output processing: nothing */ TEST_P(fbgemmu8s8acc16Test, NoRequantizeTest) { + cpuinfo_initialize(); + if (fbgemmHasAvx512VnniSupport()) { + // No need to use acc16 if VNNI is available + return; + } + vector> shapes(GetShapes_()); matrix_op_t atrans, btrans; bool test_ld; @@ -876,7 +895,7 @@ TEST_P(fbgemmPackUnpackAcc16Test, TestPackUnpack) { // Sanity check for (int i = 0; i < k; i++) { for (int j = 0; j < n_adjusted; j++) { - EXPECT_EQ(Bint8.data()[i * n + j], unpack_buf.data()[i * n + j]) + EXPECT_EQ(unpack_buf.data()[i * n + j], Bint8.data()[i * n + j]) << "Pack/Unpack results differ at index (" << i << ", " << j << ", Reference: " << static_cast(Bint8.data()[i * n + j]) << ", Pack-Unpacked: " -- cgit v1.2.3