Skip to content

Commit b48ec6d

Browse files
committed
Merge branch 'master' into r1.8
2 parents cd55bf6 + c7231d5 commit b48ec6d

File tree

79 files changed

+4077
-548
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+4077
-548
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ The common issues we run into we try to document here [Troubleshooting Guide](Tr
1818

1919
| Build Type | OS | Python | Tensorflow | Onnx opset | Status |
2020
| --- | --- | --- | --- | --- | --- |
21-
| Unit Test - Basic | Linux, MacOS<sup>\*</sup>, Windows<sup>\*</sup> | 3.6, 3.7, 3.8 | 1.12-1.15, 2.1-2.4 | 7-13 | [![Build Status](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_apis/build/status/unit_test?branchName=master)](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_build/latest?definitionId=16&branchName=master) |
22-
| Unit Test - Full | Linux, MacOS, Windows | 3.6, 3.7, 3.8 | 1.12-1.15, 2.1-2.4 | 7-13 | [![Build Status](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_apis/build/status/unit_test-matrix?branchName=master)](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_build/latest?definitionId=18&branchName=master) | |
21+
| Unit Test - Basic | Linux, MacOS<sup>\*</sup>, Windows<sup>\*</sup> | 3.6, 3.7, 3.8 | 1.12-1.15, 2.1-2.5 | 7-13 | [![Build Status](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_apis/build/status/unit_test?branchName=master)](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_build/latest?definitionId=16&branchName=master) |
22+
| Unit Test - Full | Linux, MacOS, Windows | 3.6, 3.7, 3.8 | 1.12-1.15, 2.1-2.5 | 7-13 | [![Build Status](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_apis/build/status/unit_test-matrix?branchName=master)](https://dev.azure.com/tensorflow-onnx/tensorflow-onnx/_build/latest?definitionId=18&branchName=master) | |
2323
<br/>
2424

2525
## Supported Versions

ci_build/azure_pipelines/onnxruntime_nightly_test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ stages:
3939
- template: 'unit_test.yml'
4040
report_coverage: 'True'
4141

42+
- template: 'templates/job_generator.yml'
43+
parameters:
44+
platforms: ['linux', 'windows']
45+
python_versions: [3.8']
46+
tf_versions: ['2.5.0rc1']
47+
onnx_opsets: ['']
48+
onnx_backends: {onnxruntime: ['nightly']}
49+
job:
50+
steps:
51+
- template: 'unit_test.yml'
52+
report_coverage: 'True'
53+
4254
- template: 'templates/combine_test_coverage.yml'
4355

4456
schedules:

ci_build/azure_pipelines/pretrained_model_test-matrix.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,12 @@ jobs:
2727
job:
2828
steps:
2929
- template: 'pretrained_model_test.yml'
30-
30+
31+
- template: 'templates/job_generator.yml'
32+
parameters:
33+
platforms: ['linux', 'windows']
34+
python_versions: ['3.8']
35+
tf_versions: ['2.5.0rc1']
36+
job:
37+
steps:
38+
- template: 'pretrained_model_test.yml'

ci_build/azure_pipelines/templates/job_generator.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ parameters:
66
tf_versions: ['']
77
onnx_versions: ['']
88
onnx_opsets: ['13', '12', '11', '10', '9', '8', '7']
9-
onnx_backends: {onnxruntime: ['1.6.0']}
9+
onnx_backends: {onnxruntime: ['1.7.0']}
1010
job: {}
1111
run_setup: 'True'
1212
report_coverage: 'False'

ci_build/azure_pipelines/templates/setup.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ steps:
2525
pip install --index-url https://test.pypi.org/simple/ ort-nightly
2626
fi
2727
28+
if [[ $CI_PLATFORM == "windows" ]] ;
29+
then
30+
pip install -i https://test.pypi.org/simple/ onnxruntime-customops==0.0.1
31+
if [[ $CI_TF_VERSION == 2.* ]] ;
32+
then
33+
pip install tensorflow-text
34+
fi
35+
fi
36+
2837
python setup.py install
2938
pip freeze --all
3039
displayName: 'Setup Environment'

ci_build/azure_pipelines/unit_test-matrix.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ stages:
77
parameters:
88
platforms: ['linux', 'windows']
99
python_versions: ['3.6']
10-
tf_versions: ['1.13.1', '1.12.3']
10+
tf_versions: ['1.12.3']
1111
onnx_opsets: ['']
1212
job:
1313
steps:
@@ -35,5 +35,16 @@ stages:
3535
steps:
3636
- template: 'unit_test.yml'
3737
report_coverage: 'True'
38+
39+
- template: 'templates/job_generator.yml'
40+
parameters:
41+
platforms: ['linux', 'windows']
42+
python_versions: ['3.8']
43+
tf_versions: ['2.5.0rc1']
44+
onnx_opsets: ['']
45+
job:
46+
steps:
47+
- template: 'unit_test.yml'
48+
report_coverage: 'True'
3849

3950
- template: 'templates/combine_test_coverage.yml'

ci_build/azure_pipelines/unit_test.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ stages:
66
- template: 'templates/job_generator.yml'
77
parameters:
88
python_versions: ['3.8']
9-
tf_versions: ['2.4.0']
9+
tf_versions: ['2.5.0rc1']
1010
onnx_opsets: ['']
1111
skip_tflite_tests: 'False'
1212
skip_tf_tests: 'True'
@@ -30,7 +30,7 @@ stages:
3030
- template: 'templates/job_generator.yml'
3131
parameters:
3232
python_versions: ['3.8']
33-
tf_versions: ['2.4.0']
33+
tf_versions: ['2.5.0rc1']
3434
onnx_opsets: ['']
3535
job:
3636
steps:
@@ -40,7 +40,7 @@ stages:
4040
- template: 'templates/job_generator.yml'
4141
parameters:
4242
python_versions: ['3.7']
43-
tf_versions: ['1.14.0','1.15.2','2.2.0','2.3.0']
43+
tf_versions: ['1.14.0','1.15.2','2.3.0','2.4.1']
4444
onnx_opsets: ['']
4545
job:
4646
steps:
@@ -67,5 +67,16 @@ stages:
6767
- template: 'unit_test.yml'
6868
report_coverage: 'True'
6969

70+
- template: 'templates/job_generator.yml'
71+
parameters:
72+
python_versions: ['3.7']
73+
platforms: ['windows']
74+
tf_versions: ['2.4.1']
75+
onnx_opsets: ['']
76+
job:
77+
steps:
78+
- template: 'unit_test.yml'
79+
report_coverage: 'True'
80+
7081
- template: 'templates/combine_test_coverage.yml'
7182

examples/getting_started.py

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
"""
4+
This example shows how to convert tf functions and keras models using the Python API.
5+
It also demonstrates converting saved_models from the command line.
6+
"""
7+
8+
import tensorflow as tf
9+
import tf2onnx
10+
import numpy as np
11+
import onnxruntime as ort
12+
import os
13+
14+
##################### tf function #####################
15+
16+
@tf.function
17+
def f(a, b):
18+
return a + b
19+
20+
input_signature = [tf.TensorSpec([2, 3], tf.float32), tf.TensorSpec([2, 3], tf.float32)]
21+
onnx_model, _ = tf2onnx.convert.from_function(f, input_signature, opset=13)
22+
23+
a_val = np.ones([2, 3], np.float32)
24+
b_val = np.zeros([2, 3], np.float32)
25+
26+
print("Tensorflow result")
27+
print(f(a_val, b_val).numpy())
28+
29+
print("ORT result")
30+
sess = ort.InferenceSession(onnx_model.SerializeToString())
31+
res = sess.run(None, {'a': a_val, 'b': b_val})
32+
print(res[0])
33+
34+
35+
##################### Keras Model #####################
36+
37+
model = tf.keras.Sequential()
38+
model.add(tf.keras.layers.Dense(4, activation="relu"))
39+
40+
input_signature = [tf.TensorSpec([3, 3], tf.float32, name='x')]
41+
onnx_model, _ = tf2onnx.convert.from_keras(model, input_signature, opset=13)
42+
43+
x_val = np.ones((3, 3), np.float32)
44+
45+
print("Keras result")
46+
print(model(x_val).numpy())
47+
48+
print("ORT result")
49+
sess = ort.InferenceSession(onnx_model.SerializeToString())
50+
res = sess.run(None, {'x': x_val})
51+
print(res[0])
52+
53+
54+
##################### Saved Model #####################
55+
56+
model.save("savedmodel")
57+
os.system("python -m tf2onnx.convert --saved-model savedmodel --output model.onnx --opset 13")
58+
59+
print("ORT result")
60+
sess = ort.InferenceSession("model.onnx")
61+
res = sess.run(None, {'dense_input:0': x_val})
62+
print(res[0])
63+
64+
print("Conversion succeeded")

setup.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,22 @@ def run(self):
8181
8282
author_email='[email protected]',
8383
url='https://github.com/onnx/tensorflow-onnx',
84-
install_requires=['numpy>=1.14.1', 'onnx>=1.4.1', 'requests', 'six', 'flatbuffers']
84+
install_requires=['numpy>=1.14.1', 'onnx>=1.4.1', 'requests', 'six', 'flatbuffers~=1.12'],
85+
classifiers=[
86+
'Development Status :: 5 - Production/Stable',
87+
'Intended Audience :: Developers',
88+
'Intended Audience :: Education',
89+
'Intended Audience :: Science/Research',
90+
'License :: OSI Approved :: Apache2 License',
91+
'Topic :: Scientific/Engineering',
92+
'Topic :: Scientific/Engineering :: Mathematics',
93+
'Topic :: Scientific/Engineering :: Artificial Intelligence',
94+
'Topic :: Software Development',
95+
'Topic :: Software Development :: Libraries',
96+
'Topic :: Software Development :: Libraries :: Python Modules',
97+
'Programming Language :: Python :: 3',
98+
'Programming Language :: Python :: 3.6',
99+
'Programming Language :: Python :: 3.7',
100+
'Programming Language :: Python :: 3.8',
101+
'Programming Language :: Python :: 3.9']
85102
)

0 commit comments

Comments
 (0)