blob: d09744ca21fbcbbd4a443ac1d6e575a7e75edb8c [file] [log] [blame]
Gian Marco Iodice477531c2018-08-21 17:53:38 +01001/*
Michalis Spyroud175ece2020-07-30 23:39:32 +01002 * Copyright (c) 2018-2020 Arm Limited.
Gian Marco Iodice477531c2018-08-21 17:53:38 +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"
25#include "arm_compute/runtime/CL/functions/CLReorgLayer.h"
26#include "tests/CL/CLAccessor.h"
27#include "tests/CL/Helper.h"
28#include "tests/PaddingCalculator.h"
29#include "tests/datasets/ReorgLayerDataset.h"
30#include "tests/framework/Asserts.h"
31#include "tests/framework/Macros.h"
32#include "tests/framework/datasets/Datasets.h"
33#include "tests/validation/Validation.h"
34#include "tests/validation/fixtures/ReorgLayerFixture.h"
35
36namespace arm_compute
37{
38namespace test
39{
40namespace validation
41{
42TEST_SUITE(CL)
43TEST_SUITE(ReorgLayer)
44
45// *INDENT-OFF*
46// clang-format off
47DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
48 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::S64), // Wrong output tensor
49 TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32),
50 TensorInfo(TensorShape(10U, 12U, 1U, 2U), 1, DataType::F32), // Wrong output tensor
51 TensorInfo(TensorShape(3U, 12U, 4U, 2U), 1, DataType::F32),
52 TensorInfo(TensorShape(3U, 12U, 4U, 2U), 1, DataType::F32), // Wrong data type
53 }),
54 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(3U, 4U, 10U, 2U), 1, DataType::S64),
55 TensorInfo(TensorShape(5U, 6U, 4U, 2U), 1, DataType::F32),
56 TensorInfo(TensorShape(5U, 6U, 2, 2U), 1, DataType::F32),
57 TensorInfo(TensorShape(1U, 4U, 36U, 2U), 1, DataType::F32),
58 TensorInfo(TensorShape(1U, 4U, 36U, 2U), 1, DataType::F16),
59 })),
60 framework::dataset::make("Stride", { 2, 2, 4, 3 })),
61 framework::dataset::make("Expected", { false, true, false, true, false })),
62 input_info, output_info, stride, expected)
63{
64 bool status = bool(CLReorgLayer::validate(&input_info, &output_info, stride));
65 ARM_COMPUTE_EXPECT(status == expected, framework::LogLevel::ERRORS);
66}
67// clang-format on
68// *INDENT-ON*
69
Gian Marco Iodice477531c2018-08-21 17:53:38 +010070template <typename T>
71using CLReorgLayerFixture = ReorgLayerValidationFixture<CLTensor, CLAccessor, CLReorgLayer, T>;
72
73TEST_SUITE(S32)
74FIXTURE_DATA_TEST_CASE(RunSmall, CLReorgLayerFixture<int32_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallReorgLayerDataset(), framework::dataset::make("DataType",
75 DataType::S32)),
76 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
77{
78 // Validate output
79 validate(CLAccessor(_target), _reference);
80}
81
82FIXTURE_DATA_TEST_CASE(RunLarge, CLReorgLayerFixture<int32_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeReorgLayerDataset(), framework::dataset::make("DataType",
83 DataType::S32)),
84 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
85{
86 // Validate output
87 validate(CLAccessor(_target), _reference);
88}
89TEST_SUITE_END() // S32
90
91TEST_SUITE(S16)
92FIXTURE_DATA_TEST_CASE(RunSmall, CLReorgLayerFixture<int16_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallReorgLayerDataset(), framework::dataset::make("DataType",
93 DataType::S16)),
94 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
95{
96 // Validate output
97 validate(CLAccessor(_target), _reference);
98}
99
100FIXTURE_DATA_TEST_CASE(RunLarge, CLReorgLayerFixture<int16_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeReorgLayerDataset(), framework::dataset::make("DataType",
101 DataType::S16)),
102 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
103{
104 // Validate output
105 validate(CLAccessor(_target), _reference);
106}
107TEST_SUITE_END() // S16
108
109TEST_SUITE(S8)
110FIXTURE_DATA_TEST_CASE(RunSmall, CLReorgLayerFixture<int8_t>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallReorgLayerDataset(), framework::dataset::make("DataType",
111 DataType::S8)),
112 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
113{
114 // Validate output
115 validate(CLAccessor(_target), _reference);
116}
117
118FIXTURE_DATA_TEST_CASE(RunLarge, CLReorgLayerFixture<int8_t>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeReorgLayerDataset(), framework::dataset::make("DataType", DataType::S8)),
119 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
120{
121 // Validate output
122 validate(CLAccessor(_target), _reference);
123}
124TEST_SUITE_END() // S8
125
126TEST_SUITE_END() // ReorgLayer
127TEST_SUITE_END() // CL
128} // namespace validation
129} // namespace test
130} // namespace arm_compute