blob: a8859d6f00535469b1458dbc10eabd393acaecd2 [file] [log] [blame]
Frank Lei57a150a2017-12-19 10:14:57 +08001/*
Michele Di Giorgiod9eaf612020-07-08 11:12:57 +01002 * Copyright (c) 2017-2020 Arm Limited.
Frank Lei57a150a2017-12-19 10:14:57 +08003 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#include "arm_compute/core/Helpers.h"
25#include "arm_compute/core/Types.h"
26#include "arm_compute/runtime/GLES_COMPUTE/functions/GCScale.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
29#include "tests/GLES_COMPUTE/GCAccessor.h"
30#include "tests/PaddingCalculator.h"
31#include "tests/datasets/BorderModeDataset.h"
32#include "tests/datasets/SamplingPolicyDataset.h"
33#include "tests/datasets/ShapeDatasets.h"
34#include "tests/framework/Asserts.h"
35#include "tests/framework/Macros.h"
36#include "tests/framework/datasets/Datasets.h"
37#include "tests/validation/Helpers.h"
38#include "tests/validation/Validation.h"
39#include "tests/validation/fixtures/ScaleFixture.h"
40
41namespace arm_compute
42{
43namespace test
44{
45namespace validation
46{
47namespace
48{
49/** CNN data types */
50const auto ScaleDataTypes = framework::dataset::make("DataType",
51{
52 DataType::F16,
53});
54
Sang-Hoon Park94d50512020-07-02 10:49:39 +010055/** Aligned corners, this functionality is supported only by NEON and OpenCL backends */
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000056const auto AlignCorners = framework::dataset::make("AlignCorners",
57{
58 false,
59});
60
Frank Lei57a150a2017-12-19 10:14:57 +080061/** Tolerance */
62RelativeTolerance<half> tolerance_f16(half(0.1));
63} // namespace
64
65TEST_SUITE(GC)
66TEST_SUITE(Scale)
67
Frank Lei57a150a2017-12-19 10:14:57 +080068template <typename T>
69using GCScaleFixture = ScaleValidationFixture<GCTensor, GCAccessor, GCScale, T>;
70
71TEST_SUITE(Float)
72TEST_SUITE(FP16)
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000073FIXTURE_DATA_TEST_CASE(RunSmall, GCScaleFixture<half>, framework::DatasetMode::ALL, combine(combine(combine(combine(combine(combine(datasets::SmallShapes(), framework::dataset::make("DataType",
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010074 DataType::F16)),
75 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000076 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })),
77 datasets::BorderModes()),
78 datasets::SamplingPolicies()),
79 AlignCorners))
Frank Lei57a150a2017-12-19 10:14:57 +080080{
81 //Create valid region
82 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +000083 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Frank Lei57a150a2017-12-19 10:14:57 +080084
85 // Validate output
86 validate(GCAccessor(_target), _reference, valid_region, tolerance_f16);
87}
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000088FIXTURE_DATA_TEST_CASE(RunLarge, GCScaleFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(combine(combine(combine(combine(datasets::LargeShapes(), framework::dataset::make("DataType",
Frank Lei57a150a2017-12-19 10:14:57 +080089 DataType::F16)),
Georgios Pinitas393fa4c2018-05-08 15:54:53 +010090 framework::dataset::make("DataLayout", { DataLayout::NCHW })),
Sang-Hoon Parkbb123bd2020-01-03 10:57:30 +000091 framework::dataset::make("InterpolationPolicy", { InterpolationPolicy::NEAREST_NEIGHBOR })),
92 datasets::BorderModes()),
93 datasets::SamplingPolicies()),
94 AlignCorners))
Frank Lei57a150a2017-12-19 10:14:57 +080095{
96 //Create valid region
97 TensorInfo src_info(_shape, 1, _data_type);
Diego Lopez Recas00854292018-02-22 13:08:01 +000098 const ValidRegion valid_region = calculate_valid_region_scale(src_info, _reference.shape(), _policy, _sampling_policy, (_border_mode == BorderMode::UNDEFINED));
Frank Lei57a150a2017-12-19 10:14:57 +080099
100 // Validate output
101 validate(GCAccessor(_target), _reference, valid_region, tolerance_f16);
102}
103TEST_SUITE_END()
104TEST_SUITE_END()
105
106TEST_SUITE_END()
107TEST_SUITE_END()
108} // namespace validation
109} // namespace test
110} // namespace arm_compute