This repository contains the Voyager DNN accelerator generator.
It is written in SystemC/C++ and can be used for simulation (which allows for fast verification) and for generating Verilog (RTL code). The RTL code is then used for RTL-level (cycle-accurate) simulations and further synthesis of real HW.
We are using the built-in GitLab CI. It triggers whenever someone pushes to a branch.
- We are using a single GitLab runner on
r8cad-tsmc40r
. - They can be configured using
/etc/gitlab-runner/config.toml
. - The working directory of the runners is
/sim/gitlab-runner/
.
Install conda with miniforge.
git clone git@code.stanford.edu:tsmc40r/brainpower/accelerator.git
Install direnv, and then create your own .envrc
file in the project root directory that sets up the conda environment and sources the env.sh
file. A sample configuration might look like this:
layout anaconda ./.conda-env
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
source env.sh
After creating the .envrc
file, ensure the conda environment is activated.
- Additional Requirements:
- You need to have
git lfs
installed. - You need
g++
with at least C++17 support. - You need a python3 environment with required packages installed (try running the tests and you will be notified of the missing packages).
- You need to have
git submodule update --init --recursive
- After initialization, install required packages:
- In the submodule
quantized_training
, install withpip install -r requirements.txt
- Further, run
pip install -e .
- From the root directory, execute
pip install quantized_training
- In the submodule
Once the setup is complete, you can test the environment with the following command to compile and run ResNet18 through the compiler:
make test/compiler/networks/resnet18/CFLOAT/params.pb
This will generate the folder test/compiler/networks/resnet18
with files such as a parameter list, a log file, and a tensor_files
breakdown folder, among others.
Note: You may ignore command-line output messages like:
make: lsb_release: Command not found
To run a regression test for ResNet18, you can execute:
DATATYPE=CFLOAT IC_DIMENSION=16 OC_DIMENSION=16 python run_regression.py --models resnet18 --sims gold_model --num_processes 32
Upon completion, check the regression_results
folder for the latest
subfolder, where a list of log files for each submodule will be generated. All layers should ideally pass the gold model check. Feel free to adjust parameters and run different simulations as needed.
- The easiest way to run tests is to check the CI files,
.gitlab/ci/sysc.yml
and.gitlab/ci/rtl.yml
, for SystemC and RTL simulation, respectively. The command to run regression can be found in thescript
field. The result will be written to theregression_results
directory. - You can also manually build and run individual configuration and layer. The instruction will be added later.
/data
: Test data for simulation./lib
: External libraries./models
: DNN models used for verification./scripts
: Various.tcl
scripts for RTL generation./src
: SystemC accelerator implementation./test
: Testing infrastructure, primarily SystemC/C++ files that invoke the accelerator.Makefile
: Builds the source code.run_regression.py
: Main script to invoke regression tests.
To try a new model, you’ll need to modify this script:
- run_compiler.py: Reference existing models to understand the required compilation steps.
Add the network in the following file:
- codegen.mk: Specify the model and set up any required quantization.