FPGA based Vision Transformer accelerator (Harvard CS205)
cd code/code_cpu- Everything below is done in the
code/code_cpudirectory!!!
wget https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zipunzip libtorch-shared-with-deps-latest.zip
mkdir buildcd buildcmake -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch_folder/that/you/just/downloaded ..cmake --build . --config Releasecd ..(we exit thebuilddirectory)
python download_mnist.pymkdir mnist- Put all the downloaded
.ubytefiles into./mnistfolder
cd build- run
./mainwith eithertest(test model with loaded weights) ortrain - You can move job.sh into build directory and run
./job.shto get time benchmarks in output.txt - Pretrained weights can be downloaded here: Drive (90%+ acc) or use the one in the folder (~86% accuracy)
Please checkout code/fpga/test_accel/test_accel.srcs/sim_1/imports/src/ for the testbenches. Please also import the files in code/fpga/test_accel/test_accel.srcs/sources_1/imports/src/ as the rtl sources. The testbench demonstrates the controller working in parallel with the DMA engine "spad_arbiter". Please feel free to email Eric for further questions.
| Name | Contribution |
|---|---|
| Eric | FPGA Matrix Multiplication Design + Code, SW/HW Co-Design |
| Hongyi | ViT on Pytorch C++, SW/HW Co-Design and Integration |
| Wenyun | ViT on Pytorch C++, Test and Benchmark (and corresponding shell scripts) |
| Sebastian | ViT and FPGA literature research, FPGA demo + testing |