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 "DivisionTestImpl.hpp" |
| 7 | |
| 8 | #include "ElementwiseTestImpl.hpp" |
| 9 | |
| 10 | template<> |
| 11 | std::unique_ptr<armnn::IWorkload> CreateWorkload<armnn::DivisionQueueDescriptor>( |
| 12 | const armnn::IWorkloadFactory& workloadFactory, |
| 13 | const armnn::WorkloadInfo& info, |
| 14 | const armnn::DivisionQueueDescriptor& descriptor) |
| 15 | { |
Teresa Charlin | 611c7fb | 2022-01-07 09:47:29 +0000 | [diff] [blame] | 16 | return workloadFactory.CreateWorkload(armnn::LayerType::Division, descriptor, info); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | LayerTestResult<float, 4> DivisionByZeroTest( |
| 20 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 21 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 22 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 23 | { |
Jan Eilers | 8eb2560 | 2020-03-09 12:13:48 +0000 | [diff] [blame] | 24 | IgnoreUnused(memoryManager); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 25 | const unsigned int width = 2u; |
| 26 | const unsigned int height = 2u; |
| 27 | const unsigned int channelCount = 2u; |
| 28 | const unsigned int batchSize = 2u; |
| 29 | |
| 30 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 31 | |
| 32 | std::vector<float> input0 = |
| 33 | { |
| 34 | 1.f, 1.f, 1.f, 1.f, 0.f, 0.f, 0.f, 0.f, |
| 35 | -1.f, -1.f, -1.f, -1.f, 5.f, 5.f, 5.f, 5.f |
| 36 | }; |
| 37 | |
| 38 | std::vector<float> input1 = |
| 39 | { |
| 40 | 0.f, 0.f, -0.f, -0.f, 0.f, 0.f, -0.f, -0.f, |
| 41 | 0.f, 0.f, -0.f, -0.f, 5.f, 5.f, 5.f, 5.f |
| 42 | }; |
| 43 | |
| 44 | std::vector<float> output = |
| 45 | { |
| 46 | INFINITY, INFINITY, -INFINITY, -INFINITY, NAN, NAN, -NAN, -NAN, |
| 47 | -INFINITY, -INFINITY, INFINITY, INFINITY, 1, 1, 1, 1 |
| 48 | }; |
| 49 | |
| 50 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>( |
| 51 | workloadFactory, |
| 52 | memoryManager, |
| 53 | shape, |
| 54 | input0, |
| 55 | shape, |
| 56 | input1, |
| 57 | shape, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 58 | output, |
| 59 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | LayerTestResult<float, 4> DivisionTest( |
| 63 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 64 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 65 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 66 | { |
| 67 | const unsigned int width = 2u; |
| 68 | const unsigned int height = 2u; |
| 69 | const unsigned int channelCount = 2u; |
| 70 | const unsigned int batchSize = 2u; |
| 71 | |
| 72 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 73 | |
| 74 | std::vector<float> input0 = |
| 75 | { |
| 76 | 2.f, 2.f, 2.f, 2.f, 3.f, 3.f, 3.f, 3.f, |
| 77 | 4.f, 4.f, 4.f, 4.f, 5.f, 5.f, 5.f, 5.f |
| 78 | }; |
| 79 | |
| 80 | std::vector<float> input1 = |
| 81 | { |
| 82 | 1.f, 1.f, 1.f, 1.f, 2.f, 2.f, 2.f, 2.f, |
| 83 | 4.f, 4.f, 4.f, 4.f, 4.f, 4.f, 4.f, 4.f |
| 84 | }; |
| 85 | |
| 86 | std::vector<float> output = |
| 87 | { |
| 88 | 2.f, 2.f, 2.f, 2.f, 1.50f, 1.50f, 1.50f, 1.50f, |
| 89 | 1.f, 1.f, 1.f, 1.f, 1.25f, 1.25f, 1.25f, 1.25f |
| 90 | }; |
| 91 | |
| 92 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>( |
| 93 | workloadFactory, |
| 94 | memoryManager, |
| 95 | shape, |
| 96 | input0, |
| 97 | shape, |
| 98 | input1, |
| 99 | shape, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 100 | output, |
| 101 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | LayerTestResult<float, 4> DivisionBroadcast1ElementTest( |
| 105 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 106 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 107 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 108 | { |
| 109 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 110 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 111 | |
| 112 | std::vector<float> input0({ 2, 4, 6, 8, 10, 12, 14, 16}); |
| 113 | |
| 114 | std::vector<float> input1({ 2 }); |
| 115 | |
| 116 | std::vector<float> output({ 1, 2, 3, 4, 5, 6, 7, 8}); |
| 117 | |
| 118 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>( |
| 119 | workloadFactory, |
| 120 | memoryManager, |
| 121 | shape0, |
| 122 | input0, |
| 123 | shape1, |
| 124 | input1, |
| 125 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 126 | output, |
| 127 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | LayerTestResult<float, 4> DivisionBroadcast1DVectorTest( |
| 131 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 132 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 133 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 134 | { |
| 135 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 136 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 137 | |
| 138 | std::vector<float> input0 = |
| 139 | { |
| 140 | 1.f, 4.f, 3.f, 8.f, 5.f, 12.f, |
| 141 | 7.f, 16.f, 9.f, 20.f, 11.f, 24.f, |
| 142 | 13.f, 28.f, 15.f, 32.f, 17.f, 36.f |
| 143 | }; |
| 144 | |
| 145 | std::vector<float> input1 = { 1.f, 2.f }; |
| 146 | |
| 147 | std::vector<float> output = |
| 148 | { |
| 149 | 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, |
| 150 | 7.f, 8.f, 9.f, 10.f, 11.f, 12.f, |
| 151 | 13.f, 14.f, 15.f, 16.f, 17.f, 18.f |
| 152 | }; |
| 153 | |
| 154 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float32>( |
| 155 | workloadFactory, |
| 156 | memoryManager, |
| 157 | shape0, |
| 158 | input0, |
| 159 | shape1, |
| 160 | input1, |
| 161 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 162 | output, |
| 163 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 164 | } |
| 165 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 166 | LayerTestResult<armnn::Half, 4> DivisionFloat16Test( |
| 167 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 168 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 169 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 170 | { |
| 171 | using namespace half_float::literal; |
| 172 | |
| 173 | const unsigned int width = 2u; |
| 174 | const unsigned int height = 2u; |
| 175 | const unsigned int channelCount = 2u; |
| 176 | const unsigned int batchSize = 2u; |
| 177 | |
| 178 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 179 | |
| 180 | std::vector<armnn::Half> input0 = |
| 181 | { |
| 182 | 2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h, |
| 183 | 4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h |
| 184 | }; |
| 185 | |
| 186 | std::vector<armnn::Half> input1 = |
| 187 | { |
| 188 | 1._h, 1._h, 1._h, 1._h, 2._h, 2._h, 2._h, 2._h, |
| 189 | 4._h, 4._h, 4._h, 4._h, 4._h, 4._h, 4._h, 4._h |
| 190 | }; |
| 191 | |
| 192 | std::vector<armnn::Half> output = |
| 193 | { |
| 194 | 2._h, 2._h, 2._h, 2._h, 1.50_h, 1.50_h, 1.50_h, 1.50_h, |
| 195 | 1._h, 1._h, 1._h, 1._h, 1.25_h, 1.25_h, 1.25_h, 1.25_h |
| 196 | }; |
| 197 | |
| 198 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>( |
| 199 | workloadFactory, |
| 200 | memoryManager, |
| 201 | shape, |
| 202 | input0, |
| 203 | shape, |
| 204 | input1, |
| 205 | shape, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 206 | output, |
| 207 | tensorHandleFactory); |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 208 | } |
| 209 | |
| 210 | LayerTestResult<armnn::Half, 4> DivisionBroadcast1ElementFloat16Test( |
| 211 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 212 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 213 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 214 | { |
| 215 | using namespace half_float::literal; |
| 216 | |
| 217 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 218 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 219 | |
| 220 | std::vector<armnn::Half> input0({ 2._h, 4._h, 6._h, 8._h, 10._h, 12._h, 14._h, 16._h}); |
| 221 | |
| 222 | std::vector<armnn::Half> input1({ 2._h }); |
| 223 | |
| 224 | std::vector<armnn::Half> output({ 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h}); |
| 225 | |
| 226 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>( |
| 227 | workloadFactory, |
| 228 | memoryManager, |
| 229 | shape0, |
| 230 | input0, |
| 231 | shape1, |
| 232 | input1, |
| 233 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 234 | output, |
| 235 | tensorHandleFactory); |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | LayerTestResult<armnn::Half, 4> DivisionBroadcast1DVectorFloat16Test( |
| 239 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 240 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 241 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 242 | { |
| 243 | using namespace half_float::literal; |
| 244 | |
| 245 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 246 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 247 | |
| 248 | std::vector<armnn::Half> input0 = |
| 249 | { |
| 250 | 1._h, 4._h, 3._h, 8._h, 5._h, 12._h, |
| 251 | 7._h, 16._h, 9._h, 20._h, 11._h, 24._h, |
| 252 | 13._h, 28._h, 15._h, 32._h, 17._h, 36._h |
| 253 | }; |
| 254 | |
| 255 | std::vector<armnn::Half> input1 = { 1._h, 2._h }; |
| 256 | |
| 257 | std::vector<armnn::Half> output = |
| 258 | { |
| 259 | 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, |
| 260 | 7._h, 8._h, 9._h, 10._h, 11._h, 12._h, |
| 261 | 13._h, 14._h, 15._h, 16._h, 17._h, 18._h |
| 262 | }; |
| 263 | |
| 264 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Float16>( |
| 265 | workloadFactory, |
| 266 | memoryManager, |
| 267 | shape0, |
| 268 | input0, |
| 269 | shape1, |
| 270 | input1, |
| 271 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 272 | output, |
| 273 | tensorHandleFactory); |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 274 | } |
| 275 | |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 276 | LayerTestResult<uint8_t, 4> DivisionUint8Test( |
| 277 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 278 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 279 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 280 | { |
| 281 | const unsigned int width = 2u; |
| 282 | const unsigned int height = 2u; |
| 283 | const unsigned int channelCount = 2u; |
| 284 | const unsigned int batchSize = 2u; |
| 285 | |
| 286 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 287 | |
| 288 | std::vector<uint8_t> input0 = |
| 289 | { |
| 290 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 291 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 292 | }; |
| 293 | |
| 294 | std::vector<uint8_t> input1 = |
| 295 | { |
| 296 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 297 | 4, 4, 4, 4, 4, 4, 4, 4 |
| 298 | }; |
| 299 | |
| 300 | std::vector<uint8_t> output = |
| 301 | { |
| 302 | 8, 8, 8, 8, 6, 6, 6, 6, |
| 303 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 304 | }; |
| 305 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 306 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 307 | workloadFactory, |
| 308 | memoryManager, |
| 309 | shape, |
| 310 | input0, |
| 311 | shape, |
| 312 | input1, |
| 313 | shape, |
| 314 | output, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 315 | tensorHandleFactory, |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 316 | 0.25f, |
| 317 | 0); |
| 318 | } |
| 319 | |
| 320 | LayerTestResult<uint8_t, 4> DivisionBroadcast1ElementUint8Test( |
| 321 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 322 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 323 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 324 | { |
| 325 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 326 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 327 | |
| 328 | std::vector<uint8_t> input0 = { 2, 4, 6, 8, 10, 12, 14, 16}; |
| 329 | |
| 330 | std::vector<uint8_t> input1 = { 2 }; |
| 331 | |
| 332 | std::vector<uint8_t> output = { 1, 2, 3, 4, 5, 6, 7, 8}; |
| 333 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 334 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 335 | workloadFactory, |
| 336 | memoryManager, |
| 337 | shape0, |
| 338 | input0, |
| 339 | shape1, |
| 340 | input1, |
| 341 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 342 | output, |
| 343 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 344 | } |
| 345 | |
| 346 | LayerTestResult<uint8_t, 4> DivisionBroadcast1DVectorUint8Test( |
| 347 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 348 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 349 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 350 | { |
| 351 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 352 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 353 | |
| 354 | std::vector<uint8_t> input0 = |
| 355 | { |
| 356 | 1, 4, 3, 8, 5, 12, |
| 357 | 7, 16, 9, 20, 11, 24, |
| 358 | 13, 28, 15, 32, 17, 36 |
| 359 | }; |
| 360 | |
| 361 | std::vector<uint8_t> input1 = { 1, 2 }; |
| 362 | |
| 363 | std::vector<uint8_t> output = |
| 364 | { |
| 365 | 1, 2, 3, 4, 5, 6, |
| 366 | 7, 8, 9, 10, 11, 12, |
| 367 | 13, 14, 15, 16, 17, 18 |
| 368 | }; |
| 369 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 370 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QAsymmU8>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 371 | workloadFactory, |
| 372 | memoryManager, |
| 373 | shape0, |
| 374 | input0, |
| 375 | shape1, |
| 376 | input1, |
| 377 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 378 | output, |
| 379 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | LayerTestResult<int16_t,4> DivisionInt16Test( |
| 383 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 384 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 385 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 386 | { |
| 387 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 388 | |
| 389 | std::vector<int16_t> input0 = |
| 390 | { |
| 391 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 392 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 393 | }; |
| 394 | |
| 395 | std::vector<int16_t> input1 = |
| 396 | { |
| 397 | 1, 1, 1, 1, 2, 2, 2, 2, |
| 398 | 4, 4, 4, 4, 4, 4, 4, 4 |
| 399 | }; |
| 400 | |
| 401 | std::vector<int16_t> output = |
| 402 | { |
| 403 | 8, 8, 8, 8, 6, 6, 6, 6, |
| 404 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 405 | }; |
| 406 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 407 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 408 | workloadFactory, |
| 409 | memoryManager, |
| 410 | shape, |
| 411 | input0, |
| 412 | shape, |
| 413 | input1, |
| 414 | shape, |
| 415 | output, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 416 | tensorHandleFactory, |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 417 | 0.25f, |
| 418 | 0); |
| 419 | } |
| 420 | |
| 421 | LayerTestResult<int16_t, 4> DivisionBroadcast1ElementInt16Test( |
| 422 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 423 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 424 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 425 | { |
| 426 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 427 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 428 | |
| 429 | std::vector<int16_t> input0 = { 2, 4, 6, 8, 10, 12, 14, 16}; |
| 430 | |
| 431 | std::vector<int16_t> input1 = { 2 }; |
| 432 | |
| 433 | std::vector<int16_t> output = { 1, 2, 3, 4, 5, 6, 7, 8}; |
| 434 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 435 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 436 | workloadFactory, |
| 437 | memoryManager, |
| 438 | shape0, |
| 439 | input0, |
| 440 | shape1, |
| 441 | input1, |
| 442 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 443 | output, |
| 444 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 445 | } |
| 446 | |
| 447 | LayerTestResult<int16_t, 4> DivisionBroadcast1DVectorInt16Test( |
| 448 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 449 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 450 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 451 | { |
| 452 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 453 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 454 | |
| 455 | std::vector<int16_t> input0 = |
| 456 | { |
| 457 | 1, 4, 3, 8, 5, 12, |
| 458 | 7, 16, 9, 20, 11, 24, |
| 459 | 13, 28, 15, 32, 17, 36 |
| 460 | }; |
| 461 | |
| 462 | std::vector<int16_t> input1 = { 1, 2 }; |
| 463 | |
| 464 | std::vector<int16_t> output = |
| 465 | { |
| 466 | 1, 2, 3, 4, 5, 6, |
| 467 | 7, 8, 9, 10, 11, 12, |
| 468 | 13, 14, 15, 16, 17, 18 |
| 469 | }; |
| 470 | |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 471 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::QSymmS16>( |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 472 | workloadFactory, |
| 473 | memoryManager, |
| 474 | shape0, |
| 475 | input0, |
| 476 | shape1, |
| 477 | input1, |
| 478 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 479 | output, |
| 480 | tensorHandleFactory); |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 481 | } |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 482 | |
| 483 | LayerTestResult<int32_t, 4> DivisionInt32Test( |
| 484 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 485 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 486 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 487 | { |
| 488 | const unsigned int width = 2u; |
| 489 | const unsigned int height = 2u; |
| 490 | const unsigned int channelCount = 2u; |
| 491 | const unsigned int batchSize = 2u; |
| 492 | |
| 493 | unsigned int shape[] = { batchSize, channelCount, height, width }; |
| 494 | |
| 495 | std::vector<int32_t> input0 = |
| 496 | { |
| 497 | 8, 8, 8, 8, 6, 6, 6, 6, |
| 498 | 8, 8, 8, 8, 5, 5, 5, 5 |
| 499 | }; |
| 500 | |
| 501 | std::vector<int32_t> input1 = |
| 502 | { |
| 503 | 4, 4, 4, 4, 2, 2, 2, 2, |
| 504 | 2, 2, 2, 2, 1, 1, 1, 1 |
| 505 | }; |
| 506 | |
| 507 | std::vector<int32_t> output = |
| 508 | { |
| 509 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 510 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 511 | }; |
| 512 | |
| 513 | |
| 514 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Signed32>( |
| 515 | workloadFactory, |
| 516 | memoryManager, |
| 517 | shape, |
| 518 | input0, |
| 519 | shape, |
| 520 | input1, |
| 521 | shape, |
| 522 | output, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 523 | tensorHandleFactory, |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 524 | 1.f, |
| 525 | 0); |
| 526 | } |
| 527 | |
| 528 | LayerTestResult<int32_t, 4> DivisionBroadcast1ElementInt32Test( |
| 529 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 530 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 531 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 532 | { |
| 533 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 534 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 535 | |
| 536 | std::vector<int32_t> input0 = { 2, 4, 6, 8, 10, 12, 14, 16}; |
| 537 | |
| 538 | std::vector<int32_t> input1 = { 2 }; |
| 539 | |
| 540 | std::vector<int32_t> output = { 1, 2, 3, 4, 5, 6, 7, 8}; |
| 541 | |
| 542 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Signed32>( |
| 543 | workloadFactory, |
| 544 | memoryManager, |
| 545 | shape0, |
| 546 | input0, |
| 547 | shape1, |
| 548 | input1, |
| 549 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 550 | output, |
| 551 | tensorHandleFactory); |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 552 | } |
| 553 | |
| 554 | LayerTestResult<int32_t, 4> DivisionBroadcast1DVectorInt32Test( |
| 555 | armnn::IWorkloadFactory& workloadFactory, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 556 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, |
| 557 | const armnn::ITensorHandleFactory& tensorHandleFactory) |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 558 | { |
| 559 | unsigned int shape0[] = { 1, 3, 3, 2 }; |
| 560 | unsigned int shape1[] = { 1, 1, 1, 2 }; |
| 561 | |
| 562 | std::vector<int32_t> input0 = |
| 563 | { |
| 564 | 1, 4, 3, 8, 5, 12, |
| 565 | 7, 16, 9, 20, 11, 24, |
| 566 | 13, 28, 15, 32, 17, 36 |
| 567 | }; |
| 568 | |
| 569 | std::vector<int32_t> input1 = { 1, 2 }; |
| 570 | |
| 571 | std::vector<int32_t> output = |
| 572 | { |
| 573 | 1, 2, 3, 4, 5, 6, |
| 574 | 7, 8, 9, 10, 11, 12, |
| 575 | 13, 14, 15, 16, 17, 18 |
| 576 | }; |
| 577 | |
| 578 | return ElementwiseTestHelper<4, armnn::DivisionQueueDescriptor, armnn::DataType::Signed32>( |
| 579 | workloadFactory, |
| 580 | memoryManager, |
| 581 | shape0, |
| 582 | input0, |
| 583 | shape1, |
| 584 | input1, |
| 585 | shape0, |
Keith Davis | 33a626f | 2020-08-27 15:38:12 +0100 | [diff] [blame] | 586 | output, |
| 587 | tensorHandleFactory); |
Teresa Charlin | ecb6b8e | 2020-05-22 18:08:23 +0100 | [diff] [blame] | 588 | } |