diff options
author | Moritz Pflanzer <moritz.pflanzer@arm.com> | 2017-08-02 14:51:36 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-09-17 14:16:42 +0100 |
commit | 4dfc235367e602a366952a8495679e339d7a7263 (patch) | |
tree | e01c63ed0d63e81f33b00c414af68610d393c276 /tests/validation | |
parent | 218cc52ce6f0ebf052346650d1b2004e7201f348 (diff) | |
download | ComputeLibrary-4dfc235367e602a366952a8495679e339d7a7263.tar.gz |
COMPMID-415: Move GEMM to new validation
Change-Id: Ie32f981c86fa1b01905d2776b0d0a0a47b228f0b
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/82538
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'tests/validation')
-rw-r--r-- | tests/validation/CL/GEMM.cpp | 201 | ||||
-rw-r--r-- | tests/validation/NEON/GEMM.cpp | 219 | ||||
-rw-r--r-- | tests/validation/Reference.cpp | 29 | ||||
-rw-r--r-- | tests/validation/Reference.h | 15 | ||||
-rw-r--r-- | tests/validation/ReferenceCPP.cpp | 11 | ||||
-rw-r--r-- | tests/validation/ReferenceCPP.h | 11 | ||||
-rw-r--r-- | tests/validation/TensorOperations.h | 73 | ||||
-rw-r--r-- | tests/validation/TensorVisitors.h | 23 |
8 files changed, 0 insertions, 582 deletions
diff --git a/tests/validation/CL/GEMM.cpp b/tests/validation/CL/GEMM.cpp deleted file mode 100644 index a39cdfd2e3..0000000000 --- a/tests/validation/CL/GEMM.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "CL/CLAccessor.h" -#include "TypePrinter.h" -#include "dataset/GEMMDataset.h" -#include "tests/Globals.h" -#include "tests/Utils.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/functions/CLGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_f32 = 1e-03f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -const float tolerance_q = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -CLTensor compute_gemm(const TensorShape &src_shape1, const TensorShape &src_shape2, const TensorShape &src_shape3, - const TensorShape &out_shape, float alpha, float beta, DataType dt, int fixed_point_position = 0) -{ - // Create tensors - CLTensor src1 = create_tensor<CLTensor>(src_shape1, dt, 1, fixed_point_position); - CLTensor src2 = create_tensor<CLTensor>(src_shape2, dt, 1, fixed_point_position); - CLTensor src3 = create_tensor<CLTensor>(src_shape3, dt, 1, fixed_point_position); - CLTensor dst = create_tensor<CLTensor>(out_shape, dt, 1, fixed_point_position); - - // Create and configure function - CLGEMM gemm; - gemm.configure(&src1, &src2, &src3, &dst, alpha, beta); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - src3.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!src3.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - if(dt == DataType::F32) - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(CLAccessor(src1), distribution, 0); - library->fill(CLAccessor(src2), distribution, 1); - library->fill(CLAccessor(src3), distribution, 2); - } - else - { - library->fill_tensor_uniform(CLAccessor(src1), 0); - library->fill_tensor_uniform(CLAccessor(src2), 1); - library->fill_tensor_uniform(CLAccessor(src3), 2); - } - - // Compute function - gemm.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(GEMM) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, - SmallGEMMDataset() * boost::unit_test::data::make({ DataType::F32, DataType::QS8, DataType::QS16 }), - gemm_set, dt) -{ - // Set fixed point position data type allowed - int fixed_point_position = (dt == DataType::F32) ? 0 : 3; - - // Create tensors - CLTensor src1 = create_tensor<CLTensor>(gemm_set.shape_a, dt, 1, fixed_point_position); - CLTensor src2 = create_tensor<CLTensor>(gemm_set.shape_b, dt, 1, fixed_point_position); - CLTensor src3 = create_tensor<CLTensor>(gemm_set.shape_c, dt, 1, fixed_point_position); - CLTensor dst = create_tensor<CLTensor>(gemm_set.shape_d, dt, 1, fixed_point_position); - - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(src3.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLGEMM gemm; - gemm.configure(&src1, &src2, &src3, &dst, gemm_set.alpha, gemm_set.beta); - - // Validate valid region - const ValidRegion src1_valid_region = shape_to_valid_region(gemm_set.shape_a); - const ValidRegion src2_valid_region = shape_to_valid_region(gemm_set.shape_b); - const ValidRegion src3_valid_region = shape_to_valid_region(gemm_set.shape_c); - const ValidRegion dst_valid_region = shape_to_valid_region(gemm_set.shape_d); - - validate(src1.info()->valid_region(), src1_valid_region); - validate(src2.info()->valid_region(), src2_valid_region); - validate(src3.info()->valid_region(), src3_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); -} - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(SmallGEMM, SmallGEMMDataset() * boost::unit_test::data::make(DataType::F32), - gemm_set, dt) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Compute function - CLTensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f32); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(LargeGEMM, LargeGEMMDataset() * boost::unit_test::data::make(DataType::F32), - gemm_set, dt) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Compute function - CLTensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_f32); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(SmallGEMM, SmallGEMMDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(4, 7), - gemm_set, dt, fixed_point_position) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Compute function - CLTensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_q); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(LargeGEMM, LargeGEMMDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(4, 7), - gemm_set, dt, fixed_point_position) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Compute function - CLTensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Validate output - validate(CLAccessor(dst), ref_dst, tolerance_q); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/NEON/GEMM.cpp b/tests/validation/NEON/GEMM.cpp deleted file mode 100644 index 8747f0ab72..0000000000 --- a/tests/validation/NEON/GEMM.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2017 ARM Limited. - * - * SPDX-License-Identifier: MIT - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in all - * copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -#include "AssetsLibrary.h" -#include "Globals.h" -#include "NEON/Accessor.h" -#include "TypePrinter.h" -#include "Utils.h" -#include "dataset/GEMMDataset.h" -#include "validation/Datasets.h" -#include "validation/Reference.h" -#include "validation/Validation.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGEMM.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -const float tolerance_f32 = 1e-03f; /**< Tolerance value for comparing reference's output against implementation's output for DataType::F32 */ -const float tolerance_q = 1.0f; /**< Tolerance value for comparing reference's output against implementation's output for fixed point data types */ - -Tensor compute_gemm(const TensorShape &src_shape1, const TensorShape &src_shape2, const TensorShape &src_shape3, - const TensorShape &out_shape, float alpha, float beta, DataType dt, int fixed_point_position = 0) -{ - // Create tensors - Tensor src1 = create_tensor<Tensor>(src_shape1, dt, 1, fixed_point_position); - Tensor src2 = create_tensor<Tensor>(src_shape2, dt, 1, fixed_point_position); - Tensor src3 = create_tensor<Tensor>(src_shape3, dt, 1, fixed_point_position); - Tensor dst = create_tensor<Tensor>(out_shape, dt, 1, fixed_point_position); - - // Create and configure function - NEGEMM gemm; - gemm.configure(&src1, &src2, &src3, &dst, alpha, beta); - - // Allocate tensors - src1.allocator()->allocate(); - src2.allocator()->allocate(); - src3.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src1.info()->is_resizable()); - BOOST_TEST(!src2.info()->is_resizable()); - BOOST_TEST(!src3.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - if(dt == DataType::F16 || dt == DataType::F32) - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(Accessor(src1), distribution, 0); - library->fill(Accessor(src2), distribution, 1); - library->fill(Accessor(src3), distribution, 2); - } - else - { - library->fill_tensor_uniform(Accessor(src1), 0); - library->fill_tensor_uniform(Accessor(src2), 1); - library->fill_tensor_uniform(Accessor(src3), 2); - } - - // Compute function - gemm.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(GEMM) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, - SmallGEMMDataset() * boost::unit_test::data::make({ DataType::F32, DataType::QS8, DataType::QS16 }), - gemm_set, dt) -{ - // Set fixed point position data type allowed - int fixed_point_position = (dt == DataType::F32) ? 0 : 3; - - // Create tensors - Tensor src1 = create_tensor<Tensor>(gemm_set.shape_a, dt, 1, fixed_point_position); - Tensor src2 = create_tensor<Tensor>(gemm_set.shape_b, dt, 1, fixed_point_position); - Tensor src3 = create_tensor<Tensor>(gemm_set.shape_c, dt, 1, fixed_point_position); - Tensor dst = create_tensor<Tensor>(gemm_set.shape_d, dt, 1, fixed_point_position); - - BOOST_TEST(src1.info()->is_resizable()); - BOOST_TEST(src2.info()->is_resizable()); - BOOST_TEST(src3.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEGEMM gemm; - gemm.configure(&src1, &src2, &src3, &dst, gemm_set.alpha, gemm_set.beta); - - // Validate valid region - const ValidRegion src1_valid_region = shape_to_valid_region(gemm_set.shape_a); - const ValidRegion src2_valid_region = shape_to_valid_region(gemm_set.shape_b); - const ValidRegion src3_valid_region = shape_to_valid_region(gemm_set.shape_c); - const ValidRegion dst_valid_region = shape_to_valid_region(gemm_set.shape_d); - - validate(src1.info()->valid_region(), src1_valid_region); - validate(src2.info()->valid_region(), src2_valid_region); - validate(src3.info()->valid_region(), src3_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); -} - -#ifdef ARM_COMPUTE_ENABLE_FP16 -BOOST_AUTO_TEST_SUITE(Float16) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(SmallGEMM, SmallGEMMDataset() * boost::unit_test::data::make(DataType::F16), - gemm_set, dt) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Compute function - Tensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f32); -} -BOOST_AUTO_TEST_SUITE_END() -#endif /* ARM_COMPUTE_ENABLE_FP16 */ - -BOOST_AUTO_TEST_SUITE(Float) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(SmallGEMM, SmallGEMMDataset() * boost::unit_test::data::make(DataType::F32), - gemm_set, dt) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Compute function - Tensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f32); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(LargeGEMM, LargeGEMMDataset() * boost::unit_test::data::make(DataType::F32), - gemm_set, dt) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Compute function - Tensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_f32); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE(Quantized) -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(SmallGEMM, SmallGEMMDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(1, 7), - gemm_set, dt, fixed_point_position) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Compute function - Tensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_q); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(LargeGEMM, LargeGEMMDataset() * boost::unit_test::data::make({ DataType::QS8, DataType::QS16 }) * boost::unit_test::data::xrange(1, 7), - gemm_set, dt, fixed_point_position) -{ - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Compute function - Tensor dst = compute_gemm(gemm_set.shape_a, gemm_set.shape_b, gemm_set.shape_c, gemm_set.shape_d, gemm_set.alpha, gemm_set.beta, dt, fixed_point_position); - - // Validate output - validate(Accessor(dst), ref_dst, tolerance_q); -} -BOOST_AUTO_TEST_SUITE_END() - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation/Reference.cpp b/tests/validation/Reference.cpp index 99e3095007..e5bbdf2f2e 100644 --- a/tests/validation/Reference.cpp +++ b/tests/validation/Reference.cpp @@ -340,35 +340,6 @@ RawTensor Reference::compute_reference_gaussian5x5(const TensorShape &shape, Bor return ref_dst; } -RawTensor Reference::compute_reference_gemm(const TensorShape &src_shape1, const TensorShape &src_shape2, const TensorShape &src_shape3, - const TensorShape &dst_shape, float alpha, float beta, DataType dt, int fixed_point_position) -{ - RawTensor src1(src_shape1, dt, 1, fixed_point_position); - RawTensor src2(src_shape2, dt, 1, fixed_point_position); - RawTensor src3(src_shape3, dt, 1, fixed_point_position); - RawTensor dst(dst_shape, dt, 1, fixed_point_position); - - // Fill reference - if(dt == DataType::F16 || dt == DataType::F32) - { - std::uniform_real_distribution<> distribution(-1.0f, 1.0f); - library->fill(src1, distribution, 0); - library->fill(src2, distribution, 1); - library->fill(src3, distribution, 2); - } - else - { - library->fill_tensor_uniform(src1, 0); - library->fill_tensor_uniform(src2, 1); - library->fill_tensor_uniform(src3, 2); - } - - // Compute reference - ReferenceCPP::gemm(src1, src2, src3, dst, alpha, beta); - - return dst; -} - RawTensor Reference::compute_reference_non_linear_filter(const TensorShape &shape, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) { diff --git a/tests/validation/Reference.h b/tests/validation/Reference.h index f3216fbaf9..9bcbdf7418 100644 --- a/tests/validation/Reference.h +++ b/tests/validation/Reference.h @@ -215,21 +215,6 @@ public: * @return Computed raw tensor. */ static RawTensor compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute matrix multiply function. - * - * @param[in] src_shape1 First input tensor shape - * @param[in] src_shape2 Second input tensor shape - * @param[in] src_shape3 Third input tensor shape - * @param[out] dst_shape Output tensor. - * @param[in] alpha Weight of the matrix product - * @param[in] beta Weight of the third matrix - * @param[in] dt Tensor's data type - * @param[in] fixed_point_position (Optional) Number of bits for the fractional part of the fixed point numbers - * - * @return Computed output tensor. - */ - static RawTensor compute_reference_gemm(const TensorShape &src_shape1, const TensorShape &src_shape2, const TensorShape &src_shape3, - const TensorShape &dst_shape, float alpha, float beta, DataType dt, int fixed_point_position = 0); /** Compute reference non linear filter function * * @param[in] shape Shape of the input and output tensors.Data type supported: U8 diff --git a/tests/validation/ReferenceCPP.cpp b/tests/validation/ReferenceCPP.cpp index 6b902ae3f2..0364e75ce3 100644 --- a/tests/validation/ReferenceCPP.cpp +++ b/tests/validation/ReferenceCPP.cpp @@ -222,17 +222,6 @@ void ReferenceCPP::gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode tensor_operations::gaussian5x5(s, d, border_mode, constant_border_value); } -// GEMM -void ReferenceCPP::gemm(const RawTensor &src1, const RawTensor &src2, const RawTensor &src3, - RawTensor &dst, float alpha, float beta) -{ - const TensorVariant s1 = TensorFactory::get_tensor(src1); - const TensorVariant s2 = TensorFactory::get_tensor(src2); - const TensorVariant s3 = TensorFactory::get_tensor(src3); - TensorVariant d = TensorFactory::get_tensor(dst); - - boost::apply_visitor(tensor_visitors::gemm_visitor(s1, s2, s3, alpha, beta), d); -} // Non linear filter void ReferenceCPP::non_linear_filter(const RawTensor &src, RawTensor &dst, NonLinearFilterFunction function, unsigned int mask_size, MatrixPattern pattern, const uint8_t *mask, BorderMode border_mode, uint8_t constant_border_value) diff --git a/tests/validation/ReferenceCPP.h b/tests/validation/ReferenceCPP.h index d289e8e57e..7ae45f0dac 100644 --- a/tests/validation/ReferenceCPP.h +++ b/tests/validation/ReferenceCPP.h @@ -190,17 +190,6 @@ public: * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT */ static void gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); - /** Compute GEMM function. - * - * @param[in] src1 First input tensor - * @param[in] src2 Second input tensor - * @param[in] src3 Third input tensor - * @param[out] dst Output tensr - * @param[in] alpha Weight of the matrix product - * @param[in] beta Weight of the third matrix - */ - static void gemm(const RawTensor &src1, const RawTensor &src2, const RawTensor &src3, - RawTensor &dst, float alpha, float beta); /** Compute non linear filter function. * * @param[in] src First input tensor diff --git a/tests/validation/TensorOperations.h b/tests/validation/TensorOperations.h index f4d2110387..6e6d1f5115 100644 --- a/tests/validation/TensorOperations.h +++ b/tests/validation/TensorOperations.h @@ -592,79 +592,6 @@ void gaussian5x5(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T } } -// Matrix multiplication for floating point type -template <typename T, typename std::enable_if<is_floating_point<T>::value, int>::type * = nullptr> -void gemm(const Tensor<T> &in1, const Tensor<T> &in2, const Tensor<T> &in3, Tensor<T> &out, float alpha, float beta) -{ - const int M = out.shape().y(); - const int N = out.shape().x(); - const int K = in1.shape().x(); - - for(int r = 0; r < M; ++r) - { - for(int c = 0; c < N; ++c) - { - T acc(0); - - for(int k = 0; k < K; ++k) - { - const T a0 = in1[r * K + k]; - const T b0 = in2[k * N + c]; - - acc += a0 * b0; - } - - // Finalize the result: A * B * alpha + C * beta - const T c0 = in3[c + r * N]; - out[c + r * N] = alpha * acc + beta * c0; - } - } -} - -// Matrix multiplication for fixed point type -template <typename T, typename std::enable_if<std::is_integral<T>::value, int>::type * = nullptr> -void gemm(const Tensor<T> &in1, const Tensor<T> &in2, const Tensor<T> &in3, Tensor<T> &out, float alpha, float beta) -{ - using namespace fixed_point_arithmetic; - - using promoted_type = typename fixed_point_arithmetic::traits::promote<T>::type; - - const int M = out.shape().y(); - const int N = out.shape().x(); - const int K = in1.shape().x(); - const int8_t fixed_point_position = static_cast<int8_t>(in1.fixed_point_position()); - - const fixed_point<T> alpha_q(alpha, fixed_point_position); - const fixed_point<T> beta_q(beta, fixed_point_position); - - for(int r = 0; r < M; ++r) - { - for(int c = 0; c < N; ++c) - { - fixed_point<promoted_type> acc_q(0, fixed_point_position); - - for(int k = 0; k < K; ++k) - { - const fixed_point<promoted_type> a0_q(in1[r * K + k], fixed_point_position, true); - const fixed_point<promoted_type> b0_q(in2[k * N + c], fixed_point_position, true); - const fixed_point<promoted_type> axb_q = a0_q * b0_q; - - acc_q = axb_q + acc_q; - } - - // Finalize the result: A * B * alpha + C * beta - const fixed_point<T> c0_q(in3[c + r * N], fixed_point_position, true); - - fixed_point<T> res_q(acc_q); - res_q = alpha_q * res_q; - res_q = (c0_q * beta_q) + res_q; - - // Store the result - out[c + r * N] = res_q.raw(); - } - } -} - // Non linear filter template <typename T> void non_linear_filter(const Tensor<T> &in, Tensor<T> &out, NonLinearFilterFunction function, unsigned int mask_size, diff --git a/tests/validation/TensorVisitors.h b/tests/validation/TensorVisitors.h index 67f1d8a001..5ee7ae3a9f 100644 --- a/tests/validation/TensorVisitors.h +++ b/tests/validation/TensorVisitors.h @@ -132,29 +132,6 @@ private: ConvertPolicy _policy; uint32_t _shift; }; -// GEMM visitor -struct gemm_visitor : public boost::static_visitor<> -{ -public: - explicit gemm_visitor(const TensorVariant &in1, const TensorVariant &in2, const TensorVariant &in3, float alpha, float beta) - : _in1(in1), _in2(in2), _in3(in3), _alpha(alpha), _beta(beta) - { - } - - template <typename T> - void operator()(Tensor<T> &out) const - { - const Tensor<T> &in1 = boost::get<Tensor<T>>(_in1); - const Tensor<T> &in2 = boost::get<Tensor<T>>(_in2); - const Tensor<T> &in3 = boost::get<Tensor<T>>(_in3); - tensor_operations::gemm(in1, in2, in3, out, _alpha, _beta); - } - -private: - const TensorVariant &_in1, &_in2, &_in3; - float _alpha; - float _beta; -}; // Pixel-wise Multiplication visitor struct pixel_wise_multiplication_visitor : public boost::static_visitor<> { |