Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "MinimumTestImpl.hpp" |
| 7 | |
| 8 | #include "ElementwiseTestImpl.hpp" |
| 9 | |
| 10 | template<> |
| 11 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::MinimumQueueDescriptor>( |
| 12 | const armnn::IWorkloadFactory& workloadFactory, |
| 13 | const armnn::WorkloadInfo& info, |
| 14 | const armnn::MinimumQueueDescriptor& descriptor) |
| 15 | { |
| 16 | return workloadFactory.CreateMinimum(descriptor, info); |
| 17 | } |
| 18 | |
| 19 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest1( |
| 20 | armnn::IWorkloadFactory& workloadFactory, |
| 21 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 22 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 23 | IgnoreUnused(memoryManager); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 24 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 25 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 26 | |
| 27 | std::vector<float> input0 = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f }; |
| 28 | |
| 29 | std::vector<float> input1 = { 2.f }; |
| 30 | |
| 31 | std::vector<float> output = { 1.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f }; |
| 32 | |
| 33 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 34 | workloadFactory, |
| 35 | memoryManager, |
| 36 | shape0, |
| 37 | input0, |
| 38 | shape1, |
| 39 | input1, |
| 40 | shape0, |
| 41 | output); |
| 42 | } |
| 43 | |
| 44 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest2( |
| 45 | armnn::IWorkloadFactory& workloadFactory, |
| 46 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 47 | { |
| 48 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 49 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 50 | |
| 51 | std::vector<float> input0 = { 1.f, 6.f, 3.f, 2.f, 8.f, 9.f, 1.f, 10.f }; |
| 52 | |
| 53 | std::vector<float> input1 = { 5.f }; |
| 54 | |
| 55 | std::vector<float> output = { 1.f, 5.f, 3.f, 2.f, 5.f, 5.f, 1.f, 5.f }; |
| 56 | |
| 57 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 58 | workloadFactory, |
| 59 | memoryManager, |
| 60 | shape0, |
| 61 | input0, |
| 62 | shape1, |
| 63 | input1, |
| 64 | shape0, |
| 65 | output); |
| 66 | } |
| 67 | |
| 68 | LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test( |
| 69 | armnn::IWorkloadFactory & workloadFactory, |
| 70 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager) |
| 71 | { |
| 72 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 73 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 74 | |
| 75 | std::vector<uint8_t> input0 = |
| 76 | { |
| 77 | 1, 2, 3, 3, 2, 1, |
| 78 | 7, 1, 2, 3, 4, 5 |
| 79 | }; |
| 80 | |
| 81 | std::vector<uint8_t> input1 = { 1, 2, 3 }; |
| 82 | |
| 83 | std::vector<uint8_t> output = |
| 84 | { |
| 85 | 1, 2, 3, 1, 2, 1, |
| 86 | 1, 1, 2, 1, 2, 3 |
| 87 | }; |
| 88 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 89 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QAsymmU8>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 90 | workloadFactory, |
| 91 | memoryManager, |
| 92 | shape0, |
| 93 | input0, |
| 94 | shape1, |
| 95 | input1, |
| 96 | shape0, |
| 97 | output); |
| 98 | } |
| 99 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 100 | LayerTestResult<armnn::Half, 4> MinimumFloat16Test( |
| 101 | armnn::IWorkloadFactory& workloadFactory, |
| 102 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 103 | { |
| 104 | using namespace half_float::literal; |
| 105 | |
| 106 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 107 | |
| 108 | std::vector<armnn::Half> input0 = |
| 109 | { |
| 110 | 1._h, 1._h, 1._h, 1._h, 6._h, 6._h, 6._h, 6._h, |
| 111 | 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h |
| 112 | }; |
| 113 | |
| 114 | std::vector<armnn::Half> input1 = |
| 115 | { |
| 116 | 2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h, |
| 117 | 4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h |
| 118 | }; |
| 119 | |
| 120 | std::vector<armnn::Half> output |
| 121 | { |
| 122 | 1._h, 1._h, 1._h, 1._h, 3._h, 3._h, 3._h, 3._h, |
| 123 | 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h |
| 124 | }; |
| 125 | |
| 126 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 127 | workloadFactory, |
| 128 | memoryManager, |
| 129 | shape, |
| 130 | input0, |
| 131 | shape, |
| 132 | input1, |
| 133 | shape, |
| 134 | output); |
| 135 | } |
| 136 | |
| 137 | LayerTestResult<armnn::Half, 4> MinimumBroadcast1ElementFloat16Test( |
| 138 | armnn::IWorkloadFactory& workloadFactory, |
| 139 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 140 | { |
| 141 | using namespace half_float::literal; |
| 142 | |
| 143 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 144 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 145 | |
| 146 | std::vector<armnn::Half> input0 = |
| 147 | { |
| 148 | 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, |
| 149 | 7._h, 8._h, 9._h, 10._h, 11._h, 12._h |
| 150 | }; |
| 151 | |
| 152 | std::vector<armnn::Half> input1 = { 2._h }; |
| 153 | |
| 154 | std::vector<armnn::Half> output = |
| 155 | { |
| 156 | 1._h, 2._h, 2._h, 2._h, 2._h, 2._h, |
| 157 | 2._h, 2._h, 2._h, 2._h, 2._h, 2._h |
| 158 | }; |
| 159 | |
| 160 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 161 | workloadFactory, |
| 162 | memoryManager, |
| 163 | shape0, |
| 164 | input0, |
| 165 | shape1, |
| 166 | input1, |
| 167 | shape0, |
| 168 | output); |
| 169 | } |
| 170 | |
| 171 | LayerTestResult<armnn::Half, 4> MinimumBroadcast1DVectorFloat16Test( |
| 172 | armnn::IWorkloadFactory& workloadFactory, |
| 173 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 174 | { |
| 175 | using namespace half_float::literal; |
| 176 | |
| 177 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 178 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 179 | |
| 180 | std::vector<armnn::Half> input0 = |
| 181 | { |
| 182 | 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, |
| 183 | 7._h, 8._h, 9._h, 10._h, 11._h, 12._h |
| 184 | }; |
| 185 | |
| 186 | std::vector<armnn::Half> input1 = { 1._h, 10._h, 3._h }; |
| 187 | |
| 188 | std::vector<armnn::Half> output = |
| 189 | { |
| 190 | 1._h, 2._h, 3._h, 1._h, 5._h, 3._h, |
| 191 | 1._h, 8._h, 3._h, 1._h, 10._h, 3._h |
| 192 | }; |
| 193 | |
| 194 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 195 | workloadFactory, |
| 196 | memoryManager, |
| 197 | shape0, |
| 198 | input0, |
| 199 | shape1, |
| 200 | input1, |
| 201 | shape0, |
| 202 | output); |
| 203 | } |
| 204 | |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 205 | LayerTestResult<int16_t, 4> MinimumInt16Test( |
| 206 | armnn::IWorkloadFactory& workloadFactory, |
| 207 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 208 | { |
| 209 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 210 | |
| 211 | std::vector<int16_t> input0 = |
| 212 | { |
| 213 | 1, 1, 1, 1, 6, 6, 6, 6, |
| 214 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 215 | }; |
| 216 | |
| 217 | std::vector<int16_t> input1 = |
| 218 | { |
| 219 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 220 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 221 | }; |
| 222 | |
| 223 | std::vector<int16_t> output |
| 224 | { |
| 225 | 1, 1, 1, 1, 3, 3, 3, 3, |
| 226 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 227 | }; |
| 228 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 229 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 230 | workloadFactory, |
| 231 | memoryManager, |
| 232 | shape, |
| 233 | input0, |
| 234 | shape, |
| 235 | input1, |
| 236 | shape, |
| 237 | output); |
| 238 | } |
| 239 | |
| 240 | LayerTestResult<int16_t, 4> MinimumBroadcast1ElementInt16Test( |
| 241 | armnn::IWorkloadFactory& workloadFactory, |
| 242 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 243 | { |
| 244 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 245 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 246 | |
| 247 | std::vector<int16_t> input0 = |
| 248 | { |
| 249 | 1, 2, 3, 4, 5, 6, |
| 250 | 7, 8, 9, 10, 11, 12 |
| 251 | }; |
| 252 | |
| 253 | std::vector<int16_t> input1 = { 2 }; |
| 254 | |
| 255 | std::vector<int16_t> output = |
| 256 | { |
| 257 | 1, 2, 2, 2, 2, 2, |
| 258 | 2, 2, 2, 2, 2, 2 |
| 259 | }; |
| 260 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 261 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 262 | workloadFactory, |
| 263 | memoryManager, |
| 264 | shape0, |
| 265 | input0, |
| 266 | shape1, |
| 267 | input1, |
| 268 | shape0, |
| 269 | output); |
| 270 | } |
| 271 | |
| 272 | LayerTestResult<int16_t, 4> MinimumBroadcast1DVectorInt16Test( |
| 273 | armnn::IWorkloadFactory& workloadFactory, |
| 274 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 275 | { |
| 276 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 277 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 278 | |
| 279 | std::vector<int16_t> input0 = |
| 280 | { |
| 281 | 1, 2, 3, 4, 5, 6, |
| 282 | 7, 8, 9, 10, 11, 12 |
| 283 | }; |
| 284 | |
| 285 | std::vector<int16_t> input1 = { 1, 10, 3 }; |
| 286 | |
| 287 | std::vector<int16_t> output = |
| 288 | { |
| 289 | 1, 2, 3, 1, 5, 3, |
| 290 | 1, 8, 3, 1, 10, 3 |
| 291 | }; |
| 292 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 293 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 294 | workloadFactory, |
| 295 | memoryManager, |
| 296 | shape0, |
| 297 | input0, |
| 298 | shape1, |
| 299 | input1, |
| 300 | shape0, |
| 301 | output); |
| 302 | } |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 303 | |
| 304 | LayerTestResult<int32_t, 4> MinimumInt32Test( |
| 305 | armnn::IWorkloadFactory& workloadFactory, |
| 306 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 307 | { |
| 308 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 309 | |
| 310 | std::vector<int32_t> input0 = |
| 311 | { |
| 312 | 1, 1, 1, 1, 6, 6, 6, 6, |
| 313 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 314 | }; |
| 315 | |
| 316 | std::vector<int32_t> input1 = |
| 317 | { |
| 318 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 319 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 320 | }; |
| 321 | |
| 322 | std::vector<int32_t> output |
| 323 | { |
| 324 | 1, 1, 1, 1, 3, 3, 3, 3, |
| 325 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 326 | }; |
| 327 | |
| 328 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>( |
| 329 | workloadFactory, |
| 330 | memoryManager, |
| 331 | shape, |
| 332 | input0, |
| 333 | shape, |
| 334 | input1, |
| 335 | shape, |
| 336 | output); |
| 337 | } |
| 338 | |
| 339 | LayerTestResult<int32_t, 4> MinimumBroadcast1ElementInt32Test( |
| 340 | armnn::IWorkloadFactory& workloadFactory, |
| 341 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 342 | { |
| 343 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 344 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 345 | |
| 346 | std::vector<int32_t> input0 = |
| 347 | { |
| 348 | 1, 2, 3, 4, 5, 6, |
| 349 | 7, 8, 9, 10, 11, 12 |
| 350 | }; |
| 351 | |
| 352 | std::vector<int32_t> input1 = { 2 }; |
| 353 | |
| 354 | std::vector<int32_t> output = |
| 355 | { |
| 356 | 1, 2, 2, 2, 2, 2, |
| 357 | 2, 2, 2, 2, 2, 2 |
| 358 | }; |
| 359 | |
| 360 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>( |
| 361 | workloadFactory, |
| 362 | memoryManager, |
| 363 | shape0, |
| 364 | input0, |
| 365 | shape1, |
| 366 | input1, |
| 367 | shape0, |
| 368 | output); |
| 369 | } |
| 370 | |
| 371 | LayerTestResult<int32_t, 4> MinimumBroadcast1DVectorInt32Test( |
| 372 | armnn::IWorkloadFactory& workloadFactory, |
| 373 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 374 | { |
| 375 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 376 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 377 | |
| 378 | std::vector<int32_t> input0 = |
| 379 | { |
| 380 | 1, 2, 3, 4, 5, 6, |
| 381 | 7, 8, 9, 10, 11, 12 |
| 382 | }; |
| 383 | |
| 384 | std::vector<int32_t> input1 = { 1, 10, 3 }; |
| 385 | |
| 386 | std::vector<int32_t> output = |
| 387 | { |
| 388 | 1, 2, 3, 1, 5, 3, |
| 389 | 1, 8, 3, 1, 10, 3 |
| 390 | }; |
| 391 | |
| 392 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Signed32>( |
| 393 | workloadFactory, |
| 394 | memoryManager, |
| 395 | shape0, |
| 396 | input0, |
| 397 | shape1, |
| 398 | input1, |
| 399 | shape0, |
| 400 | output); |
| 401 | } |