sunshinemyson commented on a change in pull request #9046: URL: https://github.com/apache/tvm/pull/9046#discussion_r713969535
########## File path: src/relay/backend/contrib/vsi_npu/README.md ########## @@ -0,0 +1,97 @@ +# Versilicon NPU solution on TVM + +In this implementation, we enabled offload AI-workloads to versilicon's neural network processor. + +# Terms +NBG(network binary graph) + + NBG is the executeble format for the NPU, we can compile it from host server and deployment it to a target. + +TIM-VX: (**T**ensor **I**nterface **M**odule)[https://github.com/VeriSilicon/TIM-VX] + +# Implementation details +We have four parts in this implemetation. +1. register vsi-npu supported operator + python/tvm/relay/op/contrib/vsi_npu.py defined supported operator and specific patterns we can support in the NPU. +2. implemented nbg codegen in compilation + src/relay/backend/contrib/vsi_npu/ +3. implemented runtime to execute nbg + src/runtime/contrib/vsi_npu/ +4. test scripts + test/python/contrib/test_vsi_npu/ +5. CMake build script + cmake/modules/contrib/VsiNpu.cmake + +# Build from source + +## Build TIM-VX from source + +## Build tvm as compiler +This step can be executed with a x86 host or arm based target. If you do cross build for your target, +just add toolchain configuration for cmake. + +```sh + mkdir host_compiler_build + cd host_compiler_build + cp ../cmake/config.cmake ./ + # NOTE: config llvm by set USE_LLVM to the llvm-config + # add set(USE_VSI_NPU ON) to config.cmake, you can do it with cmake command option too + # To speed up build, we can disable other backend in this configuration file + cmake -DCMAKE_BUILD_TYPE=Debug -DTIM_VX_INSTALL_DIR=<full_path_to_tim_vx_install> .. + make tvm -j12 +``` + +## Build tvm as runtime +Usually, NBG runtime will be deployed to embedded device. We need to prepare cross-compile-toolchain for cmake firstly. + +```bash + mkdir target_runtime_build + cd target_runtime_build + cp ../cmake/config.cmake ./ + # add set(USE_VSI_NPU ON) to config.cmake, you can do it with cmake command option too + cmake -DCMAKE_BUILD_TYPE=Debug -DTIM_VX_INSTALL_DIR=<full_path_to_tim_vx_target_build_install_dir> \ Review comment: We don't use debug in deployment. I'll refine it. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
