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 | { |
| 23 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 24 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 25 | |
| 26 | std::vector<float> input0 = { 1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f }; |
| 27 | |
| 28 | std::vector<float> input1 = { 2.f }; |
| 29 | |
| 30 | std::vector<float> output = { 1.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f, 2.f }; |
| 31 | |
| 32 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 33 | workloadFactory, |
| 34 | memoryManager, |
| 35 | shape0, |
| 36 | input0, |
| 37 | shape1, |
| 38 | input1, |
| 39 | shape0, |
| 40 | output); |
| 41 | } |
| 42 | |
| 43 | LayerTestResult<float, 4> MinimumBroadcast1ElementTest2( |
| 44 | armnn::IWorkloadFactory& workloadFactory, |
| 45 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 46 | { |
| 47 | unsigned int shape0[] = { 1, 2, 2, 2 }; |
| 48 | unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 49 | |
| 50 | std::vector<float> input0 = { 1.f, 6.f, 3.f, 2.f, 8.f, 9.f, 1.f, 10.f }; |
| 51 | |
| 52 | std::vector<float> input1 = { 5.f }; |
| 53 | |
| 54 | std::vector<float> output = { 1.f, 5.f, 3.f, 2.f, 5.f, 5.f, 1.f, 5.f }; |
| 55 | |
| 56 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float32>( |
| 57 | workloadFactory, |
| 58 | memoryManager, |
| 59 | shape0, |
| 60 | input0, |
| 61 | shape1, |
| 62 | input1, |
| 63 | shape0, |
| 64 | output); |
| 65 | } |
| 66 | |
| 67 | LayerTestResult<uint8_t, 4> MinimumBroadcast1DVectorUint8Test( |
| 68 | armnn::IWorkloadFactory & workloadFactory, |
| 69 | const armnn::IBackendInternal::IMemoryManagerSharedPtr & memoryManager) |
| 70 | { |
| 71 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 72 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 73 | |
| 74 | std::vector<uint8_t> input0 = |
| 75 | { |
| 76 | 1, 2, 3, 3, 2, 1, |
| 77 | 7, 1, 2, 3, 4, 5 |
| 78 | }; |
| 79 | |
| 80 | std::vector<uint8_t> input1 = { 1, 2, 3 }; |
| 81 | |
| 82 | std::vector<uint8_t> output = |
| 83 | { |
| 84 | 1, 2, 3, 1, 2, 1, |
| 85 | 1, 1, 2, 1, 2, 3 |
| 86 | }; |
| 87 | |
| 88 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedAsymm8>( |
| 89 | workloadFactory, |
| 90 | memoryManager, |
| 91 | shape0, |
| 92 | input0, |
| 93 | shape1, |
| 94 | input1, |
| 95 | shape0, |
| 96 | output); |
| 97 | } |
| 98 | |
Matthew Jackson | 9bff144 | 2019-09-12 09:08:23 +0100 | [diff] [blame] | 99 | LayerTestResult<armnn::Half, 4> MinimumFloat16Test( |
| 100 | armnn::IWorkloadFactory& workloadFactory, |
| 101 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 102 | { |
| 103 | using namespace half_float::literal; |
| 104 | |
| 105 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 106 | |
| 107 | std::vector<armnn::Half> input0 = |
| 108 | { |
| 109 | 1._h, 1._h, 1._h, 1._h, 6._h, 6._h, 6._h, 6._h, |
| 110 | 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h |
| 111 | }; |
| 112 | |
| 113 | std::vector<armnn::Half> input1 = |
| 114 | { |
| 115 | 2._h, 2._h, 2._h, 2._h, 3._h, 3._h, 3._h, 3._h, |
| 116 | 4._h, 4._h, 4._h, 4._h, 5._h, 5._h, 5._h, 5._h |
| 117 | }; |
| 118 | |
| 119 | std::vector<armnn::Half> output |
| 120 | { |
| 121 | 1._h, 1._h, 1._h, 1._h, 3._h, 3._h, 3._h, 3._h, |
| 122 | 3._h, 3._h, 3._h, 3._h, 4._h, 4._h, 4._h, 4._h |
| 123 | }; |
| 124 | |
| 125 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 126 | workloadFactory, |
| 127 | memoryManager, |
| 128 | shape, |
| 129 | input0, |
| 130 | shape, |
| 131 | input1, |
| 132 | shape, |
| 133 | output); |
| 134 | } |
| 135 | |
| 136 | LayerTestResult<armnn::Half, 4> MinimumBroadcast1ElementFloat16Test( |
| 137 | armnn::IWorkloadFactory& workloadFactory, |
| 138 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 139 | { |
| 140 | using namespace half_float::literal; |
| 141 | |
| 142 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 143 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 144 | |
| 145 | std::vector<armnn::Half> input0 = |
| 146 | { |
| 147 | 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, |
| 148 | 7._h, 8._h, 9._h, 10._h, 11._h, 12._h |
| 149 | }; |
| 150 | |
| 151 | std::vector<armnn::Half> input1 = { 2._h }; |
| 152 | |
| 153 | std::vector<armnn::Half> output = |
| 154 | { |
| 155 | 1._h, 2._h, 2._h, 2._h, 2._h, 2._h, |
| 156 | 2._h, 2._h, 2._h, 2._h, 2._h, 2._h |
| 157 | }; |
| 158 | |
| 159 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 160 | workloadFactory, |
| 161 | memoryManager, |
| 162 | shape0, |
| 163 | input0, |
| 164 | shape1, |
| 165 | input1, |
| 166 | shape0, |
| 167 | output); |
| 168 | } |
| 169 | |
| 170 | LayerTestResult<armnn::Half, 4> MinimumBroadcast1DVectorFloat16Test( |
| 171 | armnn::IWorkloadFactory& workloadFactory, |
| 172 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 173 | { |
| 174 | using namespace half_float::literal; |
| 175 | |
| 176 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 177 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 178 | |
| 179 | std::vector<armnn::Half> input0 = |
| 180 | { |
| 181 | 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, |
| 182 | 7._h, 8._h, 9._h, 10._h, 11._h, 12._h |
| 183 | }; |
| 184 | |
| 185 | std::vector<armnn::Half> input1 = { 1._h, 10._h, 3._h }; |
| 186 | |
| 187 | std::vector<armnn::Half> output = |
| 188 | { |
| 189 | 1._h, 2._h, 3._h, 1._h, 5._h, 3._h, |
| 190 | 1._h, 8._h, 3._h, 1._h, 10._h, 3._h |
| 191 | }; |
| 192 | |
| 193 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::Float16>( |
| 194 | workloadFactory, |
| 195 | memoryManager, |
| 196 | shape0, |
| 197 | input0, |
| 198 | shape1, |
| 199 | input1, |
| 200 | shape0, |
| 201 | output); |
| 202 | } |
| 203 | |
Aron Virginas-Tar | e89ebad | 2019-08-27 18:14:26 +0100 | [diff] [blame] | 204 | LayerTestResult<int16_t, 4> MinimumInt16Test( |
| 205 | armnn::IWorkloadFactory& workloadFactory, |
| 206 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 207 | { |
| 208 | unsigned int shape[] = { 2, 2, 2, 2 }; |
| 209 | |
| 210 | std::vector<int16_t> input0 = |
| 211 | { |
| 212 | 1, 1, 1, 1, 6, 6, 6, 6, |
| 213 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 214 | }; |
| 215 | |
| 216 | std::vector<int16_t> input1 = |
| 217 | { |
| 218 | 2, 2, 2, 2, 3, 3, 3, 3, |
| 219 | 4, 4, 4, 4, 5, 5, 5, 5 |
| 220 | }; |
| 221 | |
| 222 | std::vector<int16_t> output |
| 223 | { |
| 224 | 1, 1, 1, 1, 3, 3, 3, 3, |
| 225 | 3, 3, 3, 3, 4, 4, 4, 4 |
| 226 | }; |
| 227 | |
| 228 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 229 | workloadFactory, |
| 230 | memoryManager, |
| 231 | shape, |
| 232 | input0, |
| 233 | shape, |
| 234 | input1, |
| 235 | shape, |
| 236 | output); |
| 237 | } |
| 238 | |
| 239 | LayerTestResult<int16_t, 4> MinimumBroadcast1ElementInt16Test( |
| 240 | armnn::IWorkloadFactory& workloadFactory, |
| 241 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 242 | { |
| 243 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 244 | const unsigned int shape1[] = { 1, 1, 1, 1 }; |
| 245 | |
| 246 | std::vector<int16_t> input0 = |
| 247 | { |
| 248 | 1, 2, 3, 4, 5, 6, |
| 249 | 7, 8, 9, 10, 11, 12 |
| 250 | }; |
| 251 | |
| 252 | std::vector<int16_t> input1 = { 2 }; |
| 253 | |
| 254 | std::vector<int16_t> output = |
| 255 | { |
| 256 | 1, 2, 2, 2, 2, 2, |
| 257 | 2, 2, 2, 2, 2, 2 |
| 258 | }; |
| 259 | |
| 260 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 261 | workloadFactory, |
| 262 | memoryManager, |
| 263 | shape0, |
| 264 | input0, |
| 265 | shape1, |
| 266 | input1, |
| 267 | shape0, |
| 268 | output); |
| 269 | } |
| 270 | |
| 271 | LayerTestResult<int16_t, 4> MinimumBroadcast1DVectorInt16Test( |
| 272 | armnn::IWorkloadFactory& workloadFactory, |
| 273 | const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) |
| 274 | { |
| 275 | const unsigned int shape0[] = { 1, 2, 2, 3 }; |
| 276 | const unsigned int shape1[] = { 1, 1, 1, 3 }; |
| 277 | |
| 278 | std::vector<int16_t> input0 = |
| 279 | { |
| 280 | 1, 2, 3, 4, 5, 6, |
| 281 | 7, 8, 9, 10, 11, 12 |
| 282 | }; |
| 283 | |
| 284 | std::vector<int16_t> input1 = { 1, 10, 3 }; |
| 285 | |
| 286 | std::vector<int16_t> output = |
| 287 | { |
| 288 | 1, 2, 3, 1, 5, 3, |
| 289 | 1, 8, 3, 1, 10, 3 |
| 290 | }; |
| 291 | |
| 292 | return ElementwiseTestHelper<4, armnn::MinimumQueueDescriptor, armnn::DataType::QuantisedSymm16>( |
| 293 | workloadFactory, |
| 294 | memoryManager, |
| 295 | shape0, |
| 296 | input0, |
| 297 | shape1, |
| 298 | input1, |
| 299 | shape0, |
| 300 | output); |
| 301 | } |