Compute Library
 21.02
Scale.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2020 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 RelativeTolerance<half> tolerance_f16(half(0.1));
86 
87 constexpr float tolerance_num_f32(0.01f);
88 } // namespace
89 
90 TEST_SUITE(CL)
91 TEST_SUITE(Scale)
92 TEST_SUITE(Validate)
93 
94 const auto default_input_shape = TensorShape{ 2, 3, 3, 2 };
95 const auto default_output_shape = TensorShape{ 4, 6, 3, 2 };
96 
101 constexpr bool default_use_padding = false;
102 
104 {
105  const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout };
106  const auto output = TensorInfo{ default_output_shape, 1, default_data_type, default_data_layout };
107  Status result{};
108 
109  // nullptr is given as input
110  result = CLScale::validate(nullptr, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
111  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
112 
113  // nullptr is given as output
114  result = CLScale::validate(&input, nullptr, ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
115  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
116 }
117 
119 {
120  const std::map<DataType, bool> supported_data_types =
121  {
122  { DataType::U8, true },
123  { DataType::S8, false },
124  { DataType::QSYMM8, false },
125  { DataType::QASYMM8, true },
126  { DataType::QASYMM8_SIGNED, true },
127  { DataType::QSYMM8_PER_CHANNEL, false },
128  { DataType::U16, false },
129  { DataType::S16, true },
130  { DataType::QSYMM16, false },
131  { DataType::QASYMM16, false },
132  { DataType::U32, false },
133  { DataType::S32, false },
134  { DataType::U64, false },
135  { DataType::S64, false },
136  { DataType::BFLOAT16, false },
137  { DataType::F16, true },
138  { DataType::F32, true },
139  { DataType::F64, false },
140  { DataType::SIZET, false },
141  };
142  Status result{};
143  for(auto &kv : supported_data_types)
144  {
145  const auto input = TensorInfo{ default_input_shape, 1, kv.first, default_data_layout };
146  const auto output = TensorInfo{ default_output_shape, 1, kv.first, default_data_layout };
147 
148  result = CLScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
149  ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS);
150  }
151 }
152 
154 {
155  const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout };
156  Status result{};
157 
158  result = CLScale::validate(&input, &input, ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
159  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
160 }
161 
163 {
164  constexpr auto non_default_data_type = DataType::F32;
165 
166  const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout };
167  const auto output = TensorInfo{ default_output_shape, 1, non_default_data_type, default_data_layout };
168  Status result{};
169 
170  result = CLScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
171  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
172 }
173 
174 TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL)
175 {
176  // Aligned corners require sampling policy to be TOP_LEFT.
178  constexpr bool align_corners = true;
179  constexpr auto sampling_policy = SamplingPolicy::CENTER;
180 
181  const auto input = TensorInfo{ default_input_shape, 1, default_data_type, default_data_layout };
182  const auto output = TensorInfo{ default_output_shape, 1, 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{ TensorShape(37U, 37U, 2U), 1, DataType::F32 };
192  const auto output = TensorInfo{ TensorShape(39U, 55U, 2U), 1, DataType::F32 };
193  Status result{};
194 
195  result = CLScale::validate(&input.clone()->set_is_resizable(false), &output.clone()->set_is_resizable(false), ScaleKernelInfo{ default_interpolation_policy, default_border_mode });
196  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
197 }
198 
200 {
201  const auto input = TensorInfo{ TensorShape(28U, 33U, 2U), 1, DataType::F32 };
202  const auto output = TensorInfo{ TensorShape(26U, 21U, 2U), 1, DataType::F32 };
204  Status result{};
205 
206  result = CLScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode });
207  ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
208 }
209 TEST_SUITE_END() // Validate
210 
211 template <typename T>
212 using CLScaleFixture = ScaleValidationFixture<CLTensor, CLAccessor, CLScale, T>;
213 
214 TEST_SUITE(Float)
215 TEST_SUITE(FP32)
216 const auto f32_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
217 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
218 {
219  //Create valid region
220  TensorInfo src_info(_shape, 1, _data_type);
221  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
222 
223  // Validate output
224  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
225 }
226 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet))
227 {
228  //Create valid region
229  TensorInfo src_info(_shape, 1, _data_type);
230  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
231 
232  // Validate output
233  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
234 }
235 const auto f32_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
236 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleSamplingPolicySet))
237 {
238  //Create valid region
239  TensorInfo src_info(_shape, 1, _data_type);
240  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
241 
242  // Validate output
243  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
244 }
245 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<float>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f32_nightly_shape, ScaleAlignCornersSamplingPolicySet))
246 {
247  //Create valid region
248  TensorInfo src_info(_shape, 1, _data_type);
249  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
250 
251  // Validate output
252  validate(CLAccessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32, tolerance_f32_absolute);
253 }
254 TEST_SUITE_END() // FP32
255 TEST_SUITE(FP16)
256 const auto f16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
257 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet))
258 {
259  //Create valid region
260  TensorInfo src_info(_shape, 1, _data_type);
261  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
262 
263  // Validate output
264  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
265 }
266 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet))
267 {
268  //Create valid region
269  TensorInfo src_info(_shape, 1, _data_type);
270  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
271 
272  // Validate output
273  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
274 }
275 const auto f16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
276 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleSamplingPolicySet))
277 {
278  //Create valid region
279  TensorInfo src_info(_shape, 1, _data_type);
280  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
281 
282  // Validate output
283  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
284 }
285 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<half>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(f16_nightly_shape, ScaleAlignCornersSamplingPolicySet))
286 {
287  //Create valid region
288  TensorInfo src_info(_shape, 1, _data_type);
289  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
290 
291  // Validate output
292  validate(CLAccessor(_target), _reference, valid_region, tolerance_f16);
293 }
294 TEST_SUITE_END() // FP16
295 TEST_SUITE_END() // Float
296 
297 TEST_SUITE(Integer)
298 TEST_SUITE(U8)
299 const auto u8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
300 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet))
301 {
302  //Create valid region
303  TensorInfo src_info(_shape, 1, _data_type);
304  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
305 
306  // Validate output
307  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
308 }
309 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet))
310 {
311  //Create valid region
312  TensorInfo src_info(_shape, 1, _data_type);
313  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
314 
315  // Validate output
316  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
317 }
318 const auto u8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
319 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleSamplingPolicySet))
320 {
321  //Create valid region
322  TensorInfo src_info(_shape, 1, _data_type);
323  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
324 
325  // Validate output
326  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
327 }
328 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(u8_nightly_shape, ScaleAlignCornersSamplingPolicySet))
329 {
330  //Create valid region
331  TensorInfo src_info(_shape, 1, _data_type);
332  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
333 
334  // Validate output
335  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
336 }
337 TEST_SUITE_END() // U8
338 TEST_SUITE(S16)
339 const auto s16_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
340 FIXTURE_DATA_TEST_CASE(Run, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet))
341 {
342  //Create valid region
343  TensorInfo src_info(_shape, 1, _data_type);
344  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
345 
346  // Validate output
347  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
348 }
349 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet))
350 {
351  //Create valid region
352  TensorInfo src_info(_shape, 1, _data_type);
353  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
354 
355  // Validate output
356  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
357 }
358 const auto s16_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
359 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleSamplingPolicySet))
360 {
361  //Create valid region
362  TensorInfo src_info(_shape, 1, _data_type);
363  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
364 
365  // Validate output
366  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
367 }
368 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleFixture<int16_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_DATASET(s16_nightly_shape, ScaleAlignCornersSamplingPolicySet))
369 {
370  //Create valid region
371  TensorInfo src_info(_shape, 1, _data_type);
372  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
373 
374  // Validate output
375  validate(CLAccessor(_target), _reference, valid_region, tolerance_s16);
376 }
377 TEST_SUITE_END() // S16
378 TEST_SUITE_END() // Integer
379 
380 template <typename T>
381 using CLScaleQuantizedFixture = ScaleValidationQuantizedFixture<CLTensor, CLAccessor, CLScale, T>;
382 TEST_SUITE(Quantized)
383 TEST_SUITE(QASYMM8)
384 const auto qasymm8_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
385 FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
386 {
387  //Create valid region
388  TensorInfo src_info(_shape, 1, _data_type);
389  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
390 
391  // Validate output
392  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
393 }
394 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet,
395  QuantizationInfoSet))
396 {
397  //Create valid region
398  TensorInfo src_info(_shape, 1, _data_type);
399  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
400 
401  // Validate output
402  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
403 }
404 const auto qasymm8_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
405 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
406 {
407  //Create valid region
408  TensorInfo src_info(_shape, 1, _data_type);
409  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
410 
411  // Validate output
412  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
413 }
414 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<uint8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_nightly_shape, ScaleAlignCornersSamplingPolicySet,
415  QuantizationInfoSet))
416 {
417  //Create valid region
418  TensorInfo src_info(_shape, 1, _data_type);
419  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
420 
421  // Validate output
422  validate(CLAccessor(_target), _reference, valid_region, tolerance_q8);
423 }
424 TEST_SUITE_END() // QASYMM8
426 const auto qasymm8_signed_shape = combine((SCALE_PRECOMMIT_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
427 FIXTURE_DATA_TEST_CASE(Run, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
428 {
429  //Create valid region
430  TensorInfo src_info(_shape, 1, _data_type);
431  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
432 
433  // Validate output
434  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
435 }
436 FIXTURE_DATA_TEST_CASE(RunAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet,
437  QuantizationInfoSet))
438 {
439  //Create valid region
440  TensorInfo src_info(_shape, 1, _data_type);
441  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
442 
443  // Validate output
444  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
445 }
446 const auto qasymm8_signed_nightly_shape = combine((SCALE_NIGHTLY_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
447 FIXTURE_DATA_TEST_CASE(RunNightly, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape, ScaleSamplingPolicySet,
448  QuantizationInfoSet))
449 {
450  //Create valid region
451  TensorInfo src_info(_shape, 1, _data_type);
452  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
453 
454  // Validate output
455  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
456 }
457 FIXTURE_DATA_TEST_CASE(RunNightlyAlignCorners, CLScaleQuantizedFixture<int8_t>, framework::DatasetMode::NIGHTLY, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_nightly_shape,
458  ScaleAlignCornersSamplingPolicySet,
459  QuantizationInfoSet))
460 {
461  //Create valid region
462  TensorInfo src_info(_shape, 1, _data_type);
463  const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
464 
465  // Validate output
466  validate(CLAccessor(_target), _reference, valid_region, tolerance_qs8);
467 }
468 TEST_SUITE_END() // QASYMM8_SIGNED
469 TEST_SUITE_END() // Quantized
470 
471 TEST_SUITE_END() // Scale
472 TEST_SUITE_END() // CL
473 } // namespace validation
474 } // namespace test
475 } // namespace arm_compute
Class describing the value of a pixel for any image format.
Definition: PixelValue.h:34
const auto default_input_shape
Definition: Scale.cpp:94
Shape of a tensor.
Definition: TensorShape.h:39
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
1 channel, 1 U8 per channel
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.
quantized, asymmetric fixed-point 16-bit number
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.
Status class.
Definition: Error.h:52
Output values are defined to match the source pixel whose center is nearest to the sample position...
const ValidRegion valid_region
Definition: Scale.cpp:221
ScaleFixture< CLTensor, CLScale, CLAccessor > CLScaleFixture
Definition: Scale.cpp:50
Basic function to run CLScaleKernel.
Definition: CLScale.h:44
Copyright (c) 2017-2021 Arm Limited.
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:60
1 channel, 1 F16 per channel
constexpr bool default_use_padding
Definition: Scale.cpp:101
Samples are taken at pixel center.
1 channel, 1 S32 per channel
16-bit brain floating-point number
signed 64-bit number
DatasetMode
Possible dataset modes.
Definition: DatasetModes.h:40
const auto qasymm8_signed_nightly_shape
Definition: Scale.cpp:446
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
Accessor implementation for CLTensor objects.
Definition: CLAccessor.h:35
TEST_SUITE(U8_to_S8) FIXTURE_DATA_TEST_CASE(RunSmall
const auto qasymm8_nightly_shape
Definition: Scale.cpp:404
validate(CLAccessor(output_state), expected_output)
constexpr auto default_border_mode
Definition: Scale.cpp:100
constexpr auto default_data_layout
Definition: Scale.cpp:98
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
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
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
const auto default_output_shape
Definition: Scale.cpp:95
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
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
Basic implementation of the OpenCL tensor interface.
Definition: CLTensor.h:41