Compute Library
 22.05
DepthConvertLayer.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2021 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 #include "arm_compute/core/Types.h"
28 #include "tests/NEON/Accessor.h"
30 #include "tests/datasets/ConvertPolicyDataset.h"
31 #include "tests/datasets/ShapeDatasets.h"
33 #include "tests/framework/Macros.h"
36 #include "tests/validation/fixtures/DepthConvertLayerFixture.h"
37 
38 namespace arm_compute
39 {
40 namespace test
41 {
42 namespace validation
43 {
44 namespace
45 {
46 /** Input data sets **/
47 const auto DepthConvertLayerQASYMM8toF16Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::F16));
48 const auto DepthConvertLayerQASYMM8toF32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::F32));
49 const auto DepthConvertLayerQASYMM8toS32Dataset = combine(framework::dataset::make("DataType", DataType::QASYMM8), framework::dataset::make("DataType", DataType::S32));
50 const auto DepthConvertLayerU8toU16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::U16));
51 const auto DepthConvertLayerU8toS16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S16));
52 const auto DepthConvertLayerU8toS32Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::S32));
53 const auto DepthConvertLayerU8toF16Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::F16));
54 const auto DepthConvertLayerU8toF32Dataset = combine(framework::dataset::make("DataType", DataType::U8), framework::dataset::make("DataType", DataType::F32));
55 const auto DepthConvertLayerU16toU8Dataset = combine(framework::dataset::make("DataType", DataType::U16), framework::dataset::make("DataType", DataType::U8));
56 const auto DepthConvertLayerU16toU32Dataset = combine(framework::dataset::make("DataType", DataType::U16), framework::dataset::make("DataType", DataType::U32));
57 const auto DepthConvertLayerS16toU8Dataset = combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::U8));
58 const auto DepthConvertLayerS16toS32Dataset = combine(framework::dataset::make("DataType", DataType::S16), framework::dataset::make("DataType", DataType::S32));
59 const auto DepthConvertLayerBF16toF32Dataset = combine(framework::dataset::make("DataType", DataType::BFLOAT16), framework::dataset::make("DataType", DataType::F32));
60 const auto DepthConvertLayerF16toU8Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::U8));
61 const auto DepthConvertLayerF16toF32Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::F32));
62 const auto DepthConvertLayerF16toS32Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::S32));
63 const auto DepthConvertLayerF32toF16Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::F16));
64 const auto DepthConvertLayerF32toS32Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::S32));
65 const auto DepthConvertLayerF32toU8Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::U8));
66 const auto DepthConvertLayerF32toBF16Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::BFLOAT16));
67 
68 const auto DepthConvertLayerS32toF32Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::F32));
69 const auto DepthConvertLayerS32toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::QASYMM8));
70 const auto DepthConvertLayerS32toF16Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::F16));
71 const auto DepthConvertLayerS32toU8Dataset = combine(framework::dataset::make("DataType", DataType::S32), framework::dataset::make("DataType", DataType::U8));
72 
73 const auto DepthConvertLayerF16toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::F16), framework::dataset::make("DataType", DataType::QASYMM8));
74 const auto DepthConvertLayerF32toQASYMM8Dataset = combine(framework::dataset::make("DataType", DataType::F32), framework::dataset::make("DataType", DataType::QASYMM8));
75 const auto DepthConvertLayerZeroShiftDataset = framework::dataset::make("Shift", 0);
76 
77 constexpr AbsoluteTolerance<uint8_t> tolerance_qasymm8(1);
78 constexpr AbsoluteTolerance<int32_t> tolerance_one_int32(1);
79 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
80 constexpr AbsoluteTolerance<uint8_t> tolerance_one_uint8(1);
81 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
82 } // namespace
83 
84 TEST_SUITE(NEON)
85 TEST_SUITE(DepthConvertLayer)
86 
87 // *INDENT-OFF*
88 // clang-format off
89 DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
90  framework::dataset::make("InputInfo", { TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U16), // Invalid data type combination
91  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::S16), // Invalid data type combination
92  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8), // Mismatching shapes
93  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Invalid shift
94  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8), // Valid
95  }),
96  framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
97  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32),
98  TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::U8),
99  TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::U8),
100  })),
108  })),
109  framework::dataset::make("Shift",{ 0, 0, 0, 1, 1, 1, 8, 1,
110  })),
111  framework::dataset::make("Expected", { false, false, false, false, true})),
112  input_info, output_info, policy, shift, expected)
113 {
114  ARM_COMPUTE_EXPECT(bool(NEDepthConvertLayer::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), policy, shift)) == expected, framework::LogLevel::ERRORS);
115 }
116 // clang-format on
117 // *INDENT-ON*
118 
119 template <typename T>
120 using NEDepthConvertLayerToU16Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, uint16_t>;
121 template <typename T>
122 using NEDepthConvertLayerToS16Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, int16_t>;
123 template <typename T>
124 using NEDepthConvertLayerToS32Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, int32_t>;
125 template <typename T>
126 using NEDepthConvertLayerToU8Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, uint8_t>;
127 template <typename T>
128 using NEDepthConvertLayerToU32Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, uint32_t>;
129 template <typename T>
130 using NEDepthConvertLayerToBF16Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, bfloat16>;
131 template <typename T>
132 using NEDepthConvertLayerToF16Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, half>;
133 template <typename T>
134 using NEDepthConvertLayerToF32Fixture = DepthConvertLayerValidationFixture<Tensor, Accessor, NEDepthConvertLayer, T, float>;
135 template <typename T>
136 using NEDepthConvertLayerToQASYMM8Fixture = DepthConvertLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthConvertLayer, T, uint8_t>;
137 template <typename T>
138 using NEDepthConvertLayerQuantizedToF16Fixture = DepthConvertLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthConvertLayer, T, half>;
139 template <typename T>
140 using NEDepthConvertLayerQuantizedToF32Fixture = DepthConvertLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthConvertLayer, T, float>;
141 template <typename T>
142 using NEDepthConvertLayerQuantizedToS32Fixture = DepthConvertLayerValidationQuantizedFixture<Tensor, Accessor, NEDepthConvertLayer, T, int32_t>;
143 
144 TEST_SUITE(QASYMM8_to_F32)
145 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerQuantizedToF32Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
146  DepthConvertLayerQASYMM8toF32Dataset),
147  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
148  DepthConvertLayerZeroShiftDataset),
149  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
150 {
151  // Validate output
152  validate(Accessor(_target), _reference);
153 }
155  DepthConvertLayerQASYMM8toF32Dataset),
156  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
157  DepthConvertLayerZeroShiftDataset),
158  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
159 {
160  // Validate output
161  validate(Accessor(_target), _reference);
162 }
163 TEST_SUITE_END() // QASYMM8_to_F32
164 
165 TEST_SUITE(QASYMM8_to_S32)
166 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerQuantizedToS32Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
167  DepthConvertLayerQASYMM8toS32Dataset),
168  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
169  DepthConvertLayerZeroShiftDataset),
170  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
171 {
172  // Validate output
173  validate(Accessor(_target), _reference);
174 }
176  DepthConvertLayerQASYMM8toS32Dataset),
177  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
178  DepthConvertLayerZeroShiftDataset),
179  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
180 {
181  // Validate output
182  validate(Accessor(_target), _reference);
183 }
184 TEST_SUITE_END() // QASYMM8_to_S32
185 
186 TEST_SUITE(U8_to_U16)
187 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU16Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU8toU16Dataset),
188  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
189  DepthConvertLayerZeroShiftDataset))
190 {
191  // Validate output
192  validate(Accessor(_target), _reference);
193 }
194 
197  DepthConvertLayerZeroShiftDataset))
198 {
199  // Validate output
200  validate(Accessor(_target), _reference);
201 }
202 TEST_SUITE_END() // U8_to_U16
203 
204 TEST_SUITE(U8_to_S16)
205 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToS16Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU8toS16Dataset),
206  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
207  DepthConvertLayerZeroShiftDataset))
208 {
209  // Validate output
210  validate(Accessor(_target), _reference);
211 }
212 
215  DepthConvertLayerZeroShiftDataset))
216 {
217  // Validate output
218  validate(Accessor(_target), _reference);
219 }
220 TEST_SUITE_END() // U8_to_S16
221 TEST_SUITE(U8_to_S32)
222 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToS32Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU8toS32Dataset),
223  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
224  DepthConvertLayerZeroShiftDataset))
225 {
226  // Validate output
227  validate(Accessor(_target), _reference);
228 }
229 
232  DepthConvertLayerZeroShiftDataset))
233 {
234  // Validate output
235  validate(Accessor(_target), _reference);
236 }
237 TEST_SUITE_END() // U8_to_S32
238 
239 TEST_SUITE(U8_to_F32)
240 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF32Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU8toF32Dataset),
241  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
242  DepthConvertLayerZeroShiftDataset))
243 {
244  // Validate output
245  validate(Accessor(_target), _reference);
246 }
247 
250  DepthConvertLayerZeroShiftDataset))
251 {
252  // Validate output
253  validate(Accessor(_target), _reference);
254 }
255 TEST_SUITE_END() // U8_to_F32
256 
257 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
258 TEST_SUITE(U8_to_F16)
259 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF16Fixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU8toF16Dataset),
261  DepthConvertLayerZeroShiftDataset))
262 {
263  // Validate output
264  validate(Accessor(_target), _reference);
265 }
266 
267 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToF16Fixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerU8toF16Dataset),
269  DepthConvertLayerZeroShiftDataset))
270 {
271  // Validate output
272  validate(Accessor(_target), _reference);
273 }
274 TEST_SUITE_END() // U8_to_F36
275 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
276 
277 TEST_SUITE(U16_to_U8)
278 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU8Fixture<uint16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU16toU8Dataset),
279  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
280  DepthConvertLayerZeroShiftDataset))
281 {
282  // Validate output
283  validate(Accessor(_target), _reference);
284 }
287  DepthConvertLayerZeroShiftDataset))
288 {
289  // Validate output
290  validate(Accessor(_target), _reference);
291 }
292 TEST_SUITE_END() // U16_to_U8
293 
294 TEST_SUITE(U16_to_U32)
295 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU32Fixture<uint16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerU16toU32Dataset),
296  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
297  DepthConvertLayerZeroShiftDataset))
298 {
299  // Validate output
300  validate(Accessor(_target), _reference);
301 }
304  DepthConvertLayerZeroShiftDataset))
305 {
306  // Validate output
307  validate(Accessor(_target), _reference);
308 }
309 TEST_SUITE_END() // U16_to_U32
310 
311 TEST_SUITE(S16_to_U8)
312 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU8Fixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerS16toU8Dataset),
313  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
314  DepthConvertLayerZeroShiftDataset))
315 {
316  // Validate output
317  validate(Accessor(_target), _reference);
318 }
319 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToU8Fixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerS16toU8Dataset),
321  DepthConvertLayerZeroShiftDataset))
322 {
323  // Validate output
324  validate(Accessor(_target), _reference);
325 }
326 TEST_SUITE_END() // S16_to_U8
327 
328 TEST_SUITE(S16_to_S32)
329 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToS32Fixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerS16toS32Dataset),
330  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
331  DepthConvertLayerZeroShiftDataset))
332 {
333  // Validate output
334  validate(Accessor(_target), _reference);
335 }
336 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToS32Fixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerS16toS32Dataset),
338  DepthConvertLayerZeroShiftDataset))
339 {
340  // Validate output
341  validate(Accessor(_target), _reference);
342 }
343 TEST_SUITE_END() // S16_to_S32
344 
345 #if defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16)
346 TEST_SUITE(BFLOAT16_to_F32)
347 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF32Fixture<bfloat16>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerBF16toF32Dataset),
349  DepthConvertLayerZeroShiftDataset))
350 {
351  // Validate output
352  validate(Accessor(_target), _reference);
353 }
354 TEST_SUITE_END() // BFLOAT16_to_F32
355 
356 TEST_SUITE(F32_to_BFLOAT16)
357 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToBF16Fixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF32toBF16Dataset),
359  DepthConvertLayerZeroShiftDataset))
360 {
361  // Validate output
362  validate(Accessor(_target), _reference);
363 }
364 TEST_SUITE_END() // F32_to_BFLOAT16
365 #endif /* defined(__ARM_FEATURE_BF16_VECTOR_ARITHMETIC) || defined(ARM_COMPUTE_FORCE_BF16) */
366 
367 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
368 TEST_SUITE(F16_to_QASYMM8)
370  DepthConvertLayerF16toQASYMM8Dataset),
371  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
372  DepthConvertLayerZeroShiftDataset),
373  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
374 {
375  // Validate output
376  validate(Accessor(_target), _reference, tolerance_qasymm8);
377 }
379  DepthConvertLayerF16toQASYMM8Dataset),
380  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
381  DepthConvertLayerZeroShiftDataset),
382  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
383 {
384  // Validate output
385  validate(Accessor(_target), _reference, tolerance_qasymm8);
386 }
387 TEST_SUITE_END() // F16_to_QASYMM8
388 
389 TEST_SUITE(F16_to_U8)
390 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU8Fixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF16toU8Dataset),
392  DepthConvertLayerZeroShiftDataset))
393 {
394  // Validate output
395  validate(Accessor(_target), _reference, tolerance_one_uint8);
396 }
397 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToU8Fixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF16toU8Dataset),
399  DepthConvertLayerZeroShiftDataset))
400 {
401  // Validate output
402  validate(Accessor(_target), _reference, tolerance_one_uint8);
403 }
404 TEST_SUITE_END() // F16_to_U8
405 
406 TEST_SUITE(F16_to_F32)
407 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF32Fixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF16toF32Dataset),
409  DepthConvertLayerZeroShiftDataset))
410 {
411  // Validate output
412  validate(Accessor(_target), _reference);
413 }
414 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToF32Fixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF16toF32Dataset),
416  DepthConvertLayerZeroShiftDataset))
417 {
418  // Validate output
419  validate(Accessor(_target), _reference);
420 }
421 TEST_SUITE_END() // F16_to_F32
422 
423 TEST_SUITE(F16_to_S32)
424 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToS32Fixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF16toS32Dataset),
426  DepthConvertLayerZeroShiftDataset))
427 {
428  // Validate output
429  validate(Accessor(_target), _reference, tolerance_one_int32);
430 }
431 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToS32Fixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF16toS32Dataset),
433  DepthConvertLayerZeroShiftDataset))
434 {
435  // Validate output
436  validate(Accessor(_target), _reference, tolerance_one_int32);
437 }
438 
439 TEST_SUITE_END() // F16_to_S32
440 
441 TEST_SUITE(QASYMM8_to_F16)
443  DepthConvertLayerQASYMM8toF16Dataset),
444  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
445  DepthConvertLayerZeroShiftDataset),
446  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
447 {
448  // Validate output
449  validate(Accessor(_target), _reference);
450 }
452  DepthConvertLayerQASYMM8toF16Dataset),
453  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
454  DepthConvertLayerZeroShiftDataset),
455  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
456 {
457  // Validate output
458  validate(Accessor(_target), _reference);
459 }
460 TEST_SUITE_END() // QASYMM8_to_F16
461 
462 TEST_SUITE(F32_to_F16)
463 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF16Fixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF32toF16Dataset),
465  DepthConvertLayerZeroShiftDataset))
466 {
467  // Validate output
468  validate(Accessor(_target), _reference);
469 }
470 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToF16Fixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF32toF16Dataset),
472  DepthConvertLayerZeroShiftDataset))
473 {
474  // Validate output
475  validate(Accessor(_target), _reference);
476 }
477 TEST_SUITE_END() // F32_to_F16
478 
479 TEST_SUITE(S32_to_F16)
480 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF16Fixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerS32toF16Dataset),
482  DepthConvertLayerZeroShiftDataset))
483 {
484  // Validate output
485  validate(Accessor(_target), _reference);
486 }
487 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToF16Fixture<int32_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerS32toF16Dataset),
489  DepthConvertLayerZeroShiftDataset))
490 {
491  // Validate output
492  validate(Accessor(_target), _reference);
493 }
494 TEST_SUITE_END() // S32_to_F16
495 
496 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
497 
498 TEST_SUITE(F32_to_S32)
499 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToS32Fixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF32toS32Dataset),
500  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
501  DepthConvertLayerZeroShiftDataset))
502 {
503  // Validate output
504  validate(Accessor(_target), _reference, tolerance_one_int32);
505 }
506 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToS32Fixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF32toS32Dataset),
508  DepthConvertLayerZeroShiftDataset))
509 {
510  // Validate output
511  validate(Accessor(_target), _reference, tolerance_one_int32);
512 }
513 TEST_SUITE_END() // F32_to_S32
514 
515 TEST_SUITE(F32_to_U8)
516 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU8Fixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerF32toU8Dataset),
517  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
518  DepthConvertLayerZeroShiftDataset))
519 {
520  // Validate output
521  validate(Accessor(_target), _reference, tolerance_one_int32);
522 }
523 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToU8Fixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerF32toU8Dataset),
525  DepthConvertLayerZeroShiftDataset))
526 {
527  // Validate output
528  validate(Accessor(_target), _reference, tolerance_one_int32);
529 }
530 TEST_SUITE_END() // F32_to_U8
531 
532 TEST_SUITE(F32_to_QASYMM8)
533 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToQASYMM8Fixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
534  DepthConvertLayerF32toQASYMM8Dataset),
535  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
536  DepthConvertLayerZeroShiftDataset),
537  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
538 {
539  // Validate output
540  validate(Accessor(_target), _reference, tolerance_qasymm8);
541 }
543  DepthConvertLayerF32toQASYMM8Dataset),
544  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
545  DepthConvertLayerZeroShiftDataset),
546  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
547 {
548  // Validate output
549  validate(Accessor(_target), _reference, tolerance_qasymm8);
550 }
551 TEST_SUITE_END() // F32_to_QASYMM8
552 
553 TEST_SUITE(S32_to_F32)
554 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToF32Fixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerS32toF32Dataset),
555  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
556  DepthConvertLayerZeroShiftDataset))
557 {
558  // Validate output
559  validate(Accessor(_target), _reference);
560 }
561 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToF32Fixture<int32_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerS32toF32Dataset),
563  DepthConvertLayerZeroShiftDataset))
564 {
565  // Validate output
566  validate(Accessor(_target), _reference);
567 }
568 TEST_SUITE_END() // S32_to_F32
569 
570 TEST_SUITE(S32_to_QASYMM8)
571 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToQASYMM8Fixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(combine(datasets::SmallShapes(),
572  DepthConvertLayerS32toQASYMM8Dataset),
573  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
574  DepthConvertLayerZeroShiftDataset),
575  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
576 {
577  // Validate output
578  validate(Accessor(_target), _reference, tolerance_qasymm8);
579 }
581  DepthConvertLayerS32toQASYMM8Dataset),
582  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE })),
583  DepthConvertLayerZeroShiftDataset),
584  framework::dataset::make("QuantizationInfo", { QuantizationInfo(0.5f, 10) })))
585 {
586  // Validate output
587  validate(Accessor(_target), _reference, tolerance_qasymm8);
588 }
589 TEST_SUITE_END() // S32_to_QASYMM8
590 
591 TEST_SUITE(S32_to_U8)
592 FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthConvertLayerToU8Fixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(combine(datasets::SmallShapes(), DepthConvertLayerS32toU8Dataset),
593  framework::dataset::make("ConvertPolicy", { ConvertPolicy::SATURATE, ConvertPolicy::WRAP })),
594  DepthConvertLayerZeroShiftDataset))
595 {
596  // Validate output
597  validate(Accessor(_target), _reference);
598 }
599 FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthConvertLayerToU8Fixture<int32_t>, framework::DatasetMode::NIGHTLY, combine(combine(combine(datasets::LargeShapes(), DepthConvertLayerS32toU8Dataset),
601  DepthConvertLayerZeroShiftDataset))
602 {
603  // Validate output
604  validate(Accessor(_target), _reference);
605 }
606 TEST_SUITE_END() // S32_to_U8
607 
608 TEST_SUITE_END() // DepthConvertLayer
609 TEST_SUITE_END() // Neon
610 } // namespace validation
611 } // namespace test
612 } // namespace arm_compute
Shape of a tensor.
Definition: TensorShape.h:39
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, uint32_t > NEDepthConvertLayerToU32Fixture
1 channel, 1 U8 per channel
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
1 channel, 1 U16 per channel
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
DepthConvertLayerValidationQuantizedFixture< Tensor, Accessor, NEDepthConvertLayer, T, float > NEDepthConvertLayerQuantizedToF32Fixture
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, int32_t > NEDepthConvertLayerToS32Fixture
DepthConvertLayerValidationQuantizedFixture< Tensor, Accessor, NEDepthConvertLayer, T, uint8_t > NEDepthConvertLayerToQASYMM8Fixture
Copyright (c) 2017-2022 Arm Limited.
1 channel, 1 F16 per channel
static Status validate(const ITensorInfo *input, const ITensorInfo *output, ConvertPolicy policy, uint32_t shift=0)
Static function to check if given info will lead to a valid configuration of NEDepthConvertLayer.
1 channel, 1 S32 per channel
16-bit brain floating-point number
DepthConvertLayerValidationQuantizedFixture< Tensor, Accessor, NEDepthConvertLayer, T, half > NEDepthConvertLayerQuantizedToF16Fixture
DepthConvertLayerValidationQuantizedFixture< Tensor, Accessor, NEDepthConvertLayer, T, int32_t > NEDepthConvertLayerQuantizedToS32Fixture
Quantization information.
DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16), }), framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::QASYMM8), TensorInfo(TensorShape(30U, 11U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::QSYMM16, QuantizationInfo(1.f/32768.f, 0)), })), framework::dataset::make("ActivationInfo", { ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LU_BOUNDED_RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::TANH), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC), ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SQRT), })), framework::dataset::make("Expected", { false, true, true, true, false, false, true, true, false })), input_info, output_info, act_info, expected)
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, half > NEDepthConvertLayerToF16Fixture
1 channel, 1 U32 per channel
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, bfloat16 > NEDepthConvertLayerToBF16Fixture
validate(CLAccessor(output_state), expected_output)
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, int16_t > NEDepthConvertLayerToS16Fixture
1 channel, 1 S16 per channel
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, uint16_t > NEDepthConvertLayerToU16Fixture
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, uint8_t > NEDepthConvertLayerToU8Fixture
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:43
zip(zip(framework::dataset::make("Weights", { TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 2U), 1, DataType::F32), TensorInfo(TensorShape(32U, 13U, 2U, 1U), 1, DataType::F32), }), framework::dataset::make("MVBGInfo",{ TensorInfo(TensorShape(2U), 1, DataType::F32), TensorInfo(TensorShape(2U), 1, DataType::F16), TensorInfo(TensorShape(5U), 1, DataType::F32), })), framework::dataset::make("Expected", { true, false, false}))
DepthConvertLayerValidationFixture< Tensor, Accessor, NEDepthConvertLayer, T, float > NEDepthConvertLayerToF32Fixture
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
ConvertPolicy
Policy to handle integer overflow.
Definition: Types.h:404