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/datasets/ROIAlignLayerDataset.h | 143 -------------------------------- tests/datasets/ROIDataset.h | 143 ++++++++++++++++++++++++++++++++ tests/datasets/ROIPoolingLayerDataset.h | 129 ---------------------------- 3 files changed, 143 insertions(+), 272 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/datasets') 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 */ -- cgit v1.2.1