1 #include "StatsTestsF16.h" 2 #include <stdio.h> 3 #include "Error.h" 4 #include "Test.h" 5 6 7 #define SNR_THRESHOLD 48 8 #define SNR_KULLBACK_THRESHOLD 40 9 /* 10 11 Reference patterns are generated with 12 a double precision computation. 13 14 */ 15 #define REL_ERROR (6.0e-3) 16 #define REL_ERROR_ACCUMULATE (7.0e-3) 17 18 #define REL_KULLBACK_ERROR (5.0e-3) 19 #define ABS_KULLBACK_ERROR (1.0e-2) 20 test_max_f16()21 void StatsTestsF16::test_max_f16() 22 { 23 const float16_t *inp = inputA.ptr(); 24 25 float16_t result; 26 uint32_t indexval; 27 28 float16_t *refp = ref.ptr(); 29 int16_t *refind = maxIndexes.ptr(); 30 31 float16_t *outp = output.ptr(); 32 int16_t *ind = index.ptr(); 33 34 arm_max_f16(inp, 35 inputA.nbSamples(), 36 &result, 37 &indexval); 38 39 outp[0] = result; 40 ind[0] = indexval; 41 42 ASSERT_EQ(result,refp[this->refOffset]); 43 ASSERT_EQ((int16_t)indexval,refind[this->refOffset]); 44 45 } 46 test_absmax_f16()47 void StatsTestsF16::test_absmax_f16() 48 { 49 const float16_t *inp = inputA.ptr(); 50 51 float16_t result; 52 uint32_t indexval; 53 54 float16_t *refp = ref.ptr(); 55 int16_t *refind = maxIndexes.ptr(); 56 57 float16_t *outp = output.ptr(); 58 int16_t *ind = index.ptr(); 59 60 arm_absmax_f16(inp, 61 inputA.nbSamples(), 62 &result, 63 &indexval); 64 65 outp[0] = result; 66 ind[0] = indexval; 67 68 ASSERT_EQ(result,refp[this->refOffset]); 69 ASSERT_EQ((int16_t)indexval,refind[this->refOffset]); 70 71 } 72 73 test_max_no_idx_f16()74 void StatsTestsF16::test_max_no_idx_f16() 75 { 76 const float16_t *inp = inputA.ptr(); 77 78 float16_t result; 79 80 float16_t *refp = ref.ptr(); 81 82 float16_t *outp = output.ptr(); 83 84 arm_max_no_idx_f16(inp, 85 inputA.nbSamples(), 86 &result); 87 88 outp[0] = result; 89 90 ASSERT_EQ(result,refp[this->refOffset]); 91 92 } 93 test_absmax_no_idx_f16()94 void StatsTestsF16::test_absmax_no_idx_f16() 95 { 96 const float16_t *inp = inputA.ptr(); 97 98 float16_t result; 99 100 float16_t *refp = ref.ptr(); 101 102 float16_t *outp = output.ptr(); 103 104 arm_absmax_no_idx_f16(inp, 105 inputA.nbSamples(), 106 &result); 107 108 outp[0] = result; 109 110 ASSERT_EQ(result,refp[this->refOffset]); 111 112 } 113 test_min_no_idx_f16()114 void StatsTestsF16::test_min_no_idx_f16() 115 { 116 const float16_t *inp = inputA.ptr(); 117 118 float16_t result; 119 120 float16_t *refp = ref.ptr(); 121 122 float16_t *outp = output.ptr(); 123 124 arm_min_no_idx_f16(inp, 125 inputA.nbSamples(), 126 &result); 127 128 outp[0] = result; 129 130 ASSERT_EQ(result,refp[this->refOffset]); 131 132 } 133 test_absmin_no_idx_f16()134 void StatsTestsF16::test_absmin_no_idx_f16() 135 { 136 const float16_t *inp = inputA.ptr(); 137 138 float16_t result; 139 140 float16_t *refp = ref.ptr(); 141 142 float16_t *outp = output.ptr(); 143 144 arm_absmin_no_idx_f16(inp, 145 inputA.nbSamples(), 146 &result); 147 148 outp[0] = result; 149 150 ASSERT_EQ(result,refp[this->refOffset]); 151 152 } 153 154 test_min_f16()155 void StatsTestsF16::test_min_f16() 156 { 157 const float16_t *inp = inputA.ptr(); 158 159 float16_t result; 160 uint32_t indexval; 161 162 float16_t *refp = ref.ptr(); 163 int16_t *refind = minIndexes.ptr(); 164 165 float16_t *outp = output.ptr(); 166 int16_t *ind = index.ptr(); 167 168 arm_min_f16(inp, 169 inputA.nbSamples(), 170 &result, 171 &indexval); 172 173 outp[0] = result; 174 ind[0] = indexval; 175 176 ASSERT_EQ(result,refp[this->refOffset]); 177 ASSERT_EQ((int16_t)indexval,refind[this->refOffset]); 178 179 } 180 test_absmin_f16()181 void StatsTestsF16::test_absmin_f16() 182 { 183 const float16_t *inp = inputA.ptr(); 184 185 float16_t result; 186 uint32_t indexval; 187 188 float16_t *refp = ref.ptr(); 189 int16_t *refind = minIndexes.ptr(); 190 191 float16_t *outp = output.ptr(); 192 int16_t *ind = index.ptr(); 193 194 arm_absmin_f16(inp, 195 inputA.nbSamples(), 196 &result, 197 &indexval); 198 199 outp[0] = result; 200 ind[0] = indexval; 201 202 ASSERT_EQ(result,refp[this->refOffset]); 203 ASSERT_EQ((int16_t)indexval,refind[this->refOffset]); 204 205 } 206 test_mean_f16()207 void StatsTestsF16::test_mean_f16() 208 { 209 const float16_t *inp = inputA.ptr(); 210 211 float16_t result; 212 213 float16_t *refp = ref.ptr(); 214 215 float16_t *outp = output.ptr(); 216 217 arm_mean_f16(inp, 218 inputA.nbSamples(), 219 &result); 220 221 outp[0] = result; 222 223 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 224 225 ASSERT_REL_ERROR(result,refp[this->refOffset],REL_ERROR); 226 227 } 228 test_power_f16()229 void StatsTestsF16::test_power_f16() 230 { 231 const float16_t *inp = inputA.ptr(); 232 233 float16_t result; 234 235 float16_t *refp = ref.ptr(); 236 237 float16_t *outp = output.ptr(); 238 239 arm_power_f16(inp, 240 inputA.nbSamples(), 241 &result); 242 243 outp[0] = result; 244 245 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 246 247 ASSERT_REL_ERROR(result,refp[this->refOffset],REL_ERROR); 248 249 } 250 test_rms_f16()251 void StatsTestsF16::test_rms_f16() 252 { 253 const float16_t *inp = inputA.ptr(); 254 255 float16_t result; 256 257 float16_t *refp = ref.ptr(); 258 259 float16_t *outp = output.ptr(); 260 261 arm_rms_f16(inp, 262 inputA.nbSamples(), 263 &result); 264 265 outp[0] = result; 266 267 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 268 269 ASSERT_REL_ERROR(result,refp[this->refOffset],REL_ERROR); 270 271 } 272 test_std_f16()273 void StatsTestsF16::test_std_f16() 274 { 275 const float16_t *inp = inputA.ptr(); 276 277 float16_t result; 278 279 float16_t *refp = ref.ptr(); 280 281 float16_t *outp = output.ptr(); 282 283 arm_std_f16(inp, 284 inputA.nbSamples(), 285 &result); 286 287 outp[0] = result; 288 289 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 290 291 ASSERT_REL_ERROR(result,refp[this->refOffset],REL_ERROR); 292 293 } 294 test_var_f16()295 void StatsTestsF16::test_var_f16() 296 { 297 const float16_t *inp = inputA.ptr(); 298 299 float16_t result; 300 301 float16_t *refp = ref.ptr(); 302 303 float16_t *outp = output.ptr(); 304 305 arm_var_f16(inp, 306 inputA.nbSamples(), 307 &result); 308 309 outp[0] = result; 310 311 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 312 313 ASSERT_REL_ERROR(result,refp[this->refOffset],REL_ERROR); 314 315 } 316 317 test_std_stability_f16()318 void StatsTestsF16::test_std_stability_f16() 319 { 320 /* 321 322 With the textbook algorithm, those values will produce a negative 323 value for the variance. 324 325 The CMSIS-DSP variance algorithm is the two pass one so will work 326 with those values. 327 328 So, it should be possible to compute the square root for the standard 329 deviation. 330 331 */ 332 float16_t in[4]={4.0f, 7.0f, 13.0f, 16.0f}; 333 float16_t result; 334 int i; 335 336 /* 337 338 Add bigger offset so that average is much bigger than standard deviation. 339 340 */ 341 for(i=0 ; i < 4; i++) 342 { 343 in[i] += 3.0e3f; 344 } 345 346 arm_std_f16(in,4,&result); 347 348 /* 349 350 If variance is giving a negative value, the square root 351 should return zero. 352 353 We check it is not happening here. 354 355 356 */ 357 ASSERT_TRUE(fabs(5.47723f - result) < 0.32f); 358 359 } 360 361 test_entropy_f16()362 void StatsTestsF16::test_entropy_f16() 363 { 364 const float16_t *inp = inputA.ptr(); 365 const int16_t *dimsp = dims.ptr(); 366 367 float16_t *outp = output.ptr(); 368 369 for(int i=0;i < this->nbPatterns; i++) 370 { 371 *outp = arm_entropy_f16(inp,dimsp[i+1]); 372 outp++; 373 inp += dimsp[i+1]; 374 } 375 376 ASSERT_SNR(ref,output,(float16_t)SNR_THRESHOLD); 377 378 ASSERT_REL_ERROR(ref,output,REL_ERROR); 379 380 } 381 test_logsumexp_f16()382 void StatsTestsF16::test_logsumexp_f16() 383 { 384 const float16_t *inp = inputA.ptr(); 385 const int16_t *dimsp = dims.ptr(); 386 387 float16_t *outp = output.ptr(); 388 389 for(int i=0;i < this->nbPatterns; i++) 390 { 391 *outp = arm_logsumexp_f16(inp,dimsp[i+1]); 392 outp++; 393 inp += dimsp[i+1]; 394 } 395 396 ASSERT_SNR(ref,output,(float16_t)SNR_THRESHOLD); 397 398 ASSERT_REL_ERROR(ref,output,REL_ERROR); 399 } 400 401 test_kullback_leibler_f16()402 void StatsTestsF16::test_kullback_leibler_f16() 403 { 404 const float16_t *inpA = inputA.ptr(); 405 const float16_t *inpB = inputB.ptr(); 406 const int16_t *dimsp = dims.ptr(); 407 408 float16_t *outp = output.ptr(); 409 410 for(int i=0;i < this->nbPatterns; i++) 411 { 412 *outp = arm_kullback_leibler_f16(inpA,inpB,dimsp[i+1]); 413 outp++; 414 inpA += dimsp[i+1]; 415 inpB += dimsp[i+1]; 416 } 417 418 ASSERT_SNR(ref,output,(float16_t)SNR_KULLBACK_THRESHOLD); 419 420 ASSERT_CLOSE_ERROR(ref,output,ABS_KULLBACK_ERROR,REL_KULLBACK_ERROR); 421 } 422 test_logsumexp_dot_prod_f16()423 void StatsTestsF16::test_logsumexp_dot_prod_f16() 424 { 425 const float16_t *inpA = inputA.ptr(); 426 const float16_t *inpB = inputB.ptr(); 427 const int16_t *dimsp = dims.ptr(); 428 429 float16_t *outp = output.ptr(); 430 float16_t *tmpp = tmp.ptr(); 431 432 for(int i=0;i < this->nbPatterns; i++) 433 { 434 *outp = arm_logsumexp_dot_prod_f16(inpA,inpB,dimsp[i+1],tmpp); 435 outp++; 436 inpA += dimsp[i+1]; 437 inpB += dimsp[i+1]; 438 } 439 440 ASSERT_SNR(ref,output,(float16_t)SNR_THRESHOLD); 441 442 ASSERT_REL_ERROR(ref,output,REL_ERROR); 443 } 444 test_mse_f16()445 void StatsTestsF16::test_mse_f16() 446 { 447 const float16_t *inpA = inputA.ptr(); 448 const float16_t *inpB = inputB.ptr(); 449 450 float16_t result; 451 452 float16_t *refp = ref.ptr(); 453 454 float16_t *outp = output.ptr(); 455 456 arm_mse_f16(inpA,inpB, 457 inputA.nbSamples(), 458 &result); 459 460 outp[0] = result; 461 462 ASSERT_SNR(result,refp[this->refOffset],(float16_t)SNR_THRESHOLD); 463 464 ASSERT_REL_ERROR(result,refp[this->refOffset],(float16_t)REL_ERROR); 465 466 } 467 test_accumulate_f16()468 void StatsTestsF16::test_accumulate_f16() 469 { 470 const float16_t *inp = inputA.ptr(); 471 const int16_t *dimsp = dims.ptr(); 472 473 float16_t *outp = output.ptr(); 474 475 for(int i=0;i < this->nbPatterns; i++) 476 { 477 arm_accumulate_f16(inp,dimsp[i+1],outp); 478 outp++; 479 } 480 481 ASSERT_SNR(ref,output,(float16_t)SNR_THRESHOLD); 482 483 ASSERT_REL_ERROR(ref,output,REL_ERROR_ACCUMULATE); 484 485 } 486 setUp(Testing::testID_t id,std::vector<Testing::param_t> & paramsArgs,Client::PatternMgr * mgr)487 void StatsTestsF16::setUp(Testing::testID_t id,std::vector<Testing::param_t>& paramsArgs,Client::PatternMgr *mgr) 488 { 489 (void)paramsArgs; 490 switch(id) 491 { 492 case StatsTestsF16::TEST_MAX_F16_1: 493 { 494 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 495 496 maxIndexes.reload(StatsTestsF16::MAXINDEXES_S16_ID,mgr); 497 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 498 499 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 500 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 501 502 refOffset = 0; 503 } 504 break; 505 506 case StatsTestsF16::TEST_MAX_F16_2: 507 { 508 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 509 510 maxIndexes.reload(StatsTestsF16::MAXINDEXES_S16_ID,mgr); 511 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 512 513 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 514 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 515 516 refOffset = 1; 517 } 518 break; 519 520 case StatsTestsF16::TEST_MAX_F16_3: 521 { 522 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 523 524 maxIndexes.reload(StatsTestsF16::MAXINDEXES_S16_ID,mgr); 525 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 526 527 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 528 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 529 530 refOffset = 2; 531 } 532 break; 533 534 case StatsTestsF16::TEST_MEAN_F16_4: 535 { 536 inputA.reload(StatsTestsF16::INPUT2_F16_ID,mgr,7); 537 538 ref.reload(StatsTestsF16::MEANVALS_F16_ID,mgr); 539 540 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 541 542 refOffset = 0; 543 } 544 break; 545 546 case StatsTestsF16::TEST_MEAN_F16_5: 547 { 548 inputA.reload(StatsTestsF16::INPUT2_F16_ID,mgr,16); 549 550 ref.reload(StatsTestsF16::MEANVALS_F16_ID,mgr); 551 552 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 553 554 refOffset = 1; 555 } 556 break; 557 558 case StatsTestsF16::TEST_MEAN_F16_6: 559 { 560 inputA.reload(StatsTestsF16::INPUT2_F16_ID,mgr,23); 561 562 ref.reload(StatsTestsF16::MEANVALS_F16_ID,mgr); 563 564 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 565 566 refOffset = 2; 567 } 568 break; 569 570 case StatsTestsF16::TEST_MIN_F16_7: 571 { 572 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 573 574 minIndexes.reload(StatsTestsF16::MININDEXES_S16_ID,mgr); 575 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 576 577 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 578 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 579 580 refOffset = 0; 581 } 582 break; 583 584 case StatsTestsF16::TEST_MIN_F16_8: 585 { 586 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 587 588 minIndexes.reload(StatsTestsF16::MININDEXES_S16_ID,mgr); 589 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 590 591 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 592 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 593 594 refOffset = 1; 595 } 596 break; 597 598 case StatsTestsF16::TEST_MIN_F16_9: 599 { 600 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 601 602 minIndexes.reload(StatsTestsF16::MININDEXES_S16_ID,mgr); 603 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 604 605 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 606 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 607 608 refOffset = 2; 609 } 610 break; 611 612 case StatsTestsF16::TEST_POWER_F16_10: 613 { 614 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 615 616 ref.reload(StatsTestsF16::POWERVALS_F16_ID,mgr); 617 618 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 619 620 refOffset = 0; 621 } 622 break; 623 624 case StatsTestsF16::TEST_POWER_F16_11: 625 { 626 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 627 628 ref.reload(StatsTestsF16::POWERVALS_F16_ID,mgr); 629 630 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 631 632 refOffset = 1; 633 } 634 break; 635 636 case StatsTestsF16::TEST_POWER_F16_12: 637 { 638 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 639 640 ref.reload(StatsTestsF16::POWERVALS_F16_ID,mgr); 641 642 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 643 644 refOffset = 2; 645 } 646 break; 647 648 case StatsTestsF16::TEST_RMS_F16_13: 649 { 650 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 651 652 ref.reload(StatsTestsF16::RMSVALS_F16_ID,mgr); 653 654 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 655 656 refOffset = 0; 657 } 658 break; 659 660 case StatsTestsF16::TEST_RMS_F16_14: 661 { 662 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 663 664 ref.reload(StatsTestsF16::RMSVALS_F16_ID,mgr); 665 666 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 667 668 refOffset = 1; 669 } 670 break; 671 672 case StatsTestsF16::TEST_RMS_F16_15: 673 { 674 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 675 676 ref.reload(StatsTestsF16::RMSVALS_F16_ID,mgr); 677 678 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 679 680 refOffset = 2; 681 } 682 break; 683 684 case StatsTestsF16::TEST_STD_F16_16: 685 { 686 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 687 688 ref.reload(StatsTestsF16::STDVALS_F16_ID,mgr); 689 690 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 691 692 refOffset = 0; 693 } 694 break; 695 696 case StatsTestsF16::TEST_STD_F16_17: 697 { 698 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 699 700 ref.reload(StatsTestsF16::STDVALS_F16_ID,mgr); 701 702 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 703 704 refOffset = 1; 705 } 706 break; 707 708 case StatsTestsF16::TEST_STD_F16_18: 709 { 710 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 711 712 ref.reload(StatsTestsF16::STDVALS_F16_ID,mgr); 713 714 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 715 716 refOffset = 2; 717 } 718 break; 719 720 case StatsTestsF16::TEST_VAR_F16_19: 721 { 722 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 723 724 ref.reload(StatsTestsF16::VARVALS_F16_ID,mgr); 725 726 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 727 728 refOffset = 0; 729 } 730 break; 731 732 case StatsTestsF16::TEST_VAR_F16_20: 733 { 734 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 735 736 ref.reload(StatsTestsF16::VARVALS_F16_ID,mgr); 737 738 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 739 740 refOffset = 1; 741 } 742 break; 743 744 case StatsTestsF16::TEST_VAR_F16_21: 745 { 746 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 747 748 ref.reload(StatsTestsF16::VARVALS_F16_ID,mgr); 749 750 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 751 752 refOffset = 2; 753 } 754 break; 755 756 case StatsTestsF16::TEST_ENTROPY_F16_22: 757 { 758 inputA.reload(StatsTestsF16::INPUT22_F16_ID,mgr); 759 dims.reload(StatsTestsF16::DIM22_S16_ID,mgr); 760 ref.reload(StatsTestsF16::REF22_ENTROPY_F16_ID,mgr); 761 output.create(ref.nbSamples(),StatsTestsF16::OUT_F16_ID,mgr); 762 763 const int16_t *dimsp = dims.ptr(); 764 this->nbPatterns=dimsp[0]; 765 } 766 break; 767 768 case StatsTestsF16::TEST_LOGSUMEXP_F16_23: 769 { 770 inputA.reload(StatsTestsF16::INPUT23_F16_ID,mgr); 771 dims.reload(StatsTestsF16::DIM23_S16_ID,mgr); 772 ref.reload(StatsTestsF16::REF23_LOGSUMEXP_F16_ID,mgr); 773 output.create(ref.nbSamples(),StatsTestsF16::OUT_F16_ID,mgr); 774 775 const int16_t *dimsp = dims.ptr(); 776 this->nbPatterns=dimsp[0]; 777 } 778 break; 779 780 case StatsTestsF16::TEST_KULLBACK_LEIBLER_F16_24: 781 { 782 inputA.reload(StatsTestsF16::INPUTA24_F16_ID,mgr); 783 inputB.reload(StatsTestsF16::INPUTB24_F16_ID,mgr); 784 dims.reload(StatsTestsF16::DIM24_S16_ID,mgr); 785 ref.reload(StatsTestsF16::REF24_KL_F16_ID,mgr); 786 output.create(ref.nbSamples(),StatsTestsF16::OUT_F16_ID,mgr); 787 788 const int16_t *dimsp = dims.ptr(); 789 this->nbPatterns=dimsp[0]; 790 } 791 break; 792 793 case StatsTestsF16::TEST_LOGSUMEXP_DOT_PROD_F16_25: 794 { 795 inputA.reload(StatsTestsF16::INPUTA25_F16_ID,mgr); 796 inputB.reload(StatsTestsF16::INPUTB25_F16_ID,mgr); 797 dims.reload(StatsTestsF16::DIM25_S16_ID,mgr); 798 ref.reload(StatsTestsF16::REF25_LOGSUMEXP_DOT_F16_ID,mgr); 799 output.create(ref.nbSamples(),StatsTestsF16::OUT_F16_ID,mgr); 800 801 const int16_t *dimsp = dims.ptr(); 802 this->nbPatterns=dimsp[0]; 803 804 /* 12 is max vecDim as defined in Python script generating the data */ 805 tmp.create(12,StatsTestsF16::TMP_F16_ID,mgr); 806 } 807 break; 808 809 case StatsTestsF16::TEST_MAX_NO_IDX_F16_26: 810 { 811 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 812 813 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 814 815 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 816 817 refOffset = 0; 818 } 819 break; 820 821 case StatsTestsF16::TEST_MAX_NO_IDX_F16_27: 822 { 823 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 824 825 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 826 827 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 828 829 refOffset = 1; 830 } 831 break; 832 833 case StatsTestsF16::TEST_MAX_NO_IDX_F16_28: 834 { 835 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 836 837 ref.reload(StatsTestsF16::MAXVALS_F16_ID,mgr); 838 839 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 840 841 refOffset = 2; 842 } 843 break; 844 845 case TEST_MEAN_F16_29: 846 inputA.reload(StatsTestsF16::INPUT2_F16_ID,mgr,100); 847 848 ref.reload(StatsTestsF16::MEANVALS_F16_ID,mgr); 849 850 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 851 852 refOffset = 3; 853 break; 854 855 case TEST_RMS_F16_30: 856 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,100); 857 858 ref.reload(StatsTestsF16::RMSVALS_F16_ID,mgr); 859 860 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 861 862 refOffset = 3; 863 break; 864 865 case TEST_STD_F16_31: 866 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,100); 867 868 ref.reload(StatsTestsF16::STDVALS_F16_ID,mgr); 869 870 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 871 872 refOffset = 3; 873 break; 874 875 case TEST_VAR_F16_32: 876 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,100); 877 878 ref.reload(StatsTestsF16::VARVALS_F16_ID,mgr); 879 880 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 881 882 refOffset = 3; 883 break; 884 885 case StatsTestsF16::TEST_ABSMAX_F16_34: 886 { 887 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,7); 888 889 maxIndexes.reload(StatsTestsF16::ABSMAXINDEXES_S16_ID,mgr); 890 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 891 892 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 893 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 894 895 refOffset = 0; 896 } 897 break; 898 899 case StatsTestsF16::TEST_ABSMAX_F16_35: 900 { 901 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,16); 902 903 maxIndexes.reload(StatsTestsF16::ABSMAXINDEXES_S16_ID,mgr); 904 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 905 906 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 907 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 908 909 refOffset = 1; 910 } 911 break; 912 913 case StatsTestsF16::TEST_ABSMAX_F16_36: 914 { 915 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,23); 916 917 maxIndexes.reload(StatsTestsF16::ABSMAXINDEXES_S16_ID,mgr); 918 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 919 920 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 921 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 922 923 refOffset = 2; 924 } 925 break; 926 927 case StatsTestsF16::TEST_ABSMIN_F16_37: 928 { 929 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,7); 930 931 minIndexes.reload(StatsTestsF16::ABSMININDEXES_S16_ID,mgr); 932 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 933 934 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 935 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 936 937 refOffset = 0; 938 } 939 break; 940 941 case StatsTestsF16::TEST_ABSMIN_F16_38: 942 { 943 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,16); 944 945 minIndexes.reload(StatsTestsF16::ABSMININDEXES_S16_ID,mgr); 946 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 947 948 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 949 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 950 951 refOffset = 1; 952 } 953 break; 954 955 case StatsTestsF16::TEST_ABSMIN_F16_39: 956 { 957 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,23); 958 959 minIndexes.reload(StatsTestsF16::ABSMININDEXES_S16_ID,mgr); 960 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 961 962 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 963 index.create(1,StatsTestsF16::OUT_S16_ID,mgr); 964 965 refOffset = 2; 966 } 967 break; 968 969 case StatsTestsF16::TEST_MIN_NO_IDX_F16_40: 970 { 971 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,7); 972 973 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 974 975 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 976 977 refOffset = 0; 978 } 979 break; 980 981 case StatsTestsF16::TEST_MIN_NO_IDX_F16_41: 982 { 983 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,16); 984 985 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 986 987 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 988 989 refOffset = 1; 990 } 991 break; 992 993 case StatsTestsF16::TEST_MIN_NO_IDX_F16_42: 994 { 995 inputA.reload(StatsTestsF16::INPUT1_F16_ID,mgr,23); 996 997 ref.reload(StatsTestsF16::MINVALS_F16_ID,mgr); 998 999 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1000 1001 refOffset = 2; 1002 } 1003 break; 1004 1005 case StatsTestsF16::TEST_ABSMAX_NO_IDX_F16_43: 1006 { 1007 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,7); 1008 1009 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 1010 1011 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1012 1013 refOffset = 0; 1014 } 1015 break; 1016 1017 case StatsTestsF16::TEST_ABSMAX_NO_IDX_F16_44: 1018 { 1019 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,16); 1020 1021 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 1022 1023 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1024 1025 refOffset = 1; 1026 } 1027 break; 1028 1029 case StatsTestsF16::TEST_ABSMAX_NO_IDX_F16_45: 1030 { 1031 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,23); 1032 1033 ref.reload(StatsTestsF16::ABSMAXVALS_F16_ID,mgr); 1034 1035 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1036 1037 refOffset = 2; 1038 } 1039 break; 1040 1041 case StatsTestsF16::TEST_ABSMIN_NO_IDX_F16_46: 1042 { 1043 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,7); 1044 1045 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 1046 1047 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1048 1049 refOffset = 0; 1050 } 1051 break; 1052 1053 case StatsTestsF16::TEST_ABSMIN_NO_IDX_F16_47: 1054 { 1055 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,16); 1056 1057 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 1058 1059 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1060 1061 refOffset = 1; 1062 } 1063 break; 1064 1065 case StatsTestsF16::TEST_ABSMIN_NO_IDX_F16_48: 1066 { 1067 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,23); 1068 1069 ref.reload(StatsTestsF16::ABSMINVALS_F16_ID,mgr); 1070 1071 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1072 1073 refOffset = 2; 1074 } 1075 break; 1076 1077 case StatsTestsF16::TEST_MSE_F16_49: 1078 { 1079 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,7); 1080 inputB.reload(StatsTestsF16::INPUTNEW2_F16_ID,mgr,7); 1081 1082 ref.reload(StatsTestsF16::MSE_F16_ID,mgr); 1083 1084 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1085 1086 refOffset = 0; 1087 } 1088 break; 1089 1090 case StatsTestsF16::TEST_MSE_F16_50: 1091 { 1092 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,16); 1093 inputB.reload(StatsTestsF16::INPUTNEW2_F16_ID,mgr,16); 1094 1095 ref.reload(StatsTestsF16::MSE_F16_ID,mgr); 1096 1097 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1098 1099 refOffset = 1; 1100 } 1101 break; 1102 1103 case StatsTestsF16::TEST_MSE_F16_51: 1104 { 1105 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,23); 1106 inputB.reload(StatsTestsF16::INPUTNEW2_F16_ID,mgr,23); 1107 1108 ref.reload(StatsTestsF16::MSE_F16_ID,mgr); 1109 1110 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1111 1112 refOffset = 2; 1113 } 1114 break; 1115 1116 case StatsTestsF16::TEST_MSE_F16_52: 1117 { 1118 inputA.reload(StatsTestsF16::INPUTNEW1_F16_ID,mgr,100); 1119 inputB.reload(StatsTestsF16::INPUTNEW2_F16_ID,mgr,100); 1120 1121 ref.reload(StatsTestsF16::MSE_F16_ID,mgr); 1122 1123 output.create(1,StatsTestsF16::OUT_F16_ID,mgr); 1124 1125 refOffset = 3; 1126 } 1127 break; 1128 1129 case StatsTestsF16::TEST_ACCUMULATE_F16_53: 1130 { 1131 inputA.reload(StatsTestsF16::INPUT_ACCUMULATE_F16_ID,mgr); 1132 ref.reload(StatsTestsF16::REF_ACCUMULATE_F16_ID,mgr); 1133 dims.reload(StatsTestsF16::INPUT_ACCUMULATE_CONFIG_S16_ID,mgr); 1134 output.create(ref.nbSamples(),StatsTestsF16::OUT_F16_ID,mgr); 1135 1136 const int16_t *dimsp = dims.ptr(); 1137 this->nbPatterns=dimsp[0]; 1138 1139 1140 } 1141 break; 1142 } 1143 1144 } 1145 tearDown(Testing::testID_t id,Client::PatternMgr * mgr)1146 void StatsTestsF16::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) 1147 { 1148 (void)id; 1149 switch(id) 1150 { 1151 case StatsTestsF16::TEST_MAX_F16_1: 1152 case StatsTestsF16::TEST_MAX_F16_2: 1153 case StatsTestsF16::TEST_MAX_F16_3: 1154 case StatsTestsF16::TEST_MIN_F16_7: 1155 case StatsTestsF16::TEST_MIN_F16_8: 1156 case StatsTestsF16::TEST_MIN_F16_9: 1157 index.dump(mgr); 1158 output.dump(mgr); 1159 break; 1160 1161 default: 1162 output.dump(mgr); 1163 } 1164 } 1165