Ioan-Cristian Szabo | ae3c8ab | 2017-11-16 17:55:03 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017-2018 ARM Limited. |
| 3 | * |
| 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 CONCLCTION 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/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 | |
| 39 | namespace arm_compute |
| 40 | { |
| 41 | namespace test |
| 42 | { |
| 43 | namespace validation |
| 44 | { |
| 45 | namespace |
| 46 | { |
| 47 | inline 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 | |
| 73 | TEST_SUITE(NEON) |
| 74 | TEST_SUITE(ChannelCombine) |
| 75 | |
| 76 | TEST_SUITE(Configuration) |
| 77 | DATA_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 | } |
| 82 | DATA_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 | |
| 88 | DATA_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 | } |
| 93 | TEST_SUITE_END() |
| 94 | |
| 95 | template <typename T> |
| 96 | using NEChannelCombineFixture = ChannelCombineValidationFixture<MultiImage, Tensor, Accessor, NEChannelCombine, T>; |
| 97 | |
| 98 | TEST_SUITE(RGBA) |
| 99 | FIXTURE_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 | } |
| 107 | FIXTURE_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 | } |
| 115 | TEST_SUITE_END() |
| 116 | |
| 117 | TEST_SUITE(YUV) |
| 118 | FIXTURE_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 | } |
| 126 | FIXTURE_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 | } |
| 134 | TEST_SUITE_END() |
| 135 | |
| 136 | TEST_SUITE(YUVPlanar) |
| 137 | FIXTURE_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 | } |
| 145 | FIXTURE_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 | } |
| 153 | TEST_SUITE_END() |
| 154 | |
| 155 | TEST_SUITE_END() |
| 156 | TEST_SUITE_END() |
| 157 | } // namespace validation |
| 158 | } // namespace test |
| 159 | } // namespace arm_compute |