Sanghoon Lee | 1fad27a | 2018-04-05 10:57:57 +0100 | [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 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "arm_compute/runtime/MultiImage.h" |
| 25 | #include "arm_compute/runtime/NEON/functions/NEColorConvert.h" |
| 26 | #include "arm_compute/runtime/Tensor.h" |
| 27 | #include "arm_compute/runtime/TensorAllocator.h" |
| 28 | #include "tests/NEON/Accessor.h" |
| 29 | #include "tests/datasets/ShapeDatasets.h" |
| 30 | #include "tests/framework/Asserts.h" |
| 31 | #include "tests/framework/Macros.h" |
| 32 | #include "tests/validation/Validation.h" |
| 33 | #include "tests/validation/fixtures/ColorConvertFixture.h" |
| 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace test |
| 38 | { |
| 39 | namespace validation |
| 40 | { |
| 41 | namespace |
| 42 | { |
| 43 | // Input data sets |
| 44 | const auto ColorConvertRGBADataset = combine(framework::dataset::make("FormatType", { Format::RGBA8888 }), |
| 45 | framework::dataset::make("FormatType", { Format::RGB888 })); |
| 46 | const auto ColorConvertYUVDataset = combine(framework::dataset::make("FormatType", { Format::YUYV422, Format::UYVY422 }), |
| 47 | framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 })); |
| 48 | |
| 49 | const auto ColorConvertYUVPlanarDataset = combine(framework::dataset::make("FormatType", { Format::IYUV, Format::NV12, Format::NV21 }), |
| 50 | framework::dataset::make("FormatType", { Format::RGB888, Format::RGBA8888 })); |
| 51 | |
| 52 | const auto ColorConvertRGBDataset = combine(framework::dataset::make("FormatType", { Format::RGB888 }), |
| 53 | framework::dataset::make("FormatType", { Format::RGBA8888 })); |
| 54 | |
| 55 | inline void validate_configuration(const TensorShape &shape, Format src_format, Format dst_format) |
| 56 | { |
| 57 | const unsigned int src_num_planes = num_planes_from_format(src_format); |
| 58 | |
| 59 | const TensorShape dst_shape = adjust_odd_shape(shape, src_format); |
| 60 | |
| 61 | // Create tensors |
| 62 | MultiImage ref_src = create_multi_image<MultiImage>(shape, src_format); |
| 63 | Tensor dst = create_tensor<Tensor>(dst_shape, dst_format); |
| 64 | |
| 65 | // Create and Configure function |
| 66 | NEColorConvert color_convert; |
| 67 | |
| 68 | if(1U == src_num_planes) |
| 69 | { |
| 70 | const Tensor *plane_src = ref_src.plane(0); |
| 71 | |
| 72 | color_convert.configure(plane_src, &dst); |
| 73 | const ValidRegion dst_valid_region = shape_to_valid_region(dst_shape); |
| 74 | validate(dst.info()->valid_region(), dst_valid_region); |
| 75 | } |
| 76 | else |
| 77 | { |
| 78 | color_convert.configure(&ref_src, &dst); |
| 79 | } |
| 80 | } |
| 81 | } // namespace |
| 82 | |
| 83 | TEST_SUITE(NEON) |
| 84 | TEST_SUITE(ColorConvert) |
| 85 | |
| 86 | TEST_SUITE(Configuration) |
| 87 | DATA_TEST_CASE(RGBA, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), ColorConvertRGBADataset), |
| 88 | shape, src_format, dst_format) |
| 89 | { |
| 90 | validate_configuration(shape, src_format, dst_format); |
| 91 | } |
| 92 | |
| 93 | DATA_TEST_CASE(YUV, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), ColorConvertYUVDataset), |
| 94 | shape, src_format, dst_format) |
| 95 | { |
| 96 | validate_configuration(shape, src_format, dst_format); |
| 97 | } |
| 98 | |
| 99 | DATA_TEST_CASE(YUVPlanar, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), ColorConvertYUVPlanarDataset), |
| 100 | shape, src_format, dst_format) |
| 101 | { |
| 102 | validate_configuration(shape, src_format, dst_format); |
| 103 | } |
| 104 | |
| 105 | DATA_TEST_CASE(RGB, framework::DatasetMode::ALL, combine(concat(datasets::Small2DShapes(), datasets::Large2DShapes()), ColorConvertRGBDataset), |
| 106 | shape, src_format, dst_format) |
| 107 | { |
| 108 | validate_configuration(shape, src_format, dst_format); |
| 109 | } |
| 110 | TEST_SUITE_END() |
| 111 | |
| 112 | template <typename T> |
| 113 | using NEColorConvertFixture = ColorConvertValidationFixture<MultiImage, Tensor, Accessor, NEColorConvert, T>; |
| 114 | |
| 115 | TEST_SUITE(RGBA) |
| 116 | FIXTURE_DATA_TEST_CASE(RunSmall, NEColorConvertFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), ColorConvertRGBADataset)) |
| 117 | { |
| 118 | // Validate output |
| 119 | validate(Accessor(_target), _reference); |
| 120 | } |
| 121 | FIXTURE_DATA_TEST_CASE(RunLarge, NEColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvertRGBADataset)) |
| 122 | { |
| 123 | // Validate output |
| 124 | validate(Accessor(_target), _reference); |
| 125 | } |
| 126 | |
| 127 | TEST_SUITE_END() |
| 128 | |
| 129 | TEST_SUITE(YUV) |
| 130 | FIXTURE_DATA_TEST_CASE(RunSmall, NEColorConvertFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), ColorConvertYUVDataset)) |
| 131 | { |
| 132 | // Validate output |
| 133 | validate(Accessor(_target), _reference); |
| 134 | } |
| 135 | FIXTURE_DATA_TEST_CASE(RunLarge, NEColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvertYUVDataset)) |
| 136 | { |
| 137 | // Validate output |
| 138 | validate(Accessor(_target), _reference); |
| 139 | } |
| 140 | |
| 141 | TEST_SUITE_END() |
| 142 | |
| 143 | TEST_SUITE(YUVPlanar) |
| 144 | FIXTURE_DATA_TEST_CASE(RunSmall, NEColorConvertFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), ColorConvertYUVPlanarDataset)) |
| 145 | { |
| 146 | // Validate output |
| 147 | validate(Accessor(_target), _reference); |
| 148 | } |
| 149 | FIXTURE_DATA_TEST_CASE(RunLarge, NEColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvertYUVPlanarDataset)) |
| 150 | { |
| 151 | // Validate output |
| 152 | validate(Accessor(_target), _reference); |
| 153 | } |
| 154 | TEST_SUITE_END() |
| 155 | |
| 156 | TEST_SUITE(RGB) |
| 157 | FIXTURE_DATA_TEST_CASE(RunSmall, NEColorConvertFixture<uint8_t>, framework::DatasetMode::PRECOMMIT, combine(datasets::Small2DShapes(), ColorConvertRGBDataset)) |
| 158 | { |
| 159 | // Validate output |
| 160 | validate(Accessor(_target), _reference); |
| 161 | } |
| 162 | FIXTURE_DATA_TEST_CASE(RunLarge, NEColorConvertFixture<uint8_t>, framework::DatasetMode::NIGHTLY, combine(datasets::Large2DShapes(), ColorConvertRGBDataset)) |
| 163 | { |
| 164 | // Validate output |
| 165 | validate(Accessor(_target), _reference); |
| 166 | } |
| 167 | TEST_SUITE_END() |
| 168 | |
| 169 | TEST_SUITE_END() |
| 170 | TEST_SUITE_END() |
| 171 | } // namespace validation |
| 172 | } // namespace test |
| 173 | } // namespace arm_compute |