-
Notifications
You must be signed in to change notification settings - Fork 257
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add save/load for pt2e example (#1927)
Signed-off-by: Kaihui-intel <kaihui.tang@intel.com>
- Loading branch information
1 parent
50eb6fb
commit 0e724a4
Showing
12 changed files
with
502 additions
and
307 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
examples/3.x_api/pytorch/cv/static_quant/run_benchmark.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
function main { | ||
|
||
init_params "$@" | ||
run_benchmark | ||
|
||
} | ||
|
||
# init params | ||
function init_params { | ||
iters=100 | ||
batch_size=16 | ||
tuned_checkpoint=saved_results | ||
echo ${max_eval_samples} | ||
for var in "$@" | ||
do | ||
case $var in | ||
--topology=*) | ||
topology=$(echo $var |cut -f2 -d=) | ||
;; | ||
--dataset_location=*) | ||
dataset_location=$(echo $var |cut -f2 -d=) | ||
;; | ||
--input_model=*) | ||
input_model=$(echo $var |cut -f2 -d=) | ||
;; | ||
--mode=*) | ||
mode=$(echo $var |cut -f2 -d=) | ||
;; | ||
--batch_size=*) | ||
batch_size=$(echo $var |cut -f2 -d=) | ||
;; | ||
--iters=*) | ||
iters=$(echo ${var} |cut -f2 -d=) | ||
;; | ||
--int8=*) | ||
int8=$(echo ${var} |cut -f2 -d=) | ||
;; | ||
--config=*) | ||
tuned_checkpoint=$(echo $var |cut -f2 -d=) | ||
;; | ||
*) | ||
echo "Error: No such parameter: ${var}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
} | ||
|
||
|
||
# run_benchmark | ||
function run_benchmark { | ||
extra_cmd='' | ||
|
||
if [[ ${mode} == "accuracy" ]]; then | ||
mode_cmd=" --accuracy " | ||
elif [[ ${mode} == "performance" ]]; then | ||
mode_cmd=" --performance --iters "${iters} | ||
else | ||
echo "Error: No such mode: ${mode}" | ||
exit 1 | ||
fi | ||
if [[ ${int8} == "true" ]]; then | ||
extra_cmd=$extra_cmd" --int8" | ||
fi | ||
echo $extra_cmd | ||
|
||
|
||
echo $extra_cmd | ||
|
||
if [ "${topology}" = "resnet18_pt2e_static" ]; then | ||
model_name_or_path="resnet18" | ||
fi | ||
|
||
if [[ ${mode} == "accuracy" ]]; then | ||
python main.py \ | ||
--pretrained \ | ||
-a resnet18 \ | ||
-b 30 \ | ||
--tuned_checkpoint ${tuned_checkpoint} \ | ||
${dataset_location} \ | ||
${extra_cmd} \ | ||
${mode_cmd} | ||
elif [[ ${mode} == "performance" ]]; then | ||
incbench --num_cores_per_instance 4 \ | ||
main.py \ | ||
--pretrained \ | ||
-a resnet18 \ | ||
-b 30 \ | ||
--tuned_checkpoint ${tuned_checkpoint} \ | ||
${dataset_location} \ | ||
${extra_cmd} \ | ||
${mode_cmd} | ||
else | ||
echo "Error: No such mode: ${mode}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
.../nlp/huggingface_models/language-modeling/quantization/static_quant/pt2e/run_benchmark.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
set -x | ||
|
||
function main { | ||
|
||
init_params "$@" | ||
run_benchmark | ||
|
||
} | ||
|
||
# init params | ||
function init_params { | ||
iters=100 | ||
batch_size=16 | ||
tuned_checkpoint=saved_results | ||
task=lambada_openai | ||
echo ${max_eval_samples} | ||
for var in "$@" | ||
do | ||
case $var in | ||
--topology=*) | ||
topology=$(echo $var |cut -f2 -d=) | ||
;; | ||
--dataset_location=*) | ||
dataset_location=$(echo $var |cut -f2 -d=) | ||
;; | ||
--input_model=*) | ||
input_model=$(echo $var |cut -f2 -d=) | ||
;; | ||
--mode=*) | ||
mode=$(echo $var |cut -f2 -d=) | ||
;; | ||
--batch_size=*) | ||
batch_size=$(echo $var |cut -f2 -d=) | ||
;; | ||
--iters=*) | ||
iters=$(echo ${var} |cut -f2 -d=) | ||
;; | ||
--int8=*) | ||
int8=$(echo ${var} |cut -f2 -d=) | ||
;; | ||
--config=*) | ||
tuned_checkpoint=$(echo $var |cut -f2 -d=) | ||
;; | ||
*) | ||
echo "Error: No such parameter: ${var}" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
} | ||
|
||
|
||
# run_benchmark | ||
function run_benchmark { | ||
extra_cmd='' | ||
|
||
if [[ ${mode} == "accuracy" ]]; then | ||
mode_cmd=" --accuracy " | ||
extra_cmd=$extra_cmd | ||
elif [[ ${mode} == "performance" ]]; then | ||
mode_cmd=" --performance --iters "${iters} | ||
extra_cmd=$extra_cmd | ||
else | ||
echo "Error: No such mode: ${mode}" | ||
exit 1 | ||
fi | ||
|
||
if [[ ${int8} == "true" ]]; then | ||
extra_cmd=$extra_cmd" --int8" | ||
fi | ||
echo $extra_cmd | ||
|
||
echo $extra_cmd | ||
|
||
if [ "${topology}" = "opt_125m_pt2e_static" ]; then | ||
model_name_or_path="facebook/opt-125m" | ||
fi | ||
if [[ ${mode} == "accuracy" ]]; then | ||
python -u run_clm_no_trainer.py \ | ||
--model ${model_name_or_path} \ | ||
--output_dir ${tuned_checkpoint} \ | ||
--task ${task} \ | ||
--batch_size ${batch_size} \ | ||
${extra_cmd} ${mode_cmd} | ||
elif [[ ${mode} == "performance" ]]; then | ||
incbench --num_cores_per_instance 4 run_clm_no_trainer.py \ | ||
--model ${model_name_or_path} \ | ||
--batch_size ${batch_size} \ | ||
--output_dir ${tuned_checkpoint} \ | ||
${extra_cmd} ${mode_cmd} | ||
else | ||
echo "Error: No such mode: ${mode}" | ||
exit 1 | ||
fi | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.