-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate onnx nlp and obj examples into 2.x API (#579)
Signed-off-by: yuwenzho <[email protected]>
- Loading branch information
Showing
215 changed files
with
22,040 additions
and
452 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -2539,4 +2539,7 @@ zalandoresearch | |
emCgSTlJaAg | ||
matsubara | ||
yoshitomo | ||
deepset | ||
FAC | ||
electra | ||
parallelizes |
Large diffs are not rendered by default.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
examples/onnxrt/nlp/bert/quantization/ptq_dynamic/README.md
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,59 @@ | ||
Step-by-Step | ||
============ | ||
|
||
This example load a BERT model and confirm its accuracy and speed based on [GLUE data](https://gluebenchmark.com/). | ||
|
||
# Prerequisite | ||
|
||
## 1. Environment | ||
|
||
```shell | ||
pip install neural-compressor | ||
pip install -r requirements.txt | ||
``` | ||
> Note: Validated ONNX Runtime [Version](/docs/source/installation_guide.md#validated-software-environment). | ||
## 2. Prepare Dataset | ||
|
||
download the GLUE data with `prepare_data.sh` script. | ||
```shell | ||
export GLUE_DIR=path/to/glue_data | ||
export TASK_NAME=MRPC | ||
|
||
bash prepare_data.sh --data_dir=$GLUE_DIR --task_name=$TASK_NAME | ||
``` | ||
|
||
## 3. Prepare Model | ||
|
||
Please refer to [Bert-GLUE_OnnxRuntime_quantization guide](https://github.com/microsoft/onnxruntime/blob/master/onnxruntime/python/tools/quantization/notebooks/Bert-GLUE_OnnxRuntime_quantization.ipynb) for detailed model export. | ||
|
||
Run the `prepare_model.sh` script | ||
|
||
|
||
Usage: | ||
```shell | ||
bash prepare_model.sh --input_dir=./MRPC \ | ||
--task_name=$TASK_NAME \ | ||
--output_model=path/to/model # model path as *.onnx | ||
``` | ||
|
||
# Run | ||
|
||
## 1. Quantization | ||
|
||
Dynamic quantization: | ||
|
||
```bash | ||
bash run_tuning.sh --input_model=path/to/model \ # model path as *.onnx | ||
--output_model=path/to/model_tune \ # model path as *.onnx | ||
--dataset_location=path/to/glue_data | ||
``` | ||
|
||
## 2. Benchmark | ||
|
||
```bash | ||
bash run_benchmark.sh --input_model=path/to/model \ # model path as *.onnx | ||
--dataset_location=path/to/glue_data \ | ||
--batch_size=batch_size \ | ||
--mode=performance # or accuracy | ||
``` |
Oops, something went wrong.