Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into mbencer/OnnxProto…
Browse files Browse the repository at this point in the history
…SymbolsVisibility

Signed-off-by: mbencer <mateusz.bencer@intel.com>
  • Loading branch information
mbencer committed Jul 21, 2021
2 parents ffbae99 + 2875f51 commit 2781c41
Show file tree
Hide file tree
Showing 222 changed files with 4,683 additions and 465 deletions.
4 changes: 2 additions & 2 deletions .azure-pipelines/Linux-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.11.3
git checkout v3.16.0
git submodule update --init --recursive
mkdir build_source && cd build_source
Expand All @@ -57,7 +57,7 @@ jobs:
cd ../..
python -m pip install --upgrade pip
python -m pip install numpy protobuf==3.11.3
python -m pip install numpy protobuf==3.16.0
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y --no-install-recommends dos2unix
git submodule update --init --recursive
Expand Down
4 changes: 3 additions & 1 deletion .azure-pipelines/Windows-CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ jobs:
- powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts"
displayName: Add conda to PATH

- script: conda create --yes --quiet --name py$(python.version) python=$(python.version) numpy libprotobuf=3.11.3 protobuf
- script: |
conda create --yes --quiet --name py$(python.version) python=$(python.version)
conda install -n py$(python.version) -y -c conda-forge numpy libprotobuf=3.16.0
displayName: Create Anaconda environment
- script: |
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/manylinux/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ set -e -x
PY_VERSION=$1
PLAT=$2
GITHUB_EVENT_NAME=$3
BUILD_REQUIREMENTS='numpy==1.16.6 protobuf==3.11.3'
BUILD_REQUIREMENTS='numpy==1.16.6 protobuf==3.16.0'
SYSTEM_PACKAGES='cmake3'
if [ `uname -m` == 'aarch64' ]; then
SYSTEM_PACKAGES='cmake'
else
SYSTEM_PACKAGES='cmake3'
fi

export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib

Expand All @@ -20,7 +25,7 @@ ONNX_PATH=$(pwd)
cd ..
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.11.3
git checkout v3.16.0
git submodule update --init --recursive
mkdir build_source && cd build_source

Expand All @@ -31,11 +36,16 @@ cd $ONNX_PATH

# Compile wheels
# Need to be updated if there is a new Python Version
declare -A python_map=( ["3.6"]="cp36-cp36m" ["3.7"]="cp37-cp37m" ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39")
declare -A python_include=( ["3.6"]="3.6m" ["3.7"]="3.7m" ["3.8"]="3.8" ["3.9"]="3.9")
PY_VER=${python_map[$PY_VERSION]}
PIP_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir"
PYTHON_COMAND="/opt/python/"${PY_VER}"/bin/python"
if [ `uname -m` == 'aarch64' ]; then
PIP_COMMAND="$PY_VERSION -m pip install --no-cache-dir"
PYTHON_COMMAND="$PY_VERSION"
else
declare -A python_map=( ["3.6"]="cp36-cp36m" ["3.7"]="cp37-cp37m" ["3.8"]="cp38-cp38" ["3.9"]="cp39-cp39")
declare -A python_include=( ["3.6"]="3.6m" ["3.7"]="3.7m" ["3.8"]="3.8" ["3.9"]="3.9")
PY_VER=${python_map[$PY_VERSION]}
PIP_COMMAND="/opt/python/${PY_VER}/bin/pip install --no-cache-dir"
PYTHON_COMMAND="/opt/python/"${PY_VER}"/bin/python"
fi

# set ONNX build environments
export ONNX_ML=1
Expand All @@ -51,9 +61,9 @@ fi

# Build wheels
if [ "$GITHUB_EVENT_NAME" == "schedule" ]; then
$PYTHON_COMAND setup.py bdist_wheel --weekly_build || { echo "Building wheels failed."; exit 1; }
$PYTHON_COMMAND setup.py bdist_wheel --weekly_build || { echo "Building wheels failed."; exit 1; }
else
$PYTHON_COMAND setup.py bdist_wheel || { echo "Building wheels failed."; exit 1; }
$PYTHON_COMMAND setup.py bdist_wheel || { echo "Building wheels failed."; exit 1; }
fi


Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/manylinux/test_package_i686.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ PYTHON_COMAND="${PYTHON_BIN}python"
PYTEST_COMMAND="${PYTHON_BIN}pytest"

$PIP_INTALL_COMMAND --upgrade pip
$PIP_INTALL_COMMAND numpy protobuf==3.11.3
$PIP_INTALL_COMMAND numpy protobuf==3.16.0
$PIP_INTALL_COMMAND dist/*manylinux2010_i686.whl

# pytest with the built wheel
Expand Down
123 changes: 123 additions & 0 deletions .github/workflows/release_linux_aarch64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: LinuxRelease_aarch64

on:
schedule:
# Run weekly on Monday 00:00
- cron: '00 00 * * MON'
push:
branches: [master, rel-*]
pull_request:
branches: [rel-*, master]
workflow_dispatch:

jobs:
build:
if: github.event_name != 'pull_request' || startsWith( github.base_ref, 'rel-') || contains( github.event.pull_request.labels.*.name, 'run release CIs')
runs-on: ubuntu-latest
strategy:
matrix:
# the different python versions for building wheels
python-version: [cp36-cp36m, cp37-cp37m, cp38-cp38, cp39-cp39]
env:
# setting up python and docker image
py: /opt/python/${{ matrix.python-version }}/bin/python
img: quay.io/pypa/manylinux2014_aarch64

steps:
- uses: actions/checkout@v2
- name: Checkout submodules
shell: bash
run: |
auth_header="$(git config --local --get http.https://github.com/.extraheader)"
git submodule sync --recursive
git -c "http.extraheader=$auth_header" -c protocol.version=2 submodule update --init --force --recursive --depth=1
# setting up qemu for enabling aarch64 binary execution on x86 machine
- uses: docker/setup-qemu-action@v1

# Creating a virtual environment on machine with the help of docker container \
# and installing the dependencies inside that \
# so that we can use installed dependencies.
- name: Install dependencies
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '${{ env.py }} -m pip install virtualenv && ${{ env.py }} -m venv .env && \
source .env/bin/activate && \
${{ env.py }} -m pip install -U numpy protobuf==3.16.0 && \
yum install -y protobuf-compiler protobuf-devel
deactivate'
# using created virtual environment in new container and executing the script
- name: Build manylinux2014_aarch64
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
yum install -y sudo && \
sudo chmod +x .github/workflows/manylinux/entrypoint.sh && \
sudo .github/workflows/manylinux/entrypoint.sh ${{ env.py }} manylinux2014_aarch64 ${{ github.event_name }}
deactivate'
# using created virtual environment in new container and testing the wheel
- name: Test wheel with Python ${{ matrix.python-version }}
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip install --upgrade pip && \
pip install dist/*manylinux2014_aarch64.whl && \
pip install pytest nbval ipython==7.16.1 && \
pytest && \
deactivate'
- name: Test backend test data
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
# onnx.checker all existing backend data
python workflow_scripts/test_generated_backend.py && \
# onnx.checker all generated backend data && \
python onnx/backend/test/cmd_tools.py generate-data && \
python workflow_scripts/test_generated_backend.py && \
deactivate'
- uses: actions/upload-artifact@v1
with:
name: wheels
path: dist

- name: Upload wheel to TestPyPI weekly
if: (github.event_name == 'schedule') # Only triggered by weekly event
run: |
python -m pip install -q twine
twine upload --verbose dist/*.whl --repository-url https://test.pypi.org/legacy/ -u ${{ secrets.TESTPYPI_USERNAME }} -p ${{ secrets.TESTPYPI_PASSWORD }}
- name: Verify ONNX with the latest numpy and protobuf
if: ${{ always() }}
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip uninstall -y numpy onnx && python -m pip install numpy && \
python -m pip install dist/*manylinux2014_aarch64.whl && \
python -m pip install pytest && \
pytest && \
deactivate'
- name: Verify ONNX with ort-nightly
if: ${{ always() }}
run: |
docker run --rm -v ${{ github.workspace }}:/ws:rw --workdir=/ws \
${{ env.img }} \
bash -exc '\
source .env/bin/activate && \
python -m pip install flatbuffers && \
python -m pip install -i https://test.pypi.org/simple/ ort-nightly && \
python onnx/test/test_with_ort.py && \
deactivate'
2 changes: 1 addition & 1 deletion .github/workflows/release_linux_i686.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install numpy protobuf==3.11.3
python -m pip install numpy protobuf==3.16.0
sudo apt-get install protobuf-compiler libprotoc-dev
- name: Build manylinux2010_i686
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_linux_x86_64.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install numpy protobuf==3.11.3
python -m pip install numpy protobuf==3.16.0
- name: Build manylinux2010_x86_64
uses: docker://quay.io/pypa/manylinux2010_x86_64
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release_mac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,16 @@ jobs:
- name: Install protobuf dependencies
run: |
# Install protobuf 3.11.3
# Install protobuf 3.16.0
export NUM_CORES=`sysctl -n hw.ncpu`
echo Using $NUM_CORES cores
brew update
brew install autoconf && brew install automake
export ONNX_PATH=$(pwd)
cd ..
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz
tar -xvf protobuf-cpp-3.11.3.tar.gz
cd protobuf-3.11.3
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/protobuf-cpp-3.16.0.tar.gz
tar -xvf protobuf-cpp-3.16.0.tar.gz
cd protobuf-3.16.0
mkdir build_source && cd build_source
cmake ../cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
make -j${NUM_CORES}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_win.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
uses: actions/checkout@master
with:
repository: protocolbuffers/protobuf
ref: refs/tags/v3.11.3
ref: refs/tags/v3.16.0
path: ./protobuf_root/protobuf

- name: Checkout Protobuf submodules
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/weekly_mac_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ jobs:
- name: Install protobuf dependencies
run: |
# Install protobuf 3.11.3 due to compatibility
# Install protobuf 3.16.0 due to compatibility
export NUM_CORES=`sysctl -n hw.ncpu`
echo Using $NUM_CORES cores
brew update
brew install autoconf && brew install automake
export ONNX_PATH=$(pwd)
cd ..
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz
tar -xvf protobuf-cpp-3.11.3.tar.gz
cd protobuf-3.11.3
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/protobuf-cpp-3.16.0.tar.gz
tar -xvf protobuf-cpp-3.16.0.tar.gz
cd protobuf-3.16.0
mkdir build_source && cd build_source
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
make -j${NUM_CORES}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/win_no_exception_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
uses: actions/checkout@master
with:
repository: protocolbuffers/protobuf
ref: refs/tags/v3.11.3
ref: refs/tags/v3.16.0
path: ./protobuf_root/protobuf

- name: Checkout Protobuf submodules
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Stay up to date with the latest ONNX news. [[Facebook](https://www.facebook.com/
## Official Python packages
ONNX released packages are published in PyPi.
```
pip install numpy protobuf==3.11.3
pip install numpy protobuf==3.16.0
pip install onnx
```

Expand All @@ -63,7 +63,7 @@ pip install onnx
## Conda packages
A binary build of ONNX is available from [Conda](https://conda.io), in [conda-forge](https://conda-forge.org/):
```
conda install -c conda-forge numpy protobuf==3.11.3 libprotobuf=3.11.3
conda install -c conda-forge numpy protobuf==3.16.0 libprotobuf=3.16.0
conda install -c conda-forge onnx
```

Expand All @@ -72,7 +72,7 @@ You can also use the [onnx-dev docker image](https://hub.docker.com/r/onnx/onnx-

## Build ONNX from Source
Before building from source uninstall any existing versions of onnx `pip uninstall onnx`.
If you are building ONNX from source, it is recommended that you also build Protobuf locally as a static library. Specifically on Windows, the version distributed with conda-forge is a DLL, but ONNX expects it to be a static library. Building protobuf locally also let's you control the verison of protobuf. The tested and recommended version is 3.11.3.
If you are building ONNX from source, it is recommended that you also build Protobuf locally as a static library. Specifically on Windows, the version distributed with conda-forge is a DLL, but ONNX expects it to be a static library. Building protobuf locally also let's you control the verison of protobuf. The tested and recommended version is 3.16.0.

Note for Windows : The instructions in this README assume you are using Visual Studio. It is recommended that you run all the commands from a shell started from "Developer Command Prompt for VS 2019" and keep the build system generator for cmake (e.g., cmake -G "Visual Studio 16 2019") consistent while building protobuf as well as ONNX.
```
Expand All @@ -89,7 +89,7 @@ pip install -e .
```
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.11.3
git checkout v3.16.0
cd cmake
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=<protobug_install_dir> -Dprotobuf_MSVC_STATIC_RUNTIME=ON -Dprotobuf_BUILD_SHARED_LIBS=OFF -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_BUILD_EXAMPLES=OFF .
msbuild protobuf.sln /m /p:Configuration=Release
Expand All @@ -100,7 +100,7 @@ msbuild INSTALL.vcxproj /p:Configuration=Release
```
git clone https://github.com/protocolbuffers/protobuf.git
cd protobuf
git checkout v3.11.3
git checkout v3.16.0
git submodule update --init --recursive
mkdir build_source && cd build_source
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
Expand All @@ -113,9 +113,9 @@ make install
export NUM_CORES=`sysctl -n hw.ncpu`
brew update
brew install autoconf && brew install automake
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.11.3/protobuf-cpp-3.11.3.tar.gz
tar -xvf protobuf-cpp-3.11.3.tar.gz
cd protobuf-3.11.3
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.16.0/protobuf-cpp-3.16.0.tar.gz
tar -xvf protobuf-cpp-3.16.0.tar.gz
cd protobuf-3.16.0
mkdir build_source && cd build_source
cmake ../cmake -Dprotobuf_BUILD_SHARED_LIBS=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -Dprotobuf_BUILD_TESTS=OFF -DCMAKE_BUILD_TYPE=Release
make -j${NUM_CORES}
Expand Down
6 changes: 4 additions & 2 deletions docs/AddNewOp.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,11 @@ Once the criteria of proposing new operator/function has been satisfied, you wil
1. The testing examples will be extracted to the doc.
2. We also generate binary data for it.
3. Example: https://github.com/onnx/onnx/blob/master/onnx/backend/test/case/node/abs.py
5. Update the documentation and generate the test data.
5. Add at least one automatic upgrade test for your operator in https://github.com/onnx/onnx/blob/master/onnx/test/automatic_upgrade_test.py using `_test_op_upgrade`. These tests create a given operator at a given opset version (usually the version the operator was introduced in) and test that the version converter is able to convert them to the highest available version. So for a new operator `_test_op_upgrade` will not test anything, but as soon as the operator gets updated in a future opset the test will autoamtically become nontrivial.
6. Update the documentation and generate the test data.
1. Running [the script](https://github.com/onnx/onnx/blob/master/tools/update_doc.sh)
to update the doc and generate the test data.
6. Shape Inference function
7. Shape Inference function
1. Please provide a shape inference function in cases where it is meaningful and applicable.
2. In cases where shape inference is not possible, it must have logic to perform
rank inference at the very least (adding right amount of dimensions to the output shape)
Expand Down Expand Up @@ -81,6 +82,7 @@ Any operator in ONNX was added because it was required by a model and/or framewo
* Or a set of primitive operators that together can implement the same functionality and behavior of the deprecated operator (Function).
* If the deprecated operator can be decomposed by existing operators then it must be converted to a function.
* If replacement isn’t in ONNX standard yet, then add the replacement operator or set of operators first.
* Add a version adapter which turns the operator into its replacement for the version converter. Example: https://github.com/onnx/onnx/blob/master/onnx/version_converter/adapters/upsample_9_10.h
* No grace period is needed for deprecated operators.

## Removing function <a name="removing_function"></a>
Expand Down
Loading

0 comments on commit 2781c41

Please sign in to comment.