-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from HUJH511/main
Submission - LearnAFE: A Learnable Analog Front-End for Keyword Spotting
- Loading branch information
Showing
31 changed files
with
9,264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# ---------- User-specified files to ignore ---------- | ||
# Edit the following if necessary | ||
.conda/* | ||
AFE_Config/SpiceAC/* | ||
!AFE_Config/SpiceAC/README.md | ||
AFE_Config/SpiceTrans/* | ||
!AFE_Config/SpiceTrans/README.md | ||
SpeechCommands/* | ||
!SpeechCommands/README.md | ||
ckpts/* | ||
!ckpts/README.md | ||
logs/* | ||
!logs/README.md | ||
*.pyc | ||
*.pt | ||
*.pth | ||
*.tar.gz | ||
# ---------- End of user-specified list of files to ignore ---------- |
7 changes: 7 additions & 0 deletions
7
VLSI24/submitted_notebooks/LearnAFE/AFE_Config/Design/DSF16.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
C1_W 22 | ||
C2_W 60 | ||
I1 300 | ||
I2 100 | ||
scale 1.298 | ||
C_spk 5 | ||
Vth 1 |
1 change: 1 addition & 0 deletions
1
VLSI24/submitted_notebooks/LearnAFE/AFE_Config/Design/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### Directory to place initial design file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Directory to place configurations of analog front-end | ||
|
||
``` | ||
./LearnAFE_KWS/AFE_Config | ||
| | ||
├───Design | ||
│ └───DSF16.txt | ||
├───SpiceAC | ||
└───SpiceTrans | ||
``` |
1 change: 1 addition & 0 deletions
1
VLSI24/submitted_notebooks/LearnAFE/AFE_Config/SpiceAC/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### Directory to place spice files |
1 change: 1 addition & 0 deletions
1
VLSI24/submitted_notebooks/LearnAFE/AFE_Config/SpiceTrans/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
### Directory to place spice files |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 HU JINHAI | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
7,471 changes: 7,471 additions & 0 deletions
7,471
VLSI24/submitted_notebooks/LearnAFE/LearnAFE.ipynb
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
# LearnAFE: A Learnable Analog Front-End for Keyword Spotting | ||
This repository contains code for keyword spotting with learnable analog front-end. | ||
|
||
|
||
## Table of Content | ||
1. [Structure](#structure) | ||
2. [Getting Started](#getting-started) | ||
3. [Customization](#customization) | ||
4. [Architecture](#architecture) | ||
5. [Results](#results) | ||
6. [License](#license) | ||
7. [Acknowledgement](#acknowledgement) | ||
|
||
|
||
## Structure | ||
While it is possible to have a stand-alone notebook, we have decided to split up the code into modules to improve readability and documentation. The following outline the directory structure. | ||
``` | ||
./LearnAFE_KWS/ | ||
| | ||
├───AFE_Config | ||
│ ├───Design | ||
│ ├───SpiceAC | ||
│ └───SpiceTrans | ||
├───ckpts | ||
├───Figures | ||
├───logs | ||
├───SpeechCommands | ||
│ └───speech_commands_v0.02 | ||
├───src | ||
│ ├───data | ||
│ ├───models | ||
│ ├───utils | ||
│ ├───train.py | ||
│ └───test.py | ||
├───.gitignore | ||
├───environment.yaml | ||
├───README.md | ||
└───LearnAFE_KWS.ipynb | ||
``` | ||
|
||
|
||
## Getting Started | ||
|
||
### Environment Setup | ||
``` | ||
./home/ | ||
| | ||
├───EDA_Tools | ||
│ ├───magic | ||
│ └───open_pdks | ||
└───LearnAFE_KWS | ||
``` | ||
Suggest to setup following environment under `EDA_Tools` | ||
``` | ||
%%install ngspice and other possible configuration files | ||
cd /home/EDA_Tools | ||
sudo pip3 install flake8 | ||
sudo pip3 install setuptools-scm | ||
sudo apt update | ||
sudo apt install build-essential tcl8.6 tcl8.6-dev tk8.6 tk8.6-dev libx11-dev libcairo2-dev libxpm-dev | ||
sudo apt update | ||
sudo apt install flex | ||
sudo apt install bison | ||
sudo apt install libcairo2-dev libjpeg-dev | ||
sudo apt install ngspice | ||
sudo apt install gwave | ||
sudo apt-get install xterm | ||
sudo apt-get install vim-gtk | ||
sudo apt-get install build-essential tcl-dev tk-dev libcairo2-dev libncurses-dev libx11-dev | ||
git clone https://github.com/RTimothyEdwards/magic.git | ||
cd magic | ||
./configure | ||
make | ||
sudo make install | ||
``` | ||
Open PDK Installation | ||
``` | ||
%%download and install open pdk | ||
cd /home/EDA_Tools | ||
git clone https://github.com/RTimothyEdwards/open_pdks | ||
cd open_pdks | ||
./configure --enable-sky130-pdk --enable-sram-sky130 | ||
make | ||
sudo make install | ||
make veryclean | ||
``` | ||
|
||
%% Python Setup | ||
The `environment.yml` can be used as a reference for the packages required. Before running the notebook, ensure that the circuit-design tools and the required packages have been installed successfully. Additionally, create a textfile in SpeechCommands -> speech_commands_v0.02 -> noise_list.txt with the following content. This is used to add background noise to the data for a more robust result. | ||
``` | ||
%% noise_list.txt | ||
_background_noise_/doing_the_dishes.wav | ||
_background_noise_/dude_miaowing.wav | ||
_background_noise_/exercise_bike.wav | ||
_background_noise_/pink_noise.wav | ||
_background_noise_/running_tap.wav | ||
_background_noise_/white_noise.wav | ||
``` | ||
|
||
|
||
## Customization | ||
- Code-a-Chip | ||
| Data Augmentation | Filter Version | SR | Hop length | Overlap | Max samples | Model | Freeze | | ||
|----------------------|----------------|-----|------------|---------|-------------|----------------|--------| | ||
| Resample + Noise | DSF16 | 20k | 640 | False | 30 | LearnAFE_v2 | False | | ||
|
||
|
||
## Architecture | ||
- Learnable filter-bank on time domain | ||
|
||
Waveform --> `START TRAIN` --> { Time domain filter } --> Filtered waveform --> { Spiking + Framing } --> Feature Map --> { DSCNN } --> Classification Result | ||
|
||
|
||
## Results | ||
| Data Augmentation | Model | AFE Config | Freeze | SR | Hop_len | Overlap | Train Acc | Valid Acc | Test Acc | 20dB | 5dB | | ||
|-------------------|---------------|----------------|--------|------|---------|---------|-----------|-----------|----------|------|------| | ||
| Resample + Noise | LearnAFE_v2 | Design/DSF16 | True | 20k | 640 | False | 94.0 | 91.3 | 90.2 | 89.1 | 82.7 | | ||
| Resample + Noise | LearnAFE_v2 | Design/DSF16 | False | 20k | 640 | False | 95.6 | 93.8 | 92.7 | 92.4 | 89.4 | | ||
|
||
|
||
## License | ||
This project is licensed under the MIT License. See LICENSE for more details.<br /> | ||
Additionally the first version of this work has been accepted for publication in DAC. The following citation can be modified once the proceeding is made available.<br /> | ||
J. Hu, Z. Zhang, C. S. Leow, W. L. Goh, and Y. Gao, “Late Breaking Results: Circuit-Algorithm Co-design for Learnable Audio Analog Front-End,” in 61st ACM/IEEE Design Automation Conf. (DAC), accepted, 2024. | ||
|
||
|
||
## Acknowledgement | ||
This work was supported by the Agency for Science, Technology and Research (A*STAR), Singapore under the Nanosystems at the Edge programme, grant No. A18A1b0055. We thank Professor Zhengya Zhang for his insightful comments. |
12 changes: 12 additions & 0 deletions
12
VLSI24/submitted_notebooks/LearnAFE/SpeechCommands/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Directory to place Speech Commands Dataset | ||
|
||
A noise list file is added under `SpeechCommands/speech_commands_v0.02` | ||
``` | ||
%% noise_list.txt | ||
_background_noise_/doing_the_dishes.wav | ||
_background_noise_/dude_miaowing.wav | ||
_background_noise_/exercise_bike.wav | ||
_background_noise_/pink_noise.wav | ||
_background_noise_/running_tap.wav | ||
_background_noise_/white_noise.wav | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Directory to place temporary models/checkpoints |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
name: /home/LearnAFE_KWS/.conda | ||
channels: | ||
- conda-forge | ||
- defaults | ||
dependencies: | ||
- _libgcc_mutex=0.1 | ||
- _openmp_mutex=4.5 | ||
- asttokens=2.4.1 | ||
- blas=1.0 | ||
- brotli=1.0.9 | ||
- brotli-bin=1.0.9 | ||
- bzip2=1.0.8 | ||
- ca-certificates=2024.3.11 | ||
- comm=0.2.2 | ||
- contourpy=1.2.0 | ||
- cycler=0.11.0 | ||
- cyrus-sasl=2.1.28 | ||
- dbus=1.13.18 | ||
- debugpy=1.6.7 | ||
- decorator=5.1.1 | ||
- exceptiongroup=1.2.0 | ||
- executing=2.0.1 | ||
- expat=2.5.0 | ||
- fontconfig=2.14.1 | ||
- fonttools=4.25.0 | ||
- freetype=2.12.1 | ||
- glib=2.78.4 | ||
- glib-tools=2.78.4 | ||
- gst-plugins-base=1.14.1 | ||
- gstreamer=1.14.1 | ||
- icu=73.1 | ||
- importlib-metadata=7.1.0 | ||
- importlib_metadata=7.1.0 | ||
- ipykernel=6.29.3 | ||
- ipython=8.22.2 | ||
- jedi=0.19.1 | ||
- jpeg=9e | ||
- jupyter_client=8.6.1 | ||
- jupyter_core=5.7.2 | ||
- kiwisolver=1.4.4 | ||
- krb5=1.20.1 | ||
- lcms2=2.12 | ||
- ld_impl_linux-64=2.38 | ||
- lerc=3.0 | ||
- libbrotlicommon=1.0.9 | ||
- libbrotlidec=1.0.9 | ||
- libbrotlienc=1.0.9 | ||
- libclang=14.0.6 | ||
- libclang13=14.0.6 | ||
- libcups=2.4.2 | ||
- libdeflate=1.17 | ||
- libedit=3.1.20230828 | ||
- libffi=3.4.4 | ||
- libgcc-ng=13.2.0 | ||
- libgfortran-ng=11.2.0 | ||
- libgfortran5=11.2.0 | ||
- libglib=2.78.4 | ||
- libgomp=13.2.0 | ||
- libiconv=1.16 | ||
- libllvm14=14.0.6 | ||
- libopenblas=0.3.21 | ||
- libpng=1.6.39 | ||
- libpq=12.17 | ||
- libsodium=1.0.18 | ||
- libstdcxx-ng=11.2.0 | ||
- libtiff=4.5.1 | ||
- libuuid=1.41.5 | ||
- libwebp-base=1.3.2 | ||
- libxcb=1.15 | ||
- libxkbcommon=1.0.1 | ||
- libxml2=2.10.4 | ||
- lz4-c=1.9.4 | ||
- matplotlib=3.8.0 | ||
- matplotlib-base=3.8.0 | ||
- matplotlib-inline=0.1.6 | ||
- munkres=1.1.4 | ||
- mysql=5.7.24 | ||
- ncurses=6.4 | ||
- nest-asyncio=1.6.0 | ||
- numpy=1.26.4 | ||
- numpy-base=1.26.4 | ||
- openjpeg=2.4.0 | ||
- openssl=3.2.1 | ||
- packaging=24.0 | ||
- parso=0.8.3 | ||
- pcre2=10.42 | ||
- pexpect=4.9.0 | ||
- pickleshare=0.7.5 | ||
- pillow=10.2.0 | ||
- pip=23.3.1 | ||
- platformdirs=4.2.0 | ||
- ply=3.11 | ||
- prompt-toolkit=3.0.42 | ||
- psutil=5.9.8 | ||
- ptyprocess=0.7.0 | ||
- pure_eval=0.2.2 | ||
- pygments=2.17.2 | ||
- pyparsing=3.0.9 | ||
- pyqt=5.15.10 | ||
- pyqt5-sip=12.13.0 | ||
- python=3.11.8 | ||
- python-dateutil=2.9.0 | ||
- python_abi=3.11 | ||
- pyzmq=25.1.2 | ||
- qt-main=5.15.2 | ||
- readline=8.2 | ||
- setuptools=68.2.2 | ||
- sip=6.7.12 | ||
- six=1.16.0 | ||
- sqlite=3.41.2 | ||
- stack_data=0.6.2 | ||
- tk=8.6.12 | ||
- tornado=6.4 | ||
- traitlets=5.14.2 | ||
- typing_extensions=4.10.0 | ||
- wcwidth=0.2.13 | ||
- wheel=0.41.2 | ||
- xz=5.4.6 | ||
- zeromq=4.3.5 | ||
- zipp=3.17.0 | ||
- zlib=1.2.13 | ||
- zstd=1.5.5 | ||
- pip: | ||
- ax-platform==0.3.7 | ||
- botorch==0.10.0 | ||
- cffi==1.16.0 | ||
- cmake==3.29.0.1 | ||
- filelock==3.13.3 | ||
- fsspec==2024.3.1 | ||
- gpytorch==1.11 | ||
- ipywidgets==8.1.2 | ||
- jaxtyping==0.2.28 | ||
- jinja2==3.1.3 | ||
- joblib==1.3.2 | ||
- jupyterlab-widgets==3.0.10 | ||
- linear-operator==0.5.1 | ||
- lit==18.1.2 | ||
- markupsafe==2.1.5 | ||
- mpmath==1.3.0 | ||
- multipledispatch==1.0.0 | ||
- mypy-extensions==1.0.0 | ||
- networkx==3.2.1 | ||
- nvidia-cublas-cu12==12.1.3.1 | ||
- nvidia-cuda-cupti-cu12==12.1.105 | ||
- nvidia-cuda-nvrtc-cu12==12.1.105 | ||
- nvidia-cuda-runtime-cu12==12.1.105 | ||
- nvidia-cudnn-cu12==8.9.2.26 | ||
- nvidia-cufft-cu12==11.0.2.54 | ||
- nvidia-curand-cu12==10.3.2.106 | ||
- nvidia-cusolver-cu12==11.4.5.107 | ||
- nvidia-cusparse-cu12==12.1.0.106 | ||
- nvidia-nccl-cu12==2.19.3 | ||
- nvidia-nvjitlink-cu12==12.4.99 | ||
- nvidia-nvtx-cu12==12.1.105 | ||
- opt-einsum==3.3.0 | ||
- pandas==2.2.1 | ||
- plotly==5.20.0 | ||
- pycparser==2.21 | ||
- pyre-extensions==0.0.30 | ||
- pyro-api==0.1.2 | ||
- pyro-ppl==1.9.0 | ||
- pysoundfile==0.9.0.post1 | ||
- pytz==2024.1 | ||
- scikit-learn==1.4.1.post1 | ||
- scipy==1.12.0 | ||
- soundfile==0.12.1 | ||
- sympy==1.12 | ||
- tabulate==0.9.0 | ||
- tenacity==8.2.3 | ||
- threadpoolctl==3.4.0 | ||
- torch==2.2.1 | ||
- torchaudio==2.2.1 | ||
- torchinfo==1.8.0 | ||
- torchvision==0.17.1 | ||
- tqdm==4.66.2 | ||
- triton==2.2.0 | ||
- typeguard==2.13.3 | ||
- typing-inspect==0.9.0 | ||
- tzdata==2024.1 | ||
- widgetsnbextension==4.0.10 | ||
prefix: /home/LearnAFE_KWS/.conda |
Oops, something went wrong.