-
Notifications
You must be signed in to change notification settings - Fork 5
Add layer examples #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
5f1561b
58a016c
a19ca04
d1064bf
6f75b73
968c92a
06ff603
0b35696
5c038d8
183120f
d1de597
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| add_subdirectory(example) | ||
| add_subdirectory(layer_example) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| add_executable(example main.cpp) | ||
| add_executable(example main.cpp) | ||
aobolensk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #include "../ComputeLibrary/arm_compute/runtime/NEON/NEFunctions.h" | ||
| #include "../ComputeLibrary/utils/Utils.h" | ||
|
||
|
|
||
| #include <iostream> | ||
| 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); | ||
| } | ||
aobolensk marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| #include "../ComputeLibrary/arm_compute/runtime/NEON/functions/NEElementwiseOperations.h" | ||
| #include "../ComputeLibrary/utils/Utils.h" | ||
|
|
||
| #include <iostream> | ||
| 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); | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.