Skip to content

Commit 0e3720c

Browse files
hwangdeyuguschmue
andauthored
Add commit value to onnx file and clean up part of code (#1897)
* add commit value to onnx file, remove expired code and add License in generating version.py Signed-off-by: Deyu Huang <[email protected]> Co-authored-by: Guenther Schmuelling <[email protected]> * change onnx repo master to main Signed-off-by: Deyu Huang <[email protected]> * fix comments Signed-off-by: Deyu Huang <[email protected]> Co-authored-by: Guenther Schmuelling <[email protected]>
1 parent cd9f141 commit 0e3720c

File tree

12 files changed

+18
-21
lines changed

12 files changed

+18
-21
lines changed

setup.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ def finalize_options(self):
3737
pass
3838

3939
def run(self):
40+
alv2_license = '# SPDX-License-Identifier: Apache-2.0\n\n'
4041
with open(os.path.join(SRC_DIR, 'version.py'), 'w') as f:
41-
f.write(dedent('''
42+
f.write(alv2_license + dedent('''
4243
version = '{version}'
4344
git_version = '{git_version}'
4445
'''.format(**dict(VersionInfo._asdict()))))

tests/keras2onnx_applications/model_source/densenet_1/densenet_1.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
- [Densely Connected Convolutional Networks](https://arxiv.org/pdf/1608.06993.pdf)
99
- [The One Hundred Layers Tiramisu: Fully Convolutional DenseNets for Semantic Segmentation](https://arxiv.org/pdf/1611.09326.pdf)
1010
'''
11-
from __future__ import print_function
12-
from __future__ import absolute_import
13-
from __future__ import division
1411

1512
import warnings
1613

tests/keras2onnx_applications/model_source/densenet_1/subpixel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
# From https://github.com/titu1994/DenseNet/blob/master/subpixel.py
44
# Modifications Copyright (c) Microsoft.
55

6-
from __future__ import absolute_import
7-
86
from mock_keras2onnx.proto import keras
97
from keras import backend as K
108
from keras.engine import Layer

tests/test_onnx_shape_inference.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class ONNXShapeInferenceTests(Tf2OnnxBackendTestBase):
2222
"""
2323
Test shape inference, it's just a subset of all cases that can be inferred shape.
2424
For more information, please refer to onnx shape inference test:
25-
https://github.com/onnx/onnx/blob/master/onnx/test/shape_inference_test.py
25+
https://github.com/onnx/onnx/blob/main/onnx/test/shape_inference_test.py
2626
"""
2727

2828
def _run_test_case(self, graph, feed_dict):

tf2onnx/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
"tfonnx", "shape_inference", "schemas", "tf_utils", "tf_loader", "convert"]
77

88
import onnx
9-
from .version import version as __version__
9+
from .version import git_version, version as __version__
1010
from . import verbose_logging as logging
1111
from tf2onnx import tfonnx, utils, graph, graph_builder, graph_matcher, shape_inference, schemas, convert # pylint: disable=wrong-import-order
12-
#from tf2onnx import tf_utils, tf_loader

tf2onnx/graph.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import numpy as np
1313

1414
from onnx import helper, numpy_helper, shape_inference, AttributeProto, TensorProto
15-
from tf2onnx import utils, __version__
15+
from tf2onnx import utils, __version__, git_version
1616
from tf2onnx.utils import make_name, port_name, find_opset
1717
from tf2onnx import optimizer
1818
from tf2onnx.schemas import get_schema, infer_onnx_shape_dtype
@@ -1189,9 +1189,10 @@ def make_model(self, graph_doc, optimize=False, graph_name="tf2onnx", external_t
11891189
graph = self.make_graph(graph_doc, graph_name, external_tensor_storage)
11901190

11911191
if "producer_name" not in kwargs:
1192-
kwargs = {"producer_name": "tf2onnx",
1193-
"producer_version": __version__}
1194-
1192+
kwargs = {
1193+
"producer_name": "tf2onnx",
1194+
"producer_version": __version__ + " " + git_version[:6]
1195+
}
11951196
if "opset_imports" not in kwargs:
11961197
opsets = [helper.make_opsetid(constants.ONNX_DOMAIN, self._opset)]
11971198
opsets.append(constants.AI_ONNX_ML_OPSET)
@@ -1605,7 +1606,7 @@ def safe_remove_nodes(self, to_delete):
16051606
self.remove_node(n.name)
16061607

16071608
def is_safe_to_remove_nodes(self, to_delete, outputs_to_ignore=None):
1608-
"""Returns true if the outputs of all the nodes in to_delete have no third-party nodes consuming them"""
1609+
"""Returns true if the outputs of all the nodes in to_delete have no third-party nodes consuming them."""
16091610
delete_set = set(to_delete)
16101611
outputs_to_ignore_set = set(outputs_to_ignore or [])
16111612
for n in delete_set:
@@ -1660,7 +1661,7 @@ def optimize_model_proto(onnx_model_proto, catch_errors=True, return_graph=False
16601661

16611662
@staticmethod
16621663
def get_onnx_model_properties(onnx_model_proto):
1663-
"""Get ModelProto properties"""
1664+
"""Get ModelProto properties."""
16641665
kwargs = {}
16651666
if onnx_model_proto.HasField('ir_version'):
16661667
kwargs["ir_version"] = onnx_model_proto.ir_version

tf2onnx/optimizer/const_fold_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def _fold_unsqueeze(node, graph):
150150
dims_out = len(shape_in) + len(axes)
151151
axes = [i if i >= 0 else i + dims_out for i in axes]
152152
# calculate the shape of output accroding to onnx Unsqueeze's spec
153-
# https://github.com/onnx/onnx/blob/master/docs/Operators.md#Unsqueeze
153+
# https://github.com/onnx/onnx/blob/main/docs/Operators.md#Unsqueeze
154154
shape_in = iter(shape_in)
155155
shape_out = [None] * dims_out
156156
for ind in axes:

tf2onnx/optimizer/loop_optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class LoopOptimizer(GraphOptimizerBase):
1616
"""Loop Optimizer."""
1717

1818
# a lot of terms used here come from loop's onnx spec
19-
# https://github.com/onnx/onnx/blob/master/docs/Operators.md#Loop
19+
# https://github.com/onnx/onnx/blob/main/docs/Operators.md#Loop
2020
def __init__(self): # pylint: disable=useless-super-delegation
2121
super(LoopOptimizer, self).__init__()
2222

tf2onnx/version.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3+
34
version = '1.10.0'
4-
git_version = '219e00c073f6e73fba7335630dcf1f96cc82c983'
5+
git_version = '0065af6273eac0e911a0e75eab1cdf6be1c9ac7b'

tools/aggregate-patterns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def get_args():
133133
parser.add_argument("--fold", action="store_true", help="fold smaller sub graphs")
134134
parser.add_argument("--max-nodes", type=int, default=6, help="number of max nodes in a pattern")
135135
parser.add_argument("--min-frequency", type=int, default=2, help="show patterns number seen at least this")
136-
parser.add_argument("infile", nargs="*", help='event files')
136+
parser.add_argument("--infile", nargs="*", help="event files")
137137
args = parser.parse_args()
138138
return args
139139

0 commit comments

Comments
 (0)