XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1 | // Copyright (c) Facebook, Inc. and its affiliates. |
| 2 | // All rights reserved. |
| 3 | // |
| 4 | // Copyright 2019 Google LLC |
| 5 | // |
| 6 | // This source code is licensed under the BSD-style license found in the |
| 7 | // LICENSE file in the root directory of this source tree. |
| 8 | |
| 9 | #include <cmath> |
| 10 | #include <cstddef> |
| 11 | #include <cstdlib> |
| 12 | |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 13 | #include <gtest/gtest.h> |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 14 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 15 | #include <xnnpack/common.h> |
| 16 | |
| 17 | #include <xnnpack/requantization-stubs.h> |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 18 | #include "requantization-tester.h" |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | * Precise scalar implementation using unsigned 32-bit arithmetics. |
| 23 | */ |
| 24 | |
| 25 | TEST(PRECISE__SCALAR_UNSIGNED32, exact_divide_by_po2) { |
| 26 | for (uint32_t s = 1; s < 32; s++) { |
| 27 | RequantizationTester() |
| 28 | .s(s) |
| 29 | .testExactDivideByPO2(xnn_requantize_precise__scalar_unsigned32); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | TEST(PRECISE__SCALAR_UNSIGNED32, exact_divide_by_po2_with_zero_point) { |
| 34 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 35 | for (uint32_t s = 1; s < 32; s++) { |
| 36 | RequantizationTester() |
| 37 | .zeroPoint(zeroPoint) |
| 38 | .s(s) |
| 39 | .testExactDivideByPO2(xnn_requantize_precise__scalar_unsigned32); |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | TEST(PRECISE__SCALAR_UNSIGNED32, divide_by_po2_with_rounding_up) { |
| 45 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 46 | for (uint32_t s = 1; s < 32; s++) { |
| 47 | RequantizationTester() |
| 48 | .zeroPoint(zeroPoint) |
| 49 | .s(s) |
| 50 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__scalar_unsigned32); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | TEST(PRECISE__SCALAR_UNSIGNED32, divide_by_po2_with_rounding_down) { |
| 56 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 57 | for (uint32_t s = 1; s < 32; s++) { |
| 58 | RequantizationTester() |
| 59 | .zeroPoint(zeroPoint) |
| 60 | .s(s) |
| 61 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__scalar_unsigned32); |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | TEST(PRECISE__SCALAR_UNSIGNED32, divide_by_po2_with_rounding_away) { |
| 67 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 68 | for (uint32_t s = 1; s < 32; s++) { |
| 69 | RequantizationTester() |
| 70 | .zeroPoint(zeroPoint) |
| 71 | .s(s) |
| 72 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__scalar_unsigned32); |
| 73 | } |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | TEST(PRECISE__SCALAR_UNSIGNED32, special_cases) { |
| 78 | RequantizationTester() |
| 79 | .testSpecialCases(xnn_requantize_precise__scalar_unsigned32); |
| 80 | } |
| 81 | |
| 82 | TEST(PRECISE__SCALAR_UNSIGNED32, random_cases) { |
| 83 | RequantizationTester() |
| 84 | .iterations(100) |
| 85 | .testRandomCasesPrecise(xnn_requantize_precise__scalar_unsigned32); |
| 86 | } |
| 87 | |
| 88 | |
| 89 | /* |
| 90 | * Precise scalar implementation using unsigned 64-bit arithmetics. |
| 91 | */ |
| 92 | |
| 93 | TEST(PRECISE__SCALAR_UNSIGNED64, exact_divide_by_po2) { |
| 94 | for (uint32_t s = 1; s < 32; s++) { |
| 95 | RequantizationTester() |
| 96 | .s(s) |
| 97 | .testExactDivideByPO2(xnn_requantize_precise__scalar_unsigned64); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | TEST(PRECISE__SCALAR_UNSIGNED64, exact_divide_by_po2_with_zero_point) { |
| 102 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 103 | for (uint32_t s = 1; s < 32; s++) { |
| 104 | RequantizationTester() |
| 105 | .zeroPoint(zeroPoint) |
| 106 | .s(s) |
| 107 | .testExactDivideByPO2(xnn_requantize_precise__scalar_unsigned64); |
| 108 | } |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | TEST(PRECISE__SCALAR_UNSIGNED64, divide_by_po2_with_rounding_up) { |
| 113 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 114 | for (uint32_t s = 1; s < 32; s++) { |
| 115 | RequantizationTester() |
| 116 | .zeroPoint(zeroPoint) |
| 117 | .s(s) |
| 118 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__scalar_unsigned64); |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | TEST(PRECISE__SCALAR_UNSIGNED64, divide_by_po2_with_rounding_down) { |
| 124 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 125 | for (uint32_t s = 1; s < 32; s++) { |
| 126 | RequantizationTester() |
| 127 | .zeroPoint(zeroPoint) |
| 128 | .s(s) |
| 129 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__scalar_unsigned64); |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | TEST(PRECISE__SCALAR_UNSIGNED64, divide_by_po2_with_rounding_away) { |
| 135 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 136 | for (uint32_t s = 1; s < 32; s++) { |
| 137 | RequantizationTester() |
| 138 | .zeroPoint(zeroPoint) |
| 139 | .s(s) |
| 140 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__scalar_unsigned64); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | TEST(PRECISE__SCALAR_UNSIGNED64, special_cases) { |
| 146 | RequantizationTester() |
| 147 | .testSpecialCases(xnn_requantize_precise__scalar_unsigned64); |
| 148 | } |
| 149 | |
| 150 | TEST(PRECISE__SCALAR_UNSIGNED64, random_cases) { |
| 151 | RequantizationTester() |
| 152 | .iterations(100) |
| 153 | .testRandomCasesPrecise(xnn_requantize_precise__scalar_unsigned64); |
| 154 | } |
| 155 | |
| 156 | |
| 157 | /* |
| 158 | * Precise scalar implementation using signed 64-bit arithmetics. |
| 159 | */ |
| 160 | |
| 161 | TEST(PRECISE__SCALAR_SIGNED64, exact_divide_by_po2) { |
| 162 | for (uint32_t s = 1; s < 32; s++) { |
| 163 | RequantizationTester() |
| 164 | .s(s) |
| 165 | .testExactDivideByPO2(xnn_requantize_precise__scalar_signed64); |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | TEST(PRECISE__SCALAR_SIGNED64, exact_divide_by_po2_with_zero_point) { |
| 170 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 171 | for (uint32_t s = 1; s < 32; s++) { |
| 172 | RequantizationTester() |
| 173 | .zeroPoint(zeroPoint) |
| 174 | .s(s) |
| 175 | .testExactDivideByPO2(xnn_requantize_precise__scalar_signed64); |
| 176 | } |
| 177 | } |
| 178 | } |
| 179 | |
| 180 | TEST(PRECISE__SCALAR_SIGNED64, divide_by_po2_with_rounding_up) { |
| 181 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 182 | for (uint32_t s = 1; s < 32; s++) { |
| 183 | RequantizationTester() |
| 184 | .zeroPoint(zeroPoint) |
| 185 | .s(s) |
| 186 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__scalar_signed64); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | TEST(PRECISE__SCALAR_SIGNED64, divide_by_po2_with_rounding_down) { |
| 192 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 193 | for (uint32_t s = 1; s < 32; s++) { |
| 194 | RequantizationTester() |
| 195 | .zeroPoint(zeroPoint) |
| 196 | .s(s) |
| 197 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__scalar_signed64); |
| 198 | } |
| 199 | } |
| 200 | } |
| 201 | |
| 202 | TEST(PRECISE__SCALAR_SIGNED64, divide_by_po2_with_rounding_away) { |
| 203 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 204 | for (uint32_t s = 1; s < 32; s++) { |
| 205 | RequantizationTester() |
| 206 | .zeroPoint(zeroPoint) |
| 207 | .s(s) |
| 208 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__scalar_signed64); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | TEST(PRECISE__SCALAR_SIGNED64, special_cases) { |
| 214 | RequantizationTester() |
| 215 | .testSpecialCases(xnn_requantize_precise__scalar_signed64); |
| 216 | } |
| 217 | |
| 218 | TEST(PRECISE__SCALAR_SIGNED64, random_cases) { |
| 219 | RequantizationTester() |
| 220 | .iterations(100) |
| 221 | .testRandomCasesPrecise(xnn_requantize_precise__scalar_signed64); |
| 222 | } |
| 223 | |
| 224 | |
| 225 | /* |
| 226 | * FP32-based scalar implementation using lrintf function. |
| 227 | */ |
| 228 | |
| 229 | TEST(FP32__SCALAR_LRINTF, random_cases) { |
| 230 | RequantizationTester() |
| 231 | .iterations(1000) |
| 232 | .testRandomCasesApproximate(xnn_requantize_fp32__scalar_lrintf); |
| 233 | } |
| 234 | |
| 235 | |
| 236 | /* |
| 237 | * FP32-based scalar implementation using magic trick for FP32->INT32 conversion. |
| 238 | */ |
| 239 | |
| 240 | TEST(FP32__SCALAR_MAGIC, random_cases) { |
| 241 | RequantizationTester() |
| 242 | .iterations(1000) |
| 243 | .testRandomCasesApproximate(xnn_requantize_fp32__scalar_magic); |
| 244 | } |
| 245 | |
| 246 | |
| 247 | /* |
| 248 | * Q31-based scalar implementation. |
| 249 | */ |
| 250 | |
| 251 | TEST(Q31__SCALAR, exact_divide_by_po2) { |
| 252 | for (uint32_t s = 1; s < 32; s++) { |
| 253 | RequantizationTester() |
| 254 | .s(s) |
| 255 | .testExactDivideByPO2(xnn_requantize_q31__scalar); |
| 256 | } |
| 257 | } |
| 258 | |
| 259 | TEST(Q31__SCALAR, exact_divide_by_po2_with_zero_point) { |
| 260 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 261 | for (uint32_t s = 1; s < 32; s++) { |
| 262 | RequantizationTester() |
| 263 | .zeroPoint(zeroPoint) |
| 264 | .s(s) |
| 265 | .testExactDivideByPO2(xnn_requantize_q31__scalar); |
| 266 | } |
| 267 | } |
| 268 | } |
| 269 | |
| 270 | TEST(Q31__SCALAR, divide_by_po2_with_rounding_up) { |
| 271 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 272 | for (uint32_t s = 1; s < 32; s++) { |
| 273 | RequantizationTester() |
| 274 | .zeroPoint(zeroPoint) |
| 275 | .s(s) |
| 276 | .testDivideByPO2WithRoundingUp(xnn_requantize_q31__scalar); |
| 277 | } |
| 278 | } |
| 279 | } |
| 280 | |
| 281 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
| 282 | |
| 283 | TEST(Q31__SCALAR, divide_by_po2_with_rounding_away) { |
| 284 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 285 | for (uint32_t s = 1; s < 32; s++) { |
| 286 | RequantizationTester() |
| 287 | .zeroPoint(zeroPoint) |
| 288 | .s(s) |
| 289 | .testDivideByPO2WithRoundingAway(xnn_requantize_q31__scalar); |
| 290 | } |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | TEST(Q31__SCALAR, special_cases) { |
| 295 | RequantizationTester() |
| 296 | .testSpecialCases(xnn_requantize_q31__scalar); |
| 297 | } |
| 298 | |
| 299 | TEST(Q31__SCALAR, random_cases) { |
| 300 | RequantizationTester() |
| 301 | .iterations(100) |
| 302 | .testRandomCasesApproximate(xnn_requantize_q31__scalar); |
| 303 | } |
| 304 | |
| 305 | TEST(Q31__SCALAR, random_match_gemmlowp) { |
| 306 | RequantizationTester() |
| 307 | .iterations(100) |
| 308 | .testRandomCasesAgainstReference(xnn_requantize_q31__scalar, xnn_requantize_gemmlowp__scalar); |
| 309 | } |
| 310 | |
| 311 | |
| 312 | /* |
| 313 | * Scalar implementation from gemmlowp. |
| 314 | */ |
| 315 | |
| 316 | TEST(GEMMLOWP__SCALAR, random_cases) { |
| 317 | RequantizationTester() |
| 318 | .iterations(100) |
| 319 | .testRandomCasesApproximate(xnn_requantize_gemmlowp__scalar); |
| 320 | } |
| 321 | |
| 322 | |
| 323 | /* |
| 324 | * Precise PSIMD implementation using unsigned 32-bit arithmetics. |
| 325 | */ |
| 326 | |
| 327 | TEST(PRECISE__PSIMD, exact_divide_by_po2) { |
| 328 | for (uint32_t s = 1; s < 32; s++) { |
| 329 | RequantizationTester() |
| 330 | .s(s) |
| 331 | .testExactDivideByPO2(xnn_requantize_precise__psimd); |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | TEST(PRECISE__PSIMD, exact_divide_by_po2_with_zero_point) { |
| 336 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 337 | for (uint32_t s = 1; s < 32; s++) { |
| 338 | RequantizationTester() |
| 339 | .zeroPoint(zeroPoint) |
| 340 | .s(s) |
| 341 | .testExactDivideByPO2(xnn_requantize_precise__psimd); |
| 342 | } |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | TEST(PRECISE__PSIMD, divide_by_po2_with_rounding_up) { |
| 347 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 348 | for (uint32_t s = 1; s < 32; s++) { |
| 349 | RequantizationTester() |
| 350 | .zeroPoint(zeroPoint) |
| 351 | .s(s) |
| 352 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__psimd); |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | TEST(PRECISE__PSIMD, divide_by_po2_with_rounding_down) { |
| 358 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 359 | for (uint32_t s = 1; s < 32; s++) { |
| 360 | RequantizationTester() |
| 361 | .zeroPoint(zeroPoint) |
| 362 | .s(s) |
| 363 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__psimd); |
| 364 | } |
| 365 | } |
| 366 | } |
| 367 | |
| 368 | TEST(PRECISE__PSIMD, divide_by_po2_with_rounding_away) { |
| 369 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 370 | for (uint32_t s = 1; s < 32; s++) { |
| 371 | RequantizationTester() |
| 372 | .zeroPoint(zeroPoint) |
| 373 | .s(s) |
| 374 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__psimd); |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | TEST(PRECISE__PSIMD, special_cases) { |
| 380 | RequantizationTester() |
| 381 | .testSpecialCases(xnn_requantize_precise__psimd); |
| 382 | } |
| 383 | |
| 384 | TEST(PRECISE__PSIMD, random_cases) { |
| 385 | RequantizationTester() |
| 386 | .iterations(100) |
| 387 | .testRandomCasesPrecise(xnn_requantize_precise__psimd); |
| 388 | } |
| 389 | |
| 390 | |
| 391 | /* |
| 392 | * FP32-based PSIMD implementation using magic trick for FP32->INT32 conversion. |
| 393 | */ |
| 394 | |
| 395 | TEST(FP32__PSIMD, random_cases) { |
| 396 | RequantizationTester() |
| 397 | .iterations(1000) |
| 398 | .testRandomCasesApproximate(xnn_requantize_fp32__psimd); |
| 399 | } |
| 400 | |
| 401 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 402 | #if XNN_ARCH_X86 || XNN_ARCH_X86_64 |
| 403 | /* |
| 404 | * Precise SSE2 implementation using floating-point shuffle. |
| 405 | */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 406 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 407 | TEST(PRECISE__SSE2, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 408 | for (uint32_t s = 1; s < 32; s++) { |
| 409 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 410 | .s(s) |
| 411 | .testExactDivideByPO2(xnn_requantize_precise__sse2); |
| 412 | } |
| 413 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 414 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 415 | TEST(PRECISE__SSE2, exact_divide_by_po2_with_zero_point) { |
| 416 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 417 | for (uint32_t s = 1; s < 32; s++) { |
| 418 | RequantizationTester() |
| 419 | .zeroPoint(zeroPoint) |
| 420 | .s(s) |
| 421 | .testExactDivideByPO2(xnn_requantize_precise__sse2); |
| 422 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 423 | } |
| 424 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 425 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 426 | TEST(PRECISE__SSE2, divide_by_po2_with_rounding_up) { |
| 427 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 428 | for (uint32_t s = 1; s < 32; s++) { |
| 429 | RequantizationTester() |
| 430 | .zeroPoint(zeroPoint) |
| 431 | .s(s) |
| 432 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__sse2); |
| 433 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 434 | } |
| 435 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 436 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 437 | TEST(PRECISE__SSE2, divide_by_po2_with_rounding_down) { |
| 438 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 439 | for (uint32_t s = 1; s < 32; s++) { |
| 440 | RequantizationTester() |
| 441 | .zeroPoint(zeroPoint) |
| 442 | .s(s) |
| 443 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__sse2); |
| 444 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 445 | } |
| 446 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 447 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 448 | TEST(PRECISE__SSE2, divide_by_po2_with_rounding_away) { |
| 449 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 450 | for (uint32_t s = 1; s < 32; s++) { |
| 451 | RequantizationTester() |
| 452 | .zeroPoint(zeroPoint) |
| 453 | .s(s) |
| 454 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__sse2); |
| 455 | } |
| 456 | } |
| 457 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 458 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 459 | TEST(PRECISE__SSE2, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 460 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 461 | .testSpecialCases(xnn_requantize_precise__sse2); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 462 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 463 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 464 | TEST(PRECISE__SSE2, random_cases) { |
| 465 | RequantizationTester() |
| 466 | .iterations(100) |
| 467 | .testRandomCasesPrecise(xnn_requantize_precise__sse2); |
| 468 | } |
| 469 | |
| 470 | |
| 471 | /* |
| 472 | * Precise SSSE3 implementation using floating-point shuffle. |
| 473 | */ |
| 474 | |
| 475 | TEST(PRECISE__SSSE3, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 476 | for (uint32_t s = 1; s < 32; s++) { |
| 477 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 478 | .s(s) |
| 479 | .testExactDivideByPO2(xnn_requantize_precise__ssse3); |
| 480 | } |
| 481 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 482 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 483 | TEST(PRECISE__SSSE3, exact_divide_by_po2_with_zero_point) { |
| 484 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 485 | for (uint32_t s = 1; s < 32; s++) { |
| 486 | RequantizationTester() |
| 487 | .zeroPoint(zeroPoint) |
| 488 | .s(s) |
| 489 | .testExactDivideByPO2(xnn_requantize_precise__ssse3); |
| 490 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 491 | } |
| 492 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 493 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 494 | TEST(PRECISE__SSSE3, divide_by_po2_with_rounding_up) { |
| 495 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 496 | for (uint32_t s = 1; s < 32; s++) { |
| 497 | RequantizationTester() |
| 498 | .zeroPoint(zeroPoint) |
| 499 | .s(s) |
| 500 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__ssse3); |
| 501 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 502 | } |
| 503 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 504 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 505 | TEST(PRECISE__SSSE3, divide_by_po2_with_rounding_down) { |
| 506 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 507 | for (uint32_t s = 1; s < 32; s++) { |
| 508 | RequantizationTester() |
| 509 | .zeroPoint(zeroPoint) |
| 510 | .s(s) |
| 511 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__ssse3); |
| 512 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 513 | } |
| 514 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 515 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 516 | TEST(PRECISE__SSSE3, divide_by_po2_with_rounding_away) { |
| 517 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 518 | for (uint32_t s = 1; s < 32; s++) { |
| 519 | RequantizationTester() |
| 520 | .zeroPoint(zeroPoint) |
| 521 | .s(s) |
| 522 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__ssse3); |
| 523 | } |
| 524 | } |
| 525 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 526 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 527 | TEST(PRECISE__SSSE3, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 528 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 529 | .testSpecialCases(xnn_requantize_precise__ssse3); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 530 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 531 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 532 | TEST(PRECISE__SSSE3, random_cases) { |
| 533 | RequantizationTester() |
| 534 | .iterations(100) |
| 535 | .testRandomCasesPrecise(xnn_requantize_precise__ssse3); |
| 536 | } |
| 537 | |
| 538 | |
| 539 | /* |
| 540 | * Precise SSE4.1 implementation using static blend instruction. |
| 541 | */ |
| 542 | |
| 543 | TEST(PRECISE__SSE4, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 544 | for (uint32_t s = 1; s < 32; s++) { |
| 545 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 546 | .s(s) |
| 547 | .testExactDivideByPO2(xnn_requantize_precise__sse4); |
| 548 | } |
| 549 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 550 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 551 | TEST(PRECISE__SSE4, exact_divide_by_po2_with_zero_point) { |
| 552 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 553 | for (uint32_t s = 1; s < 32; s++) { |
| 554 | RequantizationTester() |
| 555 | .zeroPoint(zeroPoint) |
| 556 | .s(s) |
| 557 | .testExactDivideByPO2(xnn_requantize_precise__sse4); |
| 558 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 559 | } |
| 560 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 561 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 562 | TEST(PRECISE__SSE4, divide_by_po2_with_rounding_up) { |
| 563 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 564 | for (uint32_t s = 1; s < 32; s++) { |
| 565 | RequantizationTester() |
| 566 | .zeroPoint(zeroPoint) |
| 567 | .s(s) |
| 568 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__sse4); |
| 569 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 570 | } |
| 571 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 572 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 573 | TEST(PRECISE__SSE4, divide_by_po2_with_rounding_down) { |
| 574 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 575 | for (uint32_t s = 1; s < 32; s++) { |
| 576 | RequantizationTester() |
| 577 | .zeroPoint(zeroPoint) |
| 578 | .s(s) |
| 579 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__sse4); |
| 580 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 581 | } |
| 582 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 583 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 584 | TEST(PRECISE__SSE4, divide_by_po2_with_rounding_away) { |
| 585 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 586 | for (uint32_t s = 1; s < 32; s++) { |
| 587 | RequantizationTester() |
| 588 | .zeroPoint(zeroPoint) |
| 589 | .s(s) |
| 590 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__sse4); |
| 591 | } |
| 592 | } |
| 593 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 594 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 595 | TEST(PRECISE__SSE4, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 596 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 597 | .testSpecialCases(xnn_requantize_precise__sse4); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 598 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 599 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 600 | TEST(PRECISE__SSE4, random_cases) { |
| 601 | RequantizationTester() |
| 602 | .iterations(100) |
| 603 | .testRandomCasesPrecise(xnn_requantize_precise__sse4); |
| 604 | } |
| 605 | |
| 606 | |
| 607 | /* |
| 608 | * FP32-based x86 SSE2 implementation. |
| 609 | */ |
| 610 | |
| 611 | TEST(FP32__SSE2, random_cases) { |
| 612 | RequantizationTester() |
| 613 | .iterations(1000) |
| 614 | .testRandomCasesApproximate(xnn_requantize_fp32__sse2); |
| 615 | } |
| 616 | |
| 617 | |
| 618 | /* |
| 619 | * Q31-based x86 SSE2 implementation. |
| 620 | */ |
| 621 | |
| 622 | TEST(Q31__SSE2, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 623 | for (uint32_t s = 1; s < 32; s++) { |
| 624 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 625 | .s(s) |
| 626 | .testExactDivideByPO2(xnn_requantize_q31__sse2); |
| 627 | } |
| 628 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 629 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 630 | TEST(Q31__SSE2, exact_divide_by_po2_with_zero_point) { |
| 631 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 632 | for (uint32_t s = 1; s < 32; s++) { |
| 633 | RequantizationTester() |
| 634 | .zeroPoint(zeroPoint) |
| 635 | .s(s) |
| 636 | .testExactDivideByPO2(xnn_requantize_q31__sse2); |
| 637 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 638 | } |
| 639 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 640 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 641 | TEST(Q31__SSE2, divide_by_po2_with_rounding_up) { |
| 642 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 643 | for (uint32_t s = 1; s < 32; s++) { |
| 644 | RequantizationTester() |
| 645 | .zeroPoint(zeroPoint) |
| 646 | .s(s) |
| 647 | .testDivideByPO2WithRoundingUp(xnn_requantize_q31__sse2); |
| 648 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 649 | } |
| 650 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 651 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 652 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 653 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 654 | TEST(Q31__SSE2, divide_by_po2_with_rounding_away) { |
| 655 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 656 | for (uint32_t s = 1; s < 32; s++) { |
| 657 | RequantizationTester() |
| 658 | .zeroPoint(zeroPoint) |
| 659 | .s(s) |
| 660 | .testDivideByPO2WithRoundingAway(xnn_requantize_q31__sse2); |
| 661 | } |
| 662 | } |
| 663 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 664 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 665 | TEST(Q31__SSE2, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 666 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 667 | .testSpecialCases(xnn_requantize_q31__sse2); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 668 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 669 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 670 | TEST(Q31__SSE2, random_cases) { |
| 671 | RequantizationTester() |
| 672 | .iterations(100) |
| 673 | .testRandomCasesApproximate(xnn_requantize_q31__sse2); |
| 674 | } |
| 675 | |
| 676 | TEST(Q31__SSE2, random_match_gemmlowp) { |
| 677 | RequantizationTester() |
| 678 | .iterations(100) |
| 679 | .testRandomCasesAgainstReference(xnn_requantize_q31__sse2, xnn_requantize_gemmlowp__sse2); |
| 680 | } |
| 681 | |
| 682 | |
| 683 | /* |
| 684 | * Q31-based x86 SSSE3 implementation. |
| 685 | */ |
| 686 | |
| 687 | TEST(Q31__SSSE3, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 688 | for (uint32_t s = 1; s < 32; s++) { |
| 689 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 690 | .s(s) |
| 691 | .testExactDivideByPO2(xnn_requantize_q31__ssse3); |
| 692 | } |
| 693 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 694 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 695 | TEST(Q31__SSSE3, exact_divide_by_po2_with_zero_point) { |
| 696 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 697 | for (uint32_t s = 1; s < 32; s++) { |
| 698 | RequantizationTester() |
| 699 | .zeroPoint(zeroPoint) |
| 700 | .s(s) |
| 701 | .testExactDivideByPO2(xnn_requantize_q31__ssse3); |
| 702 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 703 | } |
| 704 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 705 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 706 | TEST(Q31__SSSE3, divide_by_po2_with_rounding_up) { |
| 707 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 708 | for (uint32_t s = 1; s < 32; s++) { |
| 709 | RequantizationTester() |
| 710 | .zeroPoint(zeroPoint) |
| 711 | .s(s) |
| 712 | .testDivideByPO2WithRoundingUp(xnn_requantize_q31__ssse3); |
| 713 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 714 | } |
| 715 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 716 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 717 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 718 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 719 | TEST(Q31__SSSE3, divide_by_po2_with_rounding_away) { |
| 720 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 721 | for (uint32_t s = 1; s < 32; s++) { |
| 722 | RequantizationTester() |
| 723 | .zeroPoint(zeroPoint) |
| 724 | .s(s) |
| 725 | .testDivideByPO2WithRoundingAway(xnn_requantize_q31__ssse3); |
| 726 | } |
| 727 | } |
| 728 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 729 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 730 | TEST(Q31__SSSE3, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 731 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 732 | .testSpecialCases(xnn_requantize_q31__ssse3); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 733 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 734 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 735 | TEST(Q31__SSSE3, random_cases) { |
| 736 | RequantizationTester() |
| 737 | .iterations(100) |
| 738 | .testRandomCasesApproximate(xnn_requantize_q31__ssse3); |
| 739 | } |
| 740 | |
| 741 | TEST(Q31__SSSE3, random_match_gemmlowp) { |
| 742 | RequantizationTester() |
| 743 | .iterations(100) |
| 744 | .testRandomCasesAgainstReference(xnn_requantize_q31__ssse3, xnn_requantize_gemmlowp__ssse3); |
| 745 | } |
| 746 | |
| 747 | |
| 748 | /* |
| 749 | * Q31-based x86 SSE4 implementation. |
| 750 | */ |
| 751 | |
| 752 | TEST(Q31__SSE4, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 753 | for (uint32_t s = 1; s < 32; s++) { |
| 754 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 755 | .s(s) |
| 756 | .testExactDivideByPO2(xnn_requantize_q31__sse4); |
| 757 | } |
| 758 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 759 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 760 | TEST(Q31__SSE4, exact_divide_by_po2_with_zero_point) { |
| 761 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 762 | for (uint32_t s = 1; s < 32; s++) { |
| 763 | RequantizationTester() |
| 764 | .zeroPoint(zeroPoint) |
| 765 | .s(s) |
| 766 | .testExactDivideByPO2(xnn_requantize_q31__sse4); |
| 767 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 768 | } |
| 769 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 770 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 771 | TEST(Q31__SSE4, divide_by_po2_with_rounding_up) { |
| 772 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 773 | for (uint32_t s = 1; s < 32; s++) { |
| 774 | RequantizationTester() |
| 775 | .zeroPoint(zeroPoint) |
| 776 | .s(s) |
| 777 | .testDivideByPO2WithRoundingUp(xnn_requantize_q31__sse4); |
| 778 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 779 | } |
| 780 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 781 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 782 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 783 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 784 | TEST(Q31__SSE4, divide_by_po2_with_rounding_away) { |
| 785 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 786 | for (uint32_t s = 1; s < 32; s++) { |
| 787 | RequantizationTester() |
| 788 | .zeroPoint(zeroPoint) |
| 789 | .s(s) |
| 790 | .testDivideByPO2WithRoundingAway(xnn_requantize_q31__sse4); |
| 791 | } |
| 792 | } |
| 793 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 794 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 795 | TEST(Q31__SSE4, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 796 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 797 | .testSpecialCases(xnn_requantize_q31__sse4); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 798 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 799 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 800 | TEST(Q31__SSE4, random_cases) { |
| 801 | RequantizationTester() |
| 802 | .iterations(100) |
| 803 | .testRandomCasesApproximate(xnn_requantize_q31__sse4); |
| 804 | } |
| 805 | |
| 806 | TEST(Q31__SSE4, random_match_gemmlowp) { |
| 807 | RequantizationTester() |
| 808 | .iterations(100) |
| 809 | .testRandomCasesAgainstReference(xnn_requantize_q31__sse4, xnn_requantize_gemmlowp__sse4); |
| 810 | } |
| 811 | |
| 812 | |
| 813 | /* |
| 814 | * x86 SSE2 implementation from gemmlowp. |
| 815 | */ |
| 816 | |
| 817 | TEST(GEMMLOWP__SSE2, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 818 | for (uint32_t s = 1; s < 32; s++) { |
| 819 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 820 | .s(s) |
| 821 | .testExactDivideByPO2(xnn_requantize_gemmlowp__sse2); |
| 822 | } |
| 823 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 824 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 825 | TEST(GEMMLOWP__SSE2, exact_divide_by_po2_with_zero_point) { |
| 826 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 827 | for (uint32_t s = 1; s < 32; s++) { |
| 828 | RequantizationTester() |
| 829 | .zeroPoint(zeroPoint) |
| 830 | .s(s) |
| 831 | .testExactDivideByPO2(xnn_requantize_gemmlowp__sse2); |
| 832 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 833 | } |
| 834 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 835 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 836 | TEST(GEMMLOWP__SSE2, divide_by_po2_with_rounding_up) { |
| 837 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 838 | for (uint32_t s = 1; s < 32; s++) { |
| 839 | RequantizationTester() |
| 840 | .zeroPoint(zeroPoint) |
| 841 | .s(s) |
| 842 | .testDivideByPO2WithRoundingUp(xnn_requantize_gemmlowp__sse2); |
| 843 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 844 | } |
| 845 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 846 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 847 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 848 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 849 | TEST(GEMMLOWP__SSE2, divide_by_po2_with_rounding_away) { |
| 850 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 851 | for (uint32_t s = 1; s < 32; s++) { |
| 852 | RequantizationTester() |
| 853 | .zeroPoint(zeroPoint) |
| 854 | .s(s) |
| 855 | .testDivideByPO2WithRoundingAway(xnn_requantize_gemmlowp__sse2); |
| 856 | } |
| 857 | } |
| 858 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 859 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 860 | TEST(GEMMLOWP__SSE2, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 861 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 862 | .testSpecialCases(xnn_requantize_gemmlowp__sse2); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 863 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 864 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 865 | TEST(GEMMLOWP__SSE2, random_cases) { |
| 866 | RequantizationTester() |
| 867 | .iterations(100) |
| 868 | .testRandomCasesApproximate(xnn_requantize_gemmlowp__sse2); |
| 869 | } |
| 870 | |
| 871 | |
| 872 | /* |
| 873 | * x86 SSSE3 implementation from gemmlowp. |
| 874 | */ |
| 875 | |
| 876 | TEST(GEMMLOWP__SSSE3, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 877 | for (uint32_t s = 1; s < 32; s++) { |
| 878 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 879 | .s(s) |
| 880 | .testExactDivideByPO2(xnn_requantize_gemmlowp__ssse3); |
| 881 | } |
| 882 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 883 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 884 | TEST(GEMMLOWP__SSSE3, exact_divide_by_po2_with_zero_point) { |
| 885 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 886 | for (uint32_t s = 1; s < 32; s++) { |
| 887 | RequantizationTester() |
| 888 | .zeroPoint(zeroPoint) |
| 889 | .s(s) |
| 890 | .testExactDivideByPO2(xnn_requantize_gemmlowp__ssse3); |
| 891 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 892 | } |
| 893 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 894 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 895 | TEST(GEMMLOWP__SSSE3, divide_by_po2_with_rounding_up) { |
| 896 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 897 | for (uint32_t s = 1; s < 32; s++) { |
| 898 | RequantizationTester() |
| 899 | .zeroPoint(zeroPoint) |
| 900 | .s(s) |
| 901 | .testDivideByPO2WithRoundingUp(xnn_requantize_gemmlowp__ssse3); |
| 902 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 903 | } |
| 904 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 905 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 906 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 907 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 908 | TEST(GEMMLOWP__SSSE3, divide_by_po2_with_rounding_away) { |
| 909 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 910 | for (uint32_t s = 1; s < 32; s++) { |
| 911 | RequantizationTester() |
| 912 | .zeroPoint(zeroPoint) |
| 913 | .s(s) |
| 914 | .testDivideByPO2WithRoundingAway(xnn_requantize_gemmlowp__ssse3); |
| 915 | } |
| 916 | } |
| 917 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 918 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 919 | TEST(GEMMLOWP__SSSE3, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 920 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 921 | .testSpecialCases(xnn_requantize_gemmlowp__ssse3); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 922 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 923 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 924 | TEST(GEMMLOWP__SSSE3, random_cases) { |
| 925 | RequantizationTester() |
| 926 | .iterations(100) |
| 927 | .testRandomCasesApproximate(xnn_requantize_gemmlowp__ssse3); |
| 928 | } |
| 929 | |
| 930 | |
| 931 | /* |
| 932 | * x86 SSE4 implementation from gemmlowp. |
| 933 | */ |
| 934 | |
| 935 | TEST(GEMMLOWP__SSE4, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 936 | for (uint32_t s = 1; s < 32; s++) { |
| 937 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 938 | .s(s) |
| 939 | .testExactDivideByPO2(xnn_requantize_gemmlowp__sse4); |
| 940 | } |
| 941 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 942 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 943 | TEST(GEMMLOWP__SSE4, exact_divide_by_po2_with_zero_point) { |
| 944 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 945 | for (uint32_t s = 1; s < 32; s++) { |
| 946 | RequantizationTester() |
| 947 | .zeroPoint(zeroPoint) |
| 948 | .s(s) |
| 949 | .testExactDivideByPO2(xnn_requantize_gemmlowp__sse4); |
| 950 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 951 | } |
| 952 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 953 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 954 | TEST(GEMMLOWP__SSE4, divide_by_po2_with_rounding_up) { |
| 955 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 956 | for (uint32_t s = 1; s < 32; s++) { |
| 957 | RequantizationTester() |
| 958 | .zeroPoint(zeroPoint) |
| 959 | .s(s) |
| 960 | .testDivideByPO2WithRoundingUp(xnn_requantize_gemmlowp__sse4); |
| 961 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 962 | } |
| 963 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 964 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 965 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 966 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 967 | TEST(GEMMLOWP__SSE4, divide_by_po2_with_rounding_away) { |
| 968 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 969 | for (uint32_t s = 1; s < 32; s++) { |
| 970 | RequantizationTester() |
| 971 | .zeroPoint(zeroPoint) |
| 972 | .s(s) |
| 973 | .testDivideByPO2WithRoundingAway(xnn_requantize_gemmlowp__sse4); |
| 974 | } |
| 975 | } |
| 976 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 977 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 978 | TEST(GEMMLOWP__SSE4, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 979 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 980 | .testSpecialCases(xnn_requantize_gemmlowp__sse4); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 981 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 982 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 983 | TEST(GEMMLOWP__SSE4, random_cases) { |
| 984 | RequantizationTester() |
| 985 | .iterations(100) |
| 986 | .testRandomCasesApproximate(xnn_requantize_gemmlowp__sse4); |
| 987 | } |
| 988 | #endif // XNN_ARCH_X86 || XNN_ARCH_X86_64 |
| 989 | |
| 990 | #if XNN_ARCH_ARM || XNN_ARCH_ARM64 |
| 991 | /* |
| 992 | * Precise ARM NEON implementation. |
| 993 | */ |
| 994 | |
| 995 | TEST(PRECISE__NEON, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 996 | for (uint32_t s = 1; s < 32; s++) { |
| 997 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 998 | .s(s) |
| 999 | .testExactDivideByPO2(xnn_requantize_precise__neon); |
| 1000 | } |
| 1001 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1002 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1003 | TEST(PRECISE__NEON, exact_divide_by_po2_with_zero_point) { |
| 1004 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 1005 | for (uint32_t s = 1; s < 32; s++) { |
| 1006 | RequantizationTester() |
| 1007 | .zeroPoint(zeroPoint) |
| 1008 | .s(s) |
| 1009 | .testExactDivideByPO2(xnn_requantize_precise__neon); |
| 1010 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1011 | } |
| 1012 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1013 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1014 | TEST(PRECISE__NEON, divide_by_po2_with_rounding_up) { |
| 1015 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 1016 | for (uint32_t s = 1; s < 32; s++) { |
| 1017 | RequantizationTester() |
| 1018 | .zeroPoint(zeroPoint) |
| 1019 | .s(s) |
| 1020 | .testDivideByPO2WithRoundingUp(xnn_requantize_precise__neon); |
| 1021 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1022 | } |
| 1023 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1024 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1025 | TEST(PRECISE__NEON, divide_by_po2_with_rounding_down) { |
| 1026 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 1027 | for (uint32_t s = 1; s < 32; s++) { |
| 1028 | RequantizationTester() |
| 1029 | .zeroPoint(zeroPoint) |
| 1030 | .s(s) |
| 1031 | .testDivideByPO2WithRoundingDown(xnn_requantize_precise__neon); |
| 1032 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1033 | } |
| 1034 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1035 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1036 | TEST(PRECISE__NEON, divide_by_po2_with_rounding_away) { |
| 1037 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 1038 | for (uint32_t s = 1; s < 32; s++) { |
| 1039 | RequantizationTester() |
| 1040 | .zeroPoint(zeroPoint) |
| 1041 | .s(s) |
| 1042 | .testDivideByPO2WithRoundingAway(xnn_requantize_precise__neon); |
| 1043 | } |
| 1044 | } |
| 1045 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1046 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1047 | TEST(PRECISE__NEON, special_cases) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1048 | RequantizationTester() |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1049 | .testSpecialCases(xnn_requantize_precise__neon); |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1050 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1051 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1052 | TEST(PRECISE__NEON, random_cases) { |
| 1053 | RequantizationTester() |
| 1054 | .iterations(100) |
| 1055 | .testRandomCasesPrecise(xnn_requantize_precise__neon); |
| 1056 | } |
| 1057 | |
| 1058 | |
| 1059 | /* |
| 1060 | * FP32-based ARM NEON implementation. |
| 1061 | */ |
| 1062 | |
| 1063 | TEST(FP32__NEON, random_cases) { |
| 1064 | RequantizationTester() |
| 1065 | .iterations(1000) |
| 1066 | .testRandomCasesApproximate(xnn_requantize_fp32__neon); |
| 1067 | } |
| 1068 | |
| 1069 | |
| 1070 | /* |
| 1071 | * Q31-based ARM NEON implementation. |
| 1072 | */ |
| 1073 | |
| 1074 | TEST(Q31__NEON, exact_divide_by_po2) { |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1075 | for (uint32_t s = 1; s < 32; s++) { |
| 1076 | RequantizationTester() |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1077 | .s(s) |
| 1078 | .testExactDivideByPO2(xnn_requantize_q31__neon); |
| 1079 | } |
| 1080 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1081 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1082 | TEST(Q31__NEON, exact_divide_by_po2_with_zero_point) { |
| 1083 | for (int32_t zeroPoint = 1; zeroPoint < 256; zeroPoint++) { |
| 1084 | for (uint32_t s = 1; s < 32; s++) { |
| 1085 | RequantizationTester() |
| 1086 | .zeroPoint(zeroPoint) |
| 1087 | .s(s) |
| 1088 | .testExactDivideByPO2(xnn_requantize_q31__neon); |
| 1089 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1090 | } |
| 1091 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1092 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1093 | TEST(Q31__NEON, divide_by_po2_with_rounding_up) { |
| 1094 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 1095 | for (uint32_t s = 1; s < 32; s++) { |
| 1096 | RequantizationTester() |
| 1097 | .zeroPoint(zeroPoint) |
| 1098 | .s(s) |
| 1099 | .testDivideByPO2WithRoundingUp(xnn_requantize_q31__neon); |
| 1100 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1101 | } |
| 1102 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1103 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1104 | /* No rounding down Test - it fails because of upward bias in multiplication */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1105 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1106 | TEST(Q31__NEON, divide_by_po2_with_rounding_away) { |
| 1107 | for (int32_t zeroPoint = 0; zeroPoint < 256; zeroPoint++) { |
| 1108 | for (uint32_t s = 1; s < 32; s++) { |
| 1109 | RequantizationTester() |
| 1110 | .zeroPoint(zeroPoint) |
| 1111 | .s(s) |
| 1112 | .testDivideByPO2WithRoundingAway(xnn_requantize_q31__neon); |
| 1113 | } |
| 1114 | } |
| 1115 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1116 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1117 | TEST(Q31__NEON, special_cases) { |
| 1118 | RequantizationTester() |
| 1119 | .testSpecialCases(xnn_requantize_q31__neon); |
| 1120 | } |
| 1121 | |
| 1122 | TEST(Q31__NEON, random_cases) { |
| 1123 | RequantizationTester() |
| 1124 | .iterations(100) |
| 1125 | .testRandomCasesApproximate(xnn_requantize_q31__neon); |
| 1126 | } |
| 1127 | |
| 1128 | TEST(Q31__NEON, random_match_gemmlowp) { |
| 1129 | RequantizationTester() |
| 1130 | .iterations(100) |
| 1131 | .testRandomCasesAgainstReference(xnn_requantize_q31__neon, xnn_requantize_gemmlowp__neon); |
| 1132 | } |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1133 | |
| 1134 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1135 | /* |
| 1136 | * ARM NEON implementation from gemmlowp. |
| 1137 | */ |
XNNPACK Team | b455b12 | 2019-09-27 18:10:33 -0700 | [diff] [blame] | 1138 | |
Marat Dukhan | 1dadbf7 | 2019-10-01 10:46:20 -0700 | [diff] [blame] | 1139 | TEST(GEMMLOWP__NEON, random_cases) { |
| 1140 | RequantizationTester() |
| 1141 | .iterations(100) |
| 1142 | .testRandomCasesApproximate(xnn_requantize_gemmlowp__neon); |
| 1143 | } |
| 1144 | #endif // XNN_ARCH_ARM || XNN_ARCH_ARM64 |