Skip to content

Commit

Permalink
Enable ONNX_ML by default (onnx#1810)
Browse files Browse the repository at this point in the history
* Enable ONNX_ML by default

Apparently, official wheel packages enable it. However, if a
user builds ONNX by herself/himself, ONNX_ML will be disabled
by default. For example, as of writing, ONNX does not have a
wheel package for Python 3.7 and users need to build ONNX.

* Disable ONNX_ML for PyTorch

* Honor ONNX_ML in an environment variable

* Fix the condition for ONNX_ML in gen_doc.py

* Revert a permission change
  • Loading branch information
shinh authored and linkerzhang committed Feb 14, 2019
1 parent 4f064a1 commit 61f1e9e
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 26 deletions.
1 change: 1 addition & 0 deletions .circleci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pip install -U pip setuptools
# setup onnx as the submodule of pytorch
PYTORCH_DIR=/tmp/pytorch
ONNX_DIR="$PYTORCH_DIR/third_party/onnx"
export ONNX_ML=0
git clone --recursive --quiet https://github.com/pytorch/pytorch.git "$PYTORCH_DIR"
rm -rf "$ONNX_DIR"
cp -r "$PWD" "$ONNX_DIR"
Expand Down
20 changes: 10 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,44 @@ matrix:
include:
- os: linux
sudo: required
env: PYTHON_VERSION=python2
env: PYTHON_VERSION=python2 ONNX_ML=0
language: python
python: "2.7"
- os: linux
sudo: required
env: PYTHON_VERSION=python3
env: PYTHON_VERSION=python3 ONNX_ML=0
language: python
python: "3.6"
- os: osx
osx_image: xcode9.3
env: PYTHON_VERSION=python2
env: PYTHON_VERSION=python2 ONNX_ML=0
- os: osx
osx_image: xcode9.3
env: PYTHON_VERSION=python3
env: PYTHON_VERSION=python3 ONNX_ML=0
- os: linux
sudo: required
env: PYTHON_VERSION=python2 ONNX_ML=1
env: PYTHON_VERSION=python2
language: python
python: "2.7"
- os: linux
sudo: required
env: PYTHON_VERSION=python3 ONNX_ML=1
env: PYTHON_VERSION=python3
language: python
python: "3.6"
- os: osx
osx_image: xcode9.3
env: PYTHON_VERSION=python2 ONNX_ML=1
env: PYTHON_VERSION=python2
- os: osx
osx_image: xcode9.3
env: PYTHON_VERSION=python3 ONNX_ML=1
env: PYTHON_VERSION=python3
- os: linux
sudo: required
env: PYTHON_VERSION=python2 ONNX_ML=1 LITE=1
env: PYTHON_VERSION=python2 LITE=1
language: python
python: "2.7"
- os: osx
osx_image: xcode9.3
env: PYTHON_VERSION=python2 ONNX_ML=1 LITE=1
env: PYTHON_VERSION=python2 LITE=1

env:
global:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ option(ONNX_WERROR "Build with Werror" OFF)
option(ONNX_COVERAGE "Build with coverage instrumentation" OFF)
option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF)
option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
if(DEFINED ENV{ONNX_ML})
set(DEFAULT_ONNX_ML $ENV{ONNX_ML})
else()
set(DEFAULT_ONNX_ML ON)
endif()
option(ONNX_ML "Enable traditional ML API." ${DEFAULT_ONNX_ML})
option(ONNXIFI_DUMMY_BACKEND "Use dummy backend in onnxifi test driver." OFF)

# Set C++11 as standard for the whole project
Expand Down
12 changes: 4 additions & 8 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,13 @@ environment:

matrix:
# onnx-ml
- ONNX_ML: 1
CONDA_PREFIX: C:\Miniconda35-x64
- CONDA_PREFIX: C:\Miniconda35-x64

- ONNX_ML: 1
CONDA_PREFIX: C:\Miniconda36-x64
- CONDA_PREFIX: C:\Miniconda36-x64

- ONNX_ML: 1
CONDA_PREFIX: C:\Miniconda36
- CONDA_PREFIX: C:\Miniconda36

- ONNX_ML: 1
CONDA_PREFIX: C:\Miniconda35
- CONDA_PREFIX: C:\Miniconda35

install:
- cmd: git submodule update --init --recursive
Expand Down
2 changes: 1 addition & 1 deletion docs/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ way to get these dependencies is via [Anaconda](https://www.anaconda.com/downloa
conda install -c conda-forge protobuf numpy
```

During development, it's convenient to install ONNX in development mode (for ONNX-ML, set environment variable `ONNX_ML=1`):
During development, it's convenient to install ONNX in development mode (to disable ONNX-ML, set environment variable `ONNX_ML=0`):

```
git clone --recursive https://github.com/onnx/onnx.git
Expand Down
10 changes: 5 additions & 5 deletions onnx/defs/gen_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

SNIPPETS = collect_snippets()
SAMPLE_IMPLEMENTATIONS = collect_sample_implementations()
ONNX_ML = bool(os.getenv('ONNX_ML') == '1')
ONNX_ML = not bool(os.getenv('ONNX_ML') == '0')


if ONNX_ML:
Expand Down Expand Up @@ -307,7 +307,7 @@ def main(args): # type: (Type[Args]) -> None
" [def files](/onnx/defs) via [this script](/onnx/defs/gen_doc.py).\n"
" Do not modify directly and instead edit function definitions.*\n")

if os.getenv('ONNX_ML'):
if ONNX_ML:
all_functions = defs.get_functions(ONNX_ML_DOMAIN)
else:
all_functions = defs.get_functions('')
Expand All @@ -317,7 +317,7 @@ def main(args): # type: (Type[Args]) -> None
for func in functions:
changelog_versionmap[func.since_version].append(func)

if os.getenv('ONNX_ML'):
if ONNX_ML:
s = '## {}\n'.format(ONNX_ML_DOMAIN)
domain_display_name = ONNX_ML_DOMAIN
domain_prefix = '{}.'.format(ONNX_ML_DOMAIN)
Expand Down Expand Up @@ -431,13 +431,13 @@ def main(args): # type: (Type[Args]) -> None
" [def files](/onnx/defs) via [this script](/onnx/defs/gen_doc.py).\n"
" Do not modify directly and instead edit function definitions.*\n")

if os.getenv('ONNX_ML'):
if ONNX_ML:
all_functions = defs.get_functions(ONNX_ML_DOMAIN)
else:
all_functions = defs.get_functions('')

if all_functions:
if os.getenv('ONNX_ML'):
if ONNX_ML:
s = '## {}\n'.format(ONNX_ML_DOMAIN)
domain_prefix = '{}.'.format(ONNX_ML_DOMAIN)
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
# Global variables for controlling the build variant
################################################################################

ONNX_ML = bool(os.getenv('ONNX_ML') == '1')
ONNX_ML = not bool(os.getenv('ONNX_ML') == '0')
ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'onnx')
ONNX_BUILD_TESTS = bool(os.getenv('ONNX_BUILD_TESTS') == '1')

Expand Down
2 changes: 1 addition & 1 deletion tools/update_doc.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

# export ONNX_ML=1, # if you need to use ONNX_ML
# export ONNX_ML=0, # if you need to disable ONNX_ML

python_exist=`command -v python`
if [ -z $python_exist ]; then
Expand Down

0 comments on commit 61f1e9e

Please sign in to comment.