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

Merge from CTuning #1019

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This portable CM script provides a unified API and CLI to benchmark ONNX models
using the [MLPerf loadgen](https://github.com/mlcommons/inference/tree/master/loadgen).
It measures performance withou accuracy using randomly generated inputs.
It measures performance without accuracy using randomly generated inputs.
If you need accuracy too, please check [this portable CM script](../run-mlperf-inference-app).

## Development status
Expand Down
23 changes: 23 additions & 0 deletions cm-mlops/script/app-loadgen-generic-python/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,29 @@ variations:
env:
CM_MODEL: resnet50

custom:
group:
models
env:
CM_MODEL: custom

huggingface:
env:
CM_CUSTOM_MODEL_SOURCE: huggingface

custom,huggingface:
deps:
- tags: get,ml-model,huggingface
names:
- hf-downloader
update_tags_from_env_with_prefix:
"_model-stub.":
- CM_ML_MODEL_STUB

model-stub.#:
env:
CM_ML_MODEL_STUB: "#"

retinanet:
group:
models
Expand Down
2 changes: 1 addition & 1 deletion cm-mlops/script/app-loadgen-generic-python/src/ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from loadgen.model import Model, ModelFactory, ModelInput, ModelInputSampler

ONNX_TO_NP_TYPE_MAP = {
"tensor(bool)": np.bool,
"tensor(bool)": bool,
"tensor(int)": np.int32,
"tensor(int32)": np.int32,
"tensor(int8)": np.int8,
Expand Down
5 changes: 5 additions & 0 deletions cm-mlops/script/get-ml-model-huggingface-zoo/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@
"CM_MODEL_ZOO_STUB": "#"
}
},
"onnx-subfolder": {
"env": {
"CM_HF_SUBFOLDER": "onnx"
}
},
"pierreguillou_bert_base_cased_squad_v1.1_portuguese": {
"env": {
"CM_MODEL_ZOO_STUB": "pierreguillou/bert-base-cased-squad-v1.1-portuguese"
Expand Down
15 changes: 12 additions & 3 deletions cm-mlops/script/get-ml-model-huggingface-zoo/download_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
if model_filename == '':
model_filename = 'model.onnx'

subfolder = os.environ.get('CM_HF_SUBFOLDER', '')

model_filenames = model_filename.split(',') if ',' in model_filename else [model_filename]

# First must be model
Expand All @@ -35,10 +37,17 @@
if extra_dir!='' and not os.path.exists(extra_dir):
os.makedirs(extra_dir)

hf_hub_download(repo_id=model_stub,
if subfolder == '':
hf_hub_download(repo_id=model_stub,
filename=model_filename,
force_filename=model_filename,
cache_dir=os.getcwd())
else:
hf_hub_download(repo_id=model_stub,
subfolder=subfolder,
filename=model_filename,
cache_dir=os.getcwd(),
force_filename=model_filename)
force_filename=model_filename,
cache_dir=os.getcwd())

with open('tmp-run-env.out', 'w') as f:
f.write(f"CM_ML_MODEL_FILE_WITH_PATH={os.path.join(os.getcwd(),base_model_filename)}")