diff options
Diffstat (limited to 'tests/validation_old')
-rw-r--r-- | tests/validation_old/CL/Gaussian3x3.cpp | 166 | ||||
-rw-r--r-- | tests/validation_old/CL/Gaussian5x5.cpp | 166 | ||||
-rw-r--r-- | tests/validation_old/NEON/Gaussian3x3.cpp | 167 | ||||
-rw-r--r-- | tests/validation_old/NEON/Gaussian5x5.cpp | 167 | ||||
-rw-r--r-- | tests/validation_old/Reference.cpp | 30 | ||||
-rw-r--r-- | tests/validation_old/Reference.h | 18 | ||||
-rw-r--r-- | tests/validation_old/ReferenceCPP.cpp | 18 | ||||
-rw-r--r-- | tests/validation_old/ReferenceCPP.h | 16 | ||||
-rw-r--r-- | tests/validation_old/TensorOperations.h | 32 |
9 files changed, 0 insertions, 780 deletions
diff --git a/tests/validation_old/CL/Gaussian3x3.cpp b/tests/validation_old/CL/Gaussian3x3.cpp deleted file mode 100644 index 6aa2d0349e..0000000000 --- a/tests/validation_old/CL/Gaussian3x3.cpp +++ /dev/null @@ -1,166 +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 "CL/CLAccessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGaussian3x3.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor<CLTensor>(shape, DataType::U8); - CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); - - // Create and configure function - CLGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - gaussian3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Gaussian3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor<CLTensor>(shape, DataType::U8); - CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/CL/Gaussian5x5.cpp b/tests/validation_old/CL/Gaussian5x5.cpp deleted file mode 100644 index 32a33d2661..0000000000 --- a/tests/validation_old/CL/Gaussian5x5.cpp +++ /dev/null @@ -1,166 +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 "CL/CLAccessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/CL/CLTensor.h" -#include "arm_compute/runtime/CL/CLTensorAllocator.h" -#include "arm_compute/runtime/CL/functions/CLGaussian5x5.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute CL gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -CLTensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - CLTensor src = create_tensor<CLTensor>(shape, DataType::U8); - CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); - - // Create and configure function - CLGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(CLAccessor(src), 0); - - // Compute function - gaussian5x5.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(CL) -BOOST_AUTO_TEST_SUITE(Gaussian5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - CLTensor src = create_tensor<CLTensor>(shape, DataType::U8); - CLTensor dst = create_tensor<CLTensor>(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - CLGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(2); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - CLTensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(CLAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Gaussian3x3.cpp b/tests/validation_old/NEON/Gaussian3x3.cpp deleted file mode 100644 index b1fdc5e069..0000000000 --- a/tests/validation_old/NEON/Gaussian3x3.cpp +++ /dev/null @@ -1,167 +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 "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGaussian3x3.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 3; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - // Create and configure function - NEGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - gaussian3x3.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Gaussian3x3) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEGaussian3x3 gaussian3x3; - gaussian3x3.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 8); - calculator.set_border_size(1); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_accessed_elements(16); - calculator.set_access_offset(-1); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian3x3(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian3x3(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/NEON/Gaussian5x5.cpp b/tests/validation_old/NEON/Gaussian5x5.cpp deleted file mode 100644 index c98d21b35c..0000000000 --- a/tests/validation_old/NEON/Gaussian5x5.cpp +++ /dev/null @@ -1,167 +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 "NEON/Accessor.h" -#include "PaddingCalculator.h" -#include "Utils.h" -#include "tests/AssetsLibrary.h" -#include "tests/Globals.h" -#include "tests/validation_old/Datasets.h" -#include "tests/validation_old/Reference.h" -#include "tests/validation_old/Validation.h" -#include "tests/validation_old/ValidationUserConfiguration.h" -#include "utils/TypePrinter.h" - -#include "arm_compute/core/Helpers.h" -#include "arm_compute/core/Types.h" -#include "arm_compute/runtime/NEON/functions/NEGaussian5x5.h" -#include "arm_compute/runtime/SubTensor.h" -#include "arm_compute/runtime/Tensor.h" -#include "arm_compute/runtime/TensorAllocator.h" - -#include "tests/validation_old/boost_wrapper.h" - -#include <random> -#include <string> - -using namespace arm_compute; -using namespace arm_compute::test; -using namespace arm_compute::test::validation; - -namespace -{ -constexpr unsigned int filter_size = 5; /** Size of the kernel/filter in number of elements. */ -constexpr BorderSize border_size(filter_size / 2); /** Border size of the kernel/filter around its central element. */ - -/** Compute Neon gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed output tensor. - */ -Tensor compute_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create tensors - Tensor src = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - // Create and configure function - NEGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode, constant_border_value); - - // Allocate tensors - src.allocator()->allocate(); - dst.allocator()->allocate(); - - BOOST_TEST(!src.info()->is_resizable()); - BOOST_TEST(!dst.info()->is_resizable()); - - // Fill tensors - library->fill_tensor_uniform(Accessor(src), 0); - - // Compute function - gaussian5x5.run(); - - return dst; -} -} // namespace - -#ifndef DOXYGEN_SKIP_THIS -BOOST_AUTO_TEST_SUITE(NEON) -BOOST_AUTO_TEST_SUITE(Gaussian5x5) - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) -{ - // Create tensors - Tensor src = create_tensor<Tensor>(shape, DataType::U8); - Tensor dst = create_tensor<Tensor>(shape, DataType::U8); - - BOOST_TEST(src.info()->is_resizable()); - BOOST_TEST(dst.info()->is_resizable()); - - // Create and configure function - NEGaussian5x5 gaussian5x5; - gaussian5x5.configure(&src, &dst, border_mode); - - // Validate valid region - const ValidRegion src_valid_region = shape_to_valid_region(shape); - const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size); - validate(src.info()->valid_region(), src_valid_region); - validate(dst.info()->valid_region(), dst_valid_region); - - // Validate padding - PaddingCalculator calculator(shape.x(), 16); - calculator.set_border_size(2); - calculator.set_border_mode(border_mode); - - const PaddingSize dst_padding = calculator.required_padding(); - - calculator.set_processed_elements(8); - calculator.set_access_offset(-2); - - const PaddingSize src_padding = calculator.required_padding(); - - validate(src.info()->padding(), src_padding); - validate(dst.info()->padding(), dst_padding); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * BorderModes(), shape, border_mode) -{ - std::mt19937 gen(user_config.seed.get()); - std::uniform_int_distribution<uint8_t> distribution(0, 255); - const uint8_t border_value = distribution(gen); - - // Compute function - Tensor dst = compute_gaussian5x5(shape, border_mode, border_value); - - // Compute reference - RawTensor ref_dst = Reference::compute_reference_gaussian5x5(shape, border_mode, border_value); - - // Validate output - validate(Accessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, border_size)); -} - -BOOST_AUTO_TEST_SUITE_END() -BOOST_AUTO_TEST_SUITE_END() -#endif /* DOXYGEN_SKIP_THIS */ diff --git a/tests/validation_old/Reference.cpp b/tests/validation_old/Reference.cpp index 91cc688ac0..32e0212596 100644 --- a/tests/validation_old/Reference.cpp +++ b/tests/validation_old/Reference.cpp @@ -160,36 +160,6 @@ RawTensor Reference::compute_reference_accumulate_weighted(const TensorShape &sh return ref_dst; } -RawTensor Reference::compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::gaussian3x3(ref_src, ref_dst, border_mode, constant_border_value); - - return ref_dst; -} - -RawTensor Reference::compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) -{ - // Create reference - RawTensor ref_src(shape, DataType::U8); - RawTensor ref_dst(shape, DataType::U8); - - // Fill reference - library->fill_tensor_uniform(ref_src, 0); - - // Compute reference - ReferenceCPP::gaussian5x5(ref_src, ref_dst, border_mode, constant_border_value); - - return ref_dst; -} - RawTensor Reference::compute_reference_pixel_wise_multiplication(const TensorShape &shape, DataType dt_in0, DataType dt_in1, DataType dt_out, float scale, ConvertPolicy convert_policy, RoundingPolicy rounding_policy) { diff --git a/tests/validation_old/Reference.h b/tests/validation_old/Reference.h index 1dfad4e080..306009df05 100644 --- a/tests/validation_old/Reference.h +++ b/tests/validation_old/Reference.h @@ -107,24 +107,6 @@ public: * @return Computed raw tensor. */ static RawTensor compute_reference_accumulate_weighted(const TensorShape &shape, float alpha); - /** Compute reference gaussian3x3 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_gaussian3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); - /** Compute reference gaussian5x5 filter. - * - * @param[in] shape Shape of the input and output tensors. - * @param[in] border_mode BorderMode used by the input tensor. - * @param[in] constant_border_value Constant to use if @p border_mode == CONSTANT. - * - * @return Computed raw tensor. - */ - static RawTensor compute_reference_gaussian5x5(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value); /** Compute reference pixel-wise multiplication * * @param[in] shape Shape of the input and output tensors. diff --git a/tests/validation_old/ReferenceCPP.cpp b/tests/validation_old/ReferenceCPP.cpp index 55aac59211..e10f9065a0 100644 --- a/tests/validation_old/ReferenceCPP.cpp +++ b/tests/validation_old/ReferenceCPP.cpp @@ -140,24 +140,6 @@ void ReferenceCPP::accumulate_weighted(const RawTensor &src, RawTensor &dst, flo tensor_operations::accumulate_weighted(s, d, alpha); } -// Gaussian3x3 filter -void ReferenceCPP::gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor<uint8_t> s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast<const uint8_t *>(src.data())); - Tensor<uint8_t> d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast<uint8_t *>(dst.data())); - tensor_operations::gaussian3x3(s, d, border_mode, constant_border_value); -} - -// Gaussian5x5 filter -void ReferenceCPP::gaussian5x5(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value) -{ - ARM_COMPUTE_ERROR_ON(src.data_type() != DataType::U8 || dst.data_type() != DataType::U8); - const Tensor<uint8_t> s(src.shape(), src.data_type(), src.fixed_point_position(), reinterpret_cast<const uint8_t *>(src.data())); - Tensor<uint8_t> d(dst.shape(), dst.data_type(), dst.fixed_point_position(), reinterpret_cast<uint8_t *>(dst.data())); - tensor_operations::gaussian5x5(s, d, border_mode, constant_border_value); -} - // 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_old/ReferenceCPP.h b/tests/validation_old/ReferenceCPP.h index b04d5e331f..3203196b5d 100644 --- a/tests/validation_old/ReferenceCPP.h +++ b/tests/validation_old/ReferenceCPP.h @@ -116,22 +116,6 @@ public: * @param[in] alpha A float value within the range of [0, 1] */ static void accumulate_weighted(const RawTensor &src, RawTensor &dst, float alpha); - /** Function to compute gaussian3x3 filtered result tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] border_mode Border mode - * @param[in] constant_border_value Constant border value if @p border_mode is BorderMode::CONSTANT - */ - static void gaussian3x3(const RawTensor &src, RawTensor &dst, BorderMode border_mode, uint8_t constant_border_value); - /** Function to compute gaussian5x5 filtered result tensor. - * - * @param[in] src Input tensor. - * @param[out] dst Result tensor. - * @param[in] border_mode Border mode - * @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 non linear filter function. * * @param[in] src First input tensor diff --git a/tests/validation_old/TensorOperations.h b/tests/validation_old/TensorOperations.h index af17ea8dfd..bba09175ca 100644 --- a/tests/validation_old/TensorOperations.h +++ b/tests/validation_old/TensorOperations.h @@ -511,38 +511,6 @@ void accumulate_weighted(const Tensor<T> &in, Tensor<T> &out, float alpha) } } -// Gaussian3x3 filter -template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> -void gaussian3x3(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T constant_border_value) -{ - const std::array<T, 9> filter{ { 1, 2, 1, 2, 4, 2, 1, 2, 1 } }; - const float scale = 1.f / 16.f; - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - apply_2d_spatial_filter(id, in, out, TensorShape(3U, 3U), filter.data(), scale, border_mode, constant_border_value); - } -} - -// Gaussian5x5 filter -template <typename T, typename = typename std::enable_if<std::is_integral<T>::value>::type> -void gaussian5x5(const Tensor<T> &in, Tensor<T> &out, BorderMode border_mode, T constant_border_value) -{ - const std::array<T, 25> filter{ { - 1, 4, 6, 4, 1, - 4, 16, 24, 16, 4, - 6, 24, 36, 24, 6, - 4, 16, 24, 16, 4, - 1, 4, 6, 4, 1 - } }; - const float scale = 1.f / 256.f; - for(int element_idx = 0; element_idx < in.num_elements(); ++element_idx) - { - const Coordinates id = index2coord(in.shape(), element_idx); - apply_2d_spatial_filter(id, in, out, TensorShape(5U, 5U), filter.data(), scale, border_mode, constant_border_value); - } -} - // Non linear filter template <typename T> void non_linear_filter(const Tensor<T> &in, Tensor<T> &out, NonLinearFilterFunction function, unsigned int mask_size, |