Compute Library
 23.11
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/CL/CLAccessor.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 16 since the maximum size of
53  * a vector used by @ref CLScaleKernel is currently 16-byte (float4).
54  */
55 constexpr uint32_t vector_byte = 16;
56 
57 template <typename T>
58 constexpr uint32_t num_elements_per_vector()
59 {
60  return vector_byte / sizeof(T);
61 }
62 
63 /** CNN data types */
64 const auto ScaleDataTypes = framework::dataset::make("DataType",
65 {
70 });
71 
72 /** Quantization information data set */
73 const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo",
74 {
75  QuantizationInfo(0.5f, -1),
76 });
77 
78 /** Tolerance */
79 constexpr AbsoluteTolerance<uint8_t> tolerance_q8(1);
80 constexpr AbsoluteTolerance<int8_t> tolerance_qs8(1);
81 constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
82 constexpr float tolerance_f32_absolute(0.001f);
83 
84 RelativeTolerance<float> tolerance_f32(0.05);
85 constexpr float abs_tolerance_f16(0.1f);
86 RelativeTolerance<half> tolerance_f16(half(0.1));
87 
88 constexpr float tolerance_num_f32(0.01f);
89 } // namespace
90 
91 TEST_SUITE(CL)
92 TEST_SUITE(Scale)
93 TEST_SUITE(Validate)
94 
95 const auto default_input_shape = TensorShape{ 2, 3, 3, 2 };
96 const auto default_output_shape = TensorShape{ 4, 6, 3, 2 };
97 
102 constexpr bool default_use_padding = false;
103 
105 {
108  Status result{};
109 
110  // nullptr is given as input
112  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
113 
114  // nullptr is given as output
116  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
117 }
118 
120 {
121  const std::map<DataType, bool> supported_data_types =
122  {
123  { DataType::U8, true },
124  { DataType::S8, false },
125  { DataType::QSYMM8, false },
126  { DataType::QASYMM8, true },
127  { DataType::QASYMM8_SIGNED, true },
128  { DataType::QSYMM8_PER_CHANNEL, false },
129  { DataType::U16, false },
130  { DataType::S16, true },
131  { DataType::QSYMM16, false },
132  { DataType::QASYMM16, false },
133  { DataType::U32, false },
134  { DataType::S32, false },
135  { DataType::U64, false },
136  { DataType::S64, false },
137  { DataType::BFLOAT16, false },
138  { DataType::F16, true },
139  { DataType::F32, true },
140  { DataType::F64, false },
141  { DataType::SIZET, false },
142  };
143  Status result{};
144  for(auto &kv : supported_data_types)
145  {
146  const auto input = TensorInfo{ default_input_shape, 1, kv.first, default_data_layout };
147  const auto output = TensorInfo{ default_output_shape, 1, kv.first, default_data_layout };
148 
150  ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS);
151  }
152 }
153 
155 {
157  Status result{};
158 
160  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
161 }
162 
164 {
165  constexpr auto non_default_data_type = DataType::F32;
166 
168  const auto output = TensorInfo{ default_output_shape, 1, non_default_data_type, default_data_layout };
169  Status result{};
170 
172  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
173 }
174 
175 TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL)
176 {
177  // Aligned corners require sampling policy to be TOP_LEFT.
179  constexpr bool align_corners = true;
180  constexpr auto sampling_policy = SamplingPolicy::CENTER;
181 
184  Status result{};
185 
187  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
188 }
189 
191 {
192  const auto input = TensorInfo{ TensorShape(28U, 33U, 2U), 1, DataType::F32 };
193  const auto output = TensorInfo{ TensorShape(26U, 21U, 2U), 1, DataType::F32 };
195  Status result{};
196 
198  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
199 }
200 TEST_SUITE_END() // Validate
201 
202 template <typename T>
203 using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
204 template <typename T>
205 using CLScaleMixedDataLayoutFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T, true>;
206 
207 TEST_SUITE(Float)
208 TEST_SUITE(FP32)
209 const auto f32_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
210 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
211 {
212  //Create valid region
213  TensorInfo src_info(_shape, 1, _data_type);
214  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
215 
216  // Validate output
217  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
218 }
219 FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, CLScaleMixedDataLayoutFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
220 {
221  //Create valid region
222  TensorInfo src_info(_shape, 1, _data_type);
223  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
224 
225  // Validate output
226  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
227 }
228 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet))
229 {
230  //Create valid region
231  TensorInfo src_info(_shape, 1, _data_type);
232  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
233 
234  // Validate output
235  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
236 }
237 const auto f32_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
238 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleSamplingPolicySet))
239 {
240  //Create valid region
241  TensorInfo src_info(_shape, 1, _data_type);
242  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
243 
244  // Validate output
245  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
246 }
247 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleAlignCornersSamplingPolicySet))
248 {
249  //Create valid region
250  TensorInfo src_info(_shape, 1, _data_type);
251  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
252 
253  // Validate output
254  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
255 }
256 TEST_SUITE_END() // FP32
257 TEST_SUITE(FP16)
258 const auto f16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
259 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet))
260 {
261  //Create valid region
262  TensorInfo src_info(_shape, 1, _data_type);
263  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
264 
265  // Validate output
266  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
267 }
268 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet))
269 {
270  //Create valid region
271  TensorInfo src_info(_shape, 1, _data_type);
272  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
273 
274  // Validate output
275  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
276 }
277 const auto f16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
278 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleSamplingPolicySet))
279 {
280  //Create valid region
281  TensorInfo src_info(_shape, 1, _data_type);
282  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
283 
284  // Validate output
285  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
286 }
287 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleAlignCornersSamplingPolicySet))
288 {
289  //Create valid region
290  TensorInfo src_info(_shape, 1, _data_type);
291  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
292 
293  // Validate output
294  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
295 }
296 TEST_SUITE_END() // FP16
297 TEST_SUITE_END() // Float
298 
299 TEST_SUITE(Integer)
300 TEST_SUITE(U8)
301 const auto u8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
302 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet))
303 {
304  //Create valid region
305  TensorInfo src_info(_shape, 1, _data_type);
306  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
307 
308  // Validate output
309  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
310 }
311 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet))
312 {
313  //Create valid region
314  TensorInfo src_info(_shape, 1, _data_type);
315  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
316 
317  // Validate output
318  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
319 }
320 const auto u8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
321 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleSamplingPolicySet))
322 {
323  //Create valid region
324  TensorInfo src_info(_shape, 1, _data_type);
325  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
326 
327  // Validate output
328  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
329 }
330 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleAlignCornersSamplingPolicySet))
331 {
332  //Create valid region
333  TensorInfo src_info(_shape, 1, _data_type);
334  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
335 
336  // Validate output
337  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
338 }
339 TEST_SUITE_END() // U8
340 TEST_SUITE(S16)
341 const auto s16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
342 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet))
343 {
344  //Create valid region
345  TensorInfo src_info(_shape, 1, _data_type);
346  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
347 
348  // Validate output
349  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
350 }
351 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet))
352 {
353  //Create valid region
354  TensorInfo src_info(_shape, 1, _data_type);
355  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
356 
357  // Validate output
358  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
359 }
360 const auto s16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
361 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleSamplingPolicySet))
362 {
363  //Create valid region
364  TensorInfo src_info(_shape, 1, _data_type);
365  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
366 
367  // Validate output
368  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
369 }
370 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleAlignCornersSamplingPolicySet))
371 {
372  //Create valid region
373  TensorInfo src_info(_shape, 1, _data_type);
374  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
375 
376  // Validate output
377  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
378 }
379 TEST_SUITE_END() // S16
380 TEST_SUITE_END() // Integer
381 
382 template <typename T>
383 using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
384 TEST_SUITE(Quantized)
385 TEST_SUITE(QASYMM8)
386 const auto qasymm8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
387 FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
388 {
389  //Create valid region
390  TensorInfo src_info(_shape, 1, _data_type);
391  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
392 
393  // Validate output
394  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
395 }
396 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet,
397  QuantizationInfoSet))
398 {
399  //Create valid region
400  TensorInfo src_info(_shape, 1, _data_type);
401  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
402 
403  // Validate output
404  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
405 }
406 const auto qasymm8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
407 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
408 {
409  //Create valid region
410  TensorInfo src_info(_shape, 1, _data_type);
411  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
412 
413  // Validate output
414  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
415 }
416 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleAlignCornersSamplingPolicySet,
417  QuantizationInfoSet))
418 {
419  //Create valid region
420  TensorInfo src_info(_shape, 1, _data_type);
421  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
422 
423  // Validate output
424  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
425 }
426 TEST_SUITE_END() // QASYMM8
427 TEST_SUITE(QASYMM8_SIGNED)
428 const auto qasymm8_signed_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
429 FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
430 {
431  //Create valid region
432  TensorInfo src_info(_shape, 1, _data_type);
433  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
434 
435  // Validate output
436  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
437 }
438 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet,
439  QuantizationInfoSet))
440 {
441  //Create valid region
442  TensorInfo src_info(_shape, 1, _data_type);
443  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
444 
445  // Validate output
446  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
447 }
448 const auto qasymm8_signed_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
449 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape, ScaleSamplingPolicySet,
450  QuantizationInfoSet))
451 {
452  //Create valid region
453  TensorInfo src_info(_shape, 1, _data_type);
454  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
455 
456  // Validate output
457  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
458 }
459 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape,
460  ScaleAlignCornersSamplingPolicySet,
461  QuantizationInfoSet))
462 {
463  //Create valid region
464  TensorInfo src_info(_shape, 1, _data_type);
465  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
466 
467  // Validate output
468  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
469 }
470 TEST_SUITE_END() // QASYMM8_SIGNED
471 TEST_SUITE_END() // Quantized
472 
473 TEST_SUITE_END() // Scale
474 TEST_SUITE_END() // CL
475 } // namespace validation
476 } // namespace test
477 } // namespace arm_compute
arm_compute::test::validation::TEST_SUITE_END
TEST_SUITE_END() FIXTURE_DATA_TEST_CASE(RunSmall
[CLActivationLayer Test snippet]
Definition: DequantizationLayer.cpp:111
arm_compute::DataType::QSYMM8_PER_CHANNEL
@ QSYMM8_PER_CHANNEL
quantized, symmetric per channel fixed-point 8-bit number
arm_compute::DataType::QASYMM16
@ QASYMM16
quantized, asymmetric fixed-point 16-bit number
arm_compute::CLScale::validate
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 CLScale.
Definition: CLScale.cpp:64
PaddingCalculator.h
arm_compute::DataType::U64
@ U64
unsigned 64-bit number
arm_compute::test::validation::TEST_CASE
TEST_CASE(FusedActivation, framework::DatasetMode::ALL)
Validate fused activation expecting the following behaviours:
Definition: ArithmeticAddition.cpp:93
arm_compute::test::validation::FIXTURE_DATA_TEST_CASE
FIXTURE_DATA_TEST_CASE(RunSmall, CLAbsLayerFixture< half >, framework::DatasetMode::PRECOMMIT, combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F16)))
Definition: AbsLayer.cpp:50
arm_compute::DataType::BFLOAT16
@ BFLOAT16
16-bit brain floating-point number
arm_compute::test::validation::qasymm8_shape
const auto qasymm8_shape
Definition: Scale.cpp:386
arm_compute::test::validation::s16_nightly_shape
const auto s16_nightly_shape
Definition: Scale.cpp:360
arm_compute::PixelValue
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:35
Helpers.h
arm_compute::test::validation::combine
combine(datasets::SmallShapes(), framework::dataset::make("DataType", DataType::F32)))
Definition: AbsLayer.cpp:65
arm_compute::DataType::F64
@ F64
64-bit floating-point number
arm_compute::test::validation::f32_shape
const auto f32_shape
Definition: Scale.cpp:209
arm_compute::DataLayout::NHWC
@ NHWC
Num samples, height, width, channels.
arm_compute::BorderMode::UNDEFINED
@ UNDEFINED
Borders are left undefined.
arm_compute::InterpolationPolicy::AREA
@ AREA
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
arm_compute::DataType::QASYMM8
@ QASYMM8
quantized, asymmetric fixed-point 8-bit number unsigned
arm_compute::DataType::U16
@ U16
unsigned 16-bit number
arm_compute::TensorShape
Shape of a tensor.
Definition: TensorShape.h:39
arm_compute::test::validation::qasymm8_nightly_shape
const auto qasymm8_nightly_shape
Definition: Scale.cpp:406
CLScale.h
arm_compute::test::validation::tolerance_f16
RelativeTolerance< half_float::half > tolerance_f16(half_float::half(0.1))
Tolerance value for comparing reference's output against implementation's output for DataType::F16.
arm_compute::DataType::QSYMM8
@ QSYMM8
quantized, symmetric fixed-point 8-bit number
Types.h
arm_compute::test::validation::u8_nightly_shape
const auto u8_nightly_shape
Definition: Scale.cpp:320
arm_compute::test::validation::sampling_policy
sampling_policy
Definition: Scale.cpp:250
arm_compute::CLTensor
Basic implementation of the OpenCL tensor interface.
Definition: CLTensor.h:41
arm_compute::DataType::S8
@ S8
signed 8-bit number
arm_compute::test::validation::default_data_type
constexpr auto default_data_type
Definition: Scale.cpp:98
arm_compute::DataType::QSYMM16
@ QSYMM16
quantized, symmetric fixed-point 16-bit number
arm_compute::test::validation::valid_region
const ValidRegion valid_region
Definition: Scale.cpp:214
arm_compute::test::validation::f32_nightly_shape
const auto f32_nightly_shape
Definition: Scale.cpp:237
CLAccessor.h
arm_compute::test::validation::validate
validate(CLAccessor(output_state), expected_output)
arm_compute::test::validation::default_interpolation_policy
constexpr auto default_interpolation_policy
Definition: Scale.cpp:100
arm_compute::half
half_float::half half
16-bit floating point type
Definition: CoreTypes.h:36
arm_compute::CLScale
Basic function to run opencl::ClScale.
Definition: CLScale.h:40
arm_compute::utils::cast::U
U
Definition: SaturateCast.h:65
arm_compute::test::validation::default_use_padding
constexpr bool default_use_padding
Definition: Scale.cpp:102
TensorAllocator.h
arm_compute::test::framework::DatasetMode::ALL
@ ALL
arm_compute::test::validation::tolerance_f32
RelativeTolerance< float > tolerance_f32(0.01f)
Tolerance value for comparing reference's output against implementation's output for DataType::F32.
arm_compute::test::validation::default_input_shape
const auto default_input_shape
Definition: Scale.cpp:95
arm_compute::DataType::U32
@ U32
unsigned 32-bit number
arm_compute::test::validation::CLScaleMixedDataLayoutFixture
ScaleValidationFixture< CLTensor, CLAccessor, CLScale, T, true > CLScaleMixedDataLayoutFixture
Definition: Scale.cpp:205
arm_compute::test::CLAccessor
Accessor implementation for CLTensor objects.
Definition: CLAccessor.h:36
arm_compute::test::validation::ARM_COMPUTE_EXPECT
ARM_COMPUTE_EXPECT(has_error==expected, framework::LogLevel::ERRORS)
arm_compute::test::framework::DatasetMode::NIGHTLY
@ NIGHTLY
arm_compute::DataType::U8
@ U8
unsigned 8-bit number
Asserts.h
arm_compute::DataType::S16
@ S16
signed 16-bit number
arm_compute::ValidRegion
Container for valid region of a window.
Definition: Types.h:143
arm_compute::Status
Status class.
Definition: Error.h:52
arm_compute::DataType::QASYMM8_SIGNED
@ QASYMM8_SIGNED
quantized, asymmetric fixed-point 8-bit number signed
Macros.h
arm_compute::test::validation::interpolation_policy
interpolation_policy
Definition: Scale.cpp:250
Tensor.h
arm_compute::test::benchmark::CLScaleFixture
ScaleFixture< CLTensor, CLScale, CLAccessor > CLScaleFixture
Definition: Scale.cpp:50
arm_compute::test::framework::dataset::make
std::enable_if< is_container< T >::value, ContainerDataset< T > >::type make(std::string name, T &&values)
Helper function to create a ContainerDataset.
Definition: ContainerDataset.h:160
arm_compute::InterpolationPolicy::BILINEAR
@ BILINEAR
Output values are defined by bilinear interpolation between the pixels.
Validation.h
arm_compute::TensorInfo
Store the tensor's metadata.
Definition: TensorInfo.h:41
arm_compute::test::validation::qasymm8_signed_nightly_shape
const auto qasymm8_signed_nightly_shape
Definition: Scale.cpp:448
arm_compute::calculate_valid_region_scale
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
arm_compute::DataType::S64
@ S64
signed 64-bit number
arm_compute
Copyright (c) 2017-2023 Arm Limited.
Definition: introduction.dox:24
arm_compute::ScaleKernelInfo
Definition: KernelDescriptors.h:199
arm_compute::test::validation::f16_nightly_shape
const auto f16_nightly_shape
Definition: Scale.cpp:277
arm_compute::test::validation::TEST_SUITE
TEST_SUITE(QASYMM8_to_F32) FIXTURE_DATA_TEST_CASE(RunSmall
arm_compute::DataType::F16
@ F16
16-bit floating-point number
arm_compute::test::validation::default_data_layout
constexpr auto default_data_layout
Definition: Scale.cpp:99
arm_compute::DataType::SIZET
@ SIZET
size_t
arm_compute::DataType::S32
@ S32
signed 32-bit number
arm_compute::test::validation::src_info
TensorInfo src_info(src_shape, 1, data_type)
arm_compute::test::validation::default_border_mode
constexpr auto default_border_mode
Definition: Scale.cpp:101
arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR
@ NEAREST_NEIGHBOR
Output values are defined to match the source pixel whose center is nearest to the sample position.
arm_compute::SamplingPolicy::CENTER
@ CENTER
Samples are taken at pixel center.
arm_compute::DataType::F32
@ F32
32-bit floating-point number
Helpers.h
arm_compute::test::validation::default_output_shape
const auto default_output_shape
Definition: Scale.cpp:96
arm_compute::test::framework::DatasetMode
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
arm_compute::DataType
DataType
Available data types.
Definition: CoreTypes.h:83
arm_compute::test::validation::input
auto input
Definition: LSTMLayerQuantized.cpp:486
arm_compute::test::framework::LogLevel::ERRORS
@ ERRORS