From b48a123c805e36014d64ef47ff9f794bf3305d7c Mon Sep 17 00:00:00 2001 From: yuwenzho Date: Fri, 25 Aug 2023 17:06:38 +0800 Subject: [PATCH] fix bug in onnxrt examples Signed-off-by: yuwenzho --- .../language_modeling/quantization/ptq_static/main.py | 4 +--- .../question_answering/quantization/ptq_dynamic/main.py | 3 --- .../quantization/ptq_dynamic/run_benchmark.sh | 1 + .../question_answering/quantization/ptq_dynamic/run_quant.sh | 1 + .../question_answering/quantization/ptq_static/main.py | 3 --- .../quantization/ptq_static/run_benchmark.sh | 1 + .../question_answering/quantization/ptq_static/run_quant.sh | 1 + 7 files changed, 5 insertions(+), 9 deletions(-) diff --git a/examples/onnxrt/nlp/huggingface_model/language_modeling/quantization/ptq_static/main.py b/examples/onnxrt/nlp/huggingface_model/language_modeling/quantization/ptq_static/main.py index b5bafa63e0c..3c45336c9f8 100644 --- a/examples/onnxrt/nlp/huggingface_model/language_modeling/quantization/ptq_static/main.py +++ b/examples/onnxrt/nlp/huggingface_model/language_modeling/quantization/ptq_static/main.py @@ -188,9 +188,7 @@ def main(): parser.add_argument('-i', "--iter", default=0, type=int, help='For accuracy measurement only.') args = parser.parse_args() - - device = torch.device("cuda" if torch.cuda.is_available() and not args.no_cuda else "cpu") - args.device = device + args.device = torch.device("cpu") # Setup logging logging.basicConfig(format = '%(asctime)s - %(levelname)s - %(name)s - %(message)s', diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/main.py b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/main.py index e0698b2a98f..f3881bb1fa4 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/main.py +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/main.py @@ -298,9 +298,6 @@ def main(): tokenizer = AutoTokenizer.from_pretrained(model_args.tokenizer_name or model_args.model_name_or_path) - training_args.do_eval = True - training_args.do_predict = False - # Prepare the dataset downloading, preprocessing and metric creation to perform the evaluation step(s) # Get the datasets: you can either provide your own CSV/JSON/TXT training and evaluation files (see below) # or just provide the name of one of the public datasets available on the hub at diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_benchmark.sh b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_benchmark.sh index 087eaa3a022..e086b4b277b 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_benchmark.sh +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_benchmark.sh @@ -51,6 +51,7 @@ function run_benchmark { --overwrite_output_dir \ --dataset_name=squad \ --batch_size=${batch_size} \ + --do_eval \ --benchmark \ ${extra_cmd} diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_quant.sh b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_quant.sh index d2d6bdfa6e7..01b02ab1fc9 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_quant.sh +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_dynamic/run_quant.sh @@ -57,6 +57,7 @@ function run_tuning { --model_name_or_path=${model_name_or_path} \ --num_heads ${num_heads} \ --hidden_size ${hidden_size} \ + --do_eval \ --tune \ ${extra_cmd} } diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/main.py b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/main.py index 67a0a282328..43eb350e75e 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/main.py +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/main.py @@ -301,9 +301,6 @@ def main(): tokenizer = AutoTokenizer.from_pretrained(model_args.tokenizer_name or model_args.model_name_or_path) - training_args.do_eval = True - training_args.do_predict = False - # Prepare the dataset downloading, preprocessing and metric creation to perform the evaluation step(s) # Get the datasets: you can either provide your own CSV/JSON/TXT training and evaluation files (see below) # or just provide the name of one of the public datasets available on the hub at diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_benchmark.sh b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_benchmark.sh index 087eaa3a022..e086b4b277b 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_benchmark.sh +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_benchmark.sh @@ -51,6 +51,7 @@ function run_benchmark { --overwrite_output_dir \ --dataset_name=squad \ --batch_size=${batch_size} \ + --do_eval \ --benchmark \ ${extra_cmd} diff --git a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_quant.sh b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_quant.sh index 758e9049adb..392b21b6852 100644 --- a/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_quant.sh +++ b/examples/onnxrt/nlp/huggingface_model/question_answering/quantization/ptq_static/run_quant.sh @@ -60,6 +60,7 @@ function run_tuning { --model_name_or_path=${model_name_or_path} \ --num_heads ${num_heads} \ --hidden_size ${hidden_size} \ + --do_eval \ --tune \ ${extra_cmd} }