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