Skip to content

Commit 2781a32

Browse files
authored
Update tf2onnx to support latest tf version. (#2131)
* Add tflite updates caused by tf 2.11. * Fix SIGN op issue for tf2.11. * Remove unused attribute of ConvTransposeWithDynamicPads op. * Add CI tests for tf 2.11.0. Signed-off-by: Jay Zhang <[email protected]>
1 parent 82ae7c4 commit 2781a32

24 files changed

+548
-51
lines changed

ci_build/azure_pipelines/keras2onnx_unit_test.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ jobs:
2929
INSTALL_ORT: pip install onnxruntime==1.12.0
3030
INSTALL_NUMPY:
3131

32+
Python310-tf2.10:
33+
python.version: '3.10'
34+
ONNX_PATH: onnx==1.12.0
35+
TENSORFLOW_PATH: tensorflow==2.10.0
36+
INSTALL_ORT: pip install onnxruntime==1.13.1
37+
INSTALL_NUMPY:
38+
3239
############ Pure Keras Unit Tests ############
3340
Keras-Py37-tf1.15.0:
3441
python.version: '3.7'
@@ -78,6 +85,13 @@ jobs:
7885
INSTALL_ORT: pip install onnxruntime==1.12.0
7986
INSTALL_NUMPY:
8087

88+
Python310-tf2.10:
89+
python.version: '3.10'
90+
ONNX_PATH: onnx==1.12.0
91+
TENSORFLOW_PATH: tensorflow==2.10.0
92+
INSTALL_ORT: pip install onnxruntime==1.13.1
93+
INSTALL_NUMPY:
94+
8195
############ Pure Keras Unit Tests ############
8296
Keras-Py37-tf1.15.0:
8397
python.version: '3.7'

ci_build/azure_pipelines/pretrained_model_test-matrix.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ jobs:
5555
steps:
5656
- template: 'pretrained_model_test.yml'
5757

58+
- template: 'templates/job_generator.yml'
59+
parameters:
60+
python_versions: ['3.9']
61+
tf_versions: ['2.11.0']
62+
job:
63+
steps:
64+
- template: 'pretrained_model_test.yml'
65+
5866
schedules:
5967
- cron: "0 10 * * *"
6068
displayName: pre-trained model test, full matrix

ci_build/azure_pipelines/templates/setup.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ steps:
7272
else
7373
pip install tensorflow-text
7474
fi
75+
if [[ $CI_TF_VERSION < 2.8 ]] ;
76+
then
77+
pip install wrapt==1.14.1
78+
fi
7579
fi
7680
7781
# Protobuf 3.20 results in linker errors on Windows in TF.

ci_build/azure_pipelines/trimmed_keras2onnx_application_tests.yml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,25 +21,37 @@ jobs:
2121
INSTALL_LEGACY: pip install h5py==2.9.0
2222
NIGHTLY_BUILD_TEST: python run_all.py --exclude "test_keras_applications_v2.py"
2323

24-
Python38-tf2-latest:
24+
Python38-tf-2.9:
2525
python.version: '3.8'
2626
ONNX_PATH: onnx==1.12.0
2727
INSTALL_KERAS:
2828
UNINSTALL_KERAS:
29-
INSTALL_TENSORFLOW: pip install tensorflow==2.10.0
30-
INSTALL_ORT: pip install onnxruntime==1.13.1
29+
INSTALL_TENSORFLOW: pip install tensorflow==2.9.1
30+
INSTALL_ORT: pip install onnxruntime==1.12.0
3131
INSTALL_KERAS_RESNET: pip install keras-resnet
3232
INSTALL_TRANSFORMERS: pip install transformers==4.2.0
3333
INSTALL_NUMPY:
3434
NIGHTLY_BUILD_TEST: python run_all_v2.py
3535

36-
Python38-tf-2.x:
36+
Python38-tf2-2.10:
3737
python.version: '3.8'
3838
ONNX_PATH: onnx==1.12.0
3939
INSTALL_KERAS:
4040
UNINSTALL_KERAS:
41-
INSTALL_TENSORFLOW: pip install tensorflow==2.9.1
42-
INSTALL_ORT: pip install onnxruntime==1.12.0
41+
INSTALL_TENSORFLOW: pip install tensorflow==2.10.0
42+
INSTALL_ORT: pip install onnxruntime==1.13.1
43+
INSTALL_KERAS_RESNET: pip install keras-resnet
44+
INSTALL_TRANSFORMERS: pip install transformers==4.2.0
45+
INSTALL_NUMPY:
46+
NIGHTLY_BUILD_TEST: python run_all_v2.py
47+
48+
Python38-tf2-2.11:
49+
python.version: '3.9'
50+
ONNX_PATH: onnx==1.13.1
51+
INSTALL_KERAS:
52+
UNINSTALL_KERAS:
53+
INSTALL_TENSORFLOW: pip install tensorflow==2.11.0
54+
INSTALL_ORT: pip install onnxruntime==1.13.1
4355
INSTALL_KERAS_RESNET: pip install keras-resnet
4456
INSTALL_TRANSFORMERS: pip install transformers==4.2.0
4557
INSTALL_NUMPY:

ci_build/azure_pipelines/trimmed_keras2onnx_unit_test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ jobs:
2525

2626
Python310-tf-latest:
2727
python.version: '3.10'
28-
ONNX_PATH: onnx==1.12.0
29-
TENSORFLOW_PATH: tensorflow==2.10.0
28+
ONNX_PATH: onnx==1.13.1
29+
TENSORFLOW_PATH: tensorflow==2.11.0
3030
INSTALL_ORT: pip install onnxruntime==1.13.1
3131
INSTALL_NUMPY:
3232

@@ -66,8 +66,8 @@ jobs:
6666

6767
Python310-tf-latest:
6868
python.version: '3.10'
69-
ONNX_PATH: onnx==1.12.0
70-
TENSORFLOW_PATH: tensorflow==2.10.0
69+
ONNX_PATH: onnx==1.13.1
70+
TENSORFLOW_PATH: tensorflow==2.11.0
7171
INSTALL_ORT: pip install onnxruntime==1.13.1
7272
INSTALL_NUMPY:
7373

ci_build/azure_pipelines/unit_test-matrix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ stages:
5151
parameters:
5252
platforms: ['windows']
5353
python_versions: ['3.9']
54-
tf_versions: ['2.9.0']
54+
tf_versions: ['2.9.1']
5555
onnx_opsets: ['']
5656
job:
5757
steps:

ci_build/azure_pipelines/unit_test.yml

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ stages:
1616
# - template: 'unit_test.yml'
1717
# report_coverage: 'True'
1818

19+
- template: 'templates/job_generator.yml'
20+
parameters:
21+
python_versions: ['3.10']
22+
tf_versions: ['2.11.0']
23+
onnx_opsets: ['']
24+
skip_tflite_tests: 'False'
25+
skip_tf_tests: 'False'
26+
skip_tfjs_tests: 'True'
27+
job:
28+
steps:
29+
- template: 'unit_test.yml'
30+
report_coverage: 'True'
31+
1932
- template: 'templates/job_generator.yml'
2033
parameters:
2134
python_versions: ['3.8']
@@ -132,10 +145,10 @@ stages:
132145

133146
- template: 'templates/job_generator.yml'
134147
parameters:
135-
python_versions: ['3.9']
148+
python_versions: ['3.10']
136149
platforms: ['windows']
137150
tf_versions: ['2.9.1']
138-
onnx_opsets: ['16']
151+
onnx_opsets: ['17']
139152
job:
140153
steps:
141154
- template: 'unit_test.yml'
@@ -145,8 +158,8 @@ stages:
145158
parameters:
146159
python_versions: ['3.10']
147160
platforms: ['windows']
148-
tf_versions: ['2.9.1']
149-
onnx_opsets: ['17']
161+
tf_versions: ['2.11.0']
162+
onnx_opsets: ['16']
150163
job:
151164
steps:
152165
- template: 'unit_test.yml'

tests/keras2onnx_unit_tests/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717

1818
# Mapping opset to ONNXRuntime version.
19+
# TODO: upgrade opset to 18 for 1.14.0 after the below issue is fixed:
20+
# https://github.com/onnx/tensorflow-onnx/issues/2132
1921
ORT_OPSET_VERSION = {
2022
"1.6.0": 13, "1.7.0": 13, "1.8.0": 14, "1.9.0": 15, "1.10.0": 15, "1.11.0": 16,
21-
"1.12.0": 17, "1.13.0": 17
23+
"1.12.0": 17, "1.13.0": 17, "1.14.0": 17
2224
}
2325

2426
working_path = os.path.abspath(os.path.dirname(__file__))

tf2onnx/tflite/ATan2Options.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
# automatically generated by the FlatBuffers compiler, do not modify
4+
5+
# namespace: tflite
6+
7+
import flatbuffers
8+
from flatbuffers.compat import import_numpy
9+
np = import_numpy()
10+
11+
class ATan2Options(object):
12+
__slots__ = ['_tab']
13+
14+
@classmethod
15+
def GetRootAs(cls, buf, offset=0):
16+
n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
17+
x = ATan2Options()
18+
x.Init(buf, n + offset)
19+
return x
20+
21+
@classmethod
22+
def GetRootAsATan2Options(cls, buf, offset=0):
23+
"""This method is deprecated. Please switch to GetRootAs."""
24+
return cls.GetRootAs(buf, offset)
25+
@classmethod
26+
def ATan2OptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
27+
return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x54\x46\x4C\x33", size_prefixed=size_prefixed)
28+
29+
# ATan2Options
30+
def Init(self, buf, pos):
31+
self._tab = flatbuffers.table.Table(buf, pos)
32+
33+
def Start(builder): builder.StartObject(0)
34+
def ATan2OptionsStart(builder):
35+
"""This method is deprecated. Please switch to Start."""
36+
return Start(builder)
37+
def End(builder): return builder.EndObject()
38+
def ATan2OptionsEnd(builder):
39+
"""This method is deprecated. Please switch to End."""
40+
return End(builder)

tf2onnx/tflite/BuiltinOperator.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,4 +157,11 @@ class BuiltinOperator(object):
157157
MULTINOMIAL = 149
158158
GELU = 150
159159
DYNAMIC_UPDATE_SLICE = 151
160+
RELU_0_TO_1 = 152
161+
UNSORTED_SEGMENT_PROD = 153
162+
UNSORTED_SEGMENT_MAX = 154
163+
UNSORTED_SEGMENT_SUM = 155
164+
ATAN2 = 156
165+
UNSORTED_SEGMENT_MIN = 157
166+
SIGN = 158
160167

0 commit comments

Comments
 (0)