Skip to content

Commit

Permalink
Add more models
Browse files Browse the repository at this point in the history
Also add .so and tuning data for easier reproducibility.
  • Loading branch information
MassimoGirondi committed Aug 15, 2024
1 parent f08292c commit b8d082c
Show file tree
Hide file tree
Showing 29 changed files with 4,692 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ mod.json
mod.params
model.tar
tuning*.json
.nfs*
957 changes: 957 additions & 0 deletions a100_resnet50_tuned/tuning.2023-07-05T12:03+02:00.json

Large diffs are not rendered by default.

990 changes: 990 additions & 0 deletions a100_squeezenet_tuned/tuning.2023-03-25T09:50+01:00.json

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions a100_superresolution_1_tuned/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
This is an extend version of the superresolution model.
Instead of using a fixed 3 upscale ratio with an input of 224x224,
we feed the model 640x480 inputs, similar to what would be a 480p video,
and by changing the value in UPSCALE_FACTOR, we can simulate various resolution enanchement.

For instance, a 6x upscaling would be close to a 4K output.
A 4x would be similar to a FullHD output.
A 12x would be a 8K output


Original code available at https://raw.githubusercontent.com/pytorch/tutorials/main/advanced_source/super_resolution_with_onnxruntime.py
Surrounding scripts released under GNU GPL v3. See [../LICENSE](../LICENSE).
1 change: 1 addition & 0 deletions a100_superresolution_1_tuned/UPSCALE_FACTOR
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
15 changes: 15 additions & 0 deletions a100_superresolution_1_tuned/compile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
TUNING=$(ls tuning* --sort=time -1 | head -n1)

set -x
python3 -m tvm.driver.tvmc compile \
--target cuda
--target-cuda-arch sm_80 \
--output model.tar \
--input-shape 'input:[1,1,640,480]' \
--tuning-records $TUNING \
super_resolution.onnx $@ \

#--output-shape 'input:[1,1,4096,3112]' \

tar -xvf model.tar
16 changes: 16 additions & 0 deletions a100_superresolution_1_tuned/convert_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

UPSCALE_FACTOR=$(cat UPSCALE_FACTOR)
#DIR=$(basename "$PWD")
DIR=a100_superresolution_${UPSCALE_FACTOR}_tuned
CMD="../a100_superresolution_1_tuned/super_resolution_with_onnxruntime.py $UPSCALE_FACTOR"

echo $CMD
set -x
sudo docker run --rm --gpus 1 \
-v $(pwd):/semla/modelzoo/$DIR \
-v $(pwd)/../a100_superresolution_1_tuned:/semla/modelzoo/a100_superresolution_1_tuned \
--workdir /semla/modelzoo/$DIR \
--entrypoint "/usr/bin/python3" \
semla/tvm_pytorch \
$CMD
4 changes: 4 additions & 0 deletions a100_superresolution_1_tuned/do.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
../a100_superresolution_1_tuned/convert.sh
../a100_superresolution_1_tuned/tune.sh
../a100_superresolution_1_tuned/compile.sh
../a100_superresolution_1_tuned/fix_sizes.sh
2 changes: 2 additions & 0 deletions a100_superresolution_1_tuned/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
wget https://github.com/onnx/models/raw/main/vision/super_resolution/sub_pixel_cnn_2016/model/super-resolution-10.onnx
13 changes: 13 additions & 0 deletions a100_superresolution_1_tuned/fix_sizes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

UPSCALE_FACTOR=$(cat UPSCALE_FACTOR)
W_OUTPUT=$(($UPSCALE_FACTOR * 640))
H_OUTPUT=$(($UPSCALE_FACTOR * 480))
MODEL_NAME=a100_superresolution_${UPSCALE_FACTOR}_tuned


cat ../a100_superresolution_1_tuned/metadata.template.json \
| sed -e "s/W_OUTPUT/${W_OUTPUT}/g" \
| sed -e "s/H_OUTPUT/${H_OUTPUT}/g" \
| sed -e "s/MODEL_NAME/${MODEL_NAME}/g" \
| tee metadata.json
16 changes: 16 additions & 0 deletions a100_superresolution_1_tuned/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"load_time": 1000000000,
"exec_time": [1000000,2000000,4000000,8000000],
"weights_size": 100000000,
"workspace_size": 500000000,
"input_name" : "input",
"output_name" : "output",
"input_shape": [1,1,640,480],
"output_shape": [1,1,640,480],
"input_type": "FP32",
"output_type": "FP32",
"device": "CUDA",
"model" : "a100_superresolution_1_tuned",
"architecture" : "CUDA_80"

}
16 changes: 16 additions & 0 deletions a100_superresolution_1_tuned/metadata.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"load_time": 1000000000,
"exec_time": [1000000,2000000,4000000,8000000],
"weights_size": 100000000,
"workspace_size": 500000000,
"input_name" : "input",
"output_name" : "output",
"input_shape": [1,1,640,480],
"output_shape": [1,1,W_OUTPUT,H_OUTPUT],
"input_type": "FP32",
"output_type": "FP32",
"device": "CUDA",
"model" : "MODEL_NAME",
"architecture" : "CUDA_80"

}
Binary file added a100_superresolution_1_tuned/model.tar
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit b8d082c

Please sign in to comment.