diff --git a/README.md b/README.md index defc8b9234bb11f79a665de286c0896b728356c9..cd08a5d08e4f841687c162c2b5fa310bdd6a961c 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,64 @@ for how to build, install, and use HPVM. 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 We provide the HPVM Backend pass `DFG2LLVM_EPOCHS` which converts those Dataflow Graph (DFG) nodes which represent specific diff --git a/hpvm/env.yaml b/hpvm/env.yaml index 3e1f6394c78ee1e25f55cb9ddb76fd5cc4a96921..69adb2635b73b768e0ca74e5771a09a65d579d25 100644 --- a/hpvm/env.yaml +++ b/hpvm/env.yaml @@ -7,6 +7,7 @@ dependencies: - jinja2=2.11 - matplotlib=3.3 - networkx=2.5 + - numpy==1.19.4 # This version doesn't have some warning compared to 1.20 - onnx==1.8.0 - pandas=1.1 - pip @@ -26,3 +27,4 @@ dependencies: - graphviz==0.10 - onnx-simplifier==0.3 - torchnet==0.0.4 + - pexpect diff --git a/hpvm/test/epoch_dnn/README.md b/hpvm/test/epoch_dnn/README.md deleted file mode 100644 index 6b55d56174599eea690b8942a025ddeffc3ed6fd..0000000000000000000000000000000000000000 --- a/hpvm/test/epoch_dnn/README.md +++ /dev/null @@ -1,70 +0,0 @@ -# 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)