blob: 2ad29fc0e5c081aa8421482707345e3724008589 [file] [log] [blame]
Giuseppe Rossinid7647d42018-07-17 18:13:13 +01001/*
Georgios Pinitasdea2d2d2018-12-19 16:23:17 +00002 * Copyright (c) 2018-2019 ARM Limited.
Giuseppe Rossinid7647d42018-07-17 18:13:13 +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/runtime/CL/CLScheduler.h"
25#include "arm_compute/runtime/CL/functions/CLPadLayer.h"
26#include "tests/CL/CLAccessor.h"
27#include "tests/Globals.h"
28#include "tests/datasets/ShapeDatasets.h"
29#include "tests/framework/Macros.h"
30#include "tests/framework/datasets/Datasets.h"
31#include "tests/validation/Validation.h"
32#include "tests/validation/fixtures/PadLayerFixture.h"
33#include "utils/TypePrinter.h"
34
35namespace arm_compute
36{
37namespace test
38{
39namespace validation
40{
41namespace
42{
43const auto PaddingSizesDataset = framework::dataset::make("PaddingSize", { PaddingList{ { 0, 0 } },
44 PaddingList{ { 1, 1 } },
45 PaddingList{ { 1, 1 }, { 2, 2 } },
Manuel Bottini60f39112019-03-18 15:25:15 +000046 PaddingList{ { 1, 1 }, { 1, 1 }, { 1, 1 } },
47 PaddingList{ { 0, 0 }, { 1, 0 }, { 0, 1 } },
48 PaddingList{ { 0, 0 }, { 0, 0 }, { 0, 0 } }
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010049});
50} // namespace
51
52TEST_SUITE(CL)
Georgios Pinitasdea2d2d2018-12-19 16:23:17 +000053TEST_SUITE(PadLayer)
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010054
55// *INDENT-OFF*
56// clang-format off
57
Manuel Bottini60f39112019-03-18 15:25:15 +000058DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(zip(
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010059 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/output
Manuel Bottini60f39112019-03-18 15:25:15 +000060 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes with padding
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010061 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
Manuel Bottini60f39112019-03-18 15:25:15 +000062 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes dimension
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010063 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
Manuel Bottini60f39112019-03-18 15:25:15 +000064 TensorInfo(TensorShape(32U, 13U), 1, DataType::F32) // Invalid padding list
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010065 }),
66 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F16),
67 TensorInfo(TensorShape(28U, 11U, 2U), 1, DataType::F32),
68 TensorInfo(TensorShape(29U, 17U, 2U), 1, DataType::F32),
69 TensorInfo(TensorShape(29U, 15U, 4U, 3U), 1, DataType::F32),
Manuel Bottini60f39112019-03-18 15:25:15 +000070 TensorInfo(TensorShape(29U, 17U, 2U), 1, DataType::F32),
71 TensorInfo(TensorShape(32U, 13U), 1, DataType::F32)
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010072 })),
73 framework::dataset::make("PaddingSize", { PaddingList{{0, 0}},
Manuel Bottini60f39112019-03-18 15:25:15 +000074 PaddingList{{1, 1}},
75 PaddingList{{1, 1}, {2, 2}},
76 PaddingList{{1,1}, {1,1}, {1,1}},
77 PaddingList{{1, 1}, {2, 2}},
78 PaddingList{{0,0}, {0,0}, {1,1}}
79 })),
80 framework::dataset::make("PaddingMode", { PaddingMode::CONSTANT,
81 PaddingMode::CONSTANT,
82 PaddingMode::CONSTANT,
83 PaddingMode::SYMMETRIC,
84 PaddingMode::REFLECT,
85 PaddingMode::REFLECT
86})),
87 framework::dataset::make("Expected", { false,
88 false,
89 true,
90 false,
91 true,
92 false })),
93 input_info, output_info, padding, mode, expected)
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010094{
Manuel Bottini60f39112019-03-18 15:25:15 +000095 ARM_COMPUTE_EXPECT(bool(CLPadLayer::validate(&input_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), padding, PixelValue(), mode)) == expected, framework::LogLevel::ERRORS);
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010096}
97
98// clang-format on
99// *INDENT-ON*
100
101template <typename T>
102using CLPaddingFixture = PaddingFixture<CLTensor, CLAccessor, CLPadLayer, T>;
103
104TEST_SUITE(Float)
105
106TEST_SUITE(FP32)
Manuel Bottini60f39112019-03-18 15:25:15 +0000107FIXTURE_DATA_TEST_CASE(RunSmall, CLPaddingFixture<float>, framework::DatasetMode::ALL,
108 combine(combine(combine(datasets::Small3DShapes(), framework::dataset::make("DataType", { DataType::F32 })), PaddingSizesDataset),
109 framework::dataset::make("PaddingMode", { PaddingMode::CONSTANT, PaddingMode::REFLECT, PaddingMode::SYMMETRIC })))
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100110{
111 // Validate output
112 validate(CLAccessor(_target), _reference);
113}
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100114TEST_SUITE_END() // FP32
115
116TEST_SUITE(FP16)
Manuel Bottini60f39112019-03-18 15:25:15 +0000117FIXTURE_DATA_TEST_CASE(RunLarge, CLPaddingFixture<half>, framework::DatasetMode::NIGHTLY,
118 combine(combine(combine(datasets::Large3DShapes(), framework::dataset::make("DataType", { DataType::F16 })), PaddingSizesDataset),
119 framework::dataset::make("PaddingMode", { PaddingMode::CONSTANT, PaddingMode::REFLECT })))
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100120{
121 // Validate output
122 validate(CLAccessor(_target), _reference);
123}
124TEST_SUITE_END() // FP16
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100125TEST_SUITE_END() // Float
126
Manuel Bottini60f39112019-03-18 15:25:15 +0000127TEST_SUITE(Quantized)
128TEST_SUITE(QASYMM8)
129FIXTURE_DATA_TEST_CASE(RunSmall, CLPaddingFixture<uint8_t>, framework::DatasetMode::PRECOMMIT,
130 combine(combine(combine(datasets::Small3DShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })), PaddingSizesDataset),
131 framework::dataset::make("PaddingMode", { PaddingMode::CONSTANT, PaddingMode::REFLECT })))
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100132{
133 // Validate output
134 validate(CLAccessor(_target), _reference);
135}
Manuel Bottini60f39112019-03-18 15:25:15 +0000136FIXTURE_DATA_TEST_CASE(RunLarge, CLPaddingFixture<uint8_t>, framework::DatasetMode::NIGHTLY,
137 combine(combine(combine(datasets::Large3DShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })), PaddingSizesDataset),
138 framework::dataset::make("PaddingMode", { PaddingMode::CONSTANT, PaddingMode::REFLECT })))
giuros0188b83622018-09-19 18:38:48 +0100139{
140 // Validate output
141 validate(CLAccessor(_target), _reference);
142}
143TEST_SUITE_END() // QASYMM8
144TEST_SUITE_END() // Quantized
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100145
Georgios Pinitasdea2d2d2018-12-19 16:23:17 +0000146TEST_SUITE_END() // PadLayer
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100147TEST_SUITE_END() // CL
148} // namespace validation
149} // namespace test
150} // namespace arm_compute