From bacaf9af9b23b01e646a2e206e119a9d8e099a70 Mon Sep 17 00:00:00 2001 From: SiCong Li Date: Mon, 19 Jun 2017 13:41:45 +0100 Subject: 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 Reviewed-by: Moritz Pflanzer --- tests/validation/NEON/Box3x3.cpp | 48 ++++++++++++++++++++++-------------- tests/validation/NEON/CMakeLists.txt | 12 ++++++++- 2 files changed, 41 insertions(+), 19 deletions(-) (limited to 'tests/validation/NEON') 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 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 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() diff --git a/tests/validation/NEON/CMakeLists.txt b/tests/validation/NEON/CMakeLists.txt index 86bcce7e93..d928362227 100644 --- a/tests/validation/NEON/CMakeLists.txt +++ b/tests/validation/NEON/CMakeLists.txt @@ -30,21 +30,31 @@ set(arm_compute_test_validation_NEON_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/AccumulateWeighted.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ArithmeticAddition.cpp ${CMAKE_CURRENT_SOURCE_DIR}/ArithmeticSubtraction.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/BatchNormalizationLayer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseAnd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseNot.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseOr.cpp ${CMAKE_CURRENT_SOURCE_DIR}/BitwiseXor.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Box3x3.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ConvolutionLayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ConvolutionLayerDirect.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/DepthConvert.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FillBorder.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Exp_QS8.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Invsqrt_QS8.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Log_QS8.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Fixedpoint/Reciprocal_QS8.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/FullyConnectedLayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/GEMM.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/IntegralImage.cpp ${CMAKE_CURRENT_SOURCE_DIR}/NormalizationLayer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/PixelWiseMultiplication.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/IntegralImage.cpp ${CMAKE_CURRENT_SOURCE_DIR}/MeanStdDev.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Pooling/PoolingLayer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Sobel3x3.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Sobel5x5.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/SoftmaxLayer.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/Threshold.cpp ) add_library(arm_compute_test_validation_NEON OBJECT -- cgit v1.2.1