BinaryTestsF64.cpp 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. #include "BinaryTestsF64.h"
  2. #include <stdio.h>
  3. #include "Error.h"
  4. #define SNR_THRESHOLD 120
  5. /*
  6. Reference patterns are generated with
  7. a double precision computation.
  8. */
  9. #define REL_ERROR (1.0e-6)
  10. #define ABS_ERROR (1.0e-5)
  11. /* Upper bound of maximum matrix dimension used by Python */
  12. #define MAXMATRIXDIM 40
  13. #define LOADDATA2() \
  14. const float64_t *inp1=input1.ptr(); \
  15. const float64_t *inp2=input2.ptr(); \
  16. \
  17. float64_t *ap=a.ptr(); \
  18. float64_t *bp=b.ptr(); \
  19. \
  20. float64_t *outp=output.ptr(); \
  21. int16_t *dimsp = dims.ptr(); \
  22. int nbMatrixes = dims.nbSamples() / 3;\
  23. int rows,internal,columns; \
  24. int i;
  25. #define PREPAREDATA2() \
  26. in1.numRows=rows; \
  27. in1.numCols=internal; \
  28. memcpy((void*)ap,(const void*)inp1,2*sizeof(float64_t)*rows*internal);\
  29. in1.pData = ap; \
  30. \
  31. in2.numRows=internal; \
  32. in2.numCols=columns; \
  33. memcpy((void*)bp,(const void*)inp2,2*sizeof(float64_t)*internal*columns);\
  34. in2.pData = bp; \
  35. \
  36. out.numRows=rows; \
  37. out.numCols=columns; \
  38. out.pData = outp;
  39. void BinaryTestsF64::test_mat_mult_f64()
  40. {
  41. LOADDATA2();
  42. for(i=0;i < nbMatrixes ; i ++)
  43. {
  44. rows = *dimsp++;
  45. internal = *dimsp++;
  46. columns = *dimsp++;
  47. PREPAREDATA2();
  48. arm_mat_mult_f64(&this->in1,&this->in2,&this->out);
  49. outp += (rows * columns);
  50. }
  51. ASSERT_EMPTY_TAIL(output);
  52. ASSERT_SNR(output,ref,(float64_t)SNR_THRESHOLD);
  53. ASSERT_CLOSE_ERROR(output,ref,ABS_ERROR,REL_ERROR);
  54. }
  55. #if 0
  56. void BinaryTestsF64::test_mat_cmplx_mult_f64()
  57. {
  58. LOADDATA2();
  59. for(i=0;i < nbMatrixes ; i ++)
  60. {
  61. rows = *dimsp++;
  62. internal = *dimsp++;
  63. columns = *dimsp++;
  64. PREPAREDATA2();
  65. arm_mat_cmplx_mult_f64(&this->in1,&this->in2,&this->out);
  66. outp += (2*rows * columns);
  67. }
  68. ASSERT_EMPTY_TAIL(output);
  69. ASSERT_SNR(output,ref,(float64_t)SNR_THRESHOLD);
  70. ASSERT_CLOSE_ERROR(output,ref,ABS_ERROR,REL_ERROR);
  71. }
  72. #endif
  73. void BinaryTestsF64::setUp(Testing::testID_t id,std::vector<Testing::param_t>& params,Client::PatternMgr *mgr)
  74. {
  75. (void)params;
  76. switch(id)
  77. {
  78. case TEST_MAT_MULT_F64_1:
  79. input1.reload(BinaryTestsF64::INPUTS1_F64_ID,mgr);
  80. input2.reload(BinaryTestsF64::INPUTS2_F64_ID,mgr);
  81. dims.reload(BinaryTestsF64::DIMSBINARY1_S16_ID,mgr);
  82. ref.reload(BinaryTestsF64::REFMUL1_F64_ID,mgr);
  83. output.create(ref.nbSamples(),BinaryTestsF64::OUT_F64_ID,mgr);
  84. a.create(MAXMATRIXDIM*MAXMATRIXDIM,BinaryTestsF64::TMPA_F64_ID,mgr);
  85. b.create(MAXMATRIXDIM*MAXMATRIXDIM,BinaryTestsF64::TMPB_F64_ID,mgr);
  86. break;
  87. #if 0
  88. case TEST_MAT_CMPLX_MULT_F64_2:
  89. input1.reload(BinaryTestsF64::INPUTSC1_F64_ID,mgr);
  90. input2.reload(BinaryTestsF64::INPUTSC2_F64_ID,mgr);
  91. dims.reload(BinaryTestsF64::DIMSBINARY1_S16_ID,mgr);
  92. ref.reload(BinaryTestsF64::REFCMPLXMUL1_F64_ID,mgr);
  93. output.create(ref.nbSamples(),BinaryTestsF64::OUT_F64_ID,mgr);
  94. a.create(2*MAXMATRIXDIM*MAXMATRIXDIM,BinaryTestsF64::TMPA_F64_ID,mgr);
  95. b.create(2*MAXMATRIXDIM*MAXMATRIXDIM,BinaryTestsF64::TMPB_F64_ID,mgr);
  96. break;
  97. #endif
  98. }
  99. }
  100. void BinaryTestsF64::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
  101. {
  102. (void)id;
  103. output.dump(mgr);
  104. }