From 5f1561bc280f41d698513fae281dda3a29c793d3 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Wed, 8 Jan 2025 16:27:04 +0300 Subject: [PATCH 1/9] Add layer examples --- app/layer_example/CMakeLists.txt | 9 ++++++ app/layer_example/ConvolutionLayer.cpp | 40 ++++++++++++++++++++++++++ app/layer_example/ElementwiseLayer.cpp | 31 ++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 app/layer_example/CMakeLists.txt create mode 100644 app/layer_example/ConvolutionLayer.cpp create mode 100644 app/layer_example/ElementwiseLayer.cpp diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt new file mode 100644 index 0000000..8eec088 --- /dev/null +++ b/app/layer_example/CMakeLists.txt @@ -0,0 +1,9 @@ +set(ARM_DIR "/3rdparty/ComputeLibrary") + +include_directories(${ARM_DIR}/include) +link_directories(${ARM_DIR}/build) + +add_executable(ConvolutionLayer ConvolutionLayer.cpp) +add_executable(ElementwiseLayer ElementwiseLayer.cpp) + +target_link_libraries(ConvolutionLayer arm_compute) \ No newline at end of file diff --git a/app/layer_example/ConvolutionLayer.cpp b/app/layer_example/ConvolutionLayer.cpp new file mode 100644 index 0000000..377b320 --- /dev/null +++ b/app/layer_example/ConvolutionLayer.cpp @@ -0,0 +1,40 @@ +#include "../ComputeLibrary/arm_compute/runtime/NEON/NEFunctions.h" +#include "../ComputeLibrary/utils/Utils.h" + +#include +using namespace arm_compute; +using namespace utils; + +int main(){ + Tensor input; + Tensor weight; + Tensor bias; + Tensor output; + + const unsigned int N = 1; + const unsigned int Hin = 3; + const unsigned int Win = 3; + const unsigned int Cin = 1; + + const unsigned int Hf = 3; + const unsigned int Wf = 3; + + const unsigned int Hout = Hin - Hf + 1; + const unsigned int Wout = Win - Wf + 1; + const unsigned int Cout = 1; + + input.allocator()->init(TensorInfo(TensorShape(Hin, Win, Cin), 1, DataType::F32)); + weight.allocator()->init(TensorInfo(TensorShape(Hf, Wf, Cin, Cout), 1, DataType::F32)); + output.allocator()->init(TensorInfo(TensorShape(Hout, Wout, Cout), 1, DataType::F32)); + + input.allocator()->allocate(); + weight.allocator()->allocate(); + output.allocator()->allocate(); + + NEConvolutionLayer conv; + conv.configure(&input, &weight, nullptr, &output, PadStrideInfo(1, 1, 0, 0)); + + conv.run(); + + output.print(std::cout); +} \ No newline at end of file diff --git a/app/layer_example/ElementwiseLayer.cpp b/app/layer_example/ElementwiseLayer.cpp new file mode 100644 index 0000000..eeeb30d --- /dev/null +++ b/app/layer_example/ElementwiseLayer.cpp @@ -0,0 +1,31 @@ +#include "../ComputeLibrary/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" +#include "../ComputeLibrary/utils/Utils.h" + +#include +using namespace arm_compute; +using namespace utils; + +int main() { + const int input_width = 5; + const int input_height = 5; + + Tensor input1, input2, output; + + input1.allocator()->init(TensorInfo(TensorShape(input_width, input_height, 1), 1, DataType::F32)); + input2.allocator()->init(TensorInfo(TensorShape(input_width, input_height, 1), 1, DataType::F32)); + output.allocator()->init(TensorInfo(TensorShape(input_width, input_height, 1), 1, DataType::F32)); + + input1.allocator()->allocate(); + input2.allocator()->allocate(); + output.allocator()->allocate(); + + fill_random_tensor(input1, 0.f, 1.f); + fill_random_tensor(input2, 0.f, 1.f); + + NEElementwiseSquaredDiff elementwise; + elementwise.configure(&input1, &input2, &output); + + elementwise.run(); + + output.print(std::cout); +} From 58a016c3d4a0e8acb7d0363fd8ef0f4ffe0512fd Mon Sep 17 00:00:00 2001 From: chekalexey Date: Wed, 8 Jan 2025 18:09:40 +0300 Subject: [PATCH 2/9] Add layer examples --- app/CMakeLists.txt | 1 + app/example/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index a5c4dce..b704bc8 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory(example) +add_subdirectory(layer_example) \ No newline at end of file diff --git a/app/example/CMakeLists.txt b/app/example/CMakeLists.txt index 033d285..5ac1ad8 100644 --- a/app/example/CMakeLists.txt +++ b/app/example/CMakeLists.txt @@ -1 +1 @@ -add_executable(example main.cpp) +add_executable(example main.cpp) \ No newline at end of file From a19ca04da31733cfc523d07c51d320fe70aeebbf Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 11 Feb 2025 21:28:24 +0300 Subject: [PATCH 3/9] fixed --- app/layer_example/CMakeLists.txt | 7 ++++--- app/layer_example/ConvolutionLayer.cpp | 4 ++-- app/layer_example/ElementwiseLayer.cpp | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index 8eec088..b89ef42 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,9 +1,10 @@ -set(ARM_DIR "/3rdparty/ComputeLibrary") +set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -include_directories(${ARM_DIR}/include) +include_directories(${ARM_DIR}) link_directories(${ARM_DIR}/build) add_executable(ConvolutionLayer ConvolutionLayer.cpp) add_executable(ElementwiseLayer ElementwiseLayer.cpp) -target_link_libraries(ConvolutionLayer arm_compute) \ No newline at end of file +target_link_libraries(ConvolutionLayer arm_compute) +target_link_libraries(ElementwiseLayer arm_compute) \ No newline at end of file diff --git a/app/layer_example/ConvolutionLayer.cpp b/app/layer_example/ConvolutionLayer.cpp index 377b320..618629b 100644 --- a/app/layer_example/ConvolutionLayer.cpp +++ b/app/layer_example/ConvolutionLayer.cpp @@ -1,5 +1,5 @@ -#include "../ComputeLibrary/arm_compute/runtime/NEON/NEFunctions.h" -#include "../ComputeLibrary/utils/Utils.h" +#include "ComputeLibrary/arm_compute/runtime/NEON/NEFunctions.h" +#include "ComputeLibrary/utils/Utils.h" #include using namespace arm_compute; diff --git a/app/layer_example/ElementwiseLayer.cpp b/app/layer_example/ElementwiseLayer.cpp index eeeb30d..3522621 100644 --- a/app/layer_example/ElementwiseLayer.cpp +++ b/app/layer_example/ElementwiseLayer.cpp @@ -1,5 +1,5 @@ -#include "../ComputeLibrary/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" -#include "../ComputeLibrary/utils/Utils.h" +#include "ComputeLibrary/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" +#include "ComputeLibrary/utils/Utils.h" #include using namespace arm_compute; From 6f75b736bfd71e6d0379768a2f6e70a81d0f48ef Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Feb 2025 12:25:52 +0300 Subject: [PATCH 4/9] correction of inclusions --- app/layer_example/CMakeLists.txt | 6 +++--- app/layer_example/ConvolutionLayer.cpp | 4 ++-- app/layer_example/ElementwiseLayer.cpp | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index b89ef42..f51b953 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,10 +1,10 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -include_directories(${ARM_DIR}) -link_directories(${ARM_DIR}/build) - add_executable(ConvolutionLayer ConvolutionLayer.cpp) add_executable(ElementwiseLayer ElementwiseLayer.cpp) +include_directories(${ARM_DIR}) +link_directories(${ARM_DIR}/build) + target_link_libraries(ConvolutionLayer arm_compute) target_link_libraries(ElementwiseLayer arm_compute) \ No newline at end of file diff --git a/app/layer_example/ConvolutionLayer.cpp b/app/layer_example/ConvolutionLayer.cpp index 618629b..60ed50a 100644 --- a/app/layer_example/ConvolutionLayer.cpp +++ b/app/layer_example/ConvolutionLayer.cpp @@ -1,5 +1,5 @@ -#include "ComputeLibrary/arm_compute/runtime/NEON/NEFunctions.h" -#include "ComputeLibrary/utils/Utils.h" +#include "arm_compute/runtime/NEON/NEFunctions.h" +#include "utils/Utils.h" #include using namespace arm_compute; diff --git a/app/layer_example/ElementwiseLayer.cpp b/app/layer_example/ElementwiseLayer.cpp index 3522621..05a60f6 100644 --- a/app/layer_example/ElementwiseLayer.cpp +++ b/app/layer_example/ElementwiseLayer.cpp @@ -1,5 +1,5 @@ -#include "ComputeLibrary/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" -#include "ComputeLibrary/utils/Utils.h" +#include "arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" +#include "utils/Utils.h" #include using namespace arm_compute; From 968c92a790760926332827307f2101d4359fb3ae Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Feb 2025 16:21:25 +0300 Subject: [PATCH 5/9] Update cmakelist --- app/layer_example/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index f51b953..5e80638 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -4,6 +4,7 @@ add_executable(ConvolutionLayer ConvolutionLayer.cpp) add_executable(ElementwiseLayer ElementwiseLayer.cpp) include_directories(${ARM_DIR}) +include_directories(${ARM_DIR/include}) link_directories(${ARM_DIR}/build) target_link_libraries(ConvolutionLayer arm_compute) From 0b35696aa44adf3f82f477973c11ece73fdd9050 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Thu, 6 Mar 2025 07:57:58 +0100 Subject: [PATCH 6/9] Update app/example/CMakeLists.txt --- app/example/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/example/CMakeLists.txt b/app/example/CMakeLists.txt index 5ac1ad8..033d285 100644 --- a/app/example/CMakeLists.txt +++ b/app/example/CMakeLists.txt @@ -1 +1 @@ -add_executable(example main.cpp) \ No newline at end of file +add_executable(example main.cpp) From 5c038d8586561d01a8ef229ae63092cc1e21e20e Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Thu, 6 Mar 2025 07:58:04 +0100 Subject: [PATCH 7/9] Update app/layer_example/CMakeLists.txt --- app/layer_example/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index 5e80638..e88aaa6 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -8,4 +8,4 @@ include_directories(${ARM_DIR/include}) link_directories(${ARM_DIR}/build) target_link_libraries(ConvolutionLayer arm_compute) -target_link_libraries(ElementwiseLayer arm_compute) \ No newline at end of file +target_link_libraries(ElementwiseLayer arm_compute) From 183120f21276dea3ddd94028f7fd0221cb021577 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Thu, 6 Mar 2025 07:58:11 +0100 Subject: [PATCH 8/9] Update app/layer_example/ConvolutionLayer.cpp --- app/layer_example/ConvolutionLayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/layer_example/ConvolutionLayer.cpp b/app/layer_example/ConvolutionLayer.cpp index 60ed50a..c1d90b9 100644 --- a/app/layer_example/ConvolutionLayer.cpp +++ b/app/layer_example/ConvolutionLayer.cpp @@ -37,4 +37,4 @@ int main(){ conv.run(); output.print(std::cout); -} \ No newline at end of file +} From d1de597d4151608c3d1b52ad47c9fc628e3f3463 Mon Sep 17 00:00:00 2001 From: Arseniy Obolenskiy Date: Thu, 6 Mar 2025 07:58:24 +0100 Subject: [PATCH 9/9] Update app/CMakeLists.txt --- app/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index b704bc8..3ef8013 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,2 +1,2 @@ add_subdirectory(example) -add_subdirectory(layer_example) \ No newline at end of file +add_subdirectory(layer_example)