blob: 0eb021fe716541a85e3b557ef38d7c143354d1c5 [file] [log] [blame]
morgolock37722d92020-04-09 14:17:48 +01001/*
Matthew Bentham314d3e22023-06-23 10:53:52 +00002 * Copyright (c) 2020-2023 Arm Limited.
morgolock37722d92020-04-09 14:17:48 +01003 *
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/Types.h"
Matthew Bentham314d3e22023-06-23 10:53:52 +000025#include "arm_compute/core/utils/StringUtils.h"
morgolock37722d92020-04-09 14:17:48 +010026#include "arm_compute/runtime/NEON/functions/NEMaxUnpoolingLayer.h"
27#include "arm_compute/runtime/NEON/functions/NEPoolingLayer.h"
28#include "arm_compute/runtime/Tensor.h"
29#include "arm_compute/runtime/TensorAllocator.h"
Dana Zlotnik149203b2022-01-26 12:38:03 +020030#include "src/cpu/kernels/CpuMaxUnpoolingLayerKernel.h"
morgolock37722d92020-04-09 14:17:48 +010031#include "tests/NEON/Accessor.h"
32#include "tests/datasets/ShapeDatasets.h"
33#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
37#include "tests/validation/fixtures/MaxUnpoolingLayerFixture.h"
morgolock37722d92020-04-09 14:17:48 +010038namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44TEST_SUITE(NEON)
45TEST_SUITE(PoolingLayer)
46
47template <typename T>
48using NEMaxUnpoolingLayerFixture = MaxUnpoolingLayerValidationFixture<Tensor, Accessor, NEPoolingLayer, NEMaxUnpoolingLayer, T>;
49
50const auto PoolingLayerIndicesDatasetFPSmall = combine(combine(framework::dataset::make("PoolType", { PoolingType::MAX }), framework::dataset::make("PoolingSize", { Size2D(2, 2) })),
51 framework::dataset::make("PadStride", { PadStrideInfo(2, 2, 0, 0), PadStrideInfo(2, 1, 0, 0) }));
52
53TEST_SUITE(Float)
54TEST_SUITE(FP32)
Gian Marco Iodice9dc558f2020-11-10 14:29:13 +000055FIXTURE_DATA_TEST_CASE(MaxUnpooling, NEMaxUnpoolingLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallNoneUnitShapes(), combine(PoolingLayerIndicesDatasetFPSmall,
morgolock37722d92020-04-09 14:17:48 +010056 framework::dataset::make("DataType", DataType::F32))),
57 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })
58
59 ))
60{
61 // Validate output
62 validate(Accessor(_target), _reference);
63}
64TEST_SUITE_END() // FP32
65#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
66TEST_SUITE(FP16)
Gian Marco Iodice9dc558f2020-11-10 14:29:13 +000067FIXTURE_DATA_TEST_CASE(MaxUnpooling, NEMaxUnpoolingLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallNoneUnitShapes(), combine(PoolingLayerIndicesDatasetFPSmall,
Sheri Zhange0681992020-07-14 15:29:28 +010068 framework::dataset::make("DataType", DataType::F16))),
69 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })
morgolock37722d92020-04-09 14:17:48 +010070
Sheri Zhange0681992020-07-14 15:29:28 +010071 ))
morgolock37722d92020-04-09 14:17:48 +010072{
73 // Validate output
74 validate(Accessor(_target), _reference);
75}
76TEST_SUITE_END() // FP16
77#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
Dana Zlotnik149203b2022-01-26 12:38:03 +020078
morgolock37722d92020-04-09 14:17:48 +010079TEST_SUITE_END() // Float
Dana Zlotnik149203b2022-01-26 12:38:03 +020080
81TEST_SUITE(KernelSelection)
82
83DATA_TEST_CASE(KernelSelection, framework::DatasetMode::ALL,
84 combine(framework::dataset::make("CpuExt", std::string("NEON")),
85 framework::dataset::make("DataType", { DataType::F32,
86 DataType::F16,
87 DataType::QASYMM8,
88 DataType::QASYMM8_SIGNED
89 })),
90 cpu_ext, data_type)
91{
92 using namespace cpu::kernels;
93
94 cpuinfo::CpuIsaInfo cpu_isa{};
95 cpu_isa.neon = (cpu_ext == "NEON");
96 cpu_isa.sve = (cpu_ext == "SVE");
97 cpu_isa.fp16 = (data_type == DataType::F16);
98
99 const auto *selected_impl = CpuMaxUnpoolingLayerKernel::get_implementation(DataTypeISASelectorData{ data_type, cpu_isa }, cpu::KernelSelectionType::Preferred);
100
101 ARM_COMPUTE_ERROR_ON_NULLPTR(selected_impl);
102
103 std::string expected = lower_string(cpu_ext) + "_" + cpu_impl_dt(data_type) + "_maxunpooling";
104 std::string actual = selected_impl->name;
105
106 ARM_COMPUTE_EXPECT_EQUAL(expected, actual, framework::LogLevel::ERRORS);
107}
108TEST_SUITE_END() // KernelSelection
morgolock37722d92020-04-09 14:17:48 +0100109TEST_SUITE_END() // PoolingLayer
Sheri Zhangac6499a2021-02-10 15:32:38 +0000110TEST_SUITE_END() // Neon
morgolock37722d92020-04-09 14:17:48 +0100111} // namespace validation
112} // namespace test
113} // namespace arm_compute