Skip to content

Add a Slice layer example #51

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_subdirectory(example)
add_subdirectory(layer_example)
2 changes: 1 addition & 1 deletion app/example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
add_executable(example main.cpp)
add_executable(example main.cpp)
11 changes: 11 additions & 0 deletions app/layer_example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
set(ARM_DIR "${CMAKE_SOURCE_DIR}/3rdparty/ComputeLibrary")

add_executable(Slice SliceLayer.cpp)

include_directories(${ARM_DIR})
include_directories(${ARM_DIR}/include)
target_link_directories(Slice PUBLIC ${ARM_DIR}/build)

target_link_libraries(Slice arm_compute)

add_dependencies(Slice build_compute_library)
32 changes: 32 additions & 0 deletions app/layer_example/SliceLayer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#include <iostream>
#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);
}
Loading