zhenglin | 0fb6cf5 | 2017-12-12 15:56:09 +0800 | [diff] [blame] | 1 | /* |
Michele Di Giorgio | d9eaf61 | 2020-07-08 11:12:57 +0100 | [diff] [blame] | 2 | * Copyright (c) 2017-2018 Arm Limited. |
zhenglin | 0fb6cf5 | 2017-12-12 15:56:09 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #ifndef ARM_COMPUTE_TEST_NORMALIZE_PLANAR_YUV_LAYER_DATASET |
| 25 | #define ARM_COMPUTE_TEST_NORMALIZE_PLANAR_YUV_LAYER_DATASET |
| 26 | |
| 27 | #include "utils/TypePrinter.h" |
| 28 | |
| 29 | #include "arm_compute/core/TensorShape.h" |
| 30 | #include "arm_compute/core/Types.h" |
| 31 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | namespace test |
| 35 | { |
| 36 | namespace datasets |
| 37 | { |
| 38 | class NormalizePlanarYUVLayerDataset |
| 39 | { |
| 40 | public: |
| 41 | using type = std::tuple<TensorShape, TensorShape>; |
| 42 | |
| 43 | struct iterator |
| 44 | { |
| 45 | iterator(std::vector<TensorShape>::const_iterator tensor_it, |
| 46 | std::vector<TensorShape>::const_iterator param_it) |
| 47 | : _tensor_it{ std::move(tensor_it) }, |
| 48 | _param_it{ std::move(param_it) } |
| 49 | { |
| 50 | } |
| 51 | |
| 52 | std::string description() const |
| 53 | { |
| 54 | std::stringstream description; |
| 55 | description << "In=" << *_tensor_it << ":"; |
| 56 | description << "Out=" << *_tensor_it << ":"; |
| 57 | description << "Mean=" << *_param_it << ":"; |
Michele Di Giorgio | b57be0d | 2018-08-31 16:26:25 +0100 | [diff] [blame] | 58 | description << "Std=" << *_param_it << ":"; |
zhenglin | 0fb6cf5 | 2017-12-12 15:56:09 +0800 | [diff] [blame] | 59 | return description.str(); |
| 60 | } |
| 61 | |
| 62 | NormalizePlanarYUVLayerDataset::type operator*() const |
| 63 | { |
| 64 | return std::make_tuple(*_tensor_it, *_param_it); |
| 65 | } |
| 66 | |
| 67 | iterator &operator++() |
| 68 | { |
| 69 | ++_tensor_it; |
| 70 | ++_param_it; |
| 71 | |
| 72 | return *this; |
| 73 | } |
| 74 | |
| 75 | private: |
| 76 | std::vector<TensorShape>::const_iterator _tensor_it; |
| 77 | std::vector<TensorShape>::const_iterator _param_it; |
| 78 | }; |
| 79 | |
| 80 | iterator begin() const |
| 81 | { |
| 82 | return iterator(_tensor_shapes.begin(), _param_shapes.begin()); |
| 83 | } |
| 84 | |
| 85 | int size() const |
| 86 | { |
| 87 | return std::min(_tensor_shapes.size(), _param_shapes.size()); |
| 88 | } |
| 89 | |
| 90 | void add_config(TensorShape tensor, TensorShape param) |
| 91 | { |
| 92 | _tensor_shapes.emplace_back(std::move(tensor)); |
| 93 | _param_shapes.emplace_back(std::move(param)); |
| 94 | } |
| 95 | |
| 96 | protected: |
| 97 | NormalizePlanarYUVLayerDataset() = default; |
| 98 | NormalizePlanarYUVLayerDataset(NormalizePlanarYUVLayerDataset &&) = default; |
| 99 | |
| 100 | private: |
| 101 | std::vector<TensorShape> _tensor_shapes{}; |
| 102 | std::vector<TensorShape> _param_shapes{}; |
| 103 | }; |
| 104 | } // namespace datasets |
| 105 | } // namespace test |
| 106 | } // namespace arm_compute |
| 107 | #endif /* ARM_COMPUTE_TEST_NORMALIZE_PLANAR_YUV_LAYER_DATASET */ |