aboutsummaryrefslogtreecommitdiff
path: root/tests/validation
diff options
context:
space:
mode:
Diffstat (limited to 'tests/validation')
-rw-r--r--tests/validation/CL/CMakeLists.txt9
-rw-r--r--tests/validation/CL/ROIPoolingLayer.cpp112
-rw-r--r--tests/validation/Helpers.cpp72
-rw-r--r--tests/validation/Helpers.h13
-rw-r--r--tests/validation/NEON/Gaussian5x5.cpp2
-rw-r--r--tests/validation/NEON/ROIPoolingLayer.cpp12
6 files changed, 129 insertions, 91 deletions
diff --git a/tests/validation/CL/CMakeLists.txt b/tests/validation/CL/CMakeLists.txt
index 67900b3edc..f4477f621f 100644
--- a/tests/validation/CL/CMakeLists.txt
+++ b/tests/validation/CL/CMakeLists.txt
@@ -27,15 +27,24 @@ set(arm_compute_test_validation_OPENCL_SOURCE_FILES
${CMAKE_SOURCE_DIR}/CL/CLAccessor.h
${CMAKE_CURRENT_SOURCE_DIR}/CLFixture.h
${CMAKE_CURRENT_SOURCE_DIR}/CLFixture.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ActivationLayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/BitwiseAnd.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Box3x3.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/ConvolutionLayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/DepthConvert.cpp
${CMAKE_CURRENT_SOURCE_DIR}/FillBorder.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/FixedPoint/FixedPoint_QS8.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/FullyConnectedLayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gaussian3x3.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Gaussian5x5.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/GEMM.cpp
` ${CMAKE_CURRENT_SOURCE_DIR}/IntegralImage.cpp
+` ${CMAKE_CURRENT_SOURCE_DIR}/NonLinearFilter.cpp
+` ${CMAKE_CURRENT_SOURCE_DIR}/PoolingLayer.cpp
+` ${CMAKE_CURRENT_SOURCE_DIR}/ROIPoolingLayer.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
${CMAKE_CURRENT_SOURCE_DIR}/DirectConvolutionLayer.cpp
${CMAKE_CURRENT_SOURCE_DIR}/MeanStdDev.cpp
diff --git a/tests/validation/CL/ROIPoolingLayer.cpp b/tests/validation/CL/ROIPoolingLayer.cpp
new file mode 100644
index 0000000000..19d7903128
--- /dev/null
+++ b/tests/validation/CL/ROIPoolingLayer.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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 "CL/CLArrayAccessor.h"
+#include "TypePrinter.h"
+#include "arm_compute/runtime/CL/CLArray.h"
+#include "arm_compute/runtime/CL/functions/CLROIPoolingLayer.h"
+#include "tests/Globals.h"
+#include "tests/Utils.h"
+#include "validation/Datasets.h"
+#include "validation/Reference.h"
+#include "validation/Validation.h"
+#include "validation/ValidationUserConfiguration.h"
+
+#include <random>
+#include <vector>
+
+using namespace arm_compute;
+using namespace arm_compute::test;
+using namespace arm_compute::test::validation;
+
+namespace
+{
+CLTensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const std::vector<ROI> &rois, ROIPoolingLayerInfo pool_info)
+{
+ TensorShape shape_dst;
+ shape_dst.set(0, pool_info.pooled_width());
+ shape_dst.set(1, pool_info.pooled_height());
+ shape_dst.set(2, shape.z());
+ shape_dst.set(3, rois.size());
+
+ // Create tensors
+ CLTensor src = create_tensor<CLTensor>(shape, dt);
+ CLTensor dst = create_tensor<CLTensor>(shape_dst, dt);
+
+ // Create ROI array
+ CLArray<ROI> rois_array(rois.size());
+ fill_array(CLArrayAccessor<ROI>(rois_array), rois);
+
+ // Create and configure function
+ CLROIPoolingLayer roi_pool;
+ roi_pool.configure(&src, &rois_array, &dst, pool_info);
+
+ // Allocate tensors
+ src.allocator()->allocate();
+ dst.allocator()->allocate();
+
+ BOOST_TEST(!src.info()->is_resizable());
+ BOOST_TEST(!dst.info()->is_resizable());
+
+ // Fill tensors
+ std::uniform_real_distribution<> distribution(-1, 1);
+ library->fill(CLAccessor(src), distribution, 0);
+
+ // Compute function
+ roi_pool.run();
+
+ return dst;
+}
+} // namespace
+
+#ifndef DOXYGEN_SKIP_THIS
+BOOST_AUTO_TEST_SUITE(CL)
+BOOST_AUTO_TEST_SUITE(ROIPoolingLayer)
+
+BOOST_AUTO_TEST_SUITE(Float)
+BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit"))
+BOOST_DATA_TEST_CASE(RunSmall, boost::unit_test::data::make({ DataType::F16, DataType::F32 }) * boost::unit_test::data::make({ 10, 20, 40 }) * boost::unit_test::data::make({ 7, 9 }) *
+ boost::unit_test::data::make({ 1.f / 8.f, 1.f / 16.f }),
+ dt, num_rois, roi_pool_size, roi_scale)
+{
+ TensorShape shape(50U, 47U, 2U, 3U);
+ ROIPoolingLayerInfo pool_info(roi_pool_size, roi_pool_size, roi_scale);
+
+ // Construct ROI vector
+ std::vector<ROI> rois = generate_random_rois(shape, pool_info, num_rois, user_config.seed);
+
+ // Compute function
+ CLTensor dst = compute_roi_pooling_layer(shape, dt, rois, pool_info);
+
+ // Compute reference
+ RawTensor ref_dst = Reference::compute_reference_roi_pooling_layer(shape, dt, rois, pool_info);
+
+ // Validate output
+ validate(CLAccessor(dst), ref_dst);
+}
+BOOST_AUTO_TEST_SUITE_END()
+
+BOOST_AUTO_TEST_SUITE_END()
+BOOST_AUTO_TEST_SUITE_END()
+#endif /* DOXYGEN_SKIP_THIS */
diff --git a/tests/validation/Helpers.cpp b/tests/validation/Helpers.cpp
deleted file mode 100644
index 747260ea99..0000000000
--- a/tests/validation/Helpers.cpp
+++ /dev/null
@@ -1,72 +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 "validation/Helpers.h"
-
-using namespace arm_compute::test;
-
-namespace arm_compute
-{
-namespace test
-{
-namespace validation
-{
-std::vector<ROI> generate_random_rois(const TensorShape &shape, const ROIPoolingLayerInfo &pool_info, unsigned int num_rois, std::random_device::result_type seed)
-{
- ARM_COMPUTE_ERROR_ON((pool_info.pooled_width() < 4) || (pool_info.pooled_height() < 4));
-
- std::vector<ROI> rois;
- std::mt19937 gen(seed);
- const int pool_width = pool_info.pooled_width();
- const int pool_height = pool_info.pooled_height();
- const float roi_scale = pool_info.spatial_scale();
-
- // Calculate distribution bounds
- const auto scaled_width = static_cast<int>((shape.x() / roi_scale) / pool_width);
- const auto scaled_height = static_cast<int>((shape.y() / roi_scale) / pool_height);
- const auto min_width = static_cast<int>(pool_width / roi_scale);
- const auto min_height = static_cast<int>(pool_height / roi_scale);
-
- // Create distributions
- std::uniform_int_distribution<int> dist_batch(0, shape[3] - 1);
- std::uniform_int_distribution<int> dist_x(0, scaled_width);
- std::uniform_int_distribution<int> dist_y(0, scaled_height);
- std::uniform_int_distribution<int> dist_w(min_width, std::max(min_width, (pool_width - 2) * scaled_width));
- std::uniform_int_distribution<int> dist_h(min_height, std::max(min_height, (pool_height - 2) * scaled_height));
-
- for(unsigned int r = 0; r < num_rois; ++r)
- {
- ROI roi{};
- roi.batch_idx = dist_batch(gen);
- roi.rect.x = dist_x(gen);
- roi.rect.y = dist_y(gen);
- roi.rect.width = dist_w(gen);
- roi.rect.height = dist_h(gen);
- rois.push_back(roi);
- }
-
- return rois;
-}
-} // namespace validation
-} // namespace test
-} // namespace arm_compute
diff --git a/tests/validation/Helpers.h b/tests/validation/Helpers.h
index 09ffda8957..19a0c4105c 100644
--- a/tests/validation/Helpers.h
+++ b/tests/validation/Helpers.h
@@ -32,6 +32,7 @@
#include "tests/validation/half.h"
#include <array>
+#include <cstring>
#include <random>
#include <type_traits>
#include <utility>
@@ -250,17 +251,6 @@ inline void fill_warp_matrix(std::array<float, SIZE> &matrix, int cols, int rows
}
}
-/** Create a vector of random ROIs.
- *
- * @param[in] shape The shape of the input tensor.
- * @param[in] pool_info The ROI pooling information.
- * @param[in] num_rois The number of ROIs to be created.
- * @param[in] seed The random seed to be used.
- *
- * @return A vector that contains the requested number of random ROIs
- */
-std::vector<ROI> generate_random_rois(const TensorShape &shape, const ROIPoolingLayerInfo &pool_info, unsigned int num_rois, std::random_device::result_type seed);
-
/** Helper function to fill the Lut random by a ILutAccessor.
*
* @param[in,out] table Accessor at the Lut.
@@ -277,7 +267,6 @@ void fill_lookuptable(T &&table)
table[i] = distribution(generator);
}
}
-
} // namespace validation
} // namespace test
} // namespace arm_compute
diff --git a/tests/validation/NEON/Gaussian5x5.cpp b/tests/validation/NEON/Gaussian5x5.cpp
index 522ececee9..7727340f66 100644
--- a/tests/validation/NEON/Gaussian5x5.cpp
+++ b/tests/validation/NEON/Gaussian5x5.cpp
@@ -41,8 +41,6 @@
#include "boost_wrapper.h"
-#include <iostream>
-
#include <random>
#include <string>
diff --git a/tests/validation/NEON/ROIPoolingLayer.cpp b/tests/validation/NEON/ROIPoolingLayer.cpp
index 5775db7e03..523885d908 100644
--- a/tests/validation/NEON/ROIPoolingLayer.cpp
+++ b/tests/validation/NEON/ROIPoolingLayer.cpp
@@ -22,13 +22,12 @@
* SOFTWARE.
*/
#include "NEON/Accessor.h"
-#include "NEON/Helper.h"
+#include "NEON/ArrayAccessor.h"
#include "TypePrinter.h"
#include "arm_compute/runtime/NEON/functions/NEROIPoolingLayer.h"
#include "tests/Globals.h"
#include "tests/Utils.h"
#include "validation/Datasets.h"
-#include "validation/Helpers.h"
#include "validation/Reference.h"
#include "validation/Validation.h"
#include "validation/ValidationUserConfiguration.h"
@@ -51,9 +50,12 @@ Tensor compute_roi_pooling_layer(const TensorShape &shape, DataType dt, const st
shape_dst.set(3, rois.size());
// Create tensors
- Tensor src = create_tensor<Tensor>(shape, dt);
- Tensor dst = create_tensor<Tensor>(shape_dst, dt);
- Array<ROI> rois_array = create_array(rois);
+ Tensor src = create_tensor<Tensor>(shape, dt);
+ Tensor dst = create_tensor<Tensor>(shape_dst, dt);
+
+ // Create ROI array
+ Array<ROI> rois_array(rois.size());
+ fill_array(ArrayAccessor<ROI>(rois_array), rois);
// Create and configure function
NEROIPoolingLayer roi_pool;