1*c217d954SCole Faust /*
2*c217d954SCole Faust * Copyright (c) 2017-2022 Arm Limited.
3*c217d954SCole Faust *
4*c217d954SCole Faust * SPDX-License-Identifier: MIT
5*c217d954SCole Faust *
6*c217d954SCole Faust * Permission is hereby granted, free of charge, to any person obtaining a copy
7*c217d954SCole Faust * of this software and associated documentation files (the "Software"), to
8*c217d954SCole Faust * deal in the Software without restriction, including without limitation the
9*c217d954SCole Faust * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10*c217d954SCole Faust * sell copies of the Software, and to permit persons to whom the Software is
11*c217d954SCole Faust * furnished to do so, subject to the following conditions:
12*c217d954SCole Faust *
13*c217d954SCole Faust * The above copyright notice and this permission notice shall be included in all
14*c217d954SCole Faust * copies or substantial portions of the Software.
15*c217d954SCole Faust *
16*c217d954SCole Faust * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17*c217d954SCole Faust * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18*c217d954SCole Faust * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19*c217d954SCole Faust * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20*c217d954SCole Faust * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21*c217d954SCole Faust * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22*c217d954SCole Faust * SOFTWARE.
23*c217d954SCole Faust */
24*c217d954SCole Faust #include "arm_compute/core/Helpers.h"
25*c217d954SCole Faust #include "arm_compute/runtime/NEON/functions/NEScale.h"
26*c217d954SCole Faust #include "tests/NEON/Accessor.h"
27*c217d954SCole Faust #include "tests/datasets/ScaleValidationDataset.h"
28*c217d954SCole Faust #include "tests/framework/Macros.h"
29*c217d954SCole Faust #include "tests/validation/Validation.h"
30*c217d954SCole Faust #include "tests/validation/fixtures/ScaleFixture.h"
31*c217d954SCole Faust
32*c217d954SCole Faust namespace arm_compute
33*c217d954SCole Faust {
34*c217d954SCole Faust namespace test
35*c217d954SCole Faust {
36*c217d954SCole Faust namespace validation
37*c217d954SCole Faust {
38*c217d954SCole Faust namespace
39*c217d954SCole Faust {
40*c217d954SCole Faust using datasets::ScaleShapesBaseDataSet;
41*c217d954SCole Faust using datasets::ScaleInterpolationPolicySet;
42*c217d954SCole Faust using datasets::ScaleDataLayouts;
43*c217d954SCole Faust using datasets::ScaleSamplingPolicySet;
44*c217d954SCole Faust using datasets::ScaleAlignCornersSamplingPolicySet;
45*c217d954SCole Faust
46*c217d954SCole Faust /** We consider vector size in byte 64 since the maximum size of
47*c217d954SCole Faust * a vector used by the kernel is currently 64-byte (float32x4x4).
48*c217d954SCole Faust * There is possibility to reduce test time further by using
49*c217d954SCole Faust * smaller vector sizes for different data types where applicable.
50*c217d954SCole Faust */
51*c217d954SCole Faust constexpr uint32_t vector_byte = 64;
52*c217d954SCole Faust
53*c217d954SCole Faust template <typename T>
num_elements_per_vector()54*c217d954SCole Faust constexpr uint32_t num_elements_per_vector()
55*c217d954SCole Faust {
56*c217d954SCole Faust return vector_byte / sizeof(T);
57*c217d954SCole Faust }
58*c217d954SCole Faust
59*c217d954SCole Faust /** Quantization information data set */
60*c217d954SCole Faust const auto QuantizationInfoSet = framework::dataset::make("QuantizationInfo",
61*c217d954SCole Faust {
62*c217d954SCole Faust QuantizationInfo(0.5f, -10),
63*c217d954SCole Faust });
64*c217d954SCole Faust
65*c217d954SCole Faust /** Quantization information data set */
66*c217d954SCole Faust const auto InputQuantizationInfoSet = framework::dataset::make("InputQuantizationInfo",
67*c217d954SCole Faust {
68*c217d954SCole Faust QuantizationInfo(0.5f, -10),
69*c217d954SCole Faust });
70*c217d954SCole Faust
71*c217d954SCole Faust /** Quantization information data set */
72*c217d954SCole Faust const auto OutputQuantizationInfoSet = framework::dataset::make("OutputQuantizationInfo",
73*c217d954SCole Faust {
74*c217d954SCole Faust QuantizationInfo(0.2f, 20),
75*c217d954SCole Faust });
76*c217d954SCole Faust
77*c217d954SCole Faust /** Tolerance */
78*c217d954SCole Faust constexpr AbsoluteTolerance<uint8_t> tolerance_u8(1);
79*c217d954SCole Faust constexpr AbsoluteTolerance<int8_t> tolerance_s8(1);
80*c217d954SCole Faust constexpr AbsoluteTolerance<int16_t> tolerance_s16(1);
81*c217d954SCole Faust RelativeTolerance<float> tolerance_f32(0.05);
82*c217d954SCole Faust #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
83*c217d954SCole Faust constexpr float abs_tolerance_f16(0.01f);
84*c217d954SCole Faust RelativeTolerance<half> tolerance_f16(half(0.1));
85*c217d954SCole Faust #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
86*c217d954SCole Faust
87*c217d954SCole Faust constexpr float tolerance_num_s16 = 0.01f;
88*c217d954SCole Faust constexpr float tolerance_num_f32 = 0.01f;
89*c217d954SCole Faust } // namespace
90*c217d954SCole Faust
91*c217d954SCole Faust TEST_SUITE(NEON)
TEST_SUITE(Scale)92*c217d954SCole Faust TEST_SUITE(Scale)
93*c217d954SCole Faust TEST_SUITE(Validate)
94*c217d954SCole Faust
95*c217d954SCole Faust /** Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros
96*c217d954SCole Faust * we use to check the validity of given arguments in @ref NEScale
97*c217d954SCole Faust * Since this is using validate() of @ref NEScale, which pre-adjust
98*c217d954SCole Faust * arguments for the kernel, the following conditions in
99*c217d954SCole Faust * the kernel are not currently tested.
100*c217d954SCole Faust * - The same input and output
101*c217d954SCole Faust * - Data type of offset, dx and dy
102*c217d954SCole Faust * This suite also tests two different validate() APIs - one is
103*c217d954SCole Faust * using @ref ScaleKernelInfo and the other one is more verbose
104*c217d954SCole Faust * one calls the other one - in the same test case. Even though
105*c217d954SCole Faust * there are possibility that it makes debugging for regression
106*c217d954SCole Faust * harder, belows are reasons of this test case implementation.
107*c217d954SCole Faust * - The more verbose one is just a wrapper function calls
108*c217d954SCole Faust * the other one without any additional logic. So we are
109*c217d954SCole Faust * safe to merge two tests into one.
110*c217d954SCole Faust * - A large amount of code duplication is test suite can be prevented.
111*c217d954SCole Faust */
112*c217d954SCole Faust
113*c217d954SCole Faust const auto input_shape = TensorShape{ 2, 3, 3, 2 };
114*c217d954SCole Faust const auto output_shape = TensorShape{ 4, 6, 3, 2 };
115*c217d954SCole Faust
116*c217d954SCole Faust constexpr auto default_data_type = DataType::U8;
117*c217d954SCole Faust constexpr auto default_data_layout = DataLayout::NHWC;
118*c217d954SCole Faust constexpr auto default_interpolation_policy = InterpolationPolicy::NEAREST_NEIGHBOR;
119*c217d954SCole Faust constexpr auto default_border_mode = BorderMode::CONSTANT;
120*c217d954SCole Faust constexpr auto default_sampling_policy = SamplingPolicy::CENTER;
121*c217d954SCole Faust
TEST_CASE(NullPtr,framework::DatasetMode::ALL)122*c217d954SCole Faust TEST_CASE(NullPtr, framework::DatasetMode::ALL)
123*c217d954SCole Faust {
124*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
125*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
126*c217d954SCole Faust Status result{};
127*c217d954SCole Faust
128*c217d954SCole Faust // nullptr is given as input
129*c217d954SCole Faust result = NEScale::validate(nullptr, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
130*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
131*c217d954SCole Faust
132*c217d954SCole Faust // nullptr is given as output
133*c217d954SCole Faust result = NEScale::validate(&input, nullptr, ScaleKernelInfo{ default_interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
134*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
135*c217d954SCole Faust }
136*c217d954SCole Faust
TEST_CASE(SupportDataType,framework::DatasetMode::ALL)137*c217d954SCole Faust TEST_CASE(SupportDataType, framework::DatasetMode::ALL)
138*c217d954SCole Faust {
139*c217d954SCole Faust const std::map<DataType, bool> supported_data_types =
140*c217d954SCole Faust {
141*c217d954SCole Faust { DataType::U8, true },
142*c217d954SCole Faust { DataType::S8, false },
143*c217d954SCole Faust { DataType::QSYMM8, false },
144*c217d954SCole Faust { DataType::QASYMM8, true },
145*c217d954SCole Faust { DataType::QASYMM8_SIGNED, true },
146*c217d954SCole Faust { DataType::QSYMM8_PER_CHANNEL, false },
147*c217d954SCole Faust { DataType::U16, false },
148*c217d954SCole Faust { DataType::S16, true },
149*c217d954SCole Faust { DataType::QSYMM16, false },
150*c217d954SCole Faust { DataType::QASYMM16, false },
151*c217d954SCole Faust { DataType::U32, false },
152*c217d954SCole Faust { DataType::S32, false },
153*c217d954SCole Faust { DataType::U64, false },
154*c217d954SCole Faust { DataType::S64, false },
155*c217d954SCole Faust { DataType::BFLOAT16, false },
156*c217d954SCole Faust #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
157*c217d954SCole Faust { DataType::F16, true },
158*c217d954SCole Faust #else // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
159*c217d954SCole Faust { DataType::F16, false },
160*c217d954SCole Faust #endif // __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
161*c217d954SCole Faust { DataType::F32, true },
162*c217d954SCole Faust { DataType::F64, false },
163*c217d954SCole Faust { DataType::SIZET, false },
164*c217d954SCole Faust };
165*c217d954SCole Faust Status result{};
166*c217d954SCole Faust for(auto &kv : supported_data_types)
167*c217d954SCole Faust {
168*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, kv.first, default_data_layout };
169*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, kv.first, default_data_layout };
170*c217d954SCole Faust
171*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
172*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == kv.second, framework::LogLevel::ERRORS);
173*c217d954SCole Faust }
174*c217d954SCole Faust }
175*c217d954SCole Faust
TEST_CASE(MissmatchingDataType,framework::DatasetMode::ALL)176*c217d954SCole Faust TEST_CASE(MissmatchingDataType, framework::DatasetMode::ALL)
177*c217d954SCole Faust {
178*c217d954SCole Faust constexpr auto non_default_data_type = DataType::F32;
179*c217d954SCole Faust
180*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
181*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, non_default_data_type, default_data_layout };
182*c217d954SCole Faust Status result{};
183*c217d954SCole Faust
184*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
185*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
186*c217d954SCole Faust }
187*c217d954SCole Faust
TEST_CASE(UsePadding,framework::DatasetMode::ALL)188*c217d954SCole Faust TEST_CASE(UsePadding, framework::DatasetMode::ALL)
189*c217d954SCole Faust {
190*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
191*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
192*c217d954SCole Faust Status result{};
193*c217d954SCole Faust
194*c217d954SCole Faust // Padding is not supported anymore
195*c217d954SCole Faust constexpr auto border_mode = BorderMode::CONSTANT;
196*c217d954SCole Faust constexpr bool use_padding = true;
197*c217d954SCole Faust
198*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ default_interpolation_policy, border_mode, PixelValue(), default_sampling_policy, use_padding });
199*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
200*c217d954SCole Faust }
201*c217d954SCole Faust
TEST_CASE(AreaWithNHWC,framework::DatasetMode::ALL)202*c217d954SCole Faust TEST_CASE(AreaWithNHWC, framework::DatasetMode::ALL)
203*c217d954SCole Faust {
204*c217d954SCole Faust // InterpolationPolicy::AREA is not supported for NHWC
205*c217d954SCole Faust constexpr auto interpolation_policy = InterpolationPolicy::AREA;
206*c217d954SCole Faust constexpr auto data_layout = DataLayout::NHWC;
207*c217d954SCole Faust
208*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, default_data_type, data_layout };
209*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, default_data_type, data_layout };
210*c217d954SCole Faust Status result{};
211*c217d954SCole Faust
212*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
213*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
214*c217d954SCole Faust }
215*c217d954SCole Faust
TEST_CASE(AreaWithNonU8,framework::DatasetMode::ALL)216*c217d954SCole Faust TEST_CASE(AreaWithNonU8, framework::DatasetMode::ALL)
217*c217d954SCole Faust {
218*c217d954SCole Faust // InterpolationPolicy::AREA only supports U8
219*c217d954SCole Faust constexpr auto interpolation_policy = InterpolationPolicy::AREA;
220*c217d954SCole Faust constexpr auto data_type = DataType::F32;
221*c217d954SCole Faust constexpr auto data_layout = DataLayout::NCHW;
222*c217d954SCole Faust
223*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, data_type, data_layout };
224*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, data_type, data_layout };
225*c217d954SCole Faust Status result{};
226*c217d954SCole Faust
227*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), SamplingPolicy::CENTER, false });
228*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
229*c217d954SCole Faust }
230*c217d954SCole Faust
TEST_CASE(AlignedCornerNotSupported,framework::DatasetMode::ALL)231*c217d954SCole Faust TEST_CASE(AlignedCornerNotSupported, framework::DatasetMode::ALL)
232*c217d954SCole Faust {
233*c217d954SCole Faust // Aligned corners require sampling policy to be TOP_LEFT.
234*c217d954SCole Faust constexpr auto interpolation_policy = InterpolationPolicy::BILINEAR;
235*c217d954SCole Faust constexpr bool align_corners = true;
236*c217d954SCole Faust constexpr auto sampling_policy = SamplingPolicy::CENTER;
237*c217d954SCole Faust
238*c217d954SCole Faust const auto input = TensorInfo{ input_shape, 1, default_data_type, default_data_layout };
239*c217d954SCole Faust const auto output = TensorInfo{ output_shape, 1, default_data_type, default_data_layout };
240*c217d954SCole Faust Status result{};
241*c217d954SCole Faust
242*c217d954SCole Faust result = NEScale::validate(&input, &output, ScaleKernelInfo{ interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false, align_corners });
243*c217d954SCole Faust ARM_COMPUTE_EXPECT(bool(result) == false, framework::LogLevel::ERRORS);
244*c217d954SCole Faust }
245*c217d954SCole Faust TEST_SUITE_END() // Validate
246*c217d954SCole Faust
247*c217d954SCole Faust DATA_TEST_CASE(CheckNoPadding, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::Medium4DShapes(),
248*c217d954SCole Faust framework::dataset::make("DataType", { DataType::F32, DataType::QASYMM8 })),
249*c217d954SCole Faust framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::BILINEAR, InterpolationPolicy::NEAREST_NEIGHBOR })),
250*c217d954SCole Faust framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER, SamplingPolicy::TOP_LEFT })),
251*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NHWC, DataLayout::NCHW })),
252*c217d954SCole Faust shape, data_type, interpolation_policy, sampling_policy, data_layout)
253*c217d954SCole Faust {
254*c217d954SCole Faust constexpr auto default_border_mode = BorderMode::CONSTANT;
255*c217d954SCole Faust ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false);
256*c217d954SCole Faust
257*c217d954SCole Faust // Create tensors
258*c217d954SCole Faust Tensor src = create_tensor<Tensor>(shape, data_type);
259*c217d954SCole Faust src.info()->set_data_layout(data_layout);
260*c217d954SCole Faust
261*c217d954SCole Faust const float scale_x = 0.5f;
262*c217d954SCole Faust const float scale_y = 0.5f;
263*c217d954SCole Faust TensorShape shape_scaled(shape);
264*c217d954SCole Faust const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
265*c217d954SCole Faust const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
266*c217d954SCole Faust shape_scaled.set(idx_width, shape[idx_width] * scale_x, /* apply_dim_correction = */ false);
267*c217d954SCole Faust shape_scaled.set(idx_height, shape[idx_height] * scale_y, /* apply_dim_correction = */ false);
268*c217d954SCole Faust Tensor dst = create_tensor<Tensor>(shape_scaled, data_type);
269*c217d954SCole Faust
270*c217d954SCole Faust ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
271*c217d954SCole Faust ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
272*c217d954SCole Faust
273*c217d954SCole Faust // Create and configure function
274*c217d954SCole Faust NEScale scale;
275*c217d954SCole Faust scale.configure(&src, &dst, info);
276*c217d954SCole Faust
277*c217d954SCole Faust validate(src.info()->padding(), PaddingSize(0, 0, 0, 0));
278*c217d954SCole Faust validate(dst.info()->padding(), PaddingSize(0, 0, 0, 0));
279*c217d954SCole Faust }
280*c217d954SCole Faust
281*c217d954SCole Faust DATA_TEST_CASE(CheckNoPaddingInterpAREA, framework::DatasetMode::ALL, combine(combine(combine(combine(datasets::Medium4DShapes(),
282*c217d954SCole Faust framework::dataset::make("DataType", { DataType::U8 })),
283*c217d954SCole Faust framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::AREA })),
284*c217d954SCole Faust framework::dataset::make("SamplingPolicy", { SamplingPolicy::CENTER, SamplingPolicy::TOP_LEFT })),
285*c217d954SCole Faust framework::dataset::make("DataLayout", { DataLayout::NCHW })),
286*c217d954SCole Faust shape, data_type, interpolation_policy, sampling_policy, data_layout)
287*c217d954SCole Faust {
288*c217d954SCole Faust constexpr auto default_border_mode = BorderMode::CONSTANT;
289*c217d954SCole Faust ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false);
290*c217d954SCole Faust
291*c217d954SCole Faust // Create tensors
292*c217d954SCole Faust Tensor src = create_tensor<Tensor>(shape, data_type);
293*c217d954SCole Faust src.info()->set_data_layout(data_layout);
294*c217d954SCole Faust
295*c217d954SCole Faust const float scale_x = 0.5f;
296*c217d954SCole Faust const float scale_y = 0.5f;
297*c217d954SCole Faust TensorShape shape_scaled(shape);
298*c217d954SCole Faust const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
299*c217d954SCole Faust const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
300*c217d954SCole Faust shape_scaled.set(idx_width, shape[idx_width] * scale_x, /* apply_dim_correction = */ false);
301*c217d954SCole Faust shape_scaled.set(idx_height, shape[idx_height] * scale_y, /* apply_dim_correction = */ false);
302*c217d954SCole Faust
303*c217d954SCole Faust Tensor dst = create_tensor<Tensor>(shape, data_type);
304*c217d954SCole Faust
305*c217d954SCole Faust ARM_COMPUTE_EXPECT(src.info()->is_resizable(), framework::LogLevel::ERRORS);
306*c217d954SCole Faust ARM_COMPUTE_EXPECT(dst.info()->is_resizable(), framework::LogLevel::ERRORS);
307*c217d954SCole Faust
308*c217d954SCole Faust // Create and configure function
309*c217d954SCole Faust NEScale scale;
310*c217d954SCole Faust scale.configure(&src, &dst, info);
311*c217d954SCole Faust
312*c217d954SCole Faust validate(src.info()->padding(), PaddingSize(0, 0, 0, 0));
313*c217d954SCole Faust validate(dst.info()->padding(), PaddingSize(0, 0, 0, 0));
314*c217d954SCole Faust }
315*c217d954SCole Faust
316*c217d954SCole Faust template <typename T>
317*c217d954SCole Faust using NEScaleFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T>;
318*c217d954SCole Faust template <typename T>
319*c217d954SCole Faust using NEScaleMixedDataLayoutFixture = ScaleValidationFixture<Tensor, Accessor, NEScale, T, true>;
320*c217d954SCole Faust template <typename T>
321*c217d954SCole Faust using NEScaleQuantizedFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T>;
322*c217d954SCole Faust template <typename T>
323*c217d954SCole Faust using NEScaleDifferentOutputQuantizedFixture = ScaleValidationDifferentOutputQuantizedFixture<Tensor, Accessor, NEScale, T>;
324*c217d954SCole Faust template <typename T>
325*c217d954SCole Faust using NEScaleQuantizedMixedDataLayoutFixture = ScaleValidationQuantizedFixture<Tensor, Accessor, NEScale, T, true>;
326*c217d954SCole Faust
327*c217d954SCole Faust TEST_SUITE(Float)
328*c217d954SCole Faust TEST_SUITE(FP32)
329*c217d954SCole Faust const auto f32_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<float>())), framework::dataset::make("DataType", DataType::F32));
330*c217d954SCole Faust const auto f32_shape_nhwc = combine(datasets::Small3DShapes(), framework::dataset::make("DataType", DataType::F32));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleFixture<float>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (f32_shape,ScaleSamplingPolicySet))331*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
332*c217d954SCole Faust {
333*c217d954SCole Faust //Create valid region
334*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
335*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
336*c217d954SCole Faust
337*c217d954SCole Faust // Validate output
338*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
339*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMixedDataLayout,NEScaleMixedDataLayoutFixture<float>,framework::DatasetMode::PRECOMMIT,ASSEMBLE_DATASET (f32_shape,ScaleSamplingPolicySet))340*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEScaleMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, ASSEMBLE_DATASET(f32_shape, ScaleSamplingPolicySet))
341*c217d954SCole Faust {
342*c217d954SCole Faust //Create valid region
343*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
344*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
345*c217d954SCole Faust
346*c217d954SCole Faust // Validate output
347*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
348*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleFixture<float>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (f32_shape,ScaleAlignCornersSamplingPolicySet))349*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f32_shape, ScaleAlignCornersSamplingPolicySet))
350*c217d954SCole Faust {
351*c217d954SCole Faust //Create valid region
352*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
353*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
354*c217d954SCole Faust
355*c217d954SCole Faust // Validate output
356*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
357*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumNHWC,NEScaleFixture<float>,framework::DatasetMode::ALL,ASSEMBLE_NHWC_DATASET (f32_shape_nhwc,ScaleSamplingPolicySet))358*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumNHWC, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_NHWC_DATASET(f32_shape_nhwc, ScaleSamplingPolicySet))
359*c217d954SCole Faust {
360*c217d954SCole Faust //Create valid region
361*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
362*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
363*c217d954SCole Faust
364*c217d954SCole Faust // Validate output
365*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
366*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumMixedDataLayoutNHWC,NEScaleMixedDataLayoutFixture<float>,framework::DatasetMode::PRECOMMIT,ASSEMBLE_NHWC_DATASET (f32_shape_nhwc,ScaleSamplingPolicySet))367*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumMixedDataLayoutNHWC, NEScaleMixedDataLayoutFixture<float>, framework::DatasetMode::PRECOMMIT, ASSEMBLE_NHWC_DATASET(f32_shape_nhwc, ScaleSamplingPolicySet))
368*c217d954SCole Faust {
369*c217d954SCole Faust //Create valid region
370*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
371*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
372*c217d954SCole Faust
373*c217d954SCole Faust // Validate output
374*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
375*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumAlignCornersNHWC,NEScaleFixture<float>,framework::DatasetMode::ALL,ASSEMBLE_NHWC_DATASET (f32_shape_nhwc,ScaleAlignCornersSamplingPolicySet))376*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumAlignCornersNHWC, NEScaleFixture<float>, framework::DatasetMode::ALL, ASSEMBLE_NHWC_DATASET(f32_shape_nhwc, ScaleAlignCornersSamplingPolicySet))
377*c217d954SCole Faust {
378*c217d954SCole Faust //Create valid region
379*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
380*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
381*c217d954SCole Faust
382*c217d954SCole Faust // Validate output
383*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f32, tolerance_num_f32);
384*c217d954SCole Faust }
385*c217d954SCole Faust TEST_SUITE_END() // FP32
386*c217d954SCole Faust #ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
387*c217d954SCole Faust TEST_SUITE(FP16)
388*c217d954SCole Faust const auto f16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<half>())), framework::dataset::make("DataType", DataType::F16));
389*c217d954SCole Faust const auto f16_shape_nhwc = combine(datasets::Small3DShapes(), framework::dataset::make("DataType", DataType::F16));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleFixture<half>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (f16_shape,ScaleSamplingPolicySet))390*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleSamplingPolicySet))
391*c217d954SCole Faust {
392*c217d954SCole Faust //Create valid region
393*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
394*c217d954SCole Faust const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
395*c217d954SCole Faust
396*c217d954SCole Faust // Validate output
397*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
398*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleFixture<half>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (f16_shape,ScaleAlignCornersSamplingPolicySet))399*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(f16_shape, ScaleAlignCornersSamplingPolicySet))
400*c217d954SCole Faust {
401*c217d954SCole Faust //Create valid region
402*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
403*c217d954SCole Faust const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
404*c217d954SCole Faust
405*c217d954SCole Faust // Validate output
406*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
407*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumNHWC,NEScaleFixture<half>,framework::DatasetMode::ALL,ASSEMBLE_NHWC_DATASET (f16_shape_nhwc,ScaleSamplingPolicySet))408*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumNHWC, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_NHWC_DATASET(f16_shape_nhwc, ScaleSamplingPolicySet))
409*c217d954SCole Faust {
410*c217d954SCole Faust //Create valid region
411*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
412*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
413*c217d954SCole Faust
414*c217d954SCole Faust // Validate output
415*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
416*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumMixedDataLayoutNHWC,NEScaleMixedDataLayoutFixture<half>,framework::DatasetMode::PRECOMMIT,ASSEMBLE_NHWC_DATASET (f16_shape_nhwc,ScaleSamplingPolicySet))417*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumMixedDataLayoutNHWC, NEScaleMixedDataLayoutFixture<half>, framework::DatasetMode::PRECOMMIT, ASSEMBLE_NHWC_DATASET(f16_shape_nhwc, ScaleSamplingPolicySet))
418*c217d954SCole Faust {
419*c217d954SCole Faust //Create valid region
420*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
421*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
422*c217d954SCole Faust
423*c217d954SCole Faust // Validate output
424*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
425*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMediumAlignCornersNHWC,NEScaleFixture<half>,framework::DatasetMode::ALL,ASSEMBLE_NHWC_DATASET (f16_shape_nhwc,ScaleAlignCornersSamplingPolicySet))426*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMediumAlignCornersNHWC, NEScaleFixture<half>, framework::DatasetMode::ALL, ASSEMBLE_NHWC_DATASET(f16_shape_nhwc, ScaleAlignCornersSamplingPolicySet))
427*c217d954SCole Faust {
428*c217d954SCole Faust //Create valid region
429*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
430*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
431*c217d954SCole Faust
432*c217d954SCole Faust // Validate output
433*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_f16, 0.0f, abs_tolerance_f16);
434*c217d954SCole Faust }
435*c217d954SCole Faust TEST_SUITE_END() // FP16
436*c217d954SCole Faust #endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
437*c217d954SCole Faust TEST_SUITE_END() // Float
438*c217d954SCole Faust
439*c217d954SCole Faust TEST_SUITE(Integer)
440*c217d954SCole Faust TEST_SUITE(U8)
441*c217d954SCole Faust const auto u8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::U8));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (u8_shape,ScaleSamplingPolicySet))442*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleSamplingPolicySet))
443*c217d954SCole Faust {
444*c217d954SCole Faust //Create valid region
445*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
446*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
447*c217d954SCole Faust
448*c217d954SCole Faust // Validate output
449*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
450*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (u8_shape,ScaleAlignCornersSamplingPolicySet))451*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(u8_shape, ScaleAlignCornersSamplingPolicySet))
452*c217d954SCole Faust {
453*c217d954SCole Faust //Create valid region
454*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
455*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
456*c217d954SCole Faust
457*c217d954SCole Faust // Validate output
458*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
459*c217d954SCole Faust }
460*c217d954SCole Faust TEST_SUITE_END() // U8
461*c217d954SCole Faust TEST_SUITE(S8)
462*c217d954SCole Faust const auto s8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::S8));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleFixture<int8_t>,framework::DatasetMode::ALL,ASSEMBLE_S8_DATASET (s8_shape,ScaleSamplingPolicySet))463*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_S8_DATASET(s8_shape, ScaleSamplingPolicySet))
464*c217d954SCole Faust {
465*c217d954SCole Faust //Create valid region
466*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
467*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
468*c217d954SCole Faust
469*c217d954SCole Faust // Validate output
470*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_s8);
471*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleFixture<int8_t>,framework::DatasetMode::ALL,ASSEMBLE_S8_DATASET (s8_shape,ScaleAlignCornersSamplingPolicySet))472*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_S8_DATASET(s8_shape, ScaleAlignCornersSamplingPolicySet))
473*c217d954SCole Faust {
474*c217d954SCole Faust //Create valid region
475*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
476*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
477*c217d954SCole Faust
478*c217d954SCole Faust // Validate output
479*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_s8);
480*c217d954SCole Faust }
481*c217d954SCole Faust TEST_SUITE_END() // S8
482*c217d954SCole Faust TEST_SUITE(S16)
483*c217d954SCole Faust const auto s16_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int16_t>())), framework::dataset::make("DataType", DataType::S16));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleFixture<int16_t>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (s16_shape,ScaleSamplingPolicySet))484*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleSamplingPolicySet))
485*c217d954SCole Faust {
486*c217d954SCole Faust //Create valid region
487*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
488*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
489*c217d954SCole Faust
490*c217d954SCole Faust // Validate output
491*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
492*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleFixture<int16_t>,framework::DatasetMode::ALL,ASSEMBLE_DATASET (s16_shape,ScaleAlignCornersSamplingPolicySet))493*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleFixture<int16_t>, framework::DatasetMode::ALL, ASSEMBLE_DATASET(s16_shape, ScaleAlignCornersSamplingPolicySet))
494*c217d954SCole Faust {
495*c217d954SCole Faust //Create valid region
496*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
497*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
498*c217d954SCole Faust
499*c217d954SCole Faust // Validate output
500*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_s16, tolerance_num_s16);
501*c217d954SCole Faust }
502*c217d954SCole Faust TEST_SUITE_END() // S16
503*c217d954SCole Faust TEST_SUITE_END() // Integer
504*c217d954SCole Faust
505*c217d954SCole Faust TEST_SUITE(Quantized)
506*c217d954SCole Faust TEST_SUITE(QASYMM8)
507*c217d954SCole Faust const auto qasymm8_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<uint8_t>())), framework::dataset::make("DataType", DataType::QASYMM8));
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleQuantizedFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_QUANTIZED_DATASET (qasymm8_shape,ScaleSamplingPolicySet,QuantizationInfoSet))508*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
509*c217d954SCole Faust {
510*c217d954SCole Faust //Create valid region
511*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
512*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
513*c217d954SCole Faust
514*c217d954SCole Faust // Validate output
515*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
516*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallDifferentOutputQuantization,NEScaleDifferentOutputQuantizedFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_DIFFERENTLY_QUANTIZED_DATASET (qasymm8_shape,ScaleSamplingPolicySet,InputQuantizationInfoSet,OutputQuantizationInfoSet))517*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallDifferentOutputQuantization, NEScaleDifferentOutputQuantizedFixture<uint8_t>, framework::DatasetMode::ALL,
518*c217d954SCole Faust ASSEMBLE_DIFFERENTLY_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet, InputQuantizationInfoSet, OutputQuantizationInfoSet))
519*c217d954SCole Faust {
520*c217d954SCole Faust //Create valid region
521*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
522*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
523*c217d954SCole Faust
524*c217d954SCole Faust // Validate output
525*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
526*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunMixedDataLayout,NEScaleQuantizedMixedDataLayoutFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_QUANTIZED_DATASET (qasymm8_shape,ScaleSamplingPolicySet,QuantizationInfoSet))527*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunMixedDataLayout, NEScaleQuantizedMixedDataLayoutFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleSamplingPolicySet,
528*c217d954SCole Faust QuantizationInfoSet))
529*c217d954SCole Faust {
530*c217d954SCole Faust //Create valid region
531*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
532*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
533*c217d954SCole Faust
534*c217d954SCole Faust // Validate output
535*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
536*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleQuantizedFixture<uint8_t>,framework::DatasetMode::ALL,ASSEMBLE_QUANTIZED_DATASET (qasymm8_shape,ScaleAlignCornersSamplingPolicySet,QuantizationInfoSet))537*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<uint8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_shape, ScaleAlignCornersSamplingPolicySet,
538*c217d954SCole Faust QuantizationInfoSet))
539*c217d954SCole Faust {
540*c217d954SCole Faust //Create valid region
541*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
542*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
543*c217d954SCole Faust
544*c217d954SCole Faust // Validate output
545*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_u8);
546*c217d954SCole Faust }
547*c217d954SCole Faust TEST_SUITE_END() // QASYMM8
548*c217d954SCole Faust TEST_SUITE(QASYMM8_SIGNED)
549*c217d954SCole Faust const auto qasymm8_signed_shape = combine((SCALE_SHAPE_DATASET(num_elements_per_vector<int8_t>())), framework::dataset::make("DataType", DataType::QASYMM8_SIGNED));
550*c217d954SCole Faust constexpr AbsoluteTolerance<int8_t> tolerance_qasymm8_signed{ 1 };
FIXTURE_DATA_TEST_CASE(RunSmall,NEScaleQuantizedFixture<int8_t>,framework::DatasetMode::ALL,ASSEMBLE_QUANTIZED_DATASET (qasymm8_signed_shape,ScaleSamplingPolicySet,QuantizationInfoSet))551*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmall, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, QuantizationInfoSet))
552*c217d954SCole Faust {
553*c217d954SCole Faust //Create valid region
554*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
555*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
556*c217d954SCole Faust
557*c217d954SCole Faust // Validate output
558*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed);
559*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallDifferentOutputQuantization,NEScaleDifferentOutputQuantizedFixture<int8_t>,framework::DatasetMode::ALL,ASSEMBLE_DIFFERENTLY_QUANTIZED_DATASET (qasymm8_signed_shape,ScaleSamplingPolicySet,InputQuantizationInfoSet,OutputQuantizationInfoSet))560*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallDifferentOutputQuantization, NEScaleDifferentOutputQuantizedFixture<int8_t>, framework::DatasetMode::ALL,
561*c217d954SCole Faust ASSEMBLE_DIFFERENTLY_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleSamplingPolicySet, InputQuantizationInfoSet, OutputQuantizationInfoSet))
562*c217d954SCole Faust {
563*c217d954SCole Faust //Create valid region
564*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
565*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
566*c217d954SCole Faust
567*c217d954SCole Faust // Validate output
568*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed);
569*c217d954SCole Faust }
FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners,NEScaleQuantizedFixture<int8_t>,framework::DatasetMode::ALL,ASSEMBLE_QUANTIZED_DATASET (qasymm8_signed_shape,ScaleAlignCornersSamplingPolicySet,QuantizationInfoSet))570*c217d954SCole Faust FIXTURE_DATA_TEST_CASE(RunSmallAlignCorners, NEScaleQuantizedFixture<int8_t>, framework::DatasetMode::ALL, ASSEMBLE_QUANTIZED_DATASET(qasymm8_signed_shape, ScaleAlignCornersSamplingPolicySet,
571*c217d954SCole Faust QuantizationInfoSet))
572*c217d954SCole Faust {
573*c217d954SCole Faust //Create valid region
574*c217d954SCole Faust TensorInfo src_info(_shape, 1, _data_type);
575*c217d954SCole Faust ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
576*c217d954SCole Faust
577*c217d954SCole Faust // Validate output
578*c217d954SCole Faust validate(Accessor(_target), _reference, valid_region, tolerance_qasymm8_signed);
579*c217d954SCole Faust }
580*c217d954SCole Faust TEST_SUITE_END() // QASYMM8_SIGNED
581*c217d954SCole Faust TEST_SUITE_END() // Quantized
582*c217d954SCole Faust
583*c217d954SCole Faust TEST_SUITE_END() // Scale
584*c217d954SCole Faust TEST_SUITE_END() // Neon
585*c217d954SCole Faust } // namespace validation
586*c217d954SCole Faust } // namespace test
587*c217d954SCole Faust } // namespace arm_compute
588