Compute Library
 21.02
Scale.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  */
25 #include "arm_compute/core/Types.h"
29 #include "tests/NEON/Accessor.h"
31 #include "tests/datasets/ScaleValidationDataset.h"
33 #include "tests/framework/Macros.h"
36 #include "tests/validation/fixtures/ScaleFixture.h"
37 
38 namespace arm_compute
39 {
40 namespace test
41 {
42 namespace validation
43 {
44 namespace
45 {
46 using datasets::ScaleShapesBaseDataSet;
47 using datasets::ScaleInterpolationPolicySet;
48 using datasets::ScaleDataLayouts;
49 using datasets::ScaleSamplingPolicySet;
50 using datasets::ScaleAlignCornersSamplingPolicySet;
51 
52 /** We consider vector size in byte 64 since the maximum size of
53  * a vector used by @ref NEScaleKernel is currently 64-byte (float32x4x4).
54  * There are possibility to reduce test time further by using
55  * smaller vector sizes for different data types where applicable.
56  */
57 constexpr uint32_t vector_byte = 64;
58 
59 template <typename T>
60 constexpr uint32_t num_elements_per_vector()
61 {
62  return vector_byte / sizeof(T);
63 }
64 
65 /** Scale data types */
66 const auto ScaleDataTypes = framework::dataset::make("DataType",
67 {
71 });
72 
73 /** Quantization information data set */
74 const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo",
75 {
76  QuantizationInfo(0.5f, -10),
77 });
78 
79 /** Tolerance */
80 constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
81 constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
82 RelativeTolerance<float> tolerance_f32(0.05);
83 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
84 RelativeTolerance<half> tolerance_f16(half(0.1));
85 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
86 
87 constexpr float tolerance_num_s16 = 0.01f;
88 constexpr float tolerance_num_f32 = 0.01f;
89 } // namespace
90 
91 TEST_SUITE(NEON)
92 TEST_SUITE(Scale)
93 TEST_SUITE(Validate)
94 
95 /** Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros
96  * we use to check the validity of given arguments in @ref NEScale
97  * and subsequent call to @ref NEScaleKernel.
98  * Since this is using validate() of @ref NEScale, which pre-adjust
99  * arguments for @ref NEScaleKernel, the following conditions in
100  * the kernel are not currently tested.
101  * - The same input and output
102  * - Data type of offset, dx and dy
103  * This suite also tests two different validate() APIs - one is
104  * using @ref ScaleKernelInfo and the other one is more verbose
105  * one calls the other one - in the same test case. Even though
106  * there are possibility that it makes debugging for regression
107  * harder, belows are reasons of this test case implementation.
108  * - The more verbose one is just a wrapper function calls
109  * the other one without any additional logic. So we are
110  * safe to merge two tests into one.
111  * - A large amount of code duplication is test suite can be prevented.
112  */
113 
114 const auto input_shape = TensorShape{ 2, 3, 3, 2 };
115 const auto output_shape = TensorShape{ 4, 6, 3, 2 };
116 
117 constexpr auto default_data_type = DataType::U8;
118 constexpr auto default_data_layout = DataLayout::NHWC;
122 
124 {
125  const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
126  const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
127  Status result{};
128 
129  // nullptr is given as input
131  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
132 
133  // nullptr is given as output
135  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
136 }
137 
138 TEST_CASE(SupportDataType, framework::DatasetMode::ALL)
139 {
140  const std::map<DataType, bool> supported_data_types =
141  {
142  { DataType::U8, true },
143  { DataType::S8, false },
144  { DataType::QSYMM8, false },
145  { DataType::QASYMM8, true },
146  { DataType::QASYMM8_SIGNED, true },
147  { DataType::QSYMM8_PER_CHANNEL, false },
148  { DataType::U16, false },
149  { DataType::S16, true },
150  { DataType::QSYMM16, false },
151  { DataType::QASYMM16, false },
152  { DataType::U32, false },
153  { DataType::S32, false },
154  { DataType::U64, false },
155  { DataType::S64, false },
156  { DataType::BFLOAT16, false },
157 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
158  { DataType::F16, true },
159 #else // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
160  { DataType::F16, false },
161 #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
162  { DataType::F32, true },
163  { DataType::F64, false },
164  { DataType::SIZET, false },
165  };
166  Status result{};
167  for(auto &kv : supported_data_types)
168  {
169  const auto input = TensorInfo{ input_shape, 1, kv.first, default_data_layout };
170  const auto output = TensorInfo{ output_shape, 1, kv.first, default_data_layout };
171 
173  ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS);
174  }
175 }
176 
177 TEST_CASE(MissmatchingDataType, framework::DatasetMode::ALL)
178 {
179  constexpr auto non_default_data_type = DataType::F32;
180 
181  const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
182  const auto output = TensorInfo{ output_shape, 1, non_default_data_type, default_data_layout };
183  Status result{};
184 
186  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
187 }
188 
190 {
191  const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
192  const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
193  Status result{};
194 
195  // Padding is not supported anymore
196  constexpr auto border_mode = BorderMode::CONSTANT;
197  constexpr bool use_padding = true;
198 
199  result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, border_mode, PixelValue(), default_sampling_policy, use_padding });
200  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
201 }
202 
204 {
205  // InterpolationPolicy::AREA is not supported for NHWC
207  constexpr auto data_layout = DataLayout::NHWC;
208 
209  const auto input = TensorInfo{ input_shape, 1, default_data_type, data_layout };
210  const auto output = TensorInfo{ output_shape, 1, default_data_type, data_layout };
211  Status result{};
212 
214  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
215 }
216 
218 {
219  // InterpolationPolicy::AREA only supports U8
221  constexpr auto data_type = DataType::F32;
222  constexpr auto data_layout = DataLayout::NCHW;
223 
224  const auto input = TensorInfo{ input_shape, 1, data_type, data_layout };
225  const auto output = TensorInfo{ output_shape, 1, data_type, data_layout };
226  Status result{};
227 
229  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
230 }
231 
232 TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL)
233 {
234  // Aligned corners require sampling policy to be TOP_LEFT.
236  constexpr bool align_corners = true;
237  constexpr auto sampling_policy = SamplingPolicy::CENTER;
238 
239  const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
240  const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
241  Status result{};
242 
244  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
245 }
246 TEST_SUITE_END() // Validate
247 
248 DATA_TEST_CASE(CheckNoPadding, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::Medium4DShapes(),
254 {
255  constexpr auto default_border_mode = BorderMode::CONSTANT;
256  ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false);
257 
258  // Create tensors
259  Tensor src = create_tensor<Tensor>(shape, data_type);
261 
262  const float scale_x = 0.5f;
263  const float scale_y = 0.5f;
264  TensorShape shape_scaled(shape);
267  shape_scaled.set(idx_width, shape[idx_width] * scale_x, /* apply_dim_correction = */ false);
268  shape_scaled.set(idx_height, shape[idx_height] * scale_y, /* apply_dim_correction = */ false);
269  Tensor dst = create_tensor<Tensor>(shape_scaled, data_type);
270 
273 
274  // Create and configure function
276  scale.configure(&src, &dst, info);
277 
278  validate(src.info()->padding(), PaddingSize(0, 0, 0, 0));
279  validate(dst.info()->padding(), PaddingSize(0, 0, 0, 0));
280 }
281 
282 DATA_TEST_CASE(CheckNoPaddingInterpAREA, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::Medium4DShapes(),
283  framework::dataset::make("DataType", { DataType::U8 })),
284  framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::AREA })),
286  framework::dataset::make("DataLayout", { DataLayout::NCHW })),
288 {
289  constexpr auto default_border_mode = BorderMode::CONSTANT;
290  ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false);
291 
292  // Create tensors
293  Tensor src = create_tensor<Tensor>(shape, data_type);
295 
296  const float scale_x = 0.5f;
297  const float scale_y = 0.5f;
298  TensorShape shape_scaled(shape);
301  shape_scaled.set(idx_width, shape[idx_width] * scale_x, /* apply_dim_correction = */ false);
302  shape_scaled.set(idx_height, shape[idx_height] * scale_y, /* apply_dim_correction = */ false);
303 
304  Tensor dst = create_tensor<Tensor>(shape, data_type);
305 
308 
309  // Create and configure function
310  NEScale scale;
311  scale.configure(&src, &dst, info);
312 
313  validate(src.info()->padding(), PaddingSize(0, 0, 0, 0));
314  validate(dst.info()->padding(), PaddingSize(0, 0, 0, 0));
315 }
316 
317 template <typename T>
318 using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>;
319 template <typename T>
320 using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>;
321 
322 TEST_SUITE(Float)
323 TEST_SUITE(FP32)
324 const auto f32_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
325 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
326 {
327  //Create valid region
328  TensorInfo src_info(_shape, 1, _data_type);
329  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
330 
331  // Validate output
332  validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
333 }
334 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet))
335 {
336  //Create valid region
337  TensorInfo src_info(_shape, 1, _data_type);
338  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
339 
340  // Validate output
341  validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
342 }
343 TEST_SUITE_END() // FP32
344 #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
345 TEST_SUITE(FP16)
346 const auto f16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
347 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet))
348 {
349  //Create valid region
350  TensorInfo src_info(_shape, 1, _data_type);
351  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
352 
353  // Validate output
354  validate(Accessor(_target), _reference, valid_region, tolerance_f16);
355 }
356 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet))
357 {
358  //Create valid region
359  TensorInfo src_info(_shape, 1, _data_type);
360  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
361 
362  // Validate output
363  validate(Accessor(_target), _reference, valid_region, tolerance_f16);
364 }
365 TEST_SUITE_END() // FP16
366 #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
367 TEST_SUITE_END() // Float
368 
369 TEST_SUITE(Integer)
370 TEST_SUITE(U8)
371 const auto u8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
372 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet))
373 {
374  //Create valid region
375  TensorInfo src_info(_shape, 1, _data_type);
376  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
377 
378  // Validate output
379  validate(Accessor(_target), _reference, valid_region, tolerance_u8);
380 }
381 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet))
382 {
383  //Create valid region
384  TensorInfo src_info(_shape, 1, _data_type);
385  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
386 
387  // Validate output
388  validate(Accessor(_target), _reference, valid_region, tolerance_u8);
389 }
390 TEST_SUITE_END() // U8
391 TEST_SUITE(S16)
392 const auto s16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
393 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet))
394 {
395  //Create valid region
396  TensorInfo src_info(_shape, 1, _data_type);
397  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
398 
399  // Validate output
400  validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
401 }
402 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet))
403 {
404  //Create valid region
405  TensorInfo src_info(_shape, 1, _data_type);
406  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
407 
408  // Validate output
409  validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
410 }
411 TEST_SUITE_END() // S16
412 TEST_SUITE_END() // Integer
413 
414 TEST_SUITE(Quantized)
415 TEST_SUITE(QASYMM8)
416 const auto qasymm8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
417 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
418 {
419  //Create valid region
420  TensorInfo src_info(_shape, 1, _data_type);
421  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
422 
423  // Validate output
424  validate(Accessor(_target), _reference, valid_region, tolerance_u8);
425 }
426 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet,
427  QuantizationInfoSet))
428 {
429  //Create valid region
430  TensorInfo src_info(_shape, 1, _data_type);
431  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
432 
433  // Validate output
434  validate(Accessor(_target), _reference, valid_region, tolerance_u8);
435 }
436 TEST_SUITE_END() // QASYMM8
438 const auto qasymm8_signed_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
440 FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
441 {
442  //Create valid region
443  TensorInfo src_info(_shape, 1, _data_type);
444  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
445 
446  // Validate output
447  validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed);
448 }
449 FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet,
450  QuantizationInfoSet))
451 {
452  //Create valid region
453  TensorInfo src_info(_shape, 1, _data_type);
454  ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
455 
456  // Validate output
457  validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed);
458 }
459 TEST_SUITE_END() // QASYMM8_SIGNED
460 TEST_SUITE_END() // Quantized
461 
462 TEST_SUITE_END() // Scale
463 TEST_SUITE_END() // Neon
464 } // namespace validation
465 } // namespace test
466 } // namespace arm_compute
ScaleValidationFixture< Tensor, Accessor, NEScale, T > NEScaleFixture
Definition: Scale.cpp:318
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
Shape of a tensor.
Definition: TensorShape.h:39
Class reprensenting an absolute tolerance value.
Definition: Validation.h:50
RelativeTolerance< float > tolerance_f32(0.001f)
F32 Tolerance value for comparing reference&#39;s output against implementation&#39;s output for floating poi...
quantized, symmetric fixed-point 16-bit number
constexpr auto default_data_type
Definition: Scale.cpp:97
TensorShape shape_scaled(shape)
1 channel, 1 U8 per channel
constexpr auto default_sampling_policy
Definition: Scale.cpp:121
half_float::half half
16-bit floating point type
Definition: Types.h:46
1 channel, 1 F32 per channel
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
Output values are defined by bilinear interpolation between the pixels.
const DataLayout data_layout
Definition: Im2Col.cpp:151
ScaleValidationQuantizedFixture< Tensor, Accessor, NEScale, T > NEScaleQuantizedFixture
Definition: Scale.cpp:320
quantized, asymmetric fixed-point 16-bit number
1 channel, 1 U16 per channel
constexpr AbsoluteTolerance< int8_t > tolerance_qasymm8_signed
Definition: Scale.cpp:439
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Status class.
Definition: Error.h:52
Output values are defined to match the source pixel whose center is nearest to the sample position...
Basic function to run NEScaleKernel.
Definition: NEScale.h:37
const ValidRegion valid_region
Definition: Scale.cpp:221
SimpleTensor< float > src
Definition: DFT.cpp:155
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
Samples are taken at pixel center.
ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor&#39;s metadata.
Definition: Tensor.cpp:33
1 channel, 1 S32 per channel
16-bit brain floating-point number
signed 64-bit number
virtual bool is_resizable() const =0
Flag indicating whether the size of the tensor can be changed.
const DataType data_type
Definition: Im2Col.cpp:150
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)
TensorShape input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
Accessor implementation for Tensor objects.
Definition: Accessor.h:35
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ScaleKernelInfo &info)
Static function to check if given info will lead to a valid configuration of NEScale.
Definition: NEScale.cpp:175
1 channel, 1 U32 per channel
virtual ITensorInfo & set_data_layout(const DataLayout &data_layout)=0
Set the data layout of the tensor.
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
quantized, asymmetric fixed-point 8-bit number unsigned
Samples are taken at pixel top left corner.
Basic implementation of the tensor interface.
Definition: Tensor.h:37
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
validate(CLAccessor(output_state), expected_output)
virtual PaddingSize padding() const =0
Padding of tensor.
BorderSize PaddingSize
Container for 2D padding size.
Definition: Types.h:382
constexpr auto default_border_mode
Definition: Scale.cpp:100
constexpr auto default_data_layout
Definition: Scale.cpp:98
void configure(ITensor *input, ITensor *output, const ScaleKernelInfo &info)
Initialize the function&#39;s source, destination, interpolation type and border_mode.
Definition: NEScale.cpp:104
1 channel, 1 S16 per channel
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
quantized, symmetric fixed-point 8-bit number
Num samples, channels, height, width.
TensorInfo src_info(src_shape, 1, data_type)
quantized, symmetric per channel fixed-point 8-bit number
ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined)
Helper function to calculate the Valid Region for Scale.
Definition: Helpers.cpp:28
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Borders are left undefined.
Num samples, height, width, channels.
constexpr auto default_interpolation_policy
Definition: Scale.cpp:99
Store the tensor&#39;s metadata.
Definition: TensorInfo.h:45
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
quantized, asymmetric fixed-point 8-bit number signed
64-bit floating-point number
RelativeTolerance< half_float::half > tolerance_f16(half(0.2))
F16 Tolerance value for comparing reference&#39;s output against implementation&#39;s output for floating poi...
Container for valid region of a window.
Definition: Types.h:188
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
Definition: Helpers.inl:193
unsigned 64-bit number
DataType
Available data types.
Definition: Types.h:77
signed 8-bit number
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
TensorShape & set(size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true)
Accessor to set the value of one of the dimensions.
Definition: TensorShape.h:79