人反对如果方法非法方法非法方法非法方法
资源内容介绍
人反对如果方法非法方法非法方法非法方法 # tvm-riscv-deployThis repository demonstrates how to deploy the TVM compiler on a RISC-V architecture using ResNet18.## Step 1: Setting up TVMFollow these steps, which are adapted from the [TVM Install from Source](http://tvm.apache.org/docs/install/from_source.html) page.### Clone the repository```bashgit clone --recursive --branch int4_direct_HWNC http://github.com/zachzzc/incubator-tvm.git ~/tvm```### Install LLVM```bashsudo bash -c "$(wget -O - http://apt.llvm.org/llvm.sh)"```### Install build dependencies```bashsudo apt-get updatesudo apt-get install -y python3 python3-dev python3-setuptools gcc libtinfo-dev zlib1g-dev build-essential cmake libedit-dev libxml2-dev```### Build TVMNavigate to the TVM directory, create a build directory, and copy the `config.cmake` file.```bashcd ~/tvmmkdir buildcp cmake/config.cmake build```Edit `build/config.cmake` to customize compilation options:- Change `set(USE_LLVM OFF)` to `set(USE_LLVM /path/to/llvm-config)` to build with LLVM (replace `/path/to/llvm-config` with the actual path, such as `/usr/lib/llvm-10/bin/llvm-config`).Then compile TVM:```bashcd buildcmake ..make -j4```### Install the TVM Python packageAdd the following lines to `~/.bashrc`:```bashexport TVM_HOME=/path/to/tvmexport PYTHONPATH=$TVM_HOME/python:$TVM_HOME/topi/python:$TVM_HOME/nnvm/python:${PYTHONPATH}```Source `~/.bashrc` to apply the changes:```bashsource ~/.bashrc```### Install Python dependenciesInstall the necessary dependencies:```bashpip3 install --user numpy decorator attrs```## Step 2: Install RISC-V GNU Compiler Toolchain```bashsudo apt updatesudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu```Compile the TVM runtime for RISC-V:```bashriscv64-linux-gnu-g++ -c -std=c++17 -O2 -fPIC -I/home/tvm/include -I/home/tvm/3rdparty/dmlc-core/include -I/home/tvm/3rdparty/dlpack/include -DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\> -o lib/libtvm_runtime_pack.o tvm_runtime_pack.cc```This will generate the `libtvm_runtime_pack.o` file.## Step 3: Generate `test_resnet18.so`Use `prepare_test_libs.py` to generate the `test_resnet18.so` file.## Step 4: Compile the Deployment Package```bashriscv64-linux-gnu-g++ -std=c++17 -O2 -fPIC -I/home/tvm/include -I/home/tvm/3rdparty/dmlc-core/include -I/home/tvm/3rdparty/dlpack/include -DDMLC_USE_LOGGING_LIBRARY=\<tvm/runtime/logging.h\> -o lib/cpp_deploy_pack cpp_deploy.cc lib/test_resnet18.so lib/libtvm_runtime_pack.o -L/home/tvm/build -ldl -pthread```This will create the `cpp_deploy_pack` executable.## Step 5: Running on RISC-V Processor or EmulatorIf you do not have a RISC-V processor to execute, you can use the QEMU emulator. For more information, please read `Qemu_usage.md`.Transfer the `cpp_deploy_pack` executable and `lib/test_resnet18.so` to riscv64 file system and execute to get the results.```bash./cpp_deploy_pack```With these steps, you have successfully deployed ResNet18 using the TVM compiler on a RISC-V processor and performed an inference.