blob: 90d3ae98d8b890d38186530d235fc0a8344a1c18 [file] [log] [blame]
Georgios Pinitasdea2d2d2018-12-19 16:23:17 +00001/*
2 * Copyright (c) 2018-2019 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 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/NEON/functions/NEPadLayer.h"
26#include "arm_compute/runtime/Tensor.h"
27#include "arm_compute/runtime/TensorAllocator.h"
28#include "tests/NEON/Accessor.h"
29#include "tests/PaddingCalculator.h"
30#include "tests/datasets/ShapeDatasets.h"
31#include "tests/framework/Asserts.h"
32#include "tests/framework/Macros.h"
33#include "tests/framework/datasets/Datasets.h"
34#include "tests/validation/Validation.h"
35#include "tests/validation/fixtures/PadLayerFixture.h"
36
37namespace arm_compute
38{
39namespace test
40{
41namespace validation
42{
43namespace
44{
45const auto PaddingSizesDataset = framework::dataset::make("PaddingSize", { PaddingList{ { 0, 0 } },
46 PaddingList{ { 1, 1 } },
47 PaddingList{ { 1, 1 }, { 2, 2 } },
48 PaddingList{ { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 } },
49 PaddingList{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 2 } },
50 PaddingList{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 1, 1 } }
51});
52} // namespace
53
54TEST_SUITE(NEON)
55TEST_SUITE(PadLayer)
56
57// *INDENT-OFF*
58// clang-format off
59
60DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
61 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/output
62 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes
63 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
64 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
65 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
66 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32)
67 }),
68 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16),
69 TensorInfo(TensorShape(28U, 11U, 2U), 1, DataType::F32),
70 TensorInfo(TensorShape(29U, 17U, 2U), 1, DataType::F32),
71 TensorInfo(TensorShape(29U, 15U, 4U, 3U), 1, DataType::F32),
72 TensorInfo(TensorShape(27U, 14U, 3U, 4U), 1, DataType::F32),
73 TensorInfo(TensorShape(32U, 13U, 2U, 3U), 1, DataType::F32)
74 })),
75 framework::dataset::make("PaddingSize", { PaddingList{{0, 0}},
76 PaddingList{{1, 1}},
77 PaddingList{{1, 1}, {2, 2}},
78 PaddingList{{1,1}, {1,1}, {1,1}, {1,1}},
79 PaddingList{{0,0}, {1,0}, {0,1}, {1,2}},
80 PaddingList{{0,0}, {0,0}, {0,0}, {1,1}}
81 })),
82 framework::dataset::make("Expected", { false, false, true, true, true, true })),
83 input_info, output_info, padding, expected)
84{
85 Status s = NEPadLayer::validate(&input_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), padding);
86 ARM_COMPUTE_EXPECT(bool(s) == expected, framework::LogLevel::ERRORS);
87}
88
89// clang-format on
90// *INDENT-ON*
91
92template <typename T>
93using NEPaddingFixture = PaddingFixture<Tensor, Accessor, NEPadLayer, T>;
94
95TEST_SUITE(Float)
96
97TEST_SUITE(FP32)
98FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<float>, framework::DatasetMode::ALL,
99 combine(
100 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F32 })),
101 PaddingSizesDataset))
102{
103 // Validate output
104 validate(Accessor(_target), _reference);
105}
106FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<float>, framework::DatasetMode::NIGHTLY,
107 combine(
108 combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::F32 })),
109 PaddingSizesDataset))
110{
111 // Validate output
112 validate(Accessor(_target), _reference);
113}
114TEST_SUITE_END() // FP32
115
116#ifdef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
117TEST_SUITE(FP16)
118FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<half>, framework::DatasetMode::ALL,
119 combine(
120 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F16 })),
121 PaddingSizesDataset))
122{
123 // Validate output
124 validate(Accessor(_target), _reference);
125}
126FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<half>, framework::DatasetMode::NIGHTLY,
127 combine(
128 combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::F16 })),
129 PaddingSizesDataset))
130{
131 // Validate output
132 validate(Accessor(_target), _reference);
133}
134TEST_SUITE_END() // FP16
135#endif /* __ARM_FEATURE_FP16_VECTOR_ARITHMETIC */
136TEST_SUITE_END() // Float
137
138TEST_SUITE(Integer)
139TEST_SUITE(S8)
140FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<int8_t>, framework::DatasetMode::ALL,
141 combine(
142 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::S8 })),
143 PaddingSizesDataset))
144{
145 // Validate output
146 validate(Accessor(_target), _reference);
147}
148FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<int8_t>, framework::DatasetMode::NIGHTLY,
149 combine(
150 combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::S8 })),
151 PaddingSizesDataset))
152{
153 // Validate output
154 validate(Accessor(_target), _reference);
155}
156TEST_SUITE_END() // S8
157TEST_SUITE_END() // Integer
158
159TEST_SUITE(Quantized)
160TEST_SUITE(QASYMM8)
161FIXTURE_DATA_TEST_CASE(RunSmall, NEPaddingFixture<uint8_t>, framework::DatasetMode::ALL,
162 combine(
163 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })),
164 PaddingSizesDataset))
165{
166 // Validate output
167 validate(Accessor(_target), _reference);
168}
169FIXTURE_DATA_TEST_CASE(RunLarge, NEPaddingFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
170 combine(
171 combine(datasets::LargeShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })),
172 PaddingSizesDataset))
173{
174 // Validate output
175 validate(Accessor(_target), _reference);
176}
177TEST_SUITE_END() // QASYMM8
178TEST_SUITE_END() // Quantized
179
180TEST_SUITE_END() // PadLayer
181TEST_SUITE_END() // NEON
182} // namespace validation
183} // namespace test
184} // namespace arm_compute