nthu-pllab / RISCV-DLR

This repository is a lightweight runtime for RISC-V utility.
10 stars 8 forks source link

RISC-V Custom Runtime (DLR)

This repository is a lightweight runtime for RISC-V utility. We uses TVM runtime to create a C++ interface that can be called by host.cpp to invoke runtime function. After saving a TVM module as .ll, .graph and .params, with supporting from LLVM and host.cpp. Users can further compile the program with riscv-gun-toolcahin and easily run the inference with Spike.

How to use

Build steps

There are 2 targets in DLR.

Because libDLR.a is for compiling with host code and eventually be executed on Spike, it need to be compiled by gcc/g++ of riscv-gnu-toolchain.

On the other hand, DumpKernel can be executed directly, so it has no need to be compiled by gcc/g++ of riscv-gnu-toolchain.

##############################
#  RISCV-build for libDLR.a  #
##############################
# set RISCV to where riscv-gnu-toolchain installed
mkdir build-riscv
cd build-riscv

CC=$RISCV/bin/riscv64-unknown-elf-gcc \
  CXX=$RISCV/bin/riscv64-unknown-elf-g++ \
  cmake .. \
  -DCMAKE_INSTALL_PREFIX=../install-riscv
cmake --build .
cmake --install .

cd ..

#################################
#  normal build for DumpKernel  #
#################################
mkdir build && cd build

cmake .. \
  -DCMAKE_INSTALL_PREFIX=../install
cmake --build .
cmake --install .

cd ..

Example - Pre-quantized mobilenet v1 model

The example is shown in example/pre_quant_mobilenet_v1_tflite

After setting up the paths of dependences in Makefile, you can run all the flow easily, as illustrated in the figure above.

make
make run

Dependent project

Acknowledgement