diff --git a/.azure-pipelines/docker/Dockerfile.devel b/.azure-pipelines/docker/Dockerfile.devel
index 30e6bf3ec..4e18199bf 100644
--- a/.azure-pipelines/docker/Dockerfile.devel
+++ b/.azure-pipelines/docker/Dockerfile.devel
@@ -32,6 +32,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \
time \
wget \
bc \
+ jq \
vim
RUN ln -sf $(which python3) /usr/bin/python
diff --git a/.azure-pipelines/model-test.yml b/.azure-pipelines/model-test.yml
new file mode 100644
index 000000000..04f3fcd7a
--- /dev/null
+++ b/.azure-pipelines/model-test.yml
@@ -0,0 +1,121 @@
+trigger: none
+
+pr:
+ autoCancel: true
+ drafts: false
+ branches:
+ include:
+ - main
+ paths:
+ include:
+ - onnx_neural_compressor
+ - setup.py
+ - requirements.txt
+ - .azure-pipelines/scripts/models
+ - .azure-pipelines/model-test.yml
+ - .azure-pipelines/template/model-template.yml
+ exclude:
+ - test
+
+variables:
+ OUT_SCRIPT_PATH: $(Build.SourcesDirectory)/.azure-pipelines/scripts/models
+ SCRIPT_PATH: /neural_compressor/.azure-pipelines/scripts
+
+parameters:
+ - name: algorithms
+ type: object
+ default:
+ - SQ
+ - WOQ
+ - name: models
+ type: object
+ default:
+ - bert_base_MRPC
+ - bert_base_MRPC_dynamic
+ - resnet50-v1-12_qdq
+ - resnet50-v1-12
+
+stages:
+ # - stage: ONNX_LLM_Models
+ # displayName: Run ONNX LLM Model
+ # pool: ICX-16C
+ # dependsOn: []
+ # jobs:
+ # - ${{ each algorithm in parameters.algorithms }}:
+ # - job:
+ # steps:
+ # - template: template/model-template.yml
+ # parameters:
+ # modelName: "facebook/opt-125m"
+ # algorithm: "${{ algorithm }}"
+ # script_path: "run_onnxrt_llm_models_trigger.sh"
+
+ - stage: ONNX_Models
+ displayName: Run ONNX Model
+ pool: MODEL_PERF_TEST
+ dependsOn: []
+ jobs:
+ - ${{ each model in parameters.models }}:
+ - job:
+ displayName: ${{ model }}
+ steps:
+ - template: template/model-template.yml
+ parameters:
+ modelName: "${{ model }}"
+ algorithm: "Quantize"
+ script_path: "run_onnxrt_models_trigger.sh"
+
+ - stage: GenerateLogs
+ displayName: Generate Report
+ pool:
+ vmImage: "ubuntu-latest"
+ dependsOn: [ONNX_Models]
+ jobs:
+ - job: GenerateReport
+ steps:
+ - script: |
+ echo ${BUILD_SOURCESDIRECTORY}
+ rm -fr ${BUILD_SOURCESDIRECTORY} || sudo rm -fr ${BUILD_SOURCESDIRECTORY} || true
+ echo y | docker system prune
+ displayName: "Clean workspace"
+ - checkout: self
+ clean: true
+ displayName: "Checkout out Repo"
+ - task: DownloadPipelineArtifact@2
+ inputs:
+ artifact:
+ patterns: "**/result.json"
+ path: $(OUT_SCRIPT_PATH)
+ - task: UsePythonVersion@0
+ displayName: "Use Python 3.10"
+ inputs:
+ versionSpec: "3.10"
+ - script: |
+ cd ${OUT_SCRIPT_PATH}
+ mkdir generated last_generated
+ python -u summarize_results.py --logs_dir $(OUT_SCRIPT_PATH) --output_dir generated
+ displayName: "Summarize all results"
+ - task: DownloadPipelineArtifact@2
+ continueOnError: true
+ inputs:
+ source: "specific"
+ artifact: "FinalReport"
+ patterns: "**.json"
+ path: $(OUT_SCRIPT_PATH)/last_generated
+ project: $(System.TeamProject)
+ pipeline: "onc model test"
+ runVersion: "specific"
+ runId: $(refer_buildId)
+ displayName: "Download last logs"
+ - script: |
+ echo "------ Generating final report.html ------"
+ cd ${OUT_SCRIPT_PATH}
+ pip install jinja2
+ python generate_report.py --json_path generated/summary.json --last_json_path last_generated/summary.json
+ displayName: "Generate report"
+ - task: PublishPipelineArtifact@1
+ inputs:
+ targetPath: $(OUT_SCRIPT_PATH)/generated
+ artifact: FinalReport
+ publishLocation: "pipeline"
+ displayName: "Publish report"
diff --git a/.azure-pipelines/scripts/models/collect_results.py b/.azure-pipelines/scripts/models/collect_results.py
new file mode 100644
index 000000000..2e977f500
--- /dev/null
+++ b/.azure-pipelines/scripts/models/collect_results.py
@@ -0,0 +1,84 @@
+import argparse
+import json
+import os
+import re
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--model", required=True, type=str)
+parser.add_argument("--build_id", required=True, type=str)
+args = parser.parse_args()
+
+URL = (
+ "https://dev.azure.com/lpot-inc/onnx-neural-compressor/_build/results?buildId="
+ + args.build_id
+ + "&view=artifacts&pathAsName=false&type=publishedArtifacts"
+)
+REFER_SUMMARY_PATH = "/neural-compressor/.azure-pipelines/scripts/models/summary.json"
+
+
+def str_to_float(value):
+ try:
+ return round(float(value), 4)
+ except ValueError:
+ return value
+
+
+def get_refer_data():
+ if not os.path.exists(REFER_SUMMARY_PATH):
+ print(f"The file '{REFER_SUMMARY_PATH}' does not exist.")
+ return {}
+
+ with open(REFER_SUMMARY_PATH, "r") as file:
+ refer = json.load(file)
+ return refer
+
+
+def check_status(performance, accuracy):
+ refer = get_refer_data()
+
+ refer_accuracy = refer.get(args.model, {}).get("accuracy", {}).get("value", "N/A")
+ refer_performance = refer.get(args.model, {}).get("performance", {}).get("value", "N/A")
+ print(f"{accuracy=}\n{refer_accuracy=}\n{performance=}\n{refer_performance=}")
+
+ assert accuracy != "N/A" and performance != "N/A"
+ if refer_accuracy != "N/A":
+ assert abs(accuracy - refer_accuracy) <= 0.001
+ if refer_performance != "N/A":
+ assert (refer_performance - performance) / refer_performance <= 0.08
+
+
+def main():
+ result_dict = {
+ args.model: {
+ "performance": {"value": "N/A", "log_path": URL},
+ "accuracy": {"value": "N/A", "log_path": URL},
+ }
+ }
+
+ pattern = {
+ "performance": r"Throughput: ([\d.]+)",
+ "accuracy": r"Accuracy: ([\d.]+)",
+ }
+
+ for mode, _ in result_dict[args.model].items():
+ log_file = f"/neural-compressor/.azure-pipelines/scripts/models/{args.model}/{mode}.log"
+ if not os.path.exists(log_file):
+ print(f"The file '{log_file}' does not exist.")
+ continue
+
+ with open(log_file, "r") as file:
+ log_content = file.read()
+
+ match = re.search(pattern[mode], log_content)
+
+ if match:
+ result_dict[args.model][mode]["value"] = str_to_float(match.group(1))
+
+ with open(f"/neural-compressor/.azure-pipelines/scripts/models/{args.model}/result.json", "w") as json_file:
+ json.dump(result_dict, json_file, indent=4)
+
+ check_status(result_dict[args.model]["performance"]["value"], result_dict[args.model]["accuracy"]["value"])
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.azure-pipelines/scripts/models/env_setup.sh b/.azure-pipelines/scripts/models/env_setup.sh
new file mode 100644
index 000000000..dba8e26ee
--- /dev/null
+++ b/.azure-pipelines/scripts/models/env_setup.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+set -eo pipefail
+PATTERN='[-a-zA-Z0-9_]*='
+
+for i in "$@"; do
+ case $i in
+ --model=*)
+ model=${i//${PATTERN}/}
+ ;;
+ *)
+ echo "Parameter $i not recognized."
+ exit 1
+ ;;
+ esac
+done
+
+CONFIG_PATH="/neural-compressor/examples/.config/model_params_onnxrt.json"
+model_src_dir=$(jq -r ".\"onnxrt\".\"$model\".\"model_src_dir\"" "$CONFIG_PATH")
+
+log_dir="/neural-compressor/.azure-pipelines/scripts/models"
+
+$BOLD_YELLOW && echo "======= creat log_dir =========" && $RESET
+if [ -d "${log_dir}/${model}" ]; then
+ $BOLD_GREEN && echo "${log_dir}/${model} already exists, don't need to mkdir." && $RESET
+else
+ $BOLD_GREEN && echo "no log dir ${log_dir}/${model}, create." && $RESET
+ cd "${log_dir}"
+ mkdir "${model}"
+fi
+
+$BOLD_YELLOW && echo "====== install ONC ======" && $RESET
+cd /neural-compressor
+source .azure-pipelines/scripts/change_color.sh
+/bin/bash .azure-pipelines/scripts/install_nc.sh
+
+$BOLD_YELLOW && echo "====== install requirements ======" && $RESET
+cd "/neural-compressor/examples/$model_src_dir"
+pip install -r requirements.txt
+pip list
diff --git a/.azure-pipelines/scripts/models/generate_report.py b/.azure-pipelines/scripts/models/generate_report.py
new file mode 100644
index 000000000..7fd2eebad
--- /dev/null
+++ b/.azure-pipelines/scripts/models/generate_report.py
@@ -0,0 +1,103 @@
+import argparse
+import json
+import os
+
+from jinja2 import Environment, FileSystemLoader
+
+parser = argparse.ArgumentParser(allow_abbrev=False)
+parser.add_argument("--json_path", type=str, required=True)
+parser.add_argument("--last_json_path", type=str, required=True)
+args = parser.parse_args()
+
+
+def get_data(json_path):
+ """
+ {
+ model: {
+ "performance": {"value": "N/A"|number, "log_path": string},
+ "accuracy": {"value": "N/A"|number, "log_path": string},
+ }
+ }
+ """
+ if os.path.exists(json_path):
+ with open(json_path, "r") as f:
+ return json.load(f)
+ else:
+ return {}
+
+
+def get_ratio(cur, last):
+ if cur == "N/A" or last == "N/A":
+ ratio = "N/A"
+ else:
+ ratio = (float(cur) - float(last)) / float(last) * 100
+ ratio = round(float(ratio), 2)
+ return ratio
+
+
+def get_accuracy_ratio(current_json, last_accuracy_dict):
+ compare_result_dict = []
+ for model, item in current_json.items():
+ current_accuracy = item.get("accuracy", {}).get("value", "N/A")
+ last_accuracy = last_accuracy_dict.get(model, {}).get("accuracy", {}).get("value", "N/A")
+ accuracy_ratio = get_ratio(current_accuracy, last_accuracy)
+
+ current_performance = item.get("performance", {}).get("value", "N/A")
+ last_performance = last_accuracy_dict.get(model, {}).get("performance", {}).get("value", "N/A")
+ performance_ratio = get_ratio(current_performance, last_performance)
+
+ if accuracy_ratio == "N/A" or performance_ratio == "N/A":
+ status = "FAILURE"
+ elif accuracy_ratio != 0:
+ status = "FAILURE"
+ elif performance_ratio > 8 or performance_ratio < -8:
+ status = "FAILURE"
+ else:
+ status = "SUCCESS"
+
+ format_ratio = lambda x: f"{x}%" if x != "N/A" else x
+
+ compare_result_dict.append(
+ {
+ "model": model,
+ "current_accuracy": current_accuracy,
+ "last_accuracy": last_accuracy,
+ "accuracy_ratio": format_ratio(accuracy_ratio),
+ "current_performance": current_performance,
+ "last_performance": last_performance,
+ "performance_ratio": format_ratio(performance_ratio),
+ "status": status,
+ }
+ )
+ return compare_result_dict
+
+
+def generate(rendered_template):
+ with open("generated/report.html", "w") as html_file:
+ html_file.write(rendered_template)
+
+
+def main():
+ path = "{}/templates/".format(os.path.dirname(__file__))
+ BUILD_BUILDID = os.getenv("BUILD_BUILDID")
+
+ loader = FileSystemLoader(path)
+ env = Environment(loader=loader)
+ template = env.get_template("model.jinja2")
+
+ data = get_data(args.json_path)
+ last_data = get_data(args.last_json_path)
+ data = get_accuracy_ratio(data, last_data)
+ info = {
+ "url": f"https://dev.azure.com/lpot-inc/onnx-neural-compressor/_build/results?buildId={BUILD_BUILDID}",
+ "branch": os.getenv("SYSTEM_PULLREQUEST_SOURCEBRANCH"),
+ "commit": os.getenv("BUILD_SOURCEVERSION"),
+ "build_number": BUILD_BUILDID,
+ }
+
+ rendered_template = template.render(data=data, info=info)
+ generate(rendered_template)
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.azure-pipelines/scripts/models/run_onnxrt_llm_models_trigger.sh b/.azure-pipelines/scripts/models/run_onnxrt_llm_models_trigger.sh
new file mode 100644
index 000000000..4454c8329
--- /dev/null
+++ b/.azure-pipelines/scripts/models/run_onnxrt_llm_models_trigger.sh
@@ -0,0 +1,60 @@
+#!/bin/bash
+set -eo pipefail
+set -xe
+PATTERN='[-a-zA-Z0-9_]*='
+
+for i in "$@"; do
+ case $i in
+ --stage=*)
+ stage=${i//${PATTERN}/}
+ ;;
+ --model=*)
+ model=${i//${PATTERN}/}
+ ;;
+ *)
+ echo "Parameter $i not recognized."
+ exit 1
+ ;;
+ esac
+done
+
+model_src_dir=/neural-compressor/examples/nlp/huggingface_model/text_generation/llama/quantization/weight_only
+dataset_location=NeelNanda/pile-10k
+input_model=/tf_dataset2/models/huggingface/opt-125m
+batch_size=16
+
+function run_prepare_model() {
+ python prepare_model.py --input_model="$input_model" --output_model="./model_export" --task=text-generation-with-past
+}
+
+function run_quantize() {
+ bash run_quant.sh --input_model="./model_export" \
+ --output_model="./model_tune" \
+ --batch_size="$batch_size" \
+ --dataset="$dataset_location" \
+ --tokenizer="$model" \
+ --algorithm=WOQ_TUNE
+}
+
+function run_accuracy() {
+ bash run_benchmark.sh --input_model="./model_tune" \
+ --batch_size="$batch_size" \
+ --mode=accuracy \
+ --tokenizer="$model" \
+ --tasks=lambada_openai | tee -a accuracy.log
+}
+
+function main() {
+ cd "$model_src_dir"
+ if [ "$stage" == "prepare_model" ]; then
+ run_prepare_model
+ elif [ "$stage" == "quantize" ]; then
+ run_quantize
+ elif [ "$stage" == "accuracy" ]; then
+ run_accuracy
+ else
+ exit 1
+ fi
+}
+
+main
diff --git a/.azure-pipelines/scripts/models/run_onnxrt_models_trigger.sh b/.azure-pipelines/scripts/models/run_onnxrt_models_trigger.sh
new file mode 100644
index 000000000..a64387043
--- /dev/null
+++ b/.azure-pipelines/scripts/models/run_onnxrt_models_trigger.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+set -eo pipefail
+set -xe
+PATTERN='[-a-zA-Z0-9_]*='
+
+for i in "$@"; do
+ case $i in
+ --stage=*)
+ stage=${i//${PATTERN}/}
+ ;;
+ --model=*)
+ model=${i//${PATTERN}/}
+ ;;
+ *)
+ echo "Parameter $i not recognized."
+ exit 1
+ ;;
+ esac
+done
+
+log_dir="/neural-compressor/.azure-pipelines/scripts/models/$model"
+CONFIG_PATH="/neural-compressor/examples/.config/model_params_onnxrt.json"
+model_src_dir=$(jq -r ".\"onnxrt\".\"$model\".\"model_src_dir\"" "$CONFIG_PATH")
+if [[ "$model" == *"resnet"* ]]; then
+ dataset_location="/tf_dataset2/datasets/imagenet/ImagenetRaw/ImagenetRaw_small_5000/ILSVRC2012_img_val"
+ label_path="/tf_dataset2/datasets/imagenet/ImagenetRaw/ImagenetRaw_small_5000/val.txt"
+else
+ dataset_location=$(jq -r ".\"onnxrt\".\"$model\".\"dataset_location\"" "$CONFIG_PATH")
+fi
+
+input_model=$(jq -r ".\"onnxrt\".\"$model\".\"input_model\"" "$CONFIG_PATH")
+
+function run_prepare_model() {
+ if [ -f "$input_model" ]; then
+ echo "model exists"
+ else
+ echo "model not found" && exit 1
+ fi
+}
+
+function run_quantize() {
+ if [[ "$model" == "bert_base_MRPC" ]]; then
+ bash run_quant.sh --input_model="$input_model" \
+ --dataset_location="$dataset_location" \
+ --label_path="$label_path" \
+ --output_model="./model_tune" \
+ --quant_format="QDQ" | tee -a "$log_dir/tuning.log"
+ else
+ bash run_quant.sh --input_model="$input_model" \
+ --dataset_location="$dataset_location" \
+ --label_path="$label_path" \
+ --output_model="./model_tune" | tee -a "$log_dir/tuning.log"
+ fi
+}
+
+function run_accuracy() {
+ bash run_benchmark.sh --input_model="./model_tune" \
+ --dataset_location="$dataset_location" \
+ --label_path="$label_path" \
+ --mode="accuracy" \
+ --batch_size="16" | tee -a "$log_dir/accuracy.log"
+}
+
+function run_performance() {
+ bash run_benchmark.sh --input_model="./model_tune" \
+ --dataset_location="$dataset_location" \
+ --label_path="$label_path" \
+ --mode="performance" \
+ --intra_op_num_threads="8" \
+ --batch_size="1" | tee -a "$log_dir/performance.log"
+}
+
+function main() {
+ cd "/neural-compressor/examples/$model_src_dir"
+ if [ "$stage" == "prepare_model" ]; then
+ run_prepare_model
+ elif [ "$stage" == "quantize" ]; then
+ run_quantize
+ elif [ "$stage" == "accuracy" ]; then
+ run_accuracy
+ elif [ "$stage" == "performance" ]; then
+ run_performance
+ else
+ echo "invalid stage: $stage" && exit 1
+ fi
+}
+
+main
diff --git a/.azure-pipelines/scripts/models/summarize_results.py b/.azure-pipelines/scripts/models/summarize_results.py
new file mode 100644
index 000000000..a9b7f0f22
--- /dev/null
+++ b/.azure-pipelines/scripts/models/summarize_results.py
@@ -0,0 +1,44 @@
+import argparse
+import json
+import os
+
+parser = argparse.ArgumentParser()
+parser.add_argument("--logs_dir", required=True, type=str)
+parser.add_argument("--output_dir", required=True, type=str)
+args = parser.parse_args()
+
+
+def read_json_file(file_path):
+ with open(file_path, "r") as file:
+ return json.load(file)
+
+
+def write_json_file(data, file_path):
+ with open(file_path, "w") as file:
+ json.dump(data, file, indent=4)
+
+
+def merge_json_files(root_dir, output_file):
+ merged_data = {}
+
+ for subdir, _, files in os.walk(root_dir):
+ for file in files:
+ if file.endswith(".json"):
+ file_path = os.path.join(subdir, file)
+ try:
+ json_data = read_json_file(file_path)
+ merged_data.update(json_data)
+ except json.JSONDecodeError:
+ print(f"Error decoding JSON from file: {file_path}")
+
+ print(merged_data)
+ write_json_file(merged_data, f"{output_file}/summary.json")
+
+
+def main():
+ merge_json_files(args.logs_dir, args.output_dir)
+ print(f"All JSON files have been merged into {args.output_dir}")
+
+
+if __name__ == "__main__":
+ main()
diff --git a/.azure-pipelines/scripts/models/templates/model.jinja2 b/.azure-pipelines/scripts/models/templates/model.jinja2
new file mode 100644
index 000000000..72f5a4881
--- /dev/null
+++ b/.azure-pipelines/scripts/models/templates/model.jinja2
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+ ONNX Neural Compressor - Model test
+
+
+
+
+
+
+
+
Summary
+
+
+
Model Test
+
+
+ {% for title in ["Platform", "Model", "Accuracy(new|last)", "Ratio(Accuracy)",
+ "Performance(new|last)", "Ratio(Performance)", "Status"] %}
+ {{ title }} |
+ {% endfor %}
+
+
+ {% for item in data %}
+
+ ICX |
+ {{ item.model }} |
+ {{ item.current_accuracy }} | {{ item.last_accuracy }} |
+ {{ item.accuracy_ratio }} |
+ {{ item.current_performance }} | {{ item.last_performance }} |
+ {{ item.performance_ratio }} |
+ {% if item.status == 'SUCCESS' %}
+ {{ item.status }} |
+ {% else %}
+ {{ item.status }} |
+ {% endif %}
+
+ {% endfor %}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.azure-pipelines/template/model-template.yml b/.azure-pipelines/template/model-template.yml
new file mode 100644
index 000000000..f777bf332
--- /dev/null
+++ b/.azure-pipelines/template/model-template.yml
@@ -0,0 +1,81 @@
+parameters:
+ - name: modelName
+ type: string
+ - name: modelContainerName
+ type: string
+ default: "ONC"
+ - name: algorithm
+ type: string
+ - name: script_path
+ type: string
+ default: "run_onnxrt_models_trigger.sh"
+
+steps:
+ - template: docker-template.yml
+ parameters:
+ dockerConfigName: "commonDockerConfig"
+ repoName: "neural-compressor"
+ repoTag: "py310"
+ dockerFileName: "Dockerfile"
+ containerName: ${{ parameters.modelContainerName }}
+
+ - script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c \
+ "cd /neural-compressor/.azure-pipelines/scripts/models && bash env_setup.sh --model=${{ parameters.modelName }}"
+ displayName: Env setup
+
+ - script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "cd /neural-compressor/.azure-pipelines/scripts/models \
+ && bash ${{ parameters.script_path }} --model=${{ parameters.modelName }} --stage='prepare_model'"
+ displayName: Export Models
+
+ - task: DownloadPipelineArtifact@2
+ continueOnError: true
+ inputs:
+ source: "specific"
+ artifact: "FinalReport"
+ patterns: "**.json"
+ path: $(Build.SourcesDirectory)/.azure-pipelines/scripts/models/
+ project: $(System.TeamProject)
+ pipeline: "onc model test"
+ runVersion: "specific"
+ runId: $(refer_buildId)
+ displayName: "Download refer logs"
+
+ - script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "cd /neural-compressor/.azure-pipelines/scripts/models \
+ && bash ${{ parameters.script_path }} --model=${{ parameters.modelName }} --stage='quantize'"
+ displayName: Quantize
+
+ - script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "cd /neural-compressor/.azure-pipelines/scripts/models \
+ && bash ${{ parameters.script_path }} --model=${{ parameters.modelName }} --stage='accuracy'"
+ displayName: Run Accuracy Test
+
+ - ${{ if eq(parameters.algorithm, 'Quantize') }}:
+ - script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "cd /neural-compressor/.azure-pipelines/scripts/models \
+ && bash ${{ parameters.script_path }} --model=${{ parameters.modelName }} --stage='performance'"
+ displayName: Run Performance Test
+
+ - task: Bash@3
+ inputs:
+ targetType: "inline"
+ script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "cd /neural-compressor/.azure-pipelines/scripts/models \
+ && python collect_results.py --model=${{ parameters.modelName }} --build_id=$(Build.BuildId)"
+ displayName: Collect Log & Check Results
+
+ - task: PublishPipelineArtifact@1
+ inputs:
+ targetPath: $(Build.SourcesDirectory)/.azure-pipelines/scripts/models/${{ parameters.modelName }}/
+ artifact: ${{ parameters.algorithm }}_${{ parameters.modelName }}
+ publishLocation: "pipeline"
+
+ - task: Bash@3
+ condition: always()
+ inputs:
+ targetType: "inline"
+ script: |
+ docker exec ${{ parameters.modelContainerName }} bash -c "rm -fr /neural-compressor/* && rm -fr /neural-compressor/.* || true"
+ displayName: "Docker Clean Up"
diff --git a/examples/.config/model_params_onnxrt.json b/examples/.config/model_params_onnxrt.json
index 085c7ef6c..e7e0cbda6 100644
--- a/examples/.config/model_params_onnxrt.json
+++ b/examples/.config/model_params_onnxrt.json
@@ -83,6 +83,6 @@
"input_model": "/tf_dataset2/models/onnx/resnet50-v1-12/resnet50-v1-12.onnx",
"main_script": "main.py",
"batch_size": 1
- },
+ }
}
}
diff --git a/examples/image_recognition/resnet50/quantization/ptq_static/prepare_model.py b/examples/image_recognition/resnet50/quantization/ptq_static/prepare_model.py
index 8d7d8d4a9..fd19b8fa8 100644
--- a/examples/image_recognition/resnet50/quantization/ptq_static/prepare_model.py
+++ b/examples/image_recognition/resnet50/quantization/ptq_static/prepare_model.py
@@ -1,7 +1,7 @@
import argparse
import os
import sys
-import urllib
+import urllib.request
MODEL_URL = "https://github.com/onnx/models/raw/main/validated/vision/classification/resnet/model/resnet50-v1-12.onnx"
MAX_TIMES_RETRY_DOWNLOAD = 5
diff --git a/examples/image_recognition/resnet50/quantization/ptq_static/requirements.txt b/examples/image_recognition/resnet50/quantization/ptq_static/requirements.txt
index 1fc10dd8a..63846dabf 100644
--- a/examples/image_recognition/resnet50/quantization/ptq_static/requirements.txt
+++ b/examples/image_recognition/resnet50/quantization/ptq_static/requirements.txt
@@ -4,3 +4,5 @@ torch
torchvision
onnxruntime-extensions
pillow>=8.2.0 # not directly required, pinned by Snyk to avoid a vulnerability
+opencv-python
+scikit-learn
diff --git a/examples/nlp/bert/quantization/ptq_dynamic/prepare_model.py b/examples/nlp/bert/quantization/ptq_dynamic/prepare_model.py
index 5b9216640..64217da37 100644
--- a/examples/nlp/bert/quantization/ptq_dynamic/prepare_model.py
+++ b/examples/nlp/bert/quantization/ptq_dynamic/prepare_model.py
@@ -1,7 +1,7 @@
import argparse
import os
import sys
-import urllib
+import urllib.request
import zipfile
import torch
diff --git a/examples/nlp/bert/quantization/ptq_dynamic/requirements.txt b/examples/nlp/bert/quantization/ptq_dynamic/requirements.txt
index 85dc725a4..a6c2432c8 100644
--- a/examples/nlp/bert/quantization/ptq_dynamic/requirements.txt
+++ b/examples/nlp/bert/quantization/ptq_dynamic/requirements.txt
@@ -6,3 +6,4 @@ onnxruntime
coloredlogs
sympy
onnxruntime-extensions
+scikit-learn
diff --git a/examples/nlp/bert/quantization/ptq_static/prepare_model.py b/examples/nlp/bert/quantization/ptq_static/prepare_model.py
index 5b9216640..64217da37 100644
--- a/examples/nlp/bert/quantization/ptq_static/prepare_model.py
+++ b/examples/nlp/bert/quantization/ptq_static/prepare_model.py
@@ -1,7 +1,7 @@
import argparse
import os
import sys
-import urllib
+import urllib.request
import zipfile
import torch
diff --git a/examples/nlp/bert/quantization/ptq_static/requirements.txt b/examples/nlp/bert/quantization/ptq_static/requirements.txt
index 85dc725a4..a6c2432c8 100644
--- a/examples/nlp/bert/quantization/ptq_static/requirements.txt
+++ b/examples/nlp/bert/quantization/ptq_static/requirements.txt
@@ -6,3 +6,4 @@ onnxruntime
coloredlogs
sympy
onnxruntime-extensions
+scikit-learn