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