Skip to content

Commit

Permalink
tflite tpu support
Browse files Browse the repository at this point in the history
  • Loading branch information
makaveli10 committed Aug 11, 2023
1 parent 2b4e234 commit 63a6142
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions cm-mlops/script/app-mlperf-inference-reference/_cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ variations:
env:
CM_MLPERF_BACKEND: tflite
CM_MLPERF_BACKEND_VERSION: <<<CM_TFLITE_VERSION>>>
CM_MLPERF_VISION_DATASET_OPTION: imagenet_tflite_tpu

tf:
group: framework
Expand Down
12 changes: 8 additions & 4 deletions cm-mlops/script/app-mlperf-inference-reference/customize.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,14 @@ def get_run_cmd_reference(env, scenario_extra_options, mode_extra_options, datas
extra_options = " --output "+ env['CM_MLPERF_OUTPUT_DIR'] +" --model-name resnet50 --dataset " + env['CM_MLPERF_VISION_DATASET_OPTION'] + ' --max-batchsize ' + env.get('CM_MLPERF_LOADGEN_MAX_BATCHSIZE', '1') + \
" --dataset-path "+env['CM_DATASET_PREPROCESSED_PATH']+" --model "+env['MODEL_FILE'] + \
" --preprocessed_dir "+env['CM_DATASET_PREPROCESSED_PATH']

cmd = "cd '" + os.path.join(env['RUN_DIR'],"python") + "' && "+env['CM_PYTHON_BIN_WITH_PATH']+ " main.py "+\
"--backend "+env['CM_MLPERF_BACKEND']+ " --scenario="+env['CM_MLPERF_LOADGEN_SCENARIO'] + \
env['CM_MLPERF_LOADGEN_EXTRA_OPTIONS'] + scenario_extra_options + mode_extra_options + dataset_options + extra_options
if env.get('CM_MLPERF_DEVICE') == "tpu":
cmd = "cd '" + os.path.join(env['RUN_DIR'],"python") + "' && sudo "+env['CM_PYTHON_BIN_WITH_PATH']+ " main.py "+\
"--backend "+env['CM_MLPERF_BACKEND']+ " --scenario="+env['CM_MLPERF_LOADGEN_SCENARIO'] + \
env['CM_MLPERF_LOADGEN_EXTRA_OPTIONS'] + scenario_extra_options + mode_extra_options + dataset_options + extra_options
else:
cmd = "cd '" + os.path.join(env['RUN_DIR'],"python") + "' && "+env['CM_PYTHON_BIN_WITH_PATH']+ " main.py "+\
"--backend "+env['CM_MLPERF_BACKEND']+ " --scenario="+env['CM_MLPERF_LOADGEN_SCENARIO'] + \
env['CM_MLPERF_LOADGEN_EXTRA_OPTIONS'] + scenario_extra_options + mode_extra_options + dataset_options + extra_options
env['SKIP_VERIFY_ACCURACY'] = True

elif "bert" in env['CM_MODEL']:
Expand Down
7 changes: 7 additions & 0 deletions cm-mlops/script/get-ml-model-resnet50/_cm.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
"CM_ML_MODEL_FILE": "resnet50_v1.no-argmax.tflite"
}
},
"tflite,fp32": {
"env": {
"CM_ML_MODEL_INPUT_SHAPES": "\\\"input_tensor 2\\\": (BATCH_SIZE, 224, 224, 3)",
"CM_PACKAGE_URL": "https://zenodo.org/record/8234946/files/resnet50_quant_full_mlperf_edgetpu.tflite?download=1",
"CM_ML_MODEL_FILE": "resnet50_quant_full_mlperf_edgetpu.tflite"
}
},
"tflite": {
"group": "framework",
"env": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
elif os.environ.get('CM_MODEL', 'resnet50') == 'resnet50' and os.environ.get('CM_PREPROCESS_PYTORCH', '') == "yes":
pre_process = dataset.pre_process_imagenet_pytorch
elif os.environ.get('CM_MODEL', 'resnet50') == 'resnet50' and os.environ.get('CM_PREPROCESS_TFLITE_TPU', '') == "yes":
pre_process = dataset.pre_process_resnet
pre_process = dataset.pre_process_imagenet_tflite_tpu
else:
pre_process = dataset.pre_process_vgg

Expand Down

0 comments on commit 63a6142

Please sign in to comment.