From cc5171b85654b9f19a5f52bbe8abea0572ee0163 Mon Sep 17 00:00:00 2001 From: Manuel Bottini Date: Wed, 9 Jan 2019 17:04:39 +0000 Subject: COMPMID-1677: Change ROIPooling layer interface to accept ROIs as tensors Change-Id: If16b572a4d906187b77f32133a72a44316fa74e4 Reviewed-on: https://review.mlplatform.org/490 Tested-by: Arm Jenkins Reviewed-by: Georgios Pinitas --- tests/Utils.h | 48 +------- tests/benchmark/CL/ROIPoolingLayer.cpp | 20 +-- tests/benchmark/NEON/ROIPoolingLayer.cpp | 13 +- tests/benchmark/fixtures/ROIPoolingLayerFixture.h | 78 +++++++++--- tests/datasets/ROIAlignLayerDataset.h | 143 ---------------------- tests/datasets/ROIDataset.h | 143 ++++++++++++++++++++++ tests/datasets/ROIPoolingLayerDataset.h | 129 ------------------- tests/validation/CL/ROIAlignLayer.cpp | 8 +- 8 files changed, 228 insertions(+), 354 deletions(-) delete mode 100644 tests/datasets/ROIAlignLayerDataset.h create mode 100644 tests/datasets/ROIDataset.h delete mode 100644 tests/datasets/ROIPoolingLayerDataset.h (limited to 'tests') diff --git a/tests/Utils.h b/tests/Utils.h index 111d80fdfe..7c55a3ef50 100644 --- a/tests/Utils.h +++ b/tests/Utils.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -647,52 +647,6 @@ inline void init_separable_conv(int16_t *conv, unsigned int width, unsigned int } } -/** 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 - */ -inline std::vector 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 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((shape.x() / roi_scale) / pool_width); - const auto scaled_height = static_cast((shape.y() / roi_scale) / pool_height); - const auto min_width = static_cast(pool_width / roi_scale); - const auto min_height = static_cast(pool_height / roi_scale); - - // Create distributions - std::uniform_int_distribution dist_batch(0, shape[3] - 1); - std::uniform_int_distribution dist_x(0, scaled_width); - std::uniform_int_distribution dist_y(0, scaled_height); - std::uniform_int_distribution dist_w(min_width, std::max(min_width, (pool_width - 2) * scaled_width)); - std::uniform_int_distribution 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; -} - /** Create a vector with a uniform distribution of floating point values across the specified range. * * @param[in] num_values The number of values to be created. diff --git a/tests/benchmark/CL/ROIPoolingLayer.cpp b/tests/benchmark/CL/ROIPoolingLayer.cpp index 2ef91d45fd..eadb027b75 100644 --- a/tests/benchmark/CL/ROIPoolingLayer.cpp +++ b/tests/benchmark/CL/ROIPoolingLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,7 @@ #include "tests/CL/CLAccessor.h" #include "tests/CL/CLArrayAccessor.h" #include "tests/benchmark/fixtures/ROIPoolingLayerFixture.h" -#include "tests/datasets/ROIPoolingLayerDataset.h" +#include "tests/datasets/ROIDataset.h" #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" #include "utils/TypePrinter.h" @@ -41,16 +41,20 @@ namespace test { namespace benchmark { -using CLROIPoolingLayerFixture = ROIPoolingLayerFixture, CLArrayAccessor>; +template +using CLROIPoolingLayerFixture = ROIPoolingLayerFixture; TEST_SUITE(CL) - -REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, CLROIPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), - framework::dataset::make("DataType", { DataType::F16, DataType::F32 })), +REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayerHalf, CLROIPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(), + framework::dataset::make("DataType", { DataType::F16 })), framework::dataset::make("Batches", { 1, 4, 8 }))); -TEST_SUITE_END() +REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayerFloat, CLROIPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(), + framework::dataset::make("DataType", { DataType::F32 })), + framework::dataset::make("Batches", { 1, 4, 8 }))); +TEST_SUITE_END() // CL } // namespace benchmark } // namespace test } // namespace arm_compute diff --git a/tests/benchmark/NEON/ROIPoolingLayer.cpp b/tests/benchmark/NEON/ROIPoolingLayer.cpp index 02cf47b189..10652a5606 100644 --- a/tests/benchmark/NEON/ROIPoolingLayer.cpp +++ b/tests/benchmark/NEON/ROIPoolingLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -30,7 +30,7 @@ #include "tests/NEON/Accessor.h" #include "tests/NEON/ArrayAccessor.h" #include "tests/benchmark/fixtures/ROIPoolingLayerFixture.h" -#include "tests/datasets/ROIPoolingLayerDataset.h" +#include "tests/datasets/ROIDataset.h" #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" #include "utils/TypePrinter.h" @@ -41,16 +41,17 @@ namespace test { namespace benchmark { -using NEROIPoolingLayerFixture = ROIPoolingLayerFixture, ArrayAccessor>; +template +using NEROIPoolingLayerFixture = ROIPoolingLayerFixture; TEST_SUITE(NEON) -REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayer, NEROIPoolingLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(framework::dataset::combine(datasets::SmallROIPoolingLayerDataset(), +REGISTER_FIXTURE_DATA_TEST_CASE(SmallROIPoolingLayerFloat, NEROIPoolingLayerFixture, framework::DatasetMode::ALL, + framework::dataset::combine(framework::dataset::combine(datasets::SmallROIDataset(), framework::dataset::make("DataType", { DataType::F32 })), framework::dataset::make("Batches", { 1, 4, 8 }))); -TEST_SUITE_END() +TEST_SUITE_END() // NEON } // namespace benchmark } // namespace test } // namespace arm_compute diff --git a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h index fa4a5b7044..2c828272de 100644 --- a/tests/benchmark/fixtures/ROIPoolingLayerFixture.h +++ b/tests/benchmark/fixtures/ROIPoolingLayerFixture.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2018 ARM Limited. + * Copyright (c) 2017-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -39,37 +39,38 @@ namespace test namespace benchmark { /** Fixture that can be used for NEON and CL */ -template +template class ROIPoolingLayerFixture : public framework::Fixture { public: template - void setup(TensorShape shape, const ROIPoolingLayerInfo pool_info, unsigned int num_rois, DataType data_type, int batches) + void setup(TensorShape input_shape, const ROIPoolingLayerInfo pool_info, TensorShape rois_shape, DataType data_type, int batches) { // Set batched in source and destination shapes TensorShape shape_dst; - shape.set(shape.num_dimensions(), batches); + rois_tensor = create_tensor(rois_shape, DataType::U16); + + input_shape.set(input_shape.num_dimensions(), batches); 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, num_rois); + shape_dst.set(2, input_shape.z()); + shape_dst.set(3, rois_shape[1]); // Create tensors - src = create_tensor(shape, data_type, 1); + src = create_tensor(input_shape, data_type, 1); dst = create_tensor(shape_dst, data_type, 1); - // Create random ROIs - std::vector rois = generate_random_rois(shape, pool_info, num_rois, 0U); - rois_array = arm_compute::support::cpp14::make_unique(num_rois); - fill_array(ArrayAccessor(*rois_array), rois); - // Create and configure function - roi_pool.configure(&src, rois_array.get(), &dst, pool_info); + roi_pool.configure(&src, &rois_tensor, &dst, pool_info); // Allocate tensors + rois_tensor.allocator()->allocate(); src.allocator()->allocate(); dst.allocator()->allocate(); + + // Create random ROIs + generate_rois(AccessorType(rois_tensor), input_shape, pool_info, rois_shape); } void run() @@ -89,11 +90,54 @@ public: dst.allocator()->free(); } +protected: + template + void generate_rois(U &&rois, const TensorShape &shape, const ROIPoolingLayerInfo &pool_info, TensorShape rois_shape) + { + const size_t values_per_roi = rois_shape.x(); + const size_t num_rois = rois_shape.y(); + + std::mt19937 gen(library->seed()); + uint16_t *rois_ptr = static_cast(rois.data()); + + const float pool_width = pool_info.pooled_width(); + const float pool_height = pool_info.pooled_height(); + const float roi_scale = pool_info.spatial_scale(); + + // Calculate distribution bounds + const auto scaled_width = static_cast((shape.x() / roi_scale) / pool_width); + const auto scaled_height = static_cast((shape.y() / roi_scale) / pool_height); + const auto min_width = static_cast(pool_width / roi_scale); + const auto min_height = static_cast(pool_height / roi_scale); + + // Create distributions + std::uniform_int_distribution dist_batch(0, shape[3] - 1); + std::uniform_int_distribution dist_x1(0, scaled_width); + std::uniform_int_distribution dist_y1(0, scaled_height); + std::uniform_int_distribution dist_w(min_width, std::max(float(min_width), (pool_width - 2) * scaled_width)); + std::uniform_int_distribution dist_h(min_height, std::max(float(min_height), (pool_height - 2) * scaled_height)); + + for(unsigned int pw = 0; pw < num_rois; ++pw) + { + const auto batch_idx = dist_batch(gen); + const auto x1 = dist_x1(gen); + const auto y1 = dist_y1(gen); + const auto x2 = x1 + dist_w(gen); + const auto y2 = y1 + dist_h(gen); + + rois_ptr[values_per_roi * pw] = batch_idx; + rois_ptr[values_per_roi * pw + 1] = x1; + rois_ptr[values_per_roi * pw + 2] = y1; + rois_ptr[values_per_roi * pw + 3] = x2; + rois_ptr[values_per_roi * pw + 4] = y2; + } + } + private: - TensorType src{}; - TensorType dst{}; - std::unique_ptr rois_array{}; - Function roi_pool{}; + TensorType src{}; + TensorType dst{}; + TensorType rois_tensor{}; + Function roi_pool{}; }; } // namespace benchmark } // namespace test diff --git a/tests/datasets/ROIAlignLayerDataset.h b/tests/datasets/ROIAlignLayerDataset.h deleted file mode 100644 index 27c6ee4d91..0000000000 --- a/tests/datasets/ROIAlignLayerDataset.h +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2018 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. - */ -#ifndef ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET -#define ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ROIAlignLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator tensor_shape_it, - std::vector::const_iterator infos_it, - std::vector::const_iterator rois_shape_it) - : _tensor_shape_it{ std::move(tensor_shape_it) }, - _infos_it{ std::move(infos_it) }, - _rois_shape_it{ std::move(rois_shape_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_tensor_shape_it << ":"; - description << "Info=" << *_infos_it << ":"; - description << "ROIS=" << *_rois_shape_it; - return description.str(); - } - - ROIAlignLayerDataset::type operator*() const - { - return std::make_tuple(*_tensor_shape_it, *_infos_it, *_rois_shape_it); - } - - iterator &operator++() - { - ++_tensor_shape_it; - ++_infos_it; - ++_rois_shape_it; - - return *this; - } - - private: - std::vector::const_iterator _tensor_shape_it; - std::vector::const_iterator _infos_it; - std::vector::const_iterator _rois_shape_it; - }; - - iterator begin() const - { - return iterator(_tensor_shapes.begin(), _infos.begin(), _rois_shape.begin()); - } - - int size() const - { - return std::min(std::min(_tensor_shapes.size(), _infos.size()), _rois_shape.size()); - } - - void add_config(TensorShape tensor_shape, ROIPoolingLayerInfo info, TensorShape rois_shape) - { - _tensor_shapes.emplace_back(std::move(tensor_shape)); - _infos.emplace_back(std::move(info)); - _rois_shape.emplace_back(std::move(rois_shape)); - } - -protected: - ROIAlignLayerDataset() = default; - ROIAlignLayerDataset(ROIAlignLayerDataset &&) = default; - -private: - std::vector _tensor_shapes{}; - std::vector _infos{}; - std::vector _rois_shape{}; -}; - -class SmallROIAlignLayerDataset final : public ROIAlignLayerDataset -{ -public: - SmallROIAlignLayerDataset() - { - add_config(TensorShape(50U, 47U, 1U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 1U)); - add_config(TensorShape(50U, 47U, 3U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 1U)); - add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 10U)); - add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 80U)); - - //Spatial Scale 1/4 - add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 40U)); - add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 80U)); - - //Spatial Scale 1/8 - add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 40U)); - add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 80U)); - - //Spatial Scale 1/16 - add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 16.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 40U)); - add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 80U)); - add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 80U)); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET */ diff --git a/tests/datasets/ROIDataset.h b/tests/datasets/ROIDataset.h new file mode 100644 index 0000000000..9e21ab119c --- /dev/null +++ b/tests/datasets/ROIDataset.h @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2018-2019 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. + */ +#ifndef ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET +#define ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET + +#include "utils/TypePrinter.h" + +#include "arm_compute/core/TensorShape.h" +#include "arm_compute/core/Types.h" + +namespace arm_compute +{ +namespace test +{ +namespace datasets +{ +class ROIDataset +{ +public: + using type = std::tuple; + + struct iterator + { + iterator(std::vector::const_iterator tensor_shape_it, + std::vector::const_iterator infos_it, + std::vector::const_iterator rois_shape_it) + : _tensor_shape_it{ std::move(tensor_shape_it) }, + _infos_it{ std::move(infos_it) }, + _rois_shape_it{ std::move(rois_shape_it) } + { + } + + std::string description() const + { + std::stringstream description; + description << "In=" << *_tensor_shape_it << ":"; + description << "Info=" << *_infos_it << ":"; + description << "ROIS=" << *_rois_shape_it; + return description.str(); + } + + ROIDataset::type operator*() const + { + return std::make_tuple(*_tensor_shape_it, *_infos_it, *_rois_shape_it); + } + + iterator &operator++() + { + ++_tensor_shape_it; + ++_infos_it; + ++_rois_shape_it; + + return *this; + } + + private: + std::vector::const_iterator _tensor_shape_it; + std::vector::const_iterator _infos_it; + std::vector::const_iterator _rois_shape_it; + }; + + iterator begin() const + { + return iterator(_tensor_shapes.begin(), _infos.begin(), _rois_shape.begin()); + } + + int size() const + { + return std::min(std::min(_tensor_shapes.size(), _infos.size()), _rois_shape.size()); + } + + void add_config(TensorShape tensor_shape, ROIPoolingLayerInfo info, TensorShape rois_shape) + { + _tensor_shapes.emplace_back(std::move(tensor_shape)); + _infos.emplace_back(std::move(info)); + _rois_shape.emplace_back(std::move(rois_shape)); + } + +protected: + ROIDataset() = default; + ROIDataset(ROIDataset &&) = default; + +private: + std::vector _tensor_shapes{}; + std::vector _infos{}; + std::vector _rois_shape{}; +}; + +class SmallROIDataset final : public ROIDataset +{ +public: + SmallROIDataset() + { + add_config(TensorShape(50U, 47U, 1U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 1U)); + add_config(TensorShape(50U, 47U, 3U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 1U)); + add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 10U)); + add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 80U)); + + //Spatial Scale 1/4 + add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 4.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 40U)); + add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 4.f), TensorShape(5U, 80U)); + + //Spatial Scale 1/8 + add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 40U)); + add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), TensorShape(5U, 80U)); + + //Spatial Scale 1/16 + add_config(TensorShape(50U, 47U, 80U, 4U), ROIPoolingLayerInfo(7U, 7U, 1.f / 16.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 3U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 40U)); + add_config(TensorShape(50U, 47U, 10U, 1U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 80U)); + add_config(TensorShape(50U, 47U, 80U, 8U), ROIPoolingLayerInfo(9U, 9U, 1.f / 16.f), TensorShape(5U, 80U)); + } +}; + +} // namespace datasets +} // namespace test +} // namespace arm_compute +#endif /* ARM_COMPUTE_TEST_ROI_ALIGN_LAYER_DATASET */ diff --git a/tests/datasets/ROIPoolingLayerDataset.h b/tests/datasets/ROIPoolingLayerDataset.h deleted file mode 100644 index eb1d165202..0000000000 --- a/tests/datasets/ROIPoolingLayerDataset.h +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017-2018 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. - */ -#ifndef ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET -#define ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET - -#include "utils/TypePrinter.h" - -#include "arm_compute/core/TensorShape.h" -#include "arm_compute/core/Types.h" - -namespace arm_compute -{ -namespace test -{ -namespace datasets -{ -class ROIPoolingLayerDataset -{ -public: - using type = std::tuple; - - struct iterator - { - iterator(std::vector::const_iterator tensor_shape_it, - std::vector::const_iterator infos_it, - std::vector::const_iterator num_rois_it) - : _tensor_shape_it{ std::move(tensor_shape_it) }, - _infos_it{ std::move(infos_it) }, - _num_rois_it{ std::move(num_rois_it) } - { - } - - std::string description() const - { - std::stringstream description; - description << "In=" << *_tensor_shape_it << ":"; - description << "Info=" << *_infos_it << ":"; - description << "NumROIS=" << *_num_rois_it; - return description.str(); - } - - ROIPoolingLayerDataset::type operator*() const - { - return std::make_tuple(*_tensor_shape_it, *_infos_it, *_num_rois_it); - } - - iterator &operator++() - { - ++_tensor_shape_it; - ++_infos_it; - ++_num_rois_it; - - return *this; - } - - private: - std::vector::const_iterator _tensor_shape_it; - std::vector::const_iterator _infos_it; - std::vector::const_iterator _num_rois_it; - }; - - iterator begin() const - { - return iterator(_tensor_shapes.begin(), _infos.begin(), _num_rois.begin()); - } - - int size() const - { - return std::min(std::min(_tensor_shapes.size(), _infos.size()), _num_rois.size()); - } - - void add_config(TensorShape tensor_shape, ROIPoolingLayerInfo info, unsigned int num_rois) - { - _tensor_shapes.emplace_back(std::move(tensor_shape)); - _infos.emplace_back(std::move(info)); - _num_rois.emplace_back(std::move(num_rois)); - } - -protected: - ROIPoolingLayerDataset() = default; - ROIPoolingLayerDataset(ROIPoolingLayerDataset &&) = default; - -private: - std::vector _tensor_shapes{}; - std::vector _infos{}; - std::vector _num_rois{}; -}; - -class SmallROIPoolingLayerDataset final : public ROIPoolingLayerDataset -{ -public: - SmallROIPoolingLayerDataset() - { - add_config(TensorShape(50U, 47U, 1U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 1U); - add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 1U); - add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 40U); - add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(7U, 7U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 3U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 40U); - add_config(TensorShape(50U, 47U, 10U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); - add_config(TensorShape(50U, 47U, 80U), ROIPoolingLayerInfo(9U, 9U, 1.f / 8.f), 80U); - } -}; - -} // namespace datasets -} // namespace test -} // namespace arm_compute -#endif /* ARM_COMPUTE_TEST_ROI_POOLING_LAYER_DATASET */ diff --git a/tests/validation/CL/ROIAlignLayer.cpp b/tests/validation/CL/ROIAlignLayer.cpp index f3fc3818f2..926a3de68d 100644 --- a/tests/validation/CL/ROIAlignLayer.cpp +++ b/tests/validation/CL/ROIAlignLayer.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 ARM Limited. + * Copyright (c) 2018-2019 ARM Limited. * * SPDX-License-Identifier: MIT * @@ -25,7 +25,7 @@ #include "arm_compute/runtime/CL/functions/CLROIAlignLayer.h" #include "tests/CL/CLAccessor.h" #include "tests/Globals.h" -#include "tests/datasets/ROIAlignLayerDataset.h" +#include "tests/datasets/ROIDataset.h" #include "tests/datasets/ShapeDatasets.h" #include "tests/framework/Macros.h" #include "tests/framework/datasets/Datasets.h" @@ -100,14 +100,14 @@ using CLROIAlignLayerFixture = ROIAlignLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(datasets::SmallROIAlignLayerDataset(), + framework::dataset::combine(datasets::SmallROIDataset(), framework::dataset::make("DataType", { DataType::F32 }))) { // Validate output validate(CLAccessor(_target), _reference, relative_tolerance_f32, .02f, absolute_tolerance_f32); } FIXTURE_DATA_TEST_CASE(SmallROIAlignLayerHalf, CLROIAlignLayerFixture, framework::DatasetMode::ALL, - framework::dataset::combine(datasets::SmallROIAlignLayerDataset(), + framework::dataset::combine(datasets::SmallROIDataset(), framework::dataset::make("DataType", { DataType::F16 }))) { // Validate output -- cgit v1.2.1