diff options
Diffstat (limited to 'tests/validation/NEON/Box3x3.cpp')
-rw-r--r-- | tests/validation/NEON/Box3x3.cpp | 48 |
1 files changed, 30 insertions, 18 deletions
diff --git a/tests/validation/NEON/Box3x3.cpp b/tests/validation/NEON/Box3x3.cpp index b2a66cde30..c05167682a 100644 --- a/tests/validation/NEON/Box3x3.cpp +++ b/tests/validation/NEON/Box3x3.cpp @@ -31,6 +31,7 @@ #include "validation/Datasets.h" #include "validation/Reference.h" #include "validation/Validation.h" +#include "validation/ValidationUserConfiguration.h" #include "arm_compute/core/Helpers.h" #include "arm_compute/core/Types.h" @@ -51,21 +52,23 @@ using namespace arm_compute::test::validation; namespace { -/** Compute Neon 3-by-3 box filter. +/** Compute Neon box3x3 filter. * - * @param[in] shape Shape of the input and output tensors. + * @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_box3x3(const TensorShape &shape) +Tensor compute_box3x3(const TensorShape &shape, BorderMode border_mode, uint8_t constant_border_value) { // Create tensors Tensor src = create_tensor(shape, DataType::U8); Tensor dst = create_tensor(shape, DataType::U8); // Create and configure function - NEBox3x3 band; - band.configure(&src, &dst, BorderMode::UNDEFINED); + NEBox3x3 box3x3; + box3x3.configure(&src, &dst, border_mode, constant_border_value); // Allocate tensors src.allocator()->allocate(); @@ -78,7 +81,7 @@ Tensor compute_box3x3(const TensorShape &shape) library->fill_tensor_uniform(NEAccessor(src), 0); // Compute function - band.run(); + box3x3.run(); return dst; } @@ -89,7 +92,7 @@ BOOST_AUTO_TEST_SUITE(NEON) BOOST_AUTO_TEST_SUITE(Box3x3) BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) +BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * BorderModes(), shape, border_mode) { // Create tensors Tensor src = create_tensor(shape, DataType::U8); @@ -99,18 +102,19 @@ BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) BOOST_TEST(dst.info()->is_resizable()); // Create and configure function - NEBox3x3 band; - band.configure(&src, &dst, BorderMode::UNDEFINED); + NEBox3x3 box3x3; + box3x3.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_undefined_border(shape, BorderSize(1)); + const ValidRegion dst_valid_region = shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(1)); 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(); @@ -124,29 +128,37 @@ BOOST_DATA_TEST_CASE(Configuration, SmallShapes() + LargeShapes(), shape) } BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) -BOOST_DATA_TEST_CASE(RunSmall, SmallShapes(), shape) +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_box3x3(shape); + Tensor dst = compute_box3x3(shape, border_mode, border_value); // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape); + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); // Validate output - validate(NEAccessor(dst), ref_dst, shape_to_valid_region_undefined_border(shape, BorderSize(1))); + validate(NEAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(1))); } BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) -BOOST_DATA_TEST_CASE(RunLarge, LargeShapes(), shape) +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_box3x3(shape); + Tensor dst = compute_box3x3(shape, border_mode, border_value); // Compute reference - RawTensor ref_dst = Reference::compute_reference_box3x3(shape); + RawTensor ref_dst = Reference::compute_reference_box3x3(shape, border_mode, border_value); // Validate output - validate(NEAccessor(dst), ref_dst, shape_to_valid_region_undefined_border(shape, BorderSize(1))); + validate(NEAccessor(dst), ref_dst, shape_to_valid_region(shape, border_mode == BorderMode::UNDEFINED, BorderSize(1))); } BOOST_AUTO_TEST_SUITE_END() |