Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more vision models from mlagility #614

Merged
merged 75 commits into from
Jun 21, 2023
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
a5a82ef
apply mlagility to create ONNX model in CI
jcwchen Apr 27, 2023
9db5fb2
correct path
jcwchen Apr 27, 2023
65c5d7e
which benchit
jcwchen Apr 27, 2023
d913609
cd mlagility
jcwchen Apr 27, 2023
ccbaf72
pip install -e .
jcwchen Apr 27, 2023
b24081d
add models
jcwchen Apr 27, 2023
acf2326
../mlagility_models/alexnet_torch_hub_2891f54c/onnx/
jcwchen Apr 27, 2023
2731ca4
git diff --exit-code -- .
jcwchen Apr 27, 2023
398b63d
add opset 17 models
jcwchen May 2, 2023
f6c54a1
add faster-rcnn in CIs
jcwchen May 2, 2023
0c06ef3
cd
jcwchen May 2, 2023
ac5f5ec
use 18 instead of 17
jcwchen May 2, 2023
05c495d
Merge branch 'jcw/add-mlagility' of https://github.com/jcwchen/models…
jcwchen May 2, 2023
1a583ec
test opset_version 18
jcwchen May 2, 2023
1f1db90
git diff subdirectory
jcwchen May 3, 2023
500b542
torch==2.0.0 torchvision==0.15.1
jcwchen May 3, 2023
ab889ae
run_mlagility.py
jcwchen May 4, 2023
0380b2f
use better path to store .onnx
jcwchen May 5, 2023
6ff1014
print exception
jcwchen May 6, 2023
db69afb
copy
jcwchen May 6, 2023
a0f0339
+base_name
jcwchen May 6, 2023
dd41d77
correct path from mlagility
jcwchen May 6, 2023
2795d20
add another way to upload new model
jcwchen Jun 6, 2023
37cf55e
validate_model
jcwchen Jun 6, 2023
cea6c52
import os.path as osp
jcwchen Jun 6, 2023
19f6bc3
correct path
jcwchen Jun 6, 2023
934765a
from pathlib import Path
jcwchen Jun 6, 2023
a6f9618
pip install -r
jcwchen Jun 6, 2023
fa5d290
[]
jcwchen Jun 6, 2023
00e4e01
fix
jcwchen Jun 6, 2023
5edb28f
dir_path
jcwchen Jun 6, 2023
388806f
correct path
jcwchen Jun 6, 2023
943fc34
add bart.py
jcwchen Jun 7, 2023
d789edd
change name
jcwchen Jun 7, 2023
3b34a19
update path
jcwchen Jun 7, 2023
ff87370
bart
jcwchen Jun 7, 2023
28c7da1
not os.path.exists(model_name)
jcwchen Jun 8, 2023
d755004
"18"
jcwchen Jun 8, 2023
9eff439
correct
jcwchen Jun 8, 2023
e0f0ff0
change path
jcwchen Jun 14, 2023
358887a
add new-models to CI trigger
jcwchen Jun 14, 2023
bec94e5
add test_data_set
jcwchen Jun 14, 2023
2e99292
add .yml
jcwchen Jun 14, 2023
9a1c97a
ls
jcwchen Jun 14, 2023
6192ee7
stdout=sys.stdout
jcwchen Jun 14, 2023
53b3c98
change commit
jcwchen Jun 14, 2023
0158b32
ls .cache
jcwchen Jun 14, 2023
6196319
ls .cache/alexnet_torch_hub_7df2a577/onnx
jcwchen Jun 14, 2023
2f6d3ee
ls
jcwchen Jun 14, 2023
cfeacf1
stdout=sys.stdout
jcwchen Jun 14, 2023
38d44af
torch==2.0.0
jcwchen Jun 14, 2023
d7d3d27
mlagility_models_dir
jcwchen Jun 14, 2023
7af0369
new config
jcwchen Jun 14, 2023
355c6c3
add 3 more models
jcwchen Jun 15, 2023
4dae47a
add config
jcwchen Jun 15, 2023
0e1a570
remove bert and gpt2 for now
jcwchen Jun 15, 2023
0ef4ef4
clean path
jcwchen Jun 15, 2023
4bc2cdc
Add more vision models from mlagility
jcwchen Jun 20, 2023
fe74ba2
remove models in wrong dir
jcwchen Jun 20, 2023
67dd03b
add new models in config
jcwchen Jun 20, 2023
4423c93
Merge branch 'new-models' into jcw/more-vision-models
jcwchen Jun 20, 2023
6a4ba08
find_model_hash_name
jcwchen Jun 20, 2023
7b752ff
switch order
jcwchen Jun 20, 2023
7195930
requirements
jcwchen Jun 20, 2023
139fcc9
check=True
jcwchen Jun 20, 2023
fcb1b1c
modified models
jcwchen Jun 21, 2023
b2210f0
fix config
jcwchen Jun 21, 2023
8a591a8
rename
jcwchen Jun 21, 2023
657c375
add missing config
jcwchen Jun 21, 2023
77f4a3c
add skip and update args
jcwchen Jun 21, 2023
1337fe8
create test_data_set on the fly
jcwchen Jun 21, 2023
e1f7704
remove maskrcnn v2
jcwchen Jun 21, 2023
8b0fb00
use final_model_dir
jcwchen Jun 21, 2023
902d751
model_hash_name + base_name
jcwchen Jun 21, 2023
b8e54db
add maskrcnn
jcwchen Jun 21, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/mlagility_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,13 @@ jobs:
- name: Install dependencies and mlagility
run: |
python -m pip install --upgrade pip
python -m pip install onnx onnxruntime requests py-cpuinfo
# Print CPU info for debugging ONNX Runtime inference difference
python -m cpuinfo
git clone https://github.com/groq/mlagility.git
cd mlagility
pip install -r models/requirements.txt
pip install -e .

- name: Validate created ONNX model from mlagility
run: |
# TODO: remove the following after mlagility has resovled version contradict issue
pip install -r models/mlagility/requirements.txt
python workflow_scripts/run_mlagility.py
3 changes: 3 additions & 0 deletions models/mlagility/densenet121/densenet121-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/densenet121/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/densenet121/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/googlenet/googlenet-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/googlenet/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/googlenet/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/inception_v3/inception_v3-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/inception_v3/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/inception_v3/test_data_set_0/output_0.pb
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/mobilenet_v2/mobilenet_v2-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/mobilenet_v2/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/mobilenet_v2/test_data_set_0/output_0.pb
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet101/resnet101-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet101/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet101/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet18/resnet18-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet18/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet18/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet34/resnet34-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet34/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/resnet34/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/ssd300_vgg16/ssd300_vgg16-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/ssd300_vgg16/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/ssd300_vgg16/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/ssd300_vgg16/test_data_set_0/output_1.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/ssd300_vgg16/test_data_set_0/output_2.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16/vgg16-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16_bn/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16_bn/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg16_bn/vgg16_bn-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19/vgg19-18.onnx
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19_bn/test_data_set_0/input_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19_bn/test_data_set_0/output_0.pb
Git LFS file not shown
3 changes: 3 additions & 0 deletions models/mlagility/vgg19_bn/vgg19_bn-18.onnx
Git LFS file not shown
6 changes: 0 additions & 6 deletions workflow_scripts/config.py

This file was deleted.

18 changes: 18 additions & 0 deletions workflow_scripts/mlagility_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
models_info = [
"torch_hub/alexnet.py",
"torch_hub/resnet50.py",
"torchvision/fasterrcnn_resnet50_fpn_v2.py",
"torchvision/maskrcnn_resnet50_fpn.py",
"torchvision/ssd_mobilenet_v2.py",
"torch_hub/mobilenet_v2.py",
"torch_hub/resnet18.py",
"torch_hub/resnet34.py",
"torch_hub/resnet101.py",
"torch_hub/vgg16.py",
"torch_hub/vgg16_bn.py",
"torch_hub/vgg19.py",
"torch_hub/vgg19_bn.py",
"torch_hub/densenet121.py",
"torch_hub/inception_v3.py",
"torch_hub/googlenet.py",
]
36 changes: 30 additions & 6 deletions workflow_scripts/run_mlagility.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,24 @@
import config
from mlagility_config import models_info
import os.path as osp
from os import listdir
from pathlib import Path
import shutil
import subprocess
import sys


def get_immediate_subdirectories_count(dir_name):
return len([name for name in listdir(dir_name)
if osp.isdir(osp.join(dir_name, name))])


def find_model_hash_name(dir_name, cache_dir_prefix):
for dir in listdir(dir_name):
if dir.startswith(cache_dir_prefix):
return dir
raise Exception(f"Cannot find model hash name: {cache_dir_prefix} in cache directory.")


ZOO_OPSET_VERSION = "18"
base_name = f"-op{ZOO_OPSET_VERSION}-base.onnx"
cwd_path = Path.cwd()
Expand All @@ -15,15 +28,19 @@

errors = 0

for script_path, model_name, model_zoo_dir in config.models_info:
for model_info in models_info:
directory_name, model_name = model_info.split("/")
model_name = model_name.replace(".py", "")
model_zoo_dir = model_name
try:
print(f"----------------Checking {model_zoo_dir}----------------")
final_model_path = osp.join(mlagility_models_dir, model_zoo_dir, f"{model_zoo_dir}-{ZOO_OPSET_VERSION}.onnx")
subprocess.run(["benchit", osp.join(mlagility_root, script_path), "--cache-dir", cache_converted_dir,
subprocess.run(["benchit", osp.join(mlagility_root, model_info), "--cache-dir", cache_converted_dir,
"--onnx-opset", ZOO_OPSET_VERSION, "--export-only"],
cwd=cwd_path, stdout=sys.stdout,
stderr=sys.stderr)
shutil.copy(osp.join(cache_converted_dir, model_name, "onnx", model_name + base_name), final_model_path)
model_hash_name = find_model_hash_name(".cache", model_name + "_" + directory_name + "_")
shutil.copy(osp.join(cache_converted_dir, model_hash_name, "onnx", model_hash_name + base_name), final_model_path)
subprocess.run(["git", "diff", "--exit-code", "--", final_model_path],
cwd=cwd_path, stdout=sys.stdout,
stderr=sys.stderr)
Expand All @@ -33,7 +50,14 @@
print(f"Failed to check {model_zoo_dir} because of {e}.")

if errors > 0:
print(f"All {len(config.models_info)} model(s) have been checked, but {errors} model(s) failed.")
print(f"All {len(models_info)} model(s) have been checked, but {errors} model(s) failed.")
sys.exit(1)
else:
print(f"All {len(config.models_info)} model(s) have been checked.")
print(f"All {len(models_info)} model(s) have been checked.")

mlagility_subdir_count = get_immediate_subdirectories_count(mlagility_models_dir)
if mlagility_subdir_count != len(models_info):
print(f"Expected {len(models_info)} model(s) in {mlagility_models_dir}, but got {mlagility_subdir_count} model(s) under models/mlagility."
f"Please check if you have added new model(s) to models_info in mlagility_config.py.")
sys.exit(1)