Skip to content

Commit 6facbf1

Browse files
committed
docs(//cpp/ptq): READMEs and documentation for running the PTQ example
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent df74136 commit 6facbf1

File tree

4 files changed

+57
-23
lines changed

4 files changed

+57
-23
lines changed

cpp/ptq/README.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22

33
This is a short example application that shows how to use TRTorch to perform post-training quantization for a module.
44

5+
## Prerequisites
6+
7+
1. Download CIFAR10 Dataset Binary version
8+
2. Train a network on CIFAR10 (see `training/` for a VGG16 recipie)
9+
3. Export model to torchscript
10+
511
## Compilation
612

713
``` shell
8-
bazel build //cpp/ptq --cxxopt="-DNDEBUG"
14+
bazel build //cpp/ptq --compilation_mode=opt
915
```
1016

1117
If you want insight into what is going under the hood or need debug symbols
@@ -17,5 +23,12 @@ bazel build //cpp/ptq --compilation_mode=dbg
1723
## Usage
1824

1925
``` shell
20-
ptq
21-
```
26+
ptq <path-to-module> <path-to-cifar10>
27+
```
28+
29+
## Citations
30+
31+
```
32+
Krizhevsky, A., & Hinton, G. (2009). Learning multiple layers of features from tiny images.
33+
Simonyan, K., & Zisserman, A. (2014). Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556.
34+
```

cpp/ptq/training/vgg16/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# VGG16 Trained on CIFAR10
2+
3+
This is a recipe to train a VGG network on CIFAR10 to use with the TRTorch PTQ example.
4+
5+
## Prequisites
6+
7+
```
8+
pip3 install -r requirements.txt --user
9+
```
10+
11+
## Training
12+
13+
The following recipe should get somewhere between 89-92% accuracy on the CIFAR10 testset
14+
```
15+
python3 main.py --lr 0.01 --batch-size 256 --drop-ratio 0.15 --ckpt-dir $(pwd)/vgg16_ckpts --epochs 100
16+
```
17+
18+
> 545 was the seed used in testing
19+
20+
You can monitor training with tensorboard, logs are stored by default at `/tmp/vgg16_logs`
21+
22+
## Exporting
23+
24+
Use the exporter script to create a torchscipt module you can compile with TRTorch
25+
26+
```
27+
python3 export_ckpt.py <path-to-checkpoint>
28+
```
29+
30+
It should produce a file called `trained_vgg16.jit.pt`
31+
32+
Once the trained VGG network is exported run it with the PTQ example.
33+
34+
## Citations
35+
36+
```
37+
Krizhevsky, A., & Hinton, G. (2009). Learning multiple layers of features from tiny images.
38+
Simonyan, K., & Zisserman, A. (2014). Very deep convolutional networks for large-scale image recognition. arXiv preprint arXiv:1409.1556.
39+
```
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
torch>=1.4.0
2+
tensorboard>=1.14.0

cpp/ptq/training/vgg16/test.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)