CMSIS-NN: Optimized version of original arm_softmax_q7 function.

pull/19/head
Christophe Favergeon 6 years ago
parent 780a7ce3d9
commit 56bd14f436

@ -5,7 +5,7 @@ import random
import numpy as np
import scipy.special as sp
NBTESTSAMPLES = 100
NBTESTSAMPLES = 500
def softmax(v):
m = sp.softmax(v)
@ -46,7 +46,7 @@ def writeTest(config,nb,vecDim):
def writeTests(config):
writeTest(config,1,15)
writeTest(config,1,20)
PATTERNDIR = os.path.join("Patterns","NN","Softmax",)

@ -1,6 +1,6 @@
H
2
// 100
0x0064
// 15
0x000F
// 500
0x01F4
// 20
0x0014

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -57,11 +57,13 @@ int16_t differences(int16_t *pa,int16_t *pb, int length)
*pOut++ = maxIndex;
vec_in += this->vecDim;
pTmp += this->vecDim;
}
int diff = differences(ref.ptr(),output.ptr(),this->nbSamples);
// 5% of errors are accepted
ASSERT_TRUE(100.0*diff/this->nbSamples <= 5);
//printf("diffs = %d\n",diff);
// 6% of errors are accepted for 20 entry samples
ASSERT_TRUE(100.0*diff/this->nbSamples <= 6);
}
@ -85,13 +87,17 @@ int16_t differences(int16_t *pa,int16_t *pb, int length)
}
output.create(ref.nbSamples(),Softmax::OUTPUT_S16_ID,mgr);
temp.create(this->vecDim,Softmax::TEMP_Q7_ID,mgr);
// Used to compare bit exactness of the reference C version
// and the optimized version.
temp.create(this->vecDim*this->nbSamples,Softmax::TEMP_Q7_ID,mgr);
}
void Softmax::tearDown(Testing::testID_t id,Client::PatternMgr *mgr)
{
output.dump(mgr);
// Array are big so by default they are not dumped and only
// used for debug.
//output.dump(mgr);
//temp.dump(mgr);
}

Loading…
Cancel
Save