From efcc87d9503329802fb4dfbbb08940390af1749a Mon Sep 17 00:00:00 2001 From: Christophe Favergeon Date: Tue, 10 Sep 2019 09:34:16 +0100 Subject: [PATCH] CMSIS-NN: Helium version of arm_avgpool_s8 --- .../Include/Benchmarks/FullyConnectedBench.h | 14 +++- .../Source/Benchmarks/FullyConnectedBench.cpp | 81 ++++++++++--------- Testing/Source/Benchmarks/PoolingBench.cpp | 4 +- Testing/bench.txt | 13 ++- 4 files changed, 64 insertions(+), 48 deletions(-) diff --git a/Testing/Include/Benchmarks/FullyConnectedBench.h b/Testing/Include/Benchmarks/FullyConnectedBench.h index 91847004..8ceca4e7 100644 --- a/Testing/Include/Benchmarks/FullyConnectedBench.h +++ b/Testing/Include/Benchmarks/FullyConnectedBench.h @@ -24,4 +24,16 @@ class FullyConnectedBench:public Client::Suite q7_t *outp; q7_t *refp; q15_t *tempp; - }; + + int32_t output_mult = 1073741824; + int16_t output_shift = -1; + int32_t filter_offset = 1; + int32_t input_offset = 1; + int32_t output_offset = -1; + int32_t act_min =-128; + int32_t act_max= 127; + int32_t nb_batches=1; + int32_t rowDim; + int32_t colDim; + + }; \ No newline at end of file diff --git a/Testing/Source/Benchmarks/FullyConnectedBench.cpp b/Testing/Source/Benchmarks/FullyConnectedBench.cpp index 2107c156..79f10f79 100644 --- a/Testing/Source/Benchmarks/FullyConnectedBench.cpp +++ b/Testing/Source/Benchmarks/FullyConnectedBench.cpp @@ -5,33 +5,24 @@ void FullyConnectedBench::test_fully_connected_tflite_s8() { - - int32_t output_mult = 1073741824; - int16_t output_shift = -1; - int32_t filter_offset = 1; - int32_t input_offset = 1; - int32_t output_offset = -1; - - - - for(int i=0; i < this->repeatNb; i++) + for(int i=0; i < this->repeatNb; i++) { - arm_fully_connected_s8((int8_t*)inp - ,(const int8_t*)weightp - ,input.nbSamples() - ,output.nbSamples() - ,1 - ,input_offset - ,filter_offset - ,output_mult - ,output_shift - ,output_offset - ,(const int32_t*)biasp - ,(int8_t*)outp - ,-128 - ,127 - ,tempp - ); + arm_fully_connected_s8((int8_t*)this->inp + ,(const int8_t*)this->weightp + ,colDim + ,rowDim + ,nb_batches + ,input_offset + ,filter_offset + ,output_mult + ,output_shift + ,output_offset + ,(const int32_t*)this->biasp + ,(int8_t*)this->outp + ,act_min + ,act_max + ,this->tempp + ); } } @@ -45,23 +36,35 @@ this->repeatNb = *it; - input.reload(FullyConnectedBench::INPUT1_S8_ID,mgr); - bias.reload(FullyConnectedBench::BIAS1_S8_ID,mgr); - weight.reload(FullyConnectedBench::WEIGHT1_S8_ID,mgr); + output_mult = 1077969154; + output_shift = 2; + filter_offset = 0; + input_offset = 0; + output_offset = 1; + act_min =-128; + act_max= 127; - ref.reload(FullyConnectedBench::REF1_S8_ID,mgr); + + nb_batches=8; - - output.create(ref.nbSamples(),FullyConnectedBench::OUTPUT_S8_ID,mgr); - temp.create(input.nbSamples(),FullyConnectedBench::TEMP_S16_ID,mgr); + colDim=8; + rowDim=5; + + input.reload(FullyConnectedBench::INPUT13_S8_ID,mgr); + bias.reload(FullyConnectedBench::BIAS13_S8_ID,mgr); + weight.reload(FullyConnectedBench::WEIGHT13_S8_ID,mgr); + + //ref.reload(FullyConnectedBench::REF13_S8_ID,mgr); - inp=input.ptr(); - biasp=bias.ptr(); - weightp=weight.ptr(); - outp=output.ptr(); - refp=ref.ptr(); - tempp=temp.ptr(); + output.create(ref.nbSamples(),FullyConnectedBench::OUTPUT_S8_ID,mgr); + temp.create(colDim,FullyConnectedBench::TEMP_S16_ID,mgr); + this->inp=input.ptr(); + this->biasp=bias.ptr(); + this->weightp=weight.ptr(); + this->outp=output.ptr(); + //this->refp=ref.ptr(); + this->tempp=temp.ptr(); } void FullyConnectedBench::tearDown(Testing::testID_t id,Client::PatternMgr *mgr) diff --git a/Testing/Source/Benchmarks/PoolingBench.cpp b/Testing/Source/Benchmarks/PoolingBench.cpp index fb68aad5..e39a297b 100755 --- a/Testing/Source/Benchmarks/PoolingBench.cpp +++ b/Testing/Source/Benchmarks/PoolingBench.cpp @@ -9,7 +9,7 @@ void PoolingBench::test_avgpool_s8() { - for(int i=0; i < this->repeatNb; i++) + //for(int i=0; i < this->repeatNb; i++) { arm_avgpool_s8( DIM_IN_Y, @@ -31,6 +31,8 @@ } + //ASSERT_EQ(this->ref,this->output); + } diff --git a/Testing/bench.txt b/Testing/bench.txt index 3adfe762..db1dd305 100755 --- a/Testing/bench.txt +++ b/Testing/bench.txt @@ -1425,17 +1425,16 @@ group Root { Formula "NB" } - Pattern INPUT1_S8_ID : TestCase_1_10_4_input_1.txt - Pattern BIAS1_S8_ID : TestCase_1_10_4_bias_1.txt - Pattern WEIGHT1_S8_ID : TestCase_1_10_4_weights_1.txt - - Pattern REF1_S8_ID : TestCase_1_10_4_output_1.txt + Pattern INPUT13_S8_ID : TestCase_8_8_5_input_13.txt + Pattern BIAS13_S8_ID : TestCase_8_8_5_bias_13.txt + Pattern WEIGHT13_S8_ID : TestCase_8_8_5_weights_13.txt + Pattern REF13_S8_ID : TestCase_8_8_5_output_13.txt Output OUTPUT_S8_ID : Output Output TEMP_S16_ID : Temp Params PARAM1_ID = { - NB = [10,20,100,200] + NB = [10,20,40,50] } Functions { @@ -1462,7 +1461,7 @@ group Root { Output TEMPINPUT_S8_ID : TempInput Params PARAM1_ID = { - NB = [10,20,100,200] + NB = [1] } Functions {