Code Monkey home page Code Monkey logo

iree-rv32-springbok's Introduction

RISC-V 32-Bit Bare-Metal ML Deployment on Springbok via IREE

This project demonstrates how to compile RISC-V 32-bit ML workloads via IREE, and deploy the workloads with IREE's c API to generate the bare-matal executables. The built artifacts are targeted for Springbok, a RISC-V 32-bit bare-metal platform, and can be simulated with Renode.

Prerequisites

First install the system packages:

sudo apt install xxd cmake ninja-build wget
pip install -r python-requirements.txt

NOTE: IREE requires CMake >= 3.17. If your system's default cmake is in an older version, please update it manually.

To get you going we have pre-compiled an RV32 LLVM toolchain. This can be installed using:

./build_tools/install_toolchain.sh

The IREE compiler can be downloaded using:

./build_tools/download_iree_compiler.py

Finally Renode can be downloaded using:

./build_tools/download_renode.py

Make sure your ${HOME}/.local/bin is in your PATH:

export PATH=${HOME}/.local/bin:${PATH}

NOTE: If your python packages are installed with the virtual environment, please set PATH accordingly.

Code structure

  • build_tools: Utility scripts for the project
  • cmake: CMake Macros for the project
  • samples: Codegen and execution of ML models based on IREE
    • device: Device HAL driver library
    • float_model: float model examples
    • quant_model: quantized model examples
    • simple_vec_mul: Point-wise vector multiplication examples
    • util: Runtime utility library for model execution
  • sim/config: Renode configuration and infrastructure
  • springbok: Low-level code and linker scripts for the Springbok machine
  • third_party/iree: IREE codebase

Build the project

All sample models we've included can be built at once using this command:

./build_tools/build_riscv.sh

Elfs will land in build/build-riscv/samples/<sample_folder>/ and come in two flavors: <model_name>_bytecode_static and <model_name>_emitc_static. The bytecode executable uses the IREE VM, while the emitc executable compiles the VM commands into C.

Run the executables

To run a simulation, run ./build_tools/sim_springbok.sh with a path to a compiled executable. For example, to run MobileNet v1:

./build_tools/sim_springbok.sh build/build-riscv/samples/quant_model/mobilenet_v1_emitc_static

Test the executables

This project utilizes LLVM lit and FileCheck to test the ML executable performance. The tests are defined in the *_test.txt files under samples. To run the tests:

lit --path $(realpath build/iree_compiler/tests/bin) -a samples

Test times can be found at build/springbok_iree/tests/.lit_test_times.txt.

iree-rv32-springbok's People

Contributors

hcindyl avatar adamjesionowski avatar lundong avatar piotrzierhoffer avatar jakubjatczak avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.