-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
first onnx neural compressor commit #3
Merged
Changes from 11 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
bff952f
first onnx neural compressor commit
chensuyue 6f7983d
update installation
chensuyue 563f113
update SECURITY.md
chensuyue 36196e8
update main branch
chensuyue 6639028
Update docs/coding_style.md
chensuyue dc26e0a
Update setup.py
chensuyue d625ce2
Update docs/coding_style.md
chensuyue fd687a9
update spell
chensuyue bc58628
remove #!/usr/bin/env python
chensuyue 9e6deac
Merge branch 'onc' of https://github.com/onnx/neural-compressor into onc
chensuyue d9db98a
update main page and ci test version
chensuyue 2fd96b0
update test scripts
chensuyue 445414a
simplify the dict
chensuyue e9251b6
update binary build
chensuyue e38882d
remove coding style
chensuyue 77bd1cb
update architecture diagram
thuang6 7556d8e
Refine readme
hshen14 eb7f994
rename python path
chensuyue File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# | ||
# Copyright (c) 2022 Intel Corporation | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
ARG UBUNTU_VER=22.04 | ||
FROM ubuntu:${UBUNTU_VER} as devel | ||
|
||
# See http://bugs.python.org/issue19846 | ||
ENV LANG C.UTF-8 | ||
|
||
RUN apt-get update && apt-get install -y --no-install-recommends --fix-missing \ | ||
python3 \ | ||
python3-pip \ | ||
python3-dev \ | ||
python3-distutils \ | ||
autoconf \ | ||
build-essential \ | ||
git \ | ||
libgl1-mesa-glx \ | ||
libglib2.0-0 \ | ||
numactl \ | ||
time \ | ||
wget \ | ||
bc \ | ||
vim | ||
|
||
RUN ln -sf $(which python3) /usr/bin/python | ||
|
||
RUN python -m pip --no-cache-dir install --upgrade pip | ||
RUN python -m pip install --no-cache-dir setuptools | ||
|
||
RUN pip list | ||
|
||
WORKDIR / | ||
|
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,81 @@ | ||
#!/bin/bash | ||
|
||
# -------------- general approach start---------------- | ||
|
||
# 1. import this file: | ||
# source path/change_color.sh | ||
# 2. use COLOR/BG: | ||
# $VARIABLE_NAME && out_put_content && $RESET | ||
# 3. COLOR + BG: | ||
# $COLOR/BG_VARIABLE_NAME && $BG/COLOR_VARIABLE_NAME && out_put_content && $RESET | ||
# 4. custom | ||
# abbreviation(change number) | ||
# txt number range (30, 37) | ||
# bg number range (40, 47) | ||
# special effects number range (1, 7) | ||
# echo -en \\E[number1 + ; + number2 + ; + number3 + m" | ||
# e.g - BG_GRAY+LIGHT_RED = "echo -en \\E[47;31m" | ||
|
||
# -------------- general approach end----------------== | ||
|
||
|
||
# general setting | ||
# ------------- light_color start---------------- | ||
# black | ||
LIGHT_BLACK="echo -en \\E[30m" | ||
# red | ||
LIGHT_RED="echo -en \\E[31m" | ||
# green | ||
LIGHT_GREEN="echo -en \\E[32m" | ||
# yellow | ||
LIGHT_YELLOW="echo -en \\E[33m" | ||
# blue | ||
LIGHT_BLUE="echo -en \\E[34m" | ||
# purple | ||
LIGHT_PURPLE="echo -en \\E[35m" | ||
# cyan | ||
LIGHT_CYAN="echo -en \\E[36m" | ||
# gray | ||
LIGHT_GRAY="echo -en \\E[37m" | ||
# ------------- light_color end---------------- | ||
|
||
# ------------- bold_color start---------------- | ||
# black | ||
BOLD_BLACK="echo -en \\E[1;30m" | ||
# red | ||
BOLD_RED="echo -en \\E[1;31m" | ||
# green | ||
BOLD_GREEN="echo -en \\E[1;32m" | ||
# yellow | ||
BOLD_YELLOW="echo -en \\E[1;33m" | ||
# blue | ||
BOLD_BLUE="echo -en \\E[1;34m" | ||
# purple | ||
BOLD_PURPLE="echo -en \\E[1;35m" | ||
# cyan | ||
BOLD_CYAN="echo -en \\E[1;36m" | ||
# gray | ||
BOLD_GRAY="echo -en \\E[1;37m" | ||
# ------------- bold_color end---------------- | ||
|
||
# ------------- background_color start---------------- | ||
# black | ||
BG_BLACK="echo -en \\E[40m" | ||
# red | ||
BG_RED="echo -en \\E[41m" | ||
# green | ||
BG_GREEN="echo -en \\E[42m" | ||
# yellow | ||
BG_YELLOW="echo -en \\E[43m" | ||
# blue | ||
BG_BLUE="echo -en \\E[44m" | ||
# purple | ||
BG_PURPLE="echo -en \\E[45m" | ||
# cyan | ||
BG_CYAN="echo -en \\E[46m" | ||
# gray | ||
BG_GRAY="echo -en \\E[47m" | ||
# ------------- background_color end---------------- | ||
|
||
# close | ||
RESET="echo -en \\E[0m" |
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,14 @@ | ||
activ | ||
ans | ||
datas | ||
ende | ||
lates | ||
masia | ||
mutli | ||
nd | ||
ot | ||
rouge | ||
te | ||
tne | ||
ue | ||
womens |
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,11 @@ | ||
#!/bin/bash | ||
|
||
echo -e "\n Install Neural Compressor ... " | ||
cd /neural-compressor | ||
|
||
python -m pip install --no-cache-dir -r requirements.txt | ||
python setup.py bdist_wheel | ||
pip install dist/neural_compressor*.whl --force-reinstall | ||
|
||
echo -e "\n pip list after install Neural Compressor ... " | ||
pip list |
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,133 @@ | ||
source /neural-compressor/.azure-pipelines/scripts/change_color.sh | ||
|
||
set -e | ||
pip install coverage | ||
export COVERAGE_RCFILE=/neural-compressor/.azure-pipelines/scripts/ut/coverage.ort | ||
coverage_log="/neural-compressor/log_dir/coverage_log" | ||
coverage_log_base="/neural-compressor/log_dir/coverage_log_base" | ||
coverage_compare="/neural-compressor/log_dir/coverage_compare.html" | ||
cd /neural-compressor/log_dir | ||
|
||
$BOLD_YELLOW && echo "collect coverage for PR branch" && $RESET | ||
cp ut_coverage/.coverage /neural-compressor/ | ||
mkdir -p coverage_PR | ||
cd /neural-compressor | ||
coverage report -m --rcfile=${COVERAGE_RCFILE} | tee ${coverage_log} | ||
coverage html -d log_dir/coverage_PR/htmlcov --rcfile=${COVERAGE_RCFILE} | ||
coverage xml -o log_dir/coverage_PR/coverage.xml --rcfile=${COVERAGE_RCFILE} | ||
ls -l log_dir/coverage_PR/htmlcov | ||
|
||
|
||
$BOLD_YELLOW && echo "collect coverage for baseline" && $RESET | ||
cd /neural-compressor | ||
cp -r /neural-compressor/.azure-pipelines .azure-pipelines-pr | ||
git config --global --add safe.directory /neural-compressor | ||
git fetch | ||
git checkout ONC | ||
rm -rf build dist *egg-info | ||
echo y | pip uninstall neural_compressor_ort | ||
cd /neural-compressor/.azure-pipelines-pr/scripts && bash install_nc.sh | ||
|
||
coverage erase | ||
cd /neural-compressor/log_dir | ||
mkdir -p coverage_base | ||
rm -rf /neural-compressor/.coverage || true | ||
cp ut_baseline_coverage/.coverage /neural-compressor | ||
|
||
cd /neural-compressor | ||
coverage report -m --rcfile=${COVERAGE_RCFILE} | tee ${coverage_log_base} | ||
coverage html -d log_dir/coverage_base/htmlcov --rcfile=${COVERAGE_RCFILE} | ||
coverage xml -o log_dir/coverage_base/coverage.xml --rcfile=${COVERAGE_RCFILE} | ||
ls -l log_dir/coverage_base/htmlcov | ||
|
||
get_coverage_data() { | ||
# Input argument | ||
local coverage_xml="$1" | ||
|
||
# Get coverage data | ||
local coverage_data=$(python3 -c "import xml.etree.ElementTree as ET; root = ET.parse('$coverage_xml').getroot(); print(ET.tostring(root).decode())") | ||
if [[ -z "$coverage_data" ]]; then | ||
echo "Failed to get coverage data from $coverage_xml." | ||
exit 1 | ||
fi | ||
|
||
# Get lines coverage | ||
local lines_covered=$(echo "$coverage_data" | grep -o 'lines-covered="[0-9]*"' | cut -d '"' -f 2) | ||
local lines_valid=$(echo "$coverage_data" | grep -o 'lines-valid="[0-9]*"' | cut -d '"' -f 2) | ||
if [ $lines_valid == 0 ]; then | ||
local lines_coverage=0 | ||
else | ||
local lines_coverage=$(awk "BEGIN {printf \"%.3f\", 100 * $lines_covered / $lines_valid}") | ||
fi | ||
|
||
# Get branches coverage | ||
local branches_covered=$(echo "$coverage_data" | grep -o 'branches-covered="[0-9]*"' | cut -d '"' -f 2) | ||
local branches_valid=$(echo "$coverage_data" | grep -o 'branches-valid="[0-9]*"' | cut -d '"' -f 2) | ||
if [ $branches_valid == 0 ]; then | ||
local branches_coverage=0 | ||
else | ||
local branches_coverage=$(awk "BEGIN {printf \"%.3f\", 100 * $branches_covered/$branches_valid}") | ||
fi | ||
|
||
# Return values | ||
echo "$lines_covered $lines_valid $lines_coverage $branches_covered $branches_valid $branches_coverage" | ||
} | ||
|
||
$BOLD_YELLOW && echo "compare coverage" && $RESET | ||
|
||
coverage_PR_xml="log_dir/coverage_PR/coverage.xml" | ||
coverage_PR_data=$(get_coverage_data $coverage_PR_xml) | ||
read lines_PR_covered lines_PR_valid coverage_PR_lines_rate branches_PR_covered branches_PR_valid coverage_PR_branches_rate <<<"$coverage_PR_data" | ||
|
||
coverage_base_xml="log_dir/coverage_base/coverage.xml" | ||
coverage_base_data=$(get_coverage_data $coverage_base_xml) | ||
read lines_base_covered lines_base_valid coverage_base_lines_rate branches_base_covered branches_base_valid coverage_base_branches_rate <<<"$coverage_base_data" | ||
|
||
$BOLD_BLUE && echo "PR lines coverage: $lines_PR_covered/$lines_PR_valid ($coverage_PR_lines_rate%)" && $RESET | ||
$BOLD_BLUE && echo "PR branches coverage: $branches_PR_covered/$branches_PR_valid ($coverage_PR_branches_rate%)" && $RESET | ||
$BOLD_BLUE && echo "BASE lines coverage: $lines_base_covered/$lines_base_valid ($coverage_base_lines_rate%)" && $RESET | ||
$BOLD_BLUE && echo "BASE branches coverage: $branches_base_covered/$branches_base_valid ($coverage_base_branches_rate%)" && $RESET | ||
|
||
$BOLD_YELLOW && echo "clear upload path" && $RESET | ||
rm -fr log_dir/coverage_PR/.coverage* | ||
rm -fr log_dir/coverage_base/.coverage* | ||
rm -fr log_dir/ut-coverage-* | ||
|
||
# Declare an array to hold failed items | ||
declare -a fail_items=() | ||
|
||
if (( $(bc -l <<< "${coverage_PR_lines_rate}+0.05 < ${coverage_base_lines_rate}") )); then | ||
fail_items+=("lines") | ||
fi | ||
if (( $(bc -l <<< "${coverage_PR_branches_rate}+0.05 < ${coverage_base_branches_rate}") )); then | ||
fail_items+=("branches") | ||
fi | ||
|
||
if [[ ${#fail_items[@]} -ne 0 ]]; then | ||
fail_items_str=$( | ||
IFS=', ' | ||
echo "${fail_items[*]}" | ||
) | ||
for item in "${fail_items[@]}"; do | ||
case "$item" in | ||
lines) | ||
decrease=$(echo $(printf "%.3f" $(echo "$coverage_PR_lines_rate - $coverage_base_lines_rate" | bc -l))) | ||
;; | ||
branches) | ||
decrease=$(echo $(printf "%.3f" $(echo "$coverage_PR_branches_rate - $coverage_base_branches_rate" | bc -l))) | ||
;; | ||
*) | ||
echo "Unknown item: $item" | ||
continue | ||
;; | ||
esac | ||
$BOLD_RED && echo "Unit Test failed with ${item} coverage decrease ${decrease}%" && $RESET | ||
done | ||
$BOLD_RED && echo "compare coverage to give detail info" && $RESET | ||
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "FAILED" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate} | ||
exit 1 | ||
else | ||
$BOLD_GREEN && echo "Unit Test success with coverage lines: ${coverage_PR_lines_rate}%, branches: ${coverage_PR_branches_rate}%" && $RESET | ||
$BOLD_GREEN && echo "compare coverage to give detail info" && $RESET | ||
bash /neural-compressor/.azure-pipelines-pr/scripts/ut/compare_coverage.sh ${coverage_compare} ${coverage_log} ${coverage_log_base} "SUCCESS" ${coverage_PR_lines_rate} ${coverage_base_lines_rate} ${coverage_PR_branches_rate} ${coverage_base_branches_rate} | ||
fi |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For CI, I would prefer github actions when possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, we can have a migrate plan. May I know the reason to choose GHA instead of Azure pipeline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - ONNX has moved to use github actions because they are easier to manage (doesn't need to belong to an ado organization which would require additional permissions) and they run faster. So that's two wins. I use chatgpt to translate the yaml files and it was pretty straightforward: onnx/onnx#6075
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw there are several comments on CI tools, those are good suggestions. In our plan, this PR intends to land a MVP scope code migration to community first and enhance the CI/CD continuously during maintenance. I suggest to get this PR merged first and address these items progressively. does it make sense? @freddychiu @justinchuby
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add issue Suggest to use github actions for CI when possible to track this comment