blob: 4bbd7b8e1497998283314a439be1beff134f3dbd [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 } },
46 PaddingList{ { 1, 1 }, { 1, 1 }, { 1, 1 }, { 1, 1 } },
47 PaddingList{ { 0, 0 }, { 1, 0 }, { 0, 1 }, { 1, 2 } },
48 PaddingList{ { 0, 0 }, { 0, 0 }, { 0, 0 }, { 1, 1 } }
49});
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
58DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
59 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching data type input/output
60 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32), // Mismatching shapes
61 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
62 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
63 TensorInfo(TensorShape(27U, 13U, 2U), 1, DataType::F32),
64 TensorInfo(TensorShape(32U, 13U, 2U), 1, DataType::F32)
65 }),
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),
70 TensorInfo(TensorShape(27U, 14U, 3U, 4U), 1, DataType::F32),
71 TensorInfo(TensorShape(32U, 13U, 2U, 3U), 1, DataType::F32)
72 })),
73 framework::dataset::make("PaddingSize", { PaddingList{{0, 0}},
74 PaddingList{{1, 1}},
75 PaddingList{{1, 1}, {2, 2}},
76 PaddingList{{1,1}, {1,1}, {1,1}, {1,1}},
77 PaddingList{{0,0}, {1,0}, {0,1}, {1,2}},
78 PaddingList{{0,0}, {0,0}, {0,0}, {1,1}}
79 })),
80 framework::dataset::make("Expected", { false, false, true, true, true, true })),
81 input_info, output_info, padding, expected)
82{
83 ARM_COMPUTE_EXPECT(bool(CLPadLayer::validate(&input_info.clone()->set_is_resizable(true), &output_info.clone()->set_is_resizable(true), padding)) == expected, framework::LogLevel::ERRORS);
84}
85
86// clang-format on
87// *INDENT-ON*
88
89template <typename T>
90using CLPaddingFixture = PaddingFixture<CLTensor, CLAccessor, CLPadLayer, T>;
91
92TEST_SUITE(Float)
93
94TEST_SUITE(FP32)
Giuseppe Rossinid7647d42018-07-17 18:13:13 +010095FIXTURE_DATA_TEST_CASE(RunPadding, CLPaddingFixture<float>, framework::DatasetMode::ALL,
96 combine(
97 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F32 })),
98 PaddingSizesDataset))
99{
100 // Validate output
101 validate(CLAccessor(_target), _reference);
102}
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100103TEST_SUITE_END() // FP32
104
105TEST_SUITE(FP16)
106FIXTURE_DATA_TEST_CASE(RunPadding, CLPaddingFixture<half>, framework::DatasetMode::ALL,
107 combine(
108 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::F16 })),
109 PaddingSizesDataset))
110{
111 // Validate output
112 validate(CLAccessor(_target), _reference);
113}
114TEST_SUITE_END() // FP16
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100115TEST_SUITE_END() // Float
116
giuros0188b83622018-09-19 18:38:48 +0100117TEST_SUITE(Integer)
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100118TEST_SUITE(S8)
119FIXTURE_DATA_TEST_CASE(RunPadding, CLPaddingFixture<int8_t>, framework::DatasetMode::ALL,
120 combine(
121 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::S8 })),
122 PaddingSizesDataset))
123{
124 // Validate output
125 validate(CLAccessor(_target), _reference);
126}
127TEST_SUITE_END() // S8
giuros0188b83622018-09-19 18:38:48 +0100128TEST_SUITE_END() // Integer
129
130TEST_SUITE(Quantized)
131TEST_SUITE(QASYMM8)
132FIXTURE_DATA_TEST_CASE(RunPadding, CLPaddingFixture<uint8_t>, framework::DatasetMode::ALL,
133 combine(
134 combine(datasets::SmallShapes(), framework::dataset::make("DataType", { DataType::QASYMM8 })),
135 PaddingSizesDataset))
136{
137 // Validate output
138 validate(CLAccessor(_target), _reference);
139}
140TEST_SUITE_END() // QASYMM8
141TEST_SUITE_END() // Quantized
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100142
Georgios Pinitasdea2d2d2018-12-19 16:23:17 +0000143TEST_SUITE_END() // PadLayer
Giuseppe Rossinid7647d42018-07-17 18:13:13 +0100144TEST_SUITE_END() // CL
145} // namespace validation
146} // namespace test
147} // namespace arm_compute