Skip to content

Commit

Permalink
Merge pull request #2 from daquexian/master
Browse files Browse the repository at this point in the history
onnx optimizer init
  • Loading branch information
linkerzhang authored Sep 7, 2020
2 parents b60acbe + 0613c20 commit 0299379
Show file tree
Hide file tree
Showing 45 changed files with 5,472 additions and 0 deletions.
103 changes: 103 additions & 0 deletions .azure-pipelines/Linux-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
trigger:
- master

jobs:
- job: 'Test'
pool:
vmImage: 'Ubuntu-16.04'
strategy:
matrix:
py27:
python.version: '2.7'
onnx_ml: 0
onnx_debug: 0
py36:
python.version: '3.6'
onnx_ml: 0
onnx_debug: 0
py37:
python.version: '3.7'
onnx_ml: 0
onnx_debug: 0
py37-ml:
python.version: '3.7'
onnx_ml: 1
onnx_debug: 0
py37-ml-debug:
python.version: '3.7'
onnx_ml: 1
onnx_debug: 1
maxParallel: 5

steps:
- script: sudo install -d -m 0777 /home/vsts/.conda/envs
displayName: Fix Conda permissions

- task: CondaEnvironment@1
inputs:
createCustomEnvironment: true
environmentName: 'py$(python.version)'
packageSpecs: 'python=$(python.version) protobuf'

- script: |
python -m pip install --upgrade pip
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y --no-install-recommends dos2unix
python -m pip install numpy
git submodule update --init --recursive
export ONNX_ML=${onnx_ml}
export DEBUG=${onnx_debug}
export ONNX_BUILD_TESTS=0
export CMAKE_ARGS="-DONNXIFI_DUMMY_BACKEND=ON"
export ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI
python setup.py --quiet install
displayName: 'Install ONNX and dependencies'
- script: |
# lint python code
pip install --quiet flake8
flake8
if [ $? -ne 0 ]; then
echo "flake8 returned failures"
exit 1
fi
# check line endings to be UNIX
find . -type f -regextype posix-extended -regex '.*\.(py|cpp|md|h|cc|proto|proto3|in)' | xargs dos2unix --quiet
# Do not hardcode onnx's namespace in the c++ source code, so that
# other libraries who statically link with onnx can hide onnx symbols
# in a private namespace.
! grep -R --include='*.cc' --include='*.h' 'namespace onnx' .
! grep -R --include='*.cc' --include='*.h' 'onnx::' .
# onnx python api tests
if [ "$(python.version)" == "2.7" ]; then
pip install --quiet pytest nbval
else
# pytest 6.0 made deprecation warnings fail by default, pinning pytest to 5.4.3.
# TODO replace deprecated function with the suggested one. https://docs.pytest.org/en/stable/deprecations.html#id5
pip install --quiet pytest==5.4.3 nbval
fi
pytest
if [ $? -ne 0 ]; then
echo "pytest failed"
exit 1
fi
# Mypy only works with Python 3
if [ "$(python.version)" != "2.7" ]; then
# Mypy only works with our generated _pb.py files when we install in develop mode, so let's do that
pip uninstall -y onnxoptimizer
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install --no-use-pep517 -e .[mypy]
python setup.py --quiet typecheck
if [ $? -ne 0 ]; then
echo "type check failed"
exit 1
fi
pip uninstall -y onnxoptimizer
rm -rf .setuptools-cmake-build
ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI pip install .
fi
displayName: 'Run ONNX Optimizer tests'
70 changes: 70 additions & 0 deletions .azure-pipelines/MacOS-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
trigger:
- master

jobs:
- job: 'Test'
pool:
vmImage: 'macOS-10.14'
strategy:
matrix:
py27:
python.version: '2.7'
onnx_ml: 0
py36:
python.version: '3.6'
onnx_ml: 0
py36-onnx-ml:
python.version: '3.6'
onnx_ml: 1
maxParallel: 3

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'

- script: |
git submodule update --init --recursive
python -m pip install --upgrade setuptools
python -m pip install numpy
conda install -y -c conda-forge pybind11 protobuf
brew update
brew install protobuf
export DEBUG=${onnx_debug}
export ONNX_ML=${onnx_ml}
export CMAKE_ARGS="-DONNX_USE_LITE_PROTO=ON -DONNXIFI_DUMMY_BACKEND=ON"
export ONNX_NAMESPACE=ONNX_NAMESPACE_FOO_BAR_FOR_CI
python setup.py --quiet install
displayName: 'Install dependencies and ONNX'
- script: |
# lint python code
pip install --quiet flake8
flake8
if [ $? -ne 0 ]; then
echo "flake8 returned failures"
exit 1
fi
# Do not hardcode onnx's namespace in the c++ source code, so that
# other libraries who statically link with onnx can hide onnx symbols
# in a private namespace.
! grep -R --include='*.cc' --include='*.h' 'namespace onnx' .
! grep -R --include='*.cc' --include='*.h' 'onnx::' .
# onnx python api tests
if [ "$(python.version)" == "2.7" ]; then
pip install --quiet pytest nbval
else
# pytest 6.0 made deprecation warnings fail by default, pinning pytest to 5.4.3.
# TODO replace deprecated function with the suggested one. https://docs.pytest.org/en/stable/deprecations.html#id5
pip install --quiet pytest==5.4.3 nbval
fi
pytest onnxoptimizer
if [ $? -ne 0 ]; then
echo "pytest failed"
exit 1
fi
displayName: 'Run ONNX Optimizer Tests'
66 changes: 66 additions & 0 deletions .azure-pipelines/Windows-CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
trigger:
- master

jobs:

- job: 'Test'
pool:
vmImage: 'vs2017-win2016'
strategy:
matrix:
py37:
python.version: '3.7'
onnx_ml: 0
onnx_verify_proto: 0
py36:
python.version: '3.6'
onnx_ml: 0
onnx_verify_proto: 0
py37_onnx_ml:
python.version: '3.7'
onnx_ml: 1
onnx_verify_proto: 0
py36_verify_proto:
python.version: '3.6'
onnx_ml: 0
onnx_verify_proto: 1
maxParallel: 4

steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'

- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH

- script: conda create --yes --quiet --name py$(python.version) -c conda-forge python=$(python.version) numpy libprotobuf=3.11.3 protobuf
displayName: Create Anaconda environment

- script: |
call activate py$(python.version)
python -m pip install --upgrade pip
# pytest 6.0 made deprecation warnings fail by default, pinning pytest to 5.4.3.
# TODO replace deprecated function with the suggested one. https://docs.pytest.org/en/stable/deprecations.html#id5
python -m pip install --quiet pytest==5.4.3 nbval numpy
git submodule update --init --recursive
set ONNX_BUILD_TESTS=1
set ONNX_ML=$(onnx_ml)
set ONNX_VERIFY_PROTO_3=$(onnx_verify_proto)
set USE_MSVC_STATIC_RUNTIME=0
set CMAKE_ARGS=-DONNX_USE_PROTOBUF_SHARED_LIBS=ON -DProtobuf_USE_STATIC_LIBS=OFF -DONNX_USE_LITE_PROTO=ON
python setup.py --quiet install
pytest
IF NOT %ERRORLEVEL% EQU 0 (
@echo "pytest failed"
EXIT 1
)
rm -rf .setuptools-cmake-build
pip install --quiet -e .[mypy]
python setup.py typecheck
displayName: Install and test ONNX Optimizer
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## General

# Compiled Object files
*.slo
*.lo
*.o
*.cuo

# Compiled Dynamic libraries
*.so
*.dylib
*.pyd

# Compiled Static libraries
*.lai
*.la
*.a

# Compiled python
*.pyc

# Compiled MATLAB
*.mex*

# IPython notebook checkpoints
.ipynb_checkpoints

# Editor temporaries
*.swn
*.swo
*.swp
*~

# Sublime Text settings
*.sublime-workspace
*.sublime-project

# Eclipse Project settings
*.*project
.settings

# QtCreator files
*.user

# PyCharm files
.idea

# Visual Studio Code files
.vscode

# OSX dir files
.DS_Store

## ONNX

# build, distribute, and bins (+ python proto bindings)
build
build_*
.build_debug/*
.build_release/*
.setuptools-cmake-build/*

# setup.py intermediates
.eggs
dist
*.egg-info
*.ninja
.ninja_deps
.ninja_log
compile_commands.json

# generated files
onnxoptimizer/version.py
compile_commands.json

# autocomplete
.ycm_extra_conf.py

# test coverage data files
*.gcov

.mypy_cache
virtualenv
venv
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "third_party/onnx"]
path = third_party/onnx
url = https://github.com/onnx/onnx
Loading

0 comments on commit 0299379

Please sign in to comment.