Skip to content
Snippets Groups Projects
Commit bf36f516 authored by Yifan Zhao's avatar Yifan Zhao
Browse files

Updated README and slightly changed conda env

parent e6fb9cbd
No related branches found
No related tags found
No related merge requests found
...@@ -17,6 +17,64 @@ for how to build, install, and use HPVM. ...@@ -17,6 +17,64 @@ for how to build, install, and use HPVM.
HPVM is currently at **version 1.0**. HPVM is currently at **version 1.0**.
## Getting Started
### Dependencies
The following components are mandatory for building HPVM:
- GCC (>=5.1)
- CMake (>=3.17)
- GNU Make (>=3.79) or Ninja (>=1.10)
### Building HPVM
1. Install [Anaconda](https://www.anaconda.com/), a Python package manager. This provides the command `conda`.
1. Clone this branch (`hpvm-release-epochs0`) of this repository:
```bash
git clone -b hpvm-release-epochs0 --single-branch https://gitlab.engr.illinois.edu/llvm/hpvm.git
```
1. Find `env.yaml` in the repo's root, and use conda to create a virtual environment with Python 3.7 and all required packages installed:
```bash
cd hpvm/
conda env create -n hpvm -f ./env.yaml
conda activate hpvm
```
1. Change directory to `./hpvm` in the repo and run the installer with recommended options:
```bash
cd hpvm/; ./install.sh -t "X86"
```
This will download additional dependencies, configure HPVM and build HPVM.
- If you have `ninja` installed (in the place of `make`),
you may use `./install.sh --ninja -t "X86"` to build HPVM with ninja.
### Generating NVDLA Buffer from PyTorch DNN
Run `test/epoch_dnn/main.py` to generate the PyTorch DNN defined at `test/epoch_dnn/torch_dnn/miniera.py` into NVDLA,
and evaluate it on real hardware:
```bash
cd test/epoch_dnn
# rm -r /tmp/miniera # Do this if you have run main.py before
python main.py
```
This script will run through the whole code generation (putting everything under `/tmp/miniera`) and evaluation, including
1. Generate quantization scale `calib.txt` for INT8 quantization;
1. Export DNN to NVDLA buffer `hpvm-mod.nvdla`;
1. Select a sample of images from the dataset and put them as JPG files (`images/$idx_$label.jpg`);
for example, the 0th image which has label 1 will be `images/0000_1.jpg`;
1. Copy NVDLA model and images to an NVDLA device via SCP;
1. Run the NVDLA model on every image we sampled;
1. Display the accuracy of this model.
## HPVM Scheduler Backend ## HPVM Scheduler Backend
We provide the HPVM Backend pass `DFG2LLVM_EPOCHS` which converts those Dataflow Graph (DFG) nodes which represent specific We provide the HPVM Backend pass `DFG2LLVM_EPOCHS` which converts those Dataflow Graph (DFG) nodes which represent specific
......
...@@ -7,6 +7,7 @@ dependencies: ...@@ -7,6 +7,7 @@ dependencies:
- jinja2=2.11 - jinja2=2.11
- matplotlib=3.3 - matplotlib=3.3
- networkx=2.5 - networkx=2.5
- numpy==1.19.4 # This version doesn't have some warning compared to 1.20
- onnx==1.8.0 - onnx==1.8.0
- pandas=1.1 - pandas=1.1
- pip - pip
...@@ -26,3 +27,4 @@ dependencies: ...@@ -26,3 +27,4 @@ dependencies:
- graphviz==0.10 - graphviz==0.10
- onnx-simplifier==0.3 - onnx-simplifier==0.3
- torchnet==0.0.4 - torchnet==0.0.4
- pexpect
# Environment setup
Add path to `libprotobuf.so` and `libnvdla_compiler.so` in LD_LIBRARY_PATH
# Compilation Command
Compilation script : `miniera-hpvm/src/compile_benchmark.sh`
Command:
```
python3 /home/hsharif3/Gitlab/hpvm_release_nvdla/hpvm/build/tools/hpvm/tools/hpvm-clang/main.py -t nvdla --conf-file data/tuner_confs.txt -DMODEL_PARAMS_DIR=${PATH_TO_MODELPARAMS} -fno-exceptions miniera-hpvm.cpp miniera-hpvm
```
*NOTE*: by default hpvm-clang is configured to read calibration inputs from a `calib.txt` file plaed in the current build directoy (see main.py.in in hpvm-clang). Default compilation mode is INT8 - modify `main.py` in build directory to use FP16 mode (easily configurable)
# Running on EPOCHS chip
The compilation creates an nvdla module named `hpvm-mod.nvdla`
Connect to EPOCHS chip:
```
ssh -q -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -p 5506 root@ espgate.cs.columbia.edu
```
*password*: `openesp`
More instructions on EPOCHS chip here:
https://docs.google.com/document/d/1rQa6sIDKtYHGKmWg5bPROJ_FijDUnaVEWkckLWtpHFU/edit?usp=sharing
Running on EPOCHS chip:
```
cd NV_NVDLA/
./nvdla_runtime --loadable hpvm-mod.nvdla --image ${test_image} --rawdump
```
*NOTE* --normalize not neeed here -- input should be INT8
# Images to use for Testing
Images to use for testing under `/benchmarks/miniera-hpvm/data/images`
The ground truth class of the image is part of the file name. For instance, `*_1.jpg` indicates file with target class `1`.
# Frontend/Source changes required
* Weights must be FP16!
* Weights for FC layers need to be tranposed
* Modify paths to readTrainedWeights to pass constant file path -- use MODEL_PARAMS_STR as part of string (see `miniera-hpvm.cpp` as example)
# Missing Support
** BatchNorm support missing (better to try on small example first)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment