diff --git a/examples/BuddyLeNet/CMakeLists.txt b/examples/BuddyLeNet/CMakeLists.txt index 91d9de00d1..9ea26f00e3 100644 --- a/examples/BuddyLeNet/CMakeLists.txt +++ b/examples/BuddyLeNet/CMakeLists.txt @@ -60,27 +60,44 @@ target_link_directories(buddy-lenet-run PRIVATE ${LLVM_LIBRARY_DIR}) if(NOT DEFINED BUDDY_ENABLE_PNG) message(FATAL_ERROR "To run LeNet inference, the png library is required. Please define BUDDY_ENABLE_PNG for CMake.") endif() -set(BUDDY_LENET_LIBS LENET mlir_c_runner_utils ${PNG_LIBRARIES}) +set(BUDDY_LENET_LIBS LENET mlir_c_runner_utils mlir_async_runtime mlir_runner_utils mlir_cuda_runtime ${PNG_LIBRARIES}) target_link_libraries(buddy-lenet-run ${BUDDY_LENET_LIBS}) set(ONE_SHOT_BUFFERIZE_OPTION "bufferize-function-boundaries=1 function-boundary-type-conversion=identity-layout-map") set(LOWER_TO_NVVM_OPTION "cubin-chip=sm_80 cubin-features=+ptx71 cubin-format=fatbin") +set(CONVERT_MEMCPY_TO_GPU_OPTION "process-args=1") +set(CONVERT_MEMCPY_TO_GPU_OPTION_DISABLE_PROCESS_ARG "process-args=0") + +add_custom_command( + OUTPUT forward_gpu.o + COMMAND ${BUDDY_BINARY_DIR}/buddy-opt ${BUDDY_EXAMPLES_DIR}/BuddyLeNet/forward.mlir + -buffer-deallocation + -canonicalize -cse -expand-strided-metadata -convert-memcpy-to-gpu -gpu-async-region | + ${LLVM_TOOLS_BINARY_DIR}/mlir-opt -llvm-request-c-wrappers --gpu-to-llvm | + ${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 -O0 -o ${BUDDY_BINARY_DIR}/../examples/BuddyLeNet/forward_gpu.o + DEPENDS ${BUDDY_EXAMPLES_DIR}/BuddyLeNet/forward.mlir + COMMENT "Building forward_gpu.o" + VERBATIM) + add_custom_command( OUTPUT subgraph0_gpu.o COMMAND ${LLVM_TOOLS_BINARY_DIR}/mlir-opt ${BUDDY_EXAMPLES_DIR}/BuddyLeNet/subgraph0.mlir -pass-pipeline "builtin.module(func.func(tosa-to-linalg-named, tosa-to-linalg, tosa-to-tensor, tosa-to-arith))" | - ${LLVM_TOOLS_BINARY_DIR}/mlir-opt - -one-shot-bufferize=${ONE_SHOT_BUFFERIZE_OPTION} - -buffer-deallocation + ${BUDDY_BINARY_DIR}/buddy-opt + -one-shot-bufferize + -func-bufferize-dynamic-offset -convert-linalg-to-parallel-loops -canonicalize -gpu-map-parallel-loops -convert-parallel-loops-to-gpu -gpu-kernel-outlining + -buffer-deallocation -canonicalize -cse | - ${BUDDY_BINARY_DIR}/buddy-opt -convert-memcpy-to-gpu -gpu-async-region -canonicalize | + ${BUDDY_BINARY_DIR}/buddy-opt -convert-memcpy-to-gpu=${CONVERT_MEMCPY_TO_GPU_OPTION_DISABLE_PROCESS_ARG} -gpu-async-region -canonicalize | ${LLVM_TOOLS_BINARY_DIR}/mlir-opt -llvm-request-c-wrappers --test-lower-to-nvvm=${LOWER_TO_NVVM_OPTION} | ${LLVM_TOOLS_BINARY_DIR}/mlir-translate -mlir-to-llvmir | ${LLVM_TOOLS_BINARY_DIR}/llvm-as | @@ -89,7 +106,7 @@ add_custom_command( COMMENT "Building subgraph0_gpu.o" VERBATIM) -add_library(LENET_GPU STATIC subgraph0_gpu.o forward.o) +add_library(LENET_GPU STATIC subgraph0_gpu.o forward_gpu.o) SET_TARGET_PROPERTIES(LENET_GPU PROPERTIES LINKER_LANGUAGE C)