From a435c758dcf888fcfd5f7294f92b19a4360a64ab Mon Sep 17 00:00:00 2001 From: Christophe Favergeon Date: Fri, 26 Jul 2019 15:28:41 +0200 Subject: [PATCH] CMSIS-NN: Added optimized version of arm_avgpool_s8 --- Testing/GeneratedInclude/Pooling_decl.h | 2 ++ Testing/GeneratedInclude/TestDrive.h | 4 +++- Testing/Include/Pooling.h | 2 ++ Testing/Source/Pooling.cpp | 15 ++++++++++++--- Testing/TestDesc.txt | 4 +++- Testing/desc.txt | 2 ++ 6 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Testing/GeneratedInclude/Pooling_decl.h b/Testing/GeneratedInclude/Pooling_decl.h index 6ad83afb..caa8fbf5 100755 --- a/Testing/GeneratedInclude/Pooling_decl.h +++ b/Testing/GeneratedInclude/Pooling_decl.h @@ -20,6 +20,8 @@ static const int REF8_S8_ID=15; // Output IDs static const int OUTPUT_S8_ID=0; +static const int TEMP_S8_ID=1; +static const int TEMPINPUT_S8_ID=2; // Test IDs static const int TEST_AVGPOOL_S8_1=1; diff --git a/Testing/GeneratedInclude/TestDrive.h b/Testing/GeneratedInclude/TestDrive.h index 8ac99a4c..9491951c 100644 --- a/Testing/GeneratedInclude/TestDrive.h +++ b/Testing/GeneratedInclude/TestDrive.h @@ -44,8 +44,10 @@ __ALIGNED(8) const char testDesc[]={ 129,15,0,0, 224,19,0,0, 1,0,0,0, -1,0,0,0, +3,0,0,0, 'O','u','t','p','u','t','\0', +'T','e','m','p','\0', +'T','e','m','p','I','n','p','u','t','\0', 0,0,0,0, 1,0,0,0, 1,0,0,0, diff --git a/Testing/Include/Pooling.h b/Testing/Include/Pooling.h index 379cc9e4..c189b8ad 100755 --- a/Testing/Include/Pooling.h +++ b/Testing/Include/Pooling.h @@ -11,7 +11,9 @@ class Pooling:public Client::Suite Client::Pattern input; + Client::LocalPattern tmpInput; Client::LocalPattern output; + Client::LocalPattern temp; // Reference patterns are not loaded when we are in dump mode Client::RefPattern ref; diff --git a/Testing/Source/Pooling.cpp b/Testing/Source/Pooling.cpp index 68cdd84c..a1bd9f50 100755 --- a/Testing/Source/Pooling.cpp +++ b/Testing/Source/Pooling.cpp @@ -9,7 +9,11 @@ void Pooling::test_avgpool_s8() { const q7_t *inp = input.ptr(); + q7_t *tmpin = tmpInput.ptr(); q7_t *outp = output.ptr(); + q15_t *tempp = temp.ptr(); + + memcpy(tmpin,inp,input.nbSamples()); arm_avgpool_s8( DIM_IN_Y, @@ -25,7 +29,8 @@ ACT_MIN, ACT_MAX, IN_CHANNEL, - inp, + tmpin, + tempp, outp); ASSERT_EQ(ref,output); @@ -194,8 +199,12 @@ } - - output.create(ref.nbSamples(),Pooling::OUTPUT_S8_ID,mgr); + temp.create(this->DIM_OUT_X * this->IN_CHANNEL,Pooling::TEMP_S8_ID,mgr); + + output.create(ref.nbSamples(),Pooling::OUTPUT_S8_ID,mgr); + tmpInput.create(input.nbSamples(),Pooling::TEMPINPUT_S8_ID,mgr); + + } diff --git a/Testing/TestDesc.txt b/Testing/TestDesc.txt index a5cc8952..b4c03742 100644 --- a/Testing/TestDesc.txt +++ b/Testing/TestDesc.txt @@ -27,8 +27,10 @@ Input7.txt Ref7.txt Input8.txt Ref8.txt -1 +3 Output +Temp +TempInput 0 1 1 n diff --git a/Testing/desc.txt b/Testing/desc.txt index 529554d1..c5b7ee62 100644 --- a/Testing/desc.txt +++ b/Testing/desc.txt @@ -627,6 +627,8 @@ group Root { Pattern REF8_S8_ID : Ref8.txt Output OUTPUT_S8_ID : Output + Output TEMP_S8_ID : Temp + Output TEMPINPUT_S8_ID : TempInput Functions { arm_avgpool_s8 Test 1:test_avgpool_s8