From 6ff12a0f7765f62b8d0fa8554021e1cac2789f19 Mon Sep 17 00:00:00 2001 From: Pablo Tello Date: Thu, 2 Nov 2017 16:09:35 +0000 Subject: COMPMID-662: Integrated the new a64_s8_gemm_12x8 + dot product kernel into ACL. Change-Id: Id8f919e486a132fc58346c9f84fccbeeb83d19b3 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/94233 Tested-by: Kaizen Reviewed-by: Anthony Barbier Reviewed-by: Gian Marco Iodice --- tests/validation/CPP/GEMMLowp.cpp | 8 ++--- tests/validation/CPP/GEMMLowp.h | 2 +- tests/validation/NEON/GEMMLowp.cpp | 26 ++++++++-------- tests/validation/fixtures/GEMMLowpFixture.h | 46 ++++++++++++++--------------- 4 files changed, 40 insertions(+), 42 deletions(-) (limited to 'tests') diff --git a/tests/validation/CPP/GEMMLowp.cpp b/tests/validation/CPP/GEMMLowp.cpp index 06926e631e..e1d76503cd 100644 --- a/tests/validation/CPP/GEMMLowp.cpp +++ b/tests/validation/CPP/GEMMLowp.cpp @@ -34,7 +34,7 @@ namespace validation { namespace reference { -SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c) +SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c) { ARM_COMPUTE_UNUSED(a); ARM_COMPUTE_UNUSED(b); @@ -99,15 +99,15 @@ SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, Sim for(int j = 0; j < cols; ++j) { const int32_t result = ((c_offset + acc[j]) * c_mult_int) >> out_shift; - c[j + i * cols] = static_cast(std::min(255, std::max(0, result))); + c[j + i * cols] = static_cast(std::min(127, std::max(-128, result))); } } return c; } -template SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c, - int32_t a_offset, int32_t b_offset, int32_t c_offset, int32_t c_mult_int, int32_t out_shift); +template SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c, + int32_t a_offset, int32_t b_offset, int32_t c_offset, int32_t c_mult_int, int32_t out_shift); } // namespace reference } // namespace validation } // namespace test diff --git a/tests/validation/CPP/GEMMLowp.h b/tests/validation/CPP/GEMMLowp.h index 0428e9e34f..2f903f2fe2 100644 --- a/tests/validation/CPP/GEMMLowp.h +++ b/tests/validation/CPP/GEMMLowp.h @@ -35,7 +35,7 @@ namespace validation { namespace reference { -SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c); +SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c); template SimpleTensor gemmlowp(const SimpleTensor &a, const SimpleTensor &b, SimpleTensor &c, diff --git a/tests/validation/NEON/GEMMLowp.cpp b/tests/validation/NEON/GEMMLowp.cpp index de7495bb6a..4924f98ea6 100644 --- a/tests/validation/NEON/GEMMLowp.cpp +++ b/tests/validation/NEON/GEMMLowp.cpp @@ -45,14 +45,15 @@ namespace validation { namespace { -const auto data_int_blk = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12) * framework::dataset::make("by", 8, 13) * framework::dataset::make("block", 4, 9); -const auto data_int_blk_tr = framework::dataset::make("M", 8, 17) * framework::dataset::make("N", 8, 14) * framework::dataset::make("by", 12) * framework::dataset::make("block", 4); +const auto data_int_blk = framework::dataset::make("M", 8, 12) * framework::dataset::make("N", 8, 12) * framework::dataset::make("by", 8, 13) * framework::dataset::make("block", 4, 9); +const auto data_int_blk_tr = framework::dataset::make("M", 8, 17) * framework::dataset::make("N", 8, 14) * framework::dataset::make("by", 12) * framework::dataset::make("block", 4); +const auto data_matrix_multiply = framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K", 16); } // namespace TEST_SUITE(NEON) TEST_SUITE(GEMMLowp) -TEST_SUITE(U8) +TEST_SUITE(S8) TEST_SUITE(INTERLEAVE_BLOCKED) @@ -79,7 +80,7 @@ TEST_SUITE_END() using NEGEMMLowpOffsetFixture = GEMMLowpOffsetValidationFixture; DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::dataset::concat(datasets::SmallGEMMLowpDataset(), datasets::LargeGEMMLowpDataset()), framework::dataset::make("DataType", - DataType::U8)), + DataType::S8)), shape_a, shape_b, shape_c, a_offset, b_offset, c_offset, c_mult_int, out_shift, data_type) { // Create tensors @@ -96,31 +97,28 @@ DATA_TEST_CASE(Configuration, framework::DatasetMode::ALL, combine(framework::da gemmlowp.configure(&a, &b, &c, a_offset, b_offset, c_offset, c_mult_int, out_shift); } -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpOffsetFixture, framework::DatasetMode::ALL, combine(datasets::SmallGEMMLowpDataset(), framework::dataset::make("DataType", DataType::U8))) +FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpOffsetFixture, framework::DatasetMode::ALL, combine(datasets::SmallGEMMLowpDataset(), framework::dataset::make("DataType", DataType::S8))) { // Validate output validate(Accessor(_target), _reference); } -FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpOffsetFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMLowpDataset(), framework::dataset::make("DataType", DataType::U8))) +FIXTURE_DATA_TEST_CASE(RunLarge, NEGEMMLowpOffsetFixture, framework::DatasetMode::NIGHTLY, combine(datasets::LargeGEMMLowpDataset(), framework::dataset::make("DataType", DataType::S8))) { // Validate output validate(Accessor(_target), _reference); } +TEST_SUITE_END() // U8 -//FIXME: This is in the process of being updated, for more info please refer to COMPMID-624. -#if 0 // defined(__aarch64__) -TEST_SUITE(U32) -using NEGEMMLowpFixture = GEMMLowpValidationFixture; -FIXTURE_DATA_TEST_CASE(RunSmall, NEGEMMLowpFixture, framework::DatasetMode::PRECOMMIT, framework::dataset::make("M", 12, 20) * framework::dataset::make("N", 12, 20) * framework::dataset::make("K", - 16)) +TEST_SUITE(S32) +using NEGEMMLowpMatrixMultiplyFixture = GEMMLowpMatrixMultiplyValidationFixture; +FIXTURE_DATA_TEST_CASE(MatrixMultiply, NEGEMMLowpMatrixMultiplyFixture, framework::DatasetMode::PRECOMMIT, data_matrix_multiply) { // Validate output validate(Accessor(_target), _reference); } TEST_SUITE_END() -#endif // defined(__aarch64__) -TEST_SUITE_END() + TEST_SUITE_END() TEST_SUITE_END() } // namespace validation diff --git a/tests/validation/fixtures/GEMMLowpFixture.h b/tests/validation/fixtures/GEMMLowpFixture.h index 1a4084fdc2..fba44008ba 100644 --- a/tests/validation/fixtures/GEMMLowpFixture.h +++ b/tests/validation/fixtures/GEMMLowpFixture.h @@ -57,7 +57,7 @@ protected: template void fill(U &&tensor, int i) { - ARM_COMPUTE_ERROR_ON(tensor.data_type() != DataType::U8); + ARM_COMPUTE_ERROR_ON(tensor.data_type() != DataType::S8); std::uniform_int_distribution<> distribution(0, 3); library->fill(tensor, distribution, i); } @@ -97,28 +97,28 @@ protected: return c; } - SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, - int32_t a_offset, int32_t b_offset, int32_t c_offset, int32_t c_mult_int, int32_t out_shift, DataType data_type) + SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c, + int32_t a_offset, int32_t b_offset, int32_t c_offset, int32_t c_mult_int, int32_t out_shift, DataType data_type) { // Create reference - SimpleTensor a{ shape_a, data_type, 1 }; - SimpleTensor b{ shape_b, data_type, 1 }; - SimpleTensor c{ shape_c, data_type, 1 }; + SimpleTensor a{ shape_a, data_type, 1 }; + SimpleTensor b{ shape_b, data_type, 1 }; + SimpleTensor c{ shape_c, data_type, 1 }; // Fill reference fill(a, 0); fill(b, 1); fill(c, 2); - return reference::gemmlowp(a, b, c, a_offset, b_offset, c_offset, c_mult_int, out_shift); + return reference::gemmlowp(a, b, c, a_offset, b_offset, c_offset, c_mult_int, out_shift); } - TensorType _target{}; - SimpleTensor _reference{}; + TensorType _target{}; + SimpleTensor _reference{}; }; template -class GEMMLowpValidationFixture : public framework::Fixture +class GEMMLowpMatrixMultiplyValidationFixture : public framework::Fixture { public: template @@ -142,9 +142,9 @@ protected: TensorType compute_target(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c) { // Create tensors - TensorType a = create_tensor(shape_a, DataType::U8, 1); - TensorType b = create_tensor(shape_b, DataType::U8, 1); - TensorType c = create_tensor(shape_c, DataType::U32, 1); + TensorType a = create_tensor(shape_a, DataType::S8, 1); + TensorType b = create_tensor(shape_b, DataType::S8, 1); + TensorType c = create_tensor(shape_c, DataType::S32, 1); // Create and configure function FunctionType gemmlowp; @@ -164,8 +164,8 @@ protected: ARM_COMPUTE_EXPECT(!c.info()->is_resizable(), framework::LogLevel::ERRORS); // Fill tensors - fill(AccessorType(a), 0, 0, 3); - fill(AccessorType(b), 1, 0, 3); + fill(AccessorType(a), 0, -128, 127); + fill(AccessorType(b), 1, -128, 127); fill(AccessorType(c), 2, 0, 0); // Compute GEMM function @@ -173,23 +173,23 @@ protected: return c; } - SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c) + SimpleTensor compute_reference(const TensorShape &shape_a, const TensorShape &shape_b, const TensorShape &shape_c) { // Create reference - SimpleTensor a{ shape_a, DataType::U8, 1 }; - SimpleTensor b{ shape_b, DataType::U8, 1 }; - SimpleTensor c{ shape_c, DataType::U32, 1 }; + SimpleTensor a{ shape_a, DataType::S8, 1 }; + SimpleTensor b{ shape_b, DataType::S8, 1 }; + SimpleTensor c{ shape_c, DataType::S32, 1 }; // Fill reference - fill(a, 0, 0, 3); - fill(b, 1, 0, 3); + fill(a, 0, -128, 127); + fill(b, 1, -128, 127); fill(c, 2, 0, 0); return reference::gemmlowp(a, b, c); } - TensorType _target{}; - SimpleTensor _reference{}; + TensorType _target{}; + SimpleTensor _reference{}; }; } // namespace validation -- cgit v1.2.1