Skip to content

Commit 61f1e9e

Browse files
shinhlinkerzhang
authored andcommitted
Enable ONNX_ML by default (onnx#1810)
* 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
1 parent 4f064a1 commit 61f1e9e

File tree

8 files changed

+29
-26
lines changed

8 files changed

+29
-26
lines changed

.circleci/build.sh

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pip install -U pip setuptools
3131
# setup onnx as the submodule of pytorch
3232
PYTORCH_DIR=/tmp/pytorch
3333
ONNX_DIR="$PYTORCH_DIR/third_party/onnx"
34+
export ONNX_ML=0
3435
git clone --recursive --quiet https://github.com/pytorch/pytorch.git "$PYTORCH_DIR"
3536
rm -rf "$ONNX_DIR"
3637
cp -r "$PWD" "$ONNX_DIR"

.travis.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ matrix:
44
include:
55
- os: linux
66
sudo: required
7-
env: PYTHON_VERSION=python2
7+
env: PYTHON_VERSION=python2 ONNX_ML=0
88
language: python
99
python: "2.7"
1010
- os: linux
1111
sudo: required
12-
env: PYTHON_VERSION=python3
12+
env: PYTHON_VERSION=python3 ONNX_ML=0
1313
language: python
1414
python: "3.6"
1515
- os: osx
1616
osx_image: xcode9.3
17-
env: PYTHON_VERSION=python2
17+
env: PYTHON_VERSION=python2 ONNX_ML=0
1818
- os: osx
1919
osx_image: xcode9.3
20-
env: PYTHON_VERSION=python3
20+
env: PYTHON_VERSION=python3 ONNX_ML=0
2121
- os: linux
2222
sudo: required
23-
env: PYTHON_VERSION=python2 ONNX_ML=1
23+
env: PYTHON_VERSION=python2
2424
language: python
2525
python: "2.7"
2626
- os: linux
2727
sudo: required
28-
env: PYTHON_VERSION=python3 ONNX_ML=1
28+
env: PYTHON_VERSION=python3
2929
language: python
3030
python: "3.6"
3131
- os: osx
3232
osx_image: xcode9.3
33-
env: PYTHON_VERSION=python2 ONNX_ML=1
33+
env: PYTHON_VERSION=python2
3434
- os: osx
3535
osx_image: xcode9.3
36-
env: PYTHON_VERSION=python3 ONNX_ML=1
36+
env: PYTHON_VERSION=python3
3737
- os: linux
3838
sudo: required
39-
env: PYTHON_VERSION=python2 ONNX_ML=1 LITE=1
39+
env: PYTHON_VERSION=python2 LITE=1
4040
language: python
4141
python: "2.7"
4242
- os: osx
4343
osx_image: xcode9.3
44-
env: PYTHON_VERSION=python2 ONNX_ML=1 LITE=1
44+
env: PYTHON_VERSION=python2 LITE=1
4545

4646
env:
4747
global:

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ option(ONNX_WERROR "Build with Werror" OFF)
2323
option(ONNX_COVERAGE "Build with coverage instrumentation" OFF)
2424
option(ONNX_BUILD_TESTS "Build ONNX C++ APIs Tests" OFF)
2525
option(ONNX_USE_LITE_PROTO "Use lite protobuf instead of full." OFF)
26+
if(DEFINED ENV{ONNX_ML})
27+
set(DEFAULT_ONNX_ML $ENV{ONNX_ML})
28+
else()
29+
set(DEFAULT_ONNX_ML ON)
30+
endif()
31+
option(ONNX_ML "Enable traditional ML API." ${DEFAULT_ONNX_ML})
2632
option(ONNXIFI_DUMMY_BACKEND "Use dummy backend in onnxifi test driver." OFF)
2733

2834
# Set C++11 as standard for the whole project

appveyor.yml

+4-8
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,13 @@ environment:
1818

1919
matrix:
2020
# onnx-ml
21-
- ONNX_ML: 1
22-
CONDA_PREFIX: C:\Miniconda35-x64
21+
- CONDA_PREFIX: C:\Miniconda35-x64
2322

24-
- ONNX_ML: 1
25-
CONDA_PREFIX: C:\Miniconda36-x64
23+
- CONDA_PREFIX: C:\Miniconda36-x64
2624

27-
- ONNX_ML: 1
28-
CONDA_PREFIX: C:\Miniconda36
25+
- CONDA_PREFIX: C:\Miniconda36
2926

30-
- ONNX_ML: 1
31-
CONDA_PREFIX: C:\Miniconda35
27+
- CONDA_PREFIX: C:\Miniconda35
3228

3329
install:
3430
- cmd: git submodule update --init --recursive

docs/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ way to get these dependencies is via [Anaconda](https://www.anaconda.com/downloa
88
conda install -c conda-forge protobuf numpy
99
```
1010

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

1313
```
1414
git clone --recursive https://github.com/onnx/onnx.git

onnx/defs/gen_doc.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
SNIPPETS = collect_snippets()
2222
SAMPLE_IMPLEMENTATIONS = collect_sample_implementations()
23-
ONNX_ML = bool(os.getenv('ONNX_ML') == '1')
23+
ONNX_ML = not bool(os.getenv('ONNX_ML') == '0')
2424

2525

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

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

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

434-
if os.getenv('ONNX_ML'):
434+
if ONNX_ML:
435435
all_functions = defs.get_functions(ONNX_ML_DOMAIN)
436436
else:
437437
all_functions = defs.get_functions('')
438438

439439
if all_functions:
440-
if os.getenv('ONNX_ML'):
440+
if ONNX_ML:
441441
s = '## {}\n'.format(ONNX_ML_DOMAIN)
442442
domain_prefix = '{}.'.format(ONNX_ML_DOMAIN)
443443
else:

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# Global variables for controlling the build variant
4242
################################################################################
4343

44-
ONNX_ML = bool(os.getenv('ONNX_ML') == '1')
44+
ONNX_ML = not bool(os.getenv('ONNX_ML') == '0')
4545
ONNX_NAMESPACE = os.getenv('ONNX_NAMESPACE', 'onnx')
4646
ONNX_BUILD_TESTS = bool(os.getenv('ONNX_BUILD_TESTS') == '1')
4747

tools/update_doc.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# export ONNX_ML=1, # if you need to use ONNX_ML
3+
# export ONNX_ML=0, # if you need to disable ONNX_ML
44

55
python_exist=`command -v python`
66
if [ -z $python_exist ]; then

0 commit comments

Comments
 (0)