Skip to content
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

[Examples]Add ResNet18 E2E Example #370

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion examples/BuddyMobileNetV3/buddy-mobilenetv3-main.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//===- MobileNetBenchmark.cpp ---------------------------------------------===//
//===- buddy-mobilenetv3-main.cpp ---------------------------------------------===//
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line of comment cannot exceed 80 columns. Please remove a few dashes to align with the comment separator below.

//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down
75 changes: 75 additions & 0 deletions examples/BuddyResNet18/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
add_custom_command(
OUTPUT ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/arg0.data
${BUDDY_EXAMPLES_DIR}/BuddyResNet18/arg1.data
${BUDDY_EXAMPLES_DIR}/BuddyResNet18/forward.mlir
${BUDDY_EXAMPLES_DIR}/BuddyResNet18/subgraph0.mlir
COMMAND python3 ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/buddy-resnet-import.py
COMMENT "Generating forward.mlir, subgraph0.mlir and parameter files"
)


add_custom_command(
OUTPUT forward.o
COMMAND ${LLVM_TOOLS_BINARY_DIR}/mlir-opt ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/forward.mlir
-pass-pipeline
"builtin.module(func.func(tosa-to-linalg-named, tosa-to-linalg, tosa-to-tensor, tosa-to-arith), \
empty-tensor-to-alloc-tensor, convert-elementwise-to-linalg, arith-bufferize, \
func.func(linalg-bufferize, tensor-bufferize), func-bufferize)" |
${LLVM_TOOLS_BINARY_DIR}/mlir-opt
-pass-pipeline
"builtin.module(func.func(buffer-deallocation-simplification, convert-linalg-to-loops), \
eliminate-empty-tensors, func.func(llvm-request-c-wrappers), \
convert-math-to-llvm, convert-math-to-libm, convert-scf-to-cf, \
convert-arith-to-llvm, expand-strided-metadata, finalize-memref-to-llvm, \
convert-func-to-llvm, reconcile-unrealized-casts)" |
${LLVM_TOOLS_BINARY_DIR}/mlir-translate -mlir-to-llvmir |
${LLVM_TOOLS_BINARY_DIR}/llvm-as |
${LLVM_TOOLS_BINARY_DIR}/llc -filetype=obj -relocation-model=pic -O3
-o ${BUDDY_BINARY_DIR}/../examples/BuddyResNet18/forward.o
DEPENDS ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/forward.mlir
COMMENT "Building forward.o"
VERBATIM)


add_custom_command(
OUTPUT subgraph0.o
COMMAND ${BUDDY_BINARY_DIR}/buddy-opt ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/subgraph0.mlir
-pass-pipeline
"builtin.module(func.func(tosa-to-linalg-named, tosa-to-arith, tosa-to-linalg, tosa-to-tensor))" |
${BUDDY_BINARY_DIR}/buddy-opt
-convert-elementwise-to-linalg
-func-bufferize-dynamic-offset
-arith-bufferize
-func-bufferize
-tensor-bufferize
-linalg-bufferize
-finalizing-bufferize
-convert-linalg-to-loops
-lower-affine
-convert-scf-to-cf
-llvm-request-c-wrappers
-convert-math-to-llvm
-convert-math-to-libm
-convert-arith-to-llvm
-convert-func-to-llvm
-expand-strided-metadata
-finalize-memref-to-llvm
-reconcile-unrealized-casts |
${LLVM_TOOLS_BINARY_DIR}/mlir-translate -mlir-to-llvmir |
${LLVM_TOOLS_BINARY_DIR}/llvm-as |
${LLVM_TOOLS_BINARY_DIR}/llc -filetype=obj -relocation-model=pic -O3
-o ${BUDDY_BINARY_DIR}/../examples/BuddyResNet18/subgraph0.o
DEPENDS ${BUDDY_EXAMPLES_DIR}/BuddyResNet18/subgraph0.mlir
buddy-opt
COMMENT "Building subgraph0.o"
VERBATIM)

add_library(RESNET STATIC subgraph0.o forward.o)

SET_TARGET_PROPERTIES(RESNET PROPERTIES LINKER_LANGUAGE C)

add_executable(buddy-resnet-run buddy-resnet-main.cpp)
target_link_directories(buddy-resnet-run PRIVATE ${LLVM_LIBRARY_DIR})

set(BUDDY_RESNET_LIBS RESNET mlir_c_runner_utils ${OpenCV_LIBS})
target_link_libraries(buddy-resnet-run ${BUDDY_RESNET_LIBS})
Loading