blob: ee449da8fa2d56138db0bbf4632e485e208ee86d [file] [log] [blame]
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +00001/*
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +00002 * Copyright (c) 2017-2019 ARM Limited.
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +00003 *
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,
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +000021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +000022 * SOFTWARE.
23 */
24#include "arm_compute/core/Types.h"
25#include "arm_compute/runtime/MultiImage.h"
26#include "arm_compute/runtime/NEON/functions/NEChannelCombine.h"
27#include "arm_compute/runtime/Tensor.h"
28#include "arm_compute/runtime/TensorAllocator.h"
29#include "tests/NEON/Accessor.h"
30#include "tests/PaddingCalculator.h"
31#include "tests/datasets/ConvertPolicyDataset.h"
32#include "tests/datasets/ShapeDatasets.h"
33#include "tests/framework/Asserts.h"
34#include "tests/framework/Macros.h"
35#include "tests/framework/datasets/Datasets.h"
36#include "tests/validation/Validation.h"
37#include "tests/validation/fixtures/ChannelCombineFixture.h"
38
39namespace arm_compute
40{
41namespace test
42{
43namespace validation
44{
45namespace
46{
47inline void validate_configuration(const TensorShape &shape, Format format)
48{
49 const int num_planes = num_planes_from_format(format);
50
51 // Create tensors
52 MultiImage dst = create_multi_image<MultiImage>(shape, format);
53 std::vector<Tensor> ref_src = create_tensor_planes<Tensor>(shape, format);
54
55 // Create and configure function
56 NEChannelCombine channel_combine;
57
58 if(num_planes == 1)
59 {
60 const Tensor *tensor_extra = Format::RGBA8888 == format ? &ref_src[3] : nullptr;
61
62 channel_combine.configure(&ref_src[0], &ref_src[1], &ref_src[2], tensor_extra, dst.plane(0));
63 }
64 else
65 {
66 channel_combine.configure(&ref_src[0], &ref_src[1], &ref_src[2], &dst);
67 }
68
69 // TODO(bsgcomp): Add validation for padding and shape (COMPMID-659)
70}
71} // namespace
72
73TEST_SUITE(NEON)
74TEST_SUITE(ChannelCombine)
75
76TEST_SUITE(Configuration)
77DATA_TEST_CASE(RGBA, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 })),
78 shape, format)
79{
80 validate_configuration(shape, format);
81}
82DATA_TEST_CASE(YUV, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("FormatType", { Format::YUYV422, Format::UYVY422 })),
83 shape, format)
84{
85 validate_configuration(shape, format);
86}
87
88DATA_TEST_CASE(YUVPlanar, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), framework::dataset::make("FormatType", { Format::IYUV, Format::YUV444, Format::NV12, Format::NV21 })),
89 shape, format)
90{
91 validate_configuration(shape, format);
92}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +000093TEST_SUITE_END() // Configuration
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +000094
95template <typename T>
96using NEChannelCombineFixture = ChannelCombineValidationFixture<MultiImage, Tensor, Accessor, NEChannelCombine, T>;
97
98TEST_SUITE(RGBA)
99FIXTURE_DATA_TEST_CASE(RunSmall, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 })))
100{
101 // Validate output
102 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
103 {
104 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
105 }
106}
107FIXTURE_DATA_TEST_CASE(RunLarge, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 })))
108{
109 // Validate output
110 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
111 {
112 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
113 }
114}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000115TEST_SUITE_END() // RGBA
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +0000116
117TEST_SUITE(YUV)
118FIXTURE_DATA_TEST_CASE(RunSmall, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("FormatType", { Format::YUYV422, Format::UYVY422 })))
119{
120 // Validate output
121 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
122 {
123 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
124 }
125}
126FIXTURE_DATA_TEST_CASE(RunLarge, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("FormatType", { Format::YUYV422, Format::UYVY422 })))
127{
128 // Validate output
129 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
130 {
131 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
132 }
133}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000134TEST_SUITE_END() // YUV
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +0000135
136TEST_SUITE(YUVPlanar)
137FIXTURE_DATA_TEST_CASE(RunSmall, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), framework::dataset::make("FormatType", { Format::NV12, Format::NV21, Format::IYUV, Format::YUV444 })))
138{
139 // Validate output
140 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
141 {
142 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
143 }
144}
145FIXTURE_DATA_TEST_CASE(RunLarge, NEChannelCombineFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), framework::dataset::make("FormatType", { Format::NV12, Format::NV21, Format::IYUV, Format::YUV444 })))
146{
147 // Validate output
148 for(unsigned int plane_idx = 0; plane_idx < _num_planes; ++plane_idx)
149 {
150 validate(Accessor(*_target.plane(plane_idx)), _reference[plane_idx]);
151 }
152}
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000153TEST_SUITE_END() // YUVPlanar
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +0000154
Michalis Spyrouaeebe4a2019-01-09 14:21:03 +0000155TEST_SUITE_END() // ChannelCombine
156TEST_SUITE_END() // NEON
Ioan-Cristian Szaboae3c8ab2017-11-16 17:55:03 +0000157} // namespace validation
158} // namespace test
159} // namespace arm_compute