aboutsummaryrefslogtreecommitdiff
path: root/tests/validation/NEON/Box3x3.cpp
diff options
context:
space:
mode:
authorSiCong Li <sicong.li@arm.com>2017-06-19 13:41:45 +0100
committerAnthony Barbier <anthony.barbier@arm.com>2018-09-17 14:14:20 +0100
commitbacaf9af9b23b01e646a2e206e119a9d8e099a70 (patch)
tree7a30f22a6b1176102204077806dc0a6f1a46138d /tests/validation/NEON/Box3x3.cpp
parent50f9fd73536fd359137702ac9c42c9a1c61ff415 (diff)
downloadComputeLibrary-bacaf9af9b23b01e646a2e206e119a9d8e099a70.tar.gz
COMPMID-424 Add CL validation tests for Box3x3
* Add tests for different border modes * Add padding calculator Change-Id: Ic4708faddfb1c8e6b59d349cf9cb48c9a181d717 Reviewed-on: http://mpd-gerrit.cambridge.arm.com/78105 Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com> Reviewed-by: Moritz Pflanzer <moritz.pflanzer@arm.com>
Diffstat (limited to 'tests/validation/NEON/Box3x3.cpp')
-rw-r--r--tests/validation/NEON/Box3x3.cpp48
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()