This repository provides the official implementation for the paper "VSALUT: A Lightweight Low-Dimensional VSA Classifier for Efficient Inference on FPGA". It extends the MicroVSA training code to support the LUT approximation and pruning techniques proposed in the VSALUT paper. Additionally, it includes scripts to generate Verilog code for seamless deployment on FPGA hardware.
- Python >=3.8
- virtualenv
- Nvidia GPU (optional but recommended for model training)
-
Create a Python virtual environment and install all dependencies
$ virtualenv -p python3 venv $ source venv/bin/activate $ pip install -r requirements_minimal.txt -
Generate sourcecode for MCU/FPGA deployment (pretrained models are available only for VSALUT)
For MCU deployment (MicroVSA)
# run `python model_converter.py -h` to view all options $ python model_converter.py -i result/har_d64_1 -o result/har_d64_1 -n har -dv 8For FPGA deployment (VSALUT)
# run `python model_converter.py -h` to view all options $ python generate_verilog.py -i pretrained_model/mnist_i -o output_verilog -n mnist_i
Note
To aid in the artifact evaluation process, we temporarily made all datasets available at this link. Simply download and replace the data directory with the version in the zip file, and skip the prepare_dataset.sh script.
-
PTB Diagnostic ECG Database (A free Kagger's account is required to download this dataset)
- Download the dataset from link
- Unzip and copy the
ptbdb_normal.csvandptbdb_abnormal.csvtodata/ptb_ecg
-
Qualcomm Keyword Speech Dataset (A free Qualcomm developer network's account is required to download this dataset)
- Download the dataset from link
- Unzip and copy the
qualcomm_keyword_speech_datasetdirectory to thedata/qksddirectory
-
UCI Human Activity Recognition Dataset
- Download the dataset from link
- Unzip the file
UCI HAR Dataset.zipand copy the text file (.txt) underUCI HAR Dataset/trainandUCI HAR Dataset/testtodata/ucihar
-
Free Spoken Digit Dataset
- Download the dataset from link
- Unzip and copy the
free-spoken-digit-dataset-1.0.10directory to thedata/fsdddirectory
-
WIreless Sensor Data Mining
- Download the dataset from link
- Unzip and copy the
WISDM_ar_v1.1directory to thedata/wisdmdirectory
-
ST multi-zone Time-of-Flight sensors hand posture recognition
- Download the dataset from link
- Unzip and copy the
ST_VL53L8CX_handposture_datasetdirectory to thedata/st_handposedirectory
-
Microsoft Scalable Noisy Speech Dataset (Use to generate negative sample to train the model on the Qualcomm Keyword Speech Dataset)
- Download the dataset from link
- Unzip and copy the dataset directory to the
datadirectory
-
UCI Spoken letter recognition (ISOLET)
- Download the dataset from link
- Unzip and copy the file
isolet1+2+3+4.dataandisolet5.datato thedata/isoletdirectory
Final data directory structure
data/
ptb_ecg/
ptb_abnormal.csv
ptb_normal.csv
qksd/
qualcomm_keyword_speech_dataset/
hey_snapdragon/
...
ucihar/
X_train.txt
y_train.txt
X_test.txt
y_test.txt
fsdd/
free-spoken-digit-dataset-1.0.10/
acquire_data/
recordings/
...
widsm/
WISDM_ar_v1.1/
st_handpose/
ST_VL53L8CX_handposture_dataset/
MS-SNSD-master/
clean_test/
...
-
Create a Python virtual environment and install all dependencies
$ virtualenv -p python3 venv $ source venv/bin/activate $ ./setup.sh -
Run the script to generate the training/testing dataset
$ ./prepare_dataset.sh -
Train the model
Option 1) automatically train some representative models (N rounds for each model) and report the best accuracy
$ ./train.sh <N>Option 2) train a model on a specific dataset with custom parameters, e.g., the following command trains five MCU-optimized LDC models (Df = 64) on the UCI Human Activity Recognition Dataset. The training script saves all trained models in the
resultdirectory and reports the best accuracy# run `python train.py -h` to view all options $ python train.py -d har -n 5 -df 64The
resultdirectory contains the model in npy format, the training log (log.txt), and an image of the confusion matrix (result.png)data/ preprocesssing/ result/ har_d64_1/ C.npy F.npy V.npy log.txt result.png har_d64_2/ ... ... ... -
Convert the trained model to a C source and header file for deployment on the MCU
# run `python model_converter.py -h` to view all options $ python model_converter.py -i result/har_d64_1 -o result/har_d64_1 -n har -dv 8