Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 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 "Globals.h" |
| 25 | #include "NEON/Helper.h" |
| 26 | #include "NEON/NEAccessor.h" |
Moritz Pflanzer | 5b51229 | 2017-06-21 15:54:07 +0100 | [diff] [blame] | 27 | #include "PaddingCalculator.h" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 28 | #include "TensorLibrary.h" |
| 29 | #include "TypePrinter.h" |
| 30 | #include "Utils.h" |
| 31 | #include "validation/Datasets.h" |
| 32 | #include "validation/Reference.h" |
| 33 | #include "validation/Validation.h" |
| 34 | |
| 35 | #include "arm_compute/core/Helpers.h" |
| 36 | #include "arm_compute/core/Types.h" |
| 37 | #include "arm_compute/runtime/NEON/functions/NEDepthConvert.h" |
| 38 | #include "arm_compute/runtime/Tensor.h" |
| 39 | #include "arm_compute/runtime/TensorAllocator.h" |
| 40 | |
| 41 | #include "boost_wrapper.h" |
| 42 | |
| 43 | #include <random> |
| 44 | #include <string> |
| 45 | |
| 46 | using namespace arm_compute; |
| 47 | using namespace arm_compute::test; |
| 48 | using namespace arm_compute::test::neon; |
| 49 | using namespace arm_compute::test::validation; |
| 50 | |
| 51 | namespace |
| 52 | { |
| 53 | /** Compute Neon depth convert function. |
| 54 | * |
| 55 | * @param[in] shape Shape of the input and output tensors. |
| 56 | * @param[in] dt_in Data type of input tensor. |
| 57 | * @param[in] dt_out Data type of the output tensor. |
| 58 | * @param[in] policy Conversion policy. |
| 59 | * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. |
| 60 | * @param[in] fixed_point_position Fixed point position. |
| 61 | * |
| 62 | * @return Computed output tensor. |
| 63 | */ |
| 64 | Tensor compute_depth_convert(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position) |
| 65 | { |
| 66 | // Create tensors |
| 67 | Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position); |
| 68 | Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); |
| 69 | |
| 70 | // Create and configure function |
| 71 | NEDepthConvert depth_convert; |
| 72 | depth_convert.configure(&src, &dst, policy, shift); |
| 73 | |
| 74 | // Allocate tensors |
| 75 | src.allocator()->allocate(); |
| 76 | dst.allocator()->allocate(); |
| 77 | |
| 78 | BOOST_TEST(!src.info()->is_resizable()); |
| 79 | BOOST_TEST(!dst.info()->is_resizable()); |
| 80 | |
| 81 | // Fill tensors |
| 82 | library->fill_tensor_uniform(NEAccessor(src), 0); |
| 83 | |
| 84 | // Compute function |
| 85 | depth_convert.run(); |
| 86 | |
| 87 | return dst; |
| 88 | } |
| 89 | /** Configure and validate region/padding function. |
| 90 | * |
| 91 | * @param[in] shape Shape of the input and output tensors. |
| 92 | * @param[in] dt_in Data type of input tensor. |
| 93 | * @param[in] dt_out Data type of the output tensor. |
| 94 | * @param[in] policy Conversion policy. |
| 95 | * @param[in] shift Value for down/up conversions. Must be 0 <= shift < 8. |
| 96 | * @param[in] fixed_point_position Fixed point position. |
| 97 | * |
| 98 | */ |
| 99 | |
| 100 | void compute_configure_validate(const TensorShape &shape, DataType dt_in, DataType dt_out, ConvertPolicy policy, uint32_t shift, uint32_t fixed_point_position) |
| 101 | { |
| 102 | // Create tensors |
| 103 | Tensor src = create_tensor(shape, dt_in, 1, fixed_point_position); |
| 104 | Tensor dst = create_tensor(shape, dt_out, 1, fixed_point_position); |
| 105 | |
| 106 | BOOST_TEST(src.info()->is_resizable()); |
| 107 | BOOST_TEST(dst.info()->is_resizable()); |
| 108 | |
| 109 | // Create and configure function |
| 110 | NEDepthConvert depth_convert; |
| 111 | depth_convert.configure(&src, &dst, policy, shift); |
| 112 | |
| 113 | // Validate valid region |
| 114 | const ValidRegion valid_region = shape_to_valid_region(shape); |
| 115 | validate(src.info()->valid_region(), valid_region); |
| 116 | validate(dst.info()->valid_region(), valid_region); |
| 117 | |
| 118 | // Validate padding |
Moritz Pflanzer | 2509fba | 2017-06-23 14:15:03 +0100 | [diff] [blame] | 119 | const PaddingSize padding = PaddingCalculator(shape.x(), 16).required_padding(); |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 120 | validate(src.info()->padding(), padding); |
| 121 | validate(dst.info()->padding(), padding); |
| 122 | } |
| 123 | } // namespace |
| 124 | |
| 125 | #ifndef DOXYGEN_SKIP_THIS |
| 126 | BOOST_AUTO_TEST_SUITE(NEON) |
| 127 | BOOST_AUTO_TEST_SUITE(DepthConvert) |
| 128 | |
| 129 | BOOST_AUTO_TEST_SUITE(QS8_to_F32) |
| 130 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 131 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 132 | * boost::unit_test::data::xrange(1, 7, 1), |
| 133 | shape, policy, fixed_point_position) |
| 134 | { |
| 135 | // Compute configure and validate region/padding |
| 136 | compute_configure_validate(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position); |
| 137 | } |
| 138 | |
| 139 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 140 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 141 | * boost::unit_test::data::xrange(1, 7, 1), |
| 142 | shape, policy, fixed_point_position) |
| 143 | { |
| 144 | // Compute function |
| 145 | Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position); |
| 146 | |
| 147 | // Compute reference |
| 148 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position); |
| 149 | |
| 150 | // Validate output |
| 151 | validate(NEAccessor(dst), ref_dst); |
| 152 | } |
| 153 | |
| 154 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 155 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 156 | * boost::unit_test::data::xrange(1, 7, 1), |
| 157 | shape, policy, fixed_point_position) |
| 158 | { |
| 159 | // Compute function |
| 160 | Tensor dst = compute_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position); |
| 161 | |
| 162 | // Compute reference |
| 163 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::QS8, DataType::F32, policy, 0, fixed_point_position); |
| 164 | |
| 165 | // Validate output |
| 166 | validate(NEAccessor(dst), ref_dst); |
| 167 | } |
| 168 | |
| 169 | BOOST_AUTO_TEST_SUITE_END() |
| 170 | |
| 171 | BOOST_AUTO_TEST_SUITE(F32_to_QS8) |
| 172 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 173 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 174 | * boost::unit_test::data::xrange(1, 7, 1), |
| 175 | shape, policy, fixed_point_position) |
| 176 | { |
| 177 | // Compute configure and validate region/padding |
| 178 | compute_configure_validate(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position); |
| 179 | } |
| 180 | |
| 181 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 182 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 183 | * boost::unit_test::data::xrange(1, 7, 1), |
| 184 | shape, policy, fixed_point_position) |
| 185 | { |
| 186 | // Compute function |
| 187 | Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position); |
| 188 | |
| 189 | // Compute reference |
| 190 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position); |
| 191 | |
| 192 | // Validate output |
| 193 | validate(NEAccessor(dst), ref_dst); |
| 194 | } |
| 195 | |
| 196 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 197 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE }) |
| 198 | * boost::unit_test::data::xrange(1, 7, 1), |
| 199 | shape, policy, fixed_point_position) |
| 200 | { |
| 201 | // Compute function |
| 202 | Tensor dst = compute_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position); |
| 203 | |
| 204 | // Compute reference |
| 205 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::F32, DataType::QS8, policy, 0, fixed_point_position); |
| 206 | |
| 207 | // Validate output |
| 208 | validate(NEAccessor(dst), ref_dst); |
| 209 | } |
| 210 | BOOST_AUTO_TEST_SUITE_END() |
| 211 | |
| 212 | BOOST_AUTO_TEST_SUITE(U8_to_U16) |
| 213 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 214 | |
| 215 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 216 | * boost::unit_test::data::xrange(0, 7, 1), |
| 217 | shape, policy, shift) |
| 218 | { |
| 219 | // Compute configure and validate region/padding |
| 220 | compute_configure_validate(shape, DataType::U8, DataType::U16, policy, shift, 0); |
| 221 | } |
| 222 | |
| 223 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 224 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 225 | * boost::unit_test::data::xrange(0, 7, 1), |
| 226 | shape, policy, shift) |
| 227 | { |
| 228 | // Compute function |
| 229 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); |
| 230 | |
| 231 | // Compute reference |
| 232 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); |
| 233 | |
| 234 | // Validate output |
| 235 | validate(NEAccessor(dst), ref_dst); |
| 236 | } |
| 237 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 238 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 239 | * boost::unit_test::data::xrange(0, 7, 1), |
| 240 | shape, policy, shift) |
| 241 | { |
| 242 | // Compute function |
| 243 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); |
| 244 | |
| 245 | // Compute reference |
| 246 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::U16, policy, shift, 0); |
| 247 | |
| 248 | // Validate output |
| 249 | validate(NEAccessor(dst), ref_dst); |
| 250 | } |
| 251 | BOOST_AUTO_TEST_SUITE_END() |
| 252 | |
| 253 | BOOST_AUTO_TEST_SUITE(U8_to_S16) |
| 254 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 255 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 256 | * boost::unit_test::data::xrange(0, 7, 1), |
| 257 | shape, policy, shift) |
| 258 | { |
| 259 | // Compute configure and validate region/padding |
| 260 | compute_configure_validate(shape, DataType::U8, DataType::S16, policy, shift, 0); |
| 261 | } |
| 262 | |
| 263 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 264 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 265 | * boost::unit_test::data::xrange(0, 7, 1), |
| 266 | shape, policy, shift) |
| 267 | { |
| 268 | // Compute function |
| 269 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); |
| 270 | |
| 271 | // Compute reference |
| 272 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); |
| 273 | |
| 274 | // Validate output |
| 275 | validate(NEAccessor(dst), ref_dst); |
| 276 | } |
| 277 | |
| 278 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 279 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 280 | * boost::unit_test::data::xrange(0, 7, 1), |
| 281 | shape, policy, shift) |
| 282 | { |
| 283 | // Compute function |
| 284 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); |
| 285 | |
| 286 | // Compute reference |
| 287 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S16, policy, shift, 0); |
| 288 | |
| 289 | // Validate output |
| 290 | validate(NEAccessor(dst), ref_dst); |
| 291 | } |
| 292 | BOOST_AUTO_TEST_SUITE_END() |
| 293 | |
| 294 | BOOST_AUTO_TEST_SUITE(U8_to_S32) |
| 295 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 296 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 297 | * boost::unit_test::data::xrange(0, 7, 1), |
| 298 | shape, policy, shift) |
| 299 | { |
| 300 | // Compute configure and validate region/padding |
| 301 | compute_configure_validate(shape, DataType::U8, DataType::S32, policy, shift, 0); |
| 302 | } |
| 303 | |
| 304 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 305 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 306 | * boost::unit_test::data::xrange(0, 7, 1), |
| 307 | shape, policy, shift) |
| 308 | { |
| 309 | // Compute function |
| 310 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); |
| 311 | |
| 312 | // Compute reference |
| 313 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); |
| 314 | |
| 315 | // Validate output |
| 316 | validate(NEAccessor(dst), ref_dst); |
| 317 | } |
| 318 | |
| 319 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 320 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 321 | * boost::unit_test::data::xrange(0, 7, 1), |
| 322 | shape, policy, shift) |
| 323 | { |
| 324 | // Compute function |
| 325 | Tensor dst = compute_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); |
| 326 | |
| 327 | // Compute reference |
| 328 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U8, DataType::S32, policy, shift, 0); |
| 329 | |
| 330 | // Validate output |
| 331 | validate(NEAccessor(dst), ref_dst); |
| 332 | } |
| 333 | BOOST_AUTO_TEST_SUITE_END() |
| 334 | |
| 335 | BOOST_AUTO_TEST_SUITE(U16_to_U8) |
| 336 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 337 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 338 | * boost::unit_test::data::xrange(0, 7, 1), |
| 339 | shape, policy, shift) |
| 340 | { |
| 341 | // Compute configure and validate region/padding |
| 342 | compute_configure_validate(shape, DataType::U16, DataType::U8, policy, shift, 0); |
| 343 | } |
| 344 | |
| 345 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 346 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 347 | * boost::unit_test::data::xrange(0, 7, 1), |
| 348 | shape, policy, shift) |
| 349 | { |
| 350 | // Compute function |
| 351 | Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); |
| 352 | |
| 353 | // Compute reference |
| 354 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); |
| 355 | |
| 356 | // Validate output |
| 357 | validate(NEAccessor(dst), ref_dst); |
| 358 | } |
| 359 | |
| 360 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 361 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 362 | * boost::unit_test::data::xrange(0, 7, 1), |
| 363 | shape, policy, shift) |
| 364 | { |
| 365 | // Compute function |
| 366 | Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); |
| 367 | |
| 368 | // Compute reference |
| 369 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U8, policy, shift, 0); |
| 370 | |
| 371 | // Validate output |
| 372 | validate(NEAccessor(dst), ref_dst); |
| 373 | } |
| 374 | BOOST_AUTO_TEST_SUITE_END() |
| 375 | |
| 376 | BOOST_AUTO_TEST_SUITE(U16_to_U32) |
| 377 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 378 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 379 | * boost::unit_test::data::xrange(0, 7, 1), |
| 380 | shape, policy, shift) |
| 381 | { |
| 382 | // Compute configure and validate region/padding |
| 383 | compute_configure_validate(shape, DataType::U16, DataType::U32, policy, shift, 0); |
| 384 | } |
| 385 | |
| 386 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 387 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 388 | * boost::unit_test::data::xrange(0, 7, 1), |
| 389 | shape, policy, shift) |
| 390 | { |
| 391 | // Compute function |
| 392 | Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); |
| 393 | |
| 394 | // Compute reference |
| 395 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); |
| 396 | |
| 397 | // Validate output |
| 398 | validate(NEAccessor(dst), ref_dst); |
| 399 | } |
| 400 | |
| 401 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 402 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 403 | * boost::unit_test::data::xrange(0, 7, 1), |
| 404 | shape, policy, shift) |
| 405 | { |
| 406 | // Compute function |
| 407 | Tensor dst = compute_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); |
| 408 | |
| 409 | // Compute reference |
| 410 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::U16, DataType::U32, policy, shift, 0); |
| 411 | |
| 412 | // Validate output |
| 413 | validate(NEAccessor(dst), ref_dst); |
| 414 | } |
| 415 | BOOST_AUTO_TEST_SUITE_END() |
| 416 | |
| 417 | BOOST_AUTO_TEST_SUITE(S16_to_U8) |
| 418 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 419 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 420 | * boost::unit_test::data::xrange(0, 7, 1), |
| 421 | shape, policy, shift) |
| 422 | { |
| 423 | // Compute configure and validate region/padding |
| 424 | compute_configure_validate(shape, DataType::S16, DataType::U8, policy, shift, 0); |
| 425 | } |
| 426 | |
| 427 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 428 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 429 | * boost::unit_test::data::xrange(0, 7, 1), |
| 430 | shape, policy, shift) |
| 431 | { |
| 432 | // Compute function |
| 433 | Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); |
| 434 | |
| 435 | // Compute reference |
| 436 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); |
| 437 | |
| 438 | // Validate output |
| 439 | validate(NEAccessor(dst), ref_dst); |
| 440 | } |
| 441 | |
| 442 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 443 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 444 | * boost::unit_test::data::xrange(0, 7, 1), |
| 445 | shape, policy, shift) |
| 446 | { |
| 447 | // Compute function |
| 448 | Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); |
| 449 | |
| 450 | // Compute reference |
| 451 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::U8, policy, shift, 0); |
| 452 | |
| 453 | // Validate output |
| 454 | validate(NEAccessor(dst), ref_dst); |
| 455 | } |
| 456 | BOOST_AUTO_TEST_SUITE_END() |
| 457 | |
| 458 | BOOST_AUTO_TEST_SUITE(S16_to_S32) |
| 459 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 460 | BOOST_DATA_TEST_CASE(Configuration, (SmallShapes() + LargeShapes()) * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 461 | * boost::unit_test::data::xrange(0, 7, 1), |
| 462 | shape, policy, shift) |
| 463 | { |
| 464 | // Compute configure and validate region/padding |
| 465 | compute_configure_validate(shape, DataType::S16, DataType::S32, policy, shift, 0); |
| 466 | } |
| 467 | |
| 468 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit")) |
| 469 | BOOST_DATA_TEST_CASE(RunSmall, SmallShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 470 | * boost::unit_test::data::xrange(0, 7, 1), |
| 471 | shape, policy, shift) |
| 472 | { |
| 473 | // Compute function |
| 474 | Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); |
| 475 | |
| 476 | // Compute reference |
| 477 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); |
| 478 | |
| 479 | // Validate output |
| 480 | validate(NEAccessor(dst), ref_dst); |
| 481 | } |
| 482 | |
| 483 | BOOST_TEST_DECORATOR(*boost::unit_test::label("nightly")) |
| 484 | BOOST_DATA_TEST_CASE(RunLarge, LargeShapes() * boost::unit_test::data::make({ ConvertPolicy::SATURATE, ConvertPolicy::WRAP }) |
| 485 | * boost::unit_test::data::xrange(0, 7, 1), |
| 486 | shape, policy, shift) |
| 487 | { |
| 488 | // Compute function |
| 489 | Tensor dst = compute_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); |
| 490 | |
| 491 | // Compute reference |
| 492 | RawTensor ref_dst = Reference::compute_reference_depth_convert(shape, DataType::S16, DataType::S32, policy, shift, 0); |
| 493 | |
| 494 | // Validate output |
| 495 | validate(NEAccessor(dst), ref_dst); |
| 496 | } |
| 497 | BOOST_AUTO_TEST_SUITE_END() |
| 498 | |
| 499 | BOOST_AUTO_TEST_SUITE_END() |
| 500 | BOOST_AUTO_TEST_SUITE_END() |
| 501 | #endif |