blob: 46ac59e95c182a2932215c0a8d334beb5f6097fe [file] [log] [blame]
Michalis Spyrou22f917c2019-05-21 13:30:10 +01001/*
Sheri Zhangac6499a2021-02-10 15:32:38 +00002 * Copyright (c) 2019-2021 Arm Limited.
Michalis Spyrou22f917c2019-05-21 13:30:10 +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/NEON/functions/NEDepthToSpaceLayer.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/DepthToSpaceDataset.h"
31#include "tests/datasets/ShapeDatasets.h"
32#include "tests/framework/Asserts.h"
33#include "tests/framework/Macros.h"
34#include "tests/framework/datasets/Datasets.h"
35#include "tests/validation/Validation.h"
36#include "tests/validation/fixtures/DepthToSpaceLayerFixture.h"
37
38namespace arm_compute
39{
40namespace test
41{
42namespace validation
43{
44TEST_SUITE(NEON)
45TEST_SUITE(DepthToSpaceLayer)
46
47template <typename T>
48using NEDepthToSpaceLayerFixture = DepthToSpaceLayerValidationFixture<Tensor, Accessor, NEDepthToSpaceLayer, T>;
49
50// *INDENT-OFF*
51// clang-format off
52DATA_TEST_CASE(Validate, framework::DatasetMode::ALL, zip(zip(zip(
53 framework::dataset::make("InputInfo", { TensorInfo(TensorShape(16U, 8U, 4U, 4U), 1, DataType::F32),
54 TensorInfo(TensorShape(16U, 8U, 4U, 4U), 1, DataType::F32), // block < 2
55 TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Mismatching data types
56 TensorInfo(TensorShape(16U, 8U, 2U, 4U), 1, DataType::F32), // Negative block shape
57 TensorInfo(TensorShape(32U, 16U, 2U, 4U, 4U), 1, DataType::F32), // Wrong tensor shape
58 }),
59 framework::dataset::make("BlockShape", { 2, 1, 2, 2, 2 })),
60 framework::dataset::make("OutputInfo",{ TensorInfo(TensorShape(32U, 16U, 1U, 4U), 1, DataType::F32),
61 TensorInfo(TensorShape(64U, 16U, 1U, 4U), 1, DataType::F32),
62 TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F16),
63 TensorInfo(TensorShape(32U, 16U, 2U, 1U), 1, DataType::F32),
64 TensorInfo(TensorShape(32U, 8U, 2U, 1U), 1, DataType::F32),
65 })),
66 framework::dataset::make("Expected", { true, false, false, false, false})),
67 input_info, block_shape, output_info, expected)
68{
69 bool has_error = bool(NEDepthToSpaceLayer::validate(&input_info.clone()->set_is_resizable(false), &output_info.clone()->set_is_resizable(false), block_shape));
70 ARM_COMPUTE_EXPECT(has_error == expected, framework::LogLevel::ERRORS);
71}
72// clang-format on
73// *INDENT-ON*
74
75TEST_SUITE(Float)
76TEST_SUITE(FP32)
77FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthToSpaceLayerFixture<float>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthToSpaceLayerDataset(), framework::dataset::make("DataType",
78 DataType::F32)),
79 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
80{
81 // Validate output
82 validate(Accessor(_target), _reference);
83}
84FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthToSpaceLayerFixture<float>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthToSpaceLayerDataset(), framework::dataset::make("DataType",
85 DataType::F32)),
86 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
87{
88 // Validate output
89 validate(Accessor(_target), _reference);
90}
91TEST_SUITE_END()
92
93TEST_SUITE(FP16)
94FIXTURE_DATA_TEST_CASE(RunSmall, NEDepthToSpaceLayerFixture<half>, framework::DatasetMode::PRECOMMIT, combine(combine(datasets::SmallDepthToSpaceLayerDataset(), framework::dataset::make("DataType",
95 DataType::F16)),
96 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
97{
98 // Validate output
99 validate(Accessor(_target), _reference);
100}
101FIXTURE_DATA_TEST_CASE(RunLarge, NEDepthToSpaceLayerFixture<half>, framework::DatasetMode::NIGHTLY, combine(combine(datasets::LargeDepthToSpaceLayerDataset(), framework::dataset::make("DataType",
102 DataType::F16)),
103 framework::dataset::make("DataLayout", { DataLayout::NCHW, DataLayout::NHWC })))
104{
105 // Validate output
106 validate(Accessor(_target), _reference);
107}
108TEST_SUITE_END()
109TEST_SUITE_END()
110
111TEST_SUITE_END() // DepthToSpace
Sheri Zhangac6499a2021-02-10 15:32:38 +0000112TEST_SUITE_END() // Neon
Michalis Spyrou22f917c2019-05-21 13:30:10 +0100113} // namespace validation
114} // namespace test
115} // namespace arm_compute