Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 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_SHAPE_DATASETS_H__ |
| 25 | #define __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ |
| 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
Moritz Pflanzer | a09de0c | 2017-09-01 20:41:12 +0100 | [diff] [blame] | 28 | #include "tests/framework/datasets/Datasets.h" |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 29 | |
| 30 | #include <type_traits> |
| 31 | |
| 32 | namespace arm_compute |
| 33 | { |
| 34 | namespace test |
| 35 | { |
| 36 | namespace datasets |
| 37 | { |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 38 | /** Data set containing 1D tensor shapes. */ |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 39 | class Small1DShape final : public framework::dataset::SingletonDataset<TensorShape> |
| 40 | { |
| 41 | public: |
| 42 | Small1DShape() |
| 43 | : SingletonDataset("Shape", TensorShape{ 256U }) |
| 44 | { |
| 45 | } |
| 46 | }; |
| 47 | |
| 48 | /** Parent type for all for shape datasets. */ |
| 49 | using ShapeDataset = framework::dataset::ContainerDataset<std::vector<TensorShape>>; |
| 50 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 51 | /** Data set containing small 2D tensor shapes. */ |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 52 | class Small2DShapes final : public ShapeDataset |
| 53 | { |
| 54 | public: |
| 55 | Small2DShapes() |
| 56 | : ShapeDataset("Shape", |
| 57 | { |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 58 | TensorShape{ 7U, 7U }, |
| 59 | TensorShape{ 27U, 13U }, |
| 60 | TensorShape{ 128U, 64U } |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 61 | }) |
| 62 | { |
| 63 | } |
| 64 | }; |
| 65 | |
Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 66 | /** Data set containing small 3D tensor shapes. */ |
| 67 | class Small3DShapes final : public ShapeDataset |
| 68 | { |
| 69 | public: |
| 70 | Small3DShapes() |
| 71 | : ShapeDataset("Shape", |
| 72 | { |
| 73 | TensorShape{ 7U, 7U, 5U }, |
| 74 | TensorShape{ 27U, 13U, 37U }, |
| 75 | TensorShape{ 128U, 64U, 21U } |
| 76 | }) |
| 77 | { |
| 78 | } |
| 79 | }; |
| 80 | |
| 81 | /** Data set containing small 4D tensor shapes. */ |
| 82 | class Small4DShapes final : public ShapeDataset |
| 83 | { |
| 84 | public: |
| 85 | Small4DShapes() |
| 86 | : ShapeDataset("Shape", |
| 87 | { |
| 88 | TensorShape{ 7U, 7U, 5U, 3U }, |
| 89 | TensorShape{ 27U, 13U, 37U, 2U }, |
| 90 | TensorShape{ 128U, 64U, 21U, 3U } |
| 91 | }) |
| 92 | { |
| 93 | } |
| 94 | }; |
| 95 | |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 96 | /** Data set containing small tensor shapes. */ |
| 97 | class SmallShapes final : public ShapeDataset |
| 98 | { |
| 99 | public: |
| 100 | SmallShapes() |
| 101 | : ShapeDataset("Shape", |
| 102 | { |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 103 | // Batch size 1 |
Gian Marco Iodice | bf17955 | 2017-09-05 13:51:21 +0100 | [diff] [blame] | 104 | TensorShape{ 9U, 9U }, |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 105 | TensorShape{ 27U, 13U, 2U }, |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 106 | TensorShape{ 128U, 64U, 1U, 3U }, |
| 107 | // Batch size 4 |
Gian Marco Iodice | bf17955 | 2017-09-05 13:51:21 +0100 | [diff] [blame] | 108 | TensorShape{ 9U, 9U, 3U, 4U }, |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 109 | TensorShape{ 27U, 13U, 2U, 4U }, |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 110 | // Arbitrary batch size |
Gian Marco Iodice | bf17955 | 2017-09-05 13:51:21 +0100 | [diff] [blame] | 111 | TensorShape{ 9U, 9U, 3U, 5U } |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 112 | }) |
| 113 | { |
| 114 | } |
| 115 | }; |
| 116 | |
| 117 | /** Data set containing large tensor shapes. */ |
| 118 | class LargeShapes final : public ShapeDataset |
| 119 | { |
| 120 | public: |
| 121 | LargeShapes() |
| 122 | : ShapeDataset("Shape", |
| 123 | { |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 124 | // Batch size 1 |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 125 | TensorShape{ 1920U, 1080U }, |
Moritz Pflanzer | d1b21f2 | 2017-09-01 10:22:47 +0100 | [diff] [blame] | 126 | TensorShape{ 640U, 480U, 2U, 3U }, |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 127 | TensorShape{ 4160U, 3120U }, |
| 128 | // Batch size 4 |
Moritz Pflanzer | d1b21f2 | 2017-09-01 10:22:47 +0100 | [diff] [blame] | 129 | TensorShape{ 800U, 600U, 1U, 4U }, |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 130 | }) |
| 131 | { |
| 132 | } |
| 133 | }; |
| 134 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 135 | /** Data set containing large 2D tensor shapes. */ |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 136 | class Large2DShapes final : public ShapeDataset |
| 137 | { |
| 138 | public: |
| 139 | Large2DShapes() |
| 140 | : ShapeDataset("Shape", |
| 141 | { |
| 142 | TensorShape{ 1920U, 1080U }, |
Moritz Pflanzer | 3ce3ff4 | 2017-07-21 17:41:02 +0100 | [diff] [blame] | 143 | TensorShape{ 1245U, 652U }, |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 144 | TensorShape{ 4160U, 3120U } |
| 145 | }) |
| 146 | { |
| 147 | } |
| 148 | }; |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 149 | |
Gian Marco Iodice | 06b184a | 2017-08-29 16:05:25 +0100 | [diff] [blame] | 150 | /** Data set containing large 3D tensor shapes. */ |
| 151 | class Large3DShapes final : public ShapeDataset |
| 152 | { |
| 153 | public: |
| 154 | Large3DShapes() |
| 155 | : ShapeDataset("Shape", |
| 156 | { |
| 157 | TensorShape{ 320U, 240U, 3U }, |
| 158 | TensorShape{ 383U, 653U, 2U }, |
| 159 | TensorShape{ 721U, 123U, 13U } |
| 160 | }) |
| 161 | { |
| 162 | } |
| 163 | }; |
| 164 | |
| 165 | /** Data set containing large 4D tensor shapes. */ |
| 166 | class Large4DShapes final : public ShapeDataset |
| 167 | { |
| 168 | public: |
| 169 | Large4DShapes() |
| 170 | : ShapeDataset("Shape", |
| 171 | { |
| 172 | TensorShape{ 320U, 123U, 3U, 3U }, |
| 173 | TensorShape{ 383U, 413U, 2U, 3U }, |
| 174 | TensorShape{ 517U, 123U, 13U, 2U } |
| 175 | }) |
| 176 | { |
| 177 | } |
| 178 | }; |
| 179 | |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 180 | /** Data set containing small tensor shapes for direct convolution. */ |
| 181 | class SmallDirectConvolutionShapes final : public ShapeDataset |
| 182 | { |
| 183 | public: |
| 184 | SmallDirectConvolutionShapes() |
| 185 | : ShapeDataset("InputShape", |
| 186 | { |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 187 | // Batch size 1 |
| 188 | TensorShape{ 5U, 5U, 3U }, |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 189 | TensorShape{ 32U, 37U, 3U }, |
SiCong Li | caf8c5e | 2017-08-21 13:12:52 +0100 | [diff] [blame] | 190 | TensorShape{ 13U, 15U, 8U }, |
| 191 | // Batch size 4 |
| 192 | TensorShape{ 5U, 5U, 3U, 4U }, |
| 193 | TensorShape{ 32U, 37U, 3U, 4U }, |
| 194 | TensorShape{ 13U, 15U, 8U, 4U }, |
| 195 | // Batch size 8 |
| 196 | TensorShape{ 5U, 5U, 3U, 8U }, |
| 197 | TensorShape{ 32U, 37U, 3U, 8U }, |
| 198 | TensorShape{ 13U, 15U, 8U, 8U }, |
| 199 | // Arbitrary batch size |
| 200 | TensorShape{ 32U, 37U, 3U, 8U } |
Moritz Pflanzer | b3d2579 | 2017-07-26 11:49:37 +0100 | [diff] [blame] | 201 | }) |
| 202 | { |
| 203 | } |
| 204 | }; |
Gian Marco Iodice | b2833b8 | 2017-09-13 16:23:18 +0100 | [diff] [blame] | 205 | |
| 206 | /** Data set containing 2D tensor shapes for DepthConcatenate. */ |
| 207 | class DepthConcatenateShapes final : public ShapeDataset |
| 208 | { |
| 209 | public: |
| 210 | DepthConcatenateShapes() |
| 211 | : ShapeDataset("Shape", |
| 212 | { |
| 213 | TensorShape{ 322U, 243U }, |
| 214 | TensorShape{ 463U, 879U }, |
| 215 | TensorShape{ 416U, 651U } |
| 216 | }) |
| 217 | { |
| 218 | } |
| 219 | }; |
| 220 | |
Gian Marco Iodice | bf17955 | 2017-09-05 13:51:21 +0100 | [diff] [blame] | 221 | /** Data set containing global pooling tensor shapes. */ |
| 222 | class GlobalPoolingShapes final : public ShapeDataset |
| 223 | { |
| 224 | public: |
| 225 | GlobalPoolingShapes() |
| 226 | : ShapeDataset("Shape", |
| 227 | { |
| 228 | // Batch size 1 |
| 229 | TensorShape{ 9U, 9U }, |
| 230 | TensorShape{ 13U, 13U, 2U }, |
| 231 | TensorShape{ 27U, 27U, 1U, 3U }, |
| 232 | // Batch size 4 |
| 233 | TensorShape{ 31U, 31U, 3U, 4U }, |
| 234 | TensorShape{ 34U, 34U, 2U, 4U } |
| 235 | }) |
| 236 | { |
| 237 | } |
| 238 | }; |
| 239 | |
Moritz Pflanzer | f6ad98a | 2017-07-21 17:19:58 +0100 | [diff] [blame] | 240 | } // namespace datasets |
| 241 | } // namespace test |
| 242 | } // namespace arm_compute |
| 243 | #endif /* __ARM_COMPUTE_TEST_SHAPE_DATASETS_H__ */ |