From 5f1561bc280f41d698513fae281dda3a29c793d3 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Wed, 8 Jan 2025 16:27:04 +0300 Subject: [PATCH 01/20] 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 02/20] 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 03/20] 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 04/20] 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 05/20] 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 7c87d3d8b04ab5c3000cbb0f6fe79246a343ab19 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 11 Mar 2025 15:19:27 +0300 Subject: [PATCH 06/20] Add a ElementwiseLayer Example --- app/layer_example/ElementwiseLayer.cpp | 73 +++++++++++++++++++++----- 1 file changed, 59 insertions(+), 14 deletions(-) diff --git a/app/layer_example/ElementwiseLayer.cpp b/app/layer_example/ElementwiseLayer.cpp index 05a60f6..6ac7794 100644 --- a/app/layer_example/ElementwiseLayer.cpp +++ b/app/layer_example/ElementwiseLayer.cpp @@ -1,31 +1,76 @@ -#include "arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" +#include "arm_compute/runtime/NEON/NEFunctions.h" #include "utils/Utils.h" #include using namespace arm_compute; using namespace utils; -int main() { +class ElementwiseLayer { 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)); +public: + void fill() { + 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(); - 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); + } - fill_random_tensor(input1, 0.f, 1.f); - fill_random_tensor(input2, 0.f, 1.f); + void SquaredDiff() { + NEElementwiseSquaredDiff elementwise; + elementwise.configure(&input1, &input2, &output); + elementwise.run(); + } + + void Division() { + NEElementwiseDivision elementwise; + elementwise.configure(&input1, &input2, &output); + elementwise.run(); + } + + void Addition() { + NEArithmeticAddition add; + add.configure(&input1, &input2, &output); + add.run(); + } + + void Swish() { + NEActivationLayer act; + act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SWISH)); + act.run(); + } + + void Abs() { + NEActivationLayer act; + act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); + act.run(); + } - NEElementwiseSquaredDiff elementwise; - elementwise.configure(&input1, &input2, &output); + void Sigmoid() { + NEActivationLayer act; + act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC)); + act.run(); + } - elementwise.run(); + void print() { + output.print(std::cout); + } +}; + +int main() { + ElementwiseLayer a; + a.fill(); + a.Addition(); + a.print(); - output.print(std::cout); + return 0; } From 9bfa382fe3cd43b60ea718e1d0cb3ed23aec2033 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 18 Mar 2025 12:47:59 +0300 Subject: [PATCH 07/20] Add a pooling layer example --- app/layer_example/PoolingLayer.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 app/layer_example/PoolingLayer.cpp diff --git a/app/layer_example/PoolingLayer.cpp b/app/layer_example/PoolingLayer.cpp new file mode 100644 index 0000000..885e63f --- /dev/null +++ b/app/layer_example/PoolingLayer.cpp @@ -0,0 +1,28 @@ +#include "arm_compute/runtime/NEON/NEFunctions.h" +#include "utils/Utils.h" + +#include +using namespace arm_compute; +using namespace utils; + +int main() { + Tensor input; + Tensor output; + + const int input_width = 5; + const int input_height = 5; + + input.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)); + + input.allocator()->allocate(); + output.allocator()->allocate(); + + fill_random_tensor(input, 0.f, 1.f); + + NEPoolingLayer pool; + pool.configure(&input, &output, PoolingLayerInfo(PoolingType::MAX, DataLayout::NHWC)); + pool.run(); + + output.print(std::cout); +} \ No newline at end of file From f02551d3b7f32c152f8974c842620f57c5739cd0 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Mar 2025 15:22:17 +0300 Subject: [PATCH 08/20] add a MatmulLayer example --- app/layer_example/MatMulLayer.cpp | 32 +++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 app/layer_example/MatMulLayer.cpp diff --git a/app/layer_example/MatMulLayer.cpp b/app/layer_example/MatMulLayer.cpp new file mode 100644 index 0000000..8844df8 --- /dev/null +++ b/app/layer_example/MatMulLayer.cpp @@ -0,0 +1,32 @@ +#include "arm_compute/runtime/NEON/NEFunctions.h" +#include "utils/Utils.h" + +#include +using namespace arm_compute; +using namespace utils; + +int main() { + Tensor input1; + Tensor input2; + Tensor output; + + const int input_width = 5; + const int input_height = 5; + + 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); + + NEMatMulLayer m; + m.configure(&input1, &input2, &output); + m.run(); + + output.print(std::cout); +} \ No newline at end of file From f81c4bc62be23699fc3e7f1684debdc53ffec58c Mon Sep 17 00:00:00 2001 From: ChekAlexey <144238010+chekalexey@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:39:20 +0300 Subject: [PATCH 09/20] Delete ElementwiseLayer.cpp --- app/layer_example/ElementwiseLayer.cpp | 76 -------------------------- 1 file changed, 76 deletions(-) delete mode 100644 app/layer_example/ElementwiseLayer.cpp diff --git a/app/layer_example/ElementwiseLayer.cpp b/app/layer_example/ElementwiseLayer.cpp deleted file mode 100644 index 6ac7794..0000000 --- a/app/layer_example/ElementwiseLayer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "arm_compute/runtime/NEON/NEFunctions.h" -#include "utils/Utils.h" - -#include -using namespace arm_compute; -using namespace utils; - -class ElementwiseLayer { - const int input_width = 5; - const int input_height = 5; - - Tensor input1, input2, output; - -public: - void fill() { - 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); - } - - void SquaredDiff() { - NEElementwiseSquaredDiff elementwise; - elementwise.configure(&input1, &input2, &output); - elementwise.run(); - } - - void Division() { - NEElementwiseDivision elementwise; - elementwise.configure(&input1, &input2, &output); - elementwise.run(); - } - - void Addition() { - NEArithmeticAddition add; - add.configure(&input1, &input2, &output); - add.run(); - } - - void Swish() { - NEActivationLayer act; - act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::SWISH)); - act.run(); - } - - void Abs() { - NEActivationLayer act; - act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::ABS)); - act.run(); - } - - void Sigmoid() { - NEActivationLayer act; - act.configure(&input1, &input2, ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::LOGISTIC)); - act.run(); - } - - void print() { - output.print(std::cout); - } -}; - -int main() { - ElementwiseLayer a; - a.fill(); - a.Addition(); - a.print(); - - return 0; -} From 87764d6bc232955d5f0b60c8c957cacd932f4ff0 Mon Sep 17 00:00:00 2001 From: ChekAlexey <144238010+chekalexey@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:39:33 +0300 Subject: [PATCH 10/20] Delete ConvolutionLayer.cpp --- app/layer_example/ConvolutionLayer.cpp | 40 -------------------------- 1 file changed, 40 deletions(-) delete mode 100644 app/layer_example/ConvolutionLayer.cpp diff --git a/app/layer_example/ConvolutionLayer.cpp b/app/layer_example/ConvolutionLayer.cpp deleted file mode 100644 index 60ed50a..0000000 --- a/app/layer_example/ConvolutionLayer.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "arm_compute/runtime/NEON/NEFunctions.h" -#include "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 From 2561b5eea8d966626e7060c6ccc944bf64cf2c16 Mon Sep 17 00:00:00 2001 From: ChekAlexey <144238010+chekalexey@users.noreply.github.com> Date: Tue, 25 Mar 2025 15:39:48 +0300 Subject: [PATCH 11/20] Delete PoolingLayer.cpp --- app/layer_example/PoolingLayer.cpp | 28 ---------------------------- 1 file changed, 28 deletions(-) delete mode 100644 app/layer_example/PoolingLayer.cpp diff --git a/app/layer_example/PoolingLayer.cpp b/app/layer_example/PoolingLayer.cpp deleted file mode 100644 index 885e63f..0000000 --- a/app/layer_example/PoolingLayer.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include "arm_compute/runtime/NEON/NEFunctions.h" -#include "utils/Utils.h" - -#include -using namespace arm_compute; -using namespace utils; - -int main() { - Tensor input; - Tensor output; - - const int input_width = 5; - const int input_height = 5; - - input.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)); - - input.allocator()->allocate(); - output.allocator()->allocate(); - - fill_random_tensor(input, 0.f, 1.f); - - NEPoolingLayer pool; - pool.configure(&input, &output, PoolingLayerInfo(PoolingType::MAX, DataLayout::NHWC)); - pool.run(); - - output.print(std::cout); -} \ No newline at end of file From daaa4729c0837dc5b4c01bfca7b5fc974f4ee1fc Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Mar 2025 15:43:42 +0300 Subject: [PATCH 12/20] Update CMakeLists --- app/layer_example/CMakeLists.txt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index 5e80638..3864154 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,11 +1,9 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -add_executable(ConvolutionLayer ConvolutionLayer.cpp) -add_executable(ElementwiseLayer ElementwiseLayer.cpp) +add_executable(MatMul MatMulLayerLayer.cpp) include_directories(${ARM_DIR}) -include_directories(${ARM_DIR/include}) +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(MatMul arm_compute) From aa8d4f1f44139891c9153c6e17a0e3c6cba2eb2d Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Mar 2025 15:49:21 +0300 Subject: [PATCH 13/20] Update CMakeLists --- 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 3864154..23d91c1 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -6,4 +6,4 @@ include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) link_directories(${ARM_DIR}/build) -target_link_libraries(MatMul arm_compute) +target_link_libraries(MatMul arm_compute) \ No newline at end of file From 2e2fe442c71d5a62ac423f0907b63a9279efbfbc Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Mar 2025 17:15:03 +0300 Subject: [PATCH 14/20] Update Cmakelist --- 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 23d91c1..d7aa276 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,6 +1,6 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -add_executable(MatMul MatMulLayerLayer.cpp) +add_executable(MatMul MatMulLayer.cpp) include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) From e874928a9b37e3bf08119c9e119a94aa12d7f558 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 25 Mar 2025 17:43:19 +0300 Subject: [PATCH 15/20] correction --- app/layer_example/MatMulLayer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/layer_example/MatMulLayer.cpp b/app/layer_example/MatMulLayer.cpp index 8844df8..ce50647 100644 --- a/app/layer_example/MatMulLayer.cpp +++ b/app/layer_example/MatMulLayer.cpp @@ -24,8 +24,8 @@ int main() { fill_random_tensor(input1, 0.f, 1.f); fill_random_tensor(input2, 0.f, 1.f); - NEMatMulLayer m; - m.configure(&input1, &input2, &output); + NEMatMul m; + m.configure(&input1, &input2, &output, MatMulInfo(), CpuMatMulSettings(), ActivationLayerInfo()); m.run(); output.print(std::cout); From 0cd542590d3bc4dc6dc6768044c6cae6ac0ab54a Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 15 Apr 2025 11:33:25 +0300 Subject: [PATCH 16/20] Update CMakeLists --- 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 d7aa276..843f187 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -4,6 +4,6 @@ add_executable(MatMul MatMulLayer.cpp) include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) -link_directories(${ARM_DIR}/build) +target_link_directories(MatMul PUBLIC ${ARM_DIR}/build) target_link_libraries(MatMul arm_compute) \ No newline at end of file From d7cf92693c776804175f81fad8f7ddcdef4ac740 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 22 Apr 2025 15:11:09 +0300 Subject: [PATCH 17/20] Add dependencies in CMakeLists --- app/layer_example/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index 843f187..c71fbd3 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -6,4 +6,6 @@ include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) target_link_directories(MatMul PUBLIC ${ARM_DIR}/build) -target_link_libraries(MatMul arm_compute) \ No newline at end of file +target_link_libraries(MatMul arm_compute) + +add_dependencies(MatMul build_compute_library) \ No newline at end of file From 51b0a089f285c3a35390dce2796e24ce9fbac292 Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 29 Apr 2025 17:39:48 +0300 Subject: [PATCH 18/20] Add a Reshape Layer example --- app/layer_example/CMakeLists.txt | 8 ++++---- app/layer_example/MatMulLayer.cpp | 32 ------------------------------ app/layer_example/ReshapeLayer.cpp | 29 +++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 36 deletions(-) delete mode 100644 app/layer_example/MatMulLayer.cpp create mode 100644 app/layer_example/ReshapeLayer.cpp diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index c71fbd3..da0972f 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,11 +1,11 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -add_executable(MatMul MatMulLayer.cpp) +add_executable(Reshape ReshapeLayer.cpp) include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) -target_link_directories(MatMul PUBLIC ${ARM_DIR}/build) +target_link_directories(Reshape PUBLIC ${ARM_DIR}/build) -target_link_libraries(MatMul arm_compute) +target_link_libraries(Reshape arm_compute) -add_dependencies(MatMul build_compute_library) \ No newline at end of file +add_dependencies(Reshape build_compute_library) \ No newline at end of file diff --git a/app/layer_example/MatMulLayer.cpp b/app/layer_example/MatMulLayer.cpp deleted file mode 100644 index ce50647..0000000 --- a/app/layer_example/MatMulLayer.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include "arm_compute/runtime/NEON/NEFunctions.h" -#include "utils/Utils.h" - -#include -using namespace arm_compute; -using namespace utils; - -int main() { - Tensor input1; - Tensor input2; - Tensor output; - - const int input_width = 5; - const int input_height = 5; - - 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); - - NEMatMul m; - m.configure(&input1, &input2, &output, MatMulInfo(), CpuMatMulSettings(), ActivationLayerInfo()); - m.run(); - - output.print(std::cout); -} \ No newline at end of file diff --git a/app/layer_example/ReshapeLayer.cpp b/app/layer_example/ReshapeLayer.cpp new file mode 100644 index 0000000..218de87 --- /dev/null +++ b/app/layer_example/ReshapeLayer.cpp @@ -0,0 +1,29 @@ +#include +#include "arm_compute/runtime/NEON/NEFunctions.h" +#include "utils/Utils.h" + +using namespace arm_compute; +using namespace utils; + +int main() { + Tensor input; + Tensor output; + + const int input_width = 3; + const int input_height = 3; + + input.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)); + + input.allocator()->allocate(); + output.allocator()->allocate(); + + fill_random_tensor(input, 0.f, 1.f); + + NEReshapeLayer reshape; + reshape.configure(&input, &output); + + reshape.run(); + + output.print(std::cout); +} \ No newline at end of file From 3bab99a34d1cc0a9724064b207b38f2bffd773ed Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 29 Apr 2025 17:54:01 +0300 Subject: [PATCH 19/20] Add a Slice Layer example --- app/layer_example/CMakeLists.txt | 8 ++++---- app/layer_example/{ReshapeLayer.cpp => SliceLayer.cpp} | 9 ++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) rename app/layer_example/{ReshapeLayer.cpp => SliceLayer.cpp} (73%) diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index da0972f..c40b428 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,11 +1,11 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -add_executable(Reshape ReshapeLayer.cpp) +add_executable(Slice SliceLayer.cpp) include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) -target_link_directories(Reshape PUBLIC ${ARM_DIR}/build) +target_link_directories(Slice PUBLIC ${ARM_DIR}/build) -target_link_libraries(Reshape arm_compute) +target_link_libraries(Slice arm_compute) -add_dependencies(Reshape build_compute_library) \ No newline at end of file +add_dependencies(Slice build_compute_library) \ No newline at end of file diff --git a/app/layer_example/ReshapeLayer.cpp b/app/layer_example/SliceLayer.cpp similarity index 73% rename from app/layer_example/ReshapeLayer.cpp rename to app/layer_example/SliceLayer.cpp index 218de87..2b97cfd 100644 --- a/app/layer_example/ReshapeLayer.cpp +++ b/app/layer_example/SliceLayer.cpp @@ -12,6 +12,9 @@ int main() { const int input_width = 3; const int input_height = 3; + const Coordinates Starts = Coordinates(0, 0); + const Coordinates Ends = Coordinates(2, 0); + input.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)); @@ -20,10 +23,10 @@ int main() { fill_random_tensor(input, 0.f, 1.f); - NEReshapeLayer reshape; - reshape.configure(&input, &output); + NESlice slice; + slice.configure(&input, &output, Starts, Ends); - reshape.run(); + slice.run(); output.print(std::cout); } \ No newline at end of file From fa78bd3881fa333c5c02072442300257a4f4763f Mon Sep 17 00:00:00 2001 From: chekalexey Date: Tue, 6 May 2025 17:30:10 +0300 Subject: [PATCH 20/20] Added a split layer example --- app/layer_example/CMakeLists.txt | 8 ++++---- app/layer_example/SliceLayer.cpp | 32 ------------------------------ app/layer_example/SplitLayer.cpp | 34 ++++++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 36 deletions(-) delete mode 100644 app/layer_example/SliceLayer.cpp create mode 100644 app/layer_example/SplitLayer.cpp diff --git a/app/layer_example/CMakeLists.txt b/app/layer_example/CMakeLists.txt index c40b428..0dc37a2 100644 --- a/app/layer_example/CMakeLists.txt +++ b/app/layer_example/CMakeLists.txt @@ -1,11 +1,11 @@ set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary") -add_executable(Slice SliceLayer.cpp) +add_executable(Split SplitLayer.cpp) include_directories(${ARM_DIR}) include_directories(${ARM_DIR}/include) -target_link_directories(Slice PUBLIC ${ARM_DIR}/build) +target_link_directories(Split PUBLIC ${ARM_DIR}/build) -target_link_libraries(Slice arm_compute) +target_link_libraries(Split arm_compute) -add_dependencies(Slice build_compute_library) \ No newline at end of file +add_dependencies(Split build_compute_library) \ No newline at end of file diff --git a/app/layer_example/SliceLayer.cpp b/app/layer_example/SliceLayer.cpp deleted file mode 100644 index 2b97cfd..0000000 --- a/app/layer_example/SliceLayer.cpp +++ /dev/null @@ -1,32 +0,0 @@ -#include -#include "arm_compute/runtime/NEON/NEFunctions.h" -#include "utils/Utils.h" - -using namespace arm_compute; -using namespace utils; - -int main() { - Tensor input; - Tensor output; - - const int input_width = 3; - const int input_height = 3; - - const Coordinates Starts = Coordinates(0, 0); - const Coordinates Ends = Coordinates(2, 0); - - input.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)); - - input.allocator()->allocate(); - output.allocator()->allocate(); - - fill_random_tensor(input, 0.f, 1.f); - - NESlice slice; - slice.configure(&input, &output, Starts, Ends); - - slice.run(); - - output.print(std::cout); -} \ No newline at end of file diff --git a/app/layer_example/SplitLayer.cpp b/app/layer_example/SplitLayer.cpp new file mode 100644 index 0000000..d02fd24 --- /dev/null +++ b/app/layer_example/SplitLayer.cpp @@ -0,0 +1,34 @@ +#include +#include "arm_compute/runtime/NEON/NEFunctions.h" +#include "utils/Utils.h" + +using namespace arm_compute; +using namespace utils; + +int main() { + Tensor input; + const int input_width = 3; + const int input_height = 3; + const int channels = 2; + const int axis = 2; + + input.allocator()->init(TensorInfo(TensorShape(input_width, input_height, channels), 1, DataType::F32)); + input.allocator()->allocate(); + fill_random_tensor(input, 0.f, 1.f); + + Tensor output1, output2; + std::vector outputs = { &output1, &output2 }; + + NESplit split; + split.configure(&input, outputs, axis); + + output1.allocator()->allocate(); + output2.allocator()->allocate(); + + split.run(); + + output1.print(std::cout); + output2.print(std::cout); + + return 0; +} \ No newline at end of file