onnx2tf 1.25.15__py3-none-any.whl → 1.26.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- onnx2tf/__init__.py +1 -1
- onnx2tf/onnx2tf.py +33 -13
- onnx2tf/ops/Conv.py +12 -0
- onnx2tf/utils/common_functions.py +13 -6
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/METADATA +19 -9
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/RECORD +11 -11
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/LICENSE +0 -0
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/LICENSE_onnx-tensorflow +0 -0
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/WHEEL +0 -0
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/entry_points.txt +0 -0
- {onnx2tf-1.25.15.dist-info → onnx2tf-1.26.0.dist-info}/top_level.txt +0 -0
onnx2tf/__init__.py
CHANGED
onnx2tf/onnx2tf.py
CHANGED
|
@@ -72,7 +72,8 @@ def convert(
|
|
|
72
72
|
output_integer_quantized_tflite: Optional[bool] = False,
|
|
73
73
|
quant_type: Optional[str] = 'per-channel',
|
|
74
74
|
custom_input_op_name_np_data_path: Optional[List] = None,
|
|
75
|
-
|
|
75
|
+
input_quant_dtype: Optional[str] = 'int8',
|
|
76
|
+
output_quant_dtype: Optional[str] = 'int8',
|
|
76
77
|
not_use_onnxsim: Optional[bool] = False,
|
|
77
78
|
not_use_opname_auto_generate: Optional[bool] = False,
|
|
78
79
|
batch_size: Optional[int] = None,
|
|
@@ -1693,15 +1694,23 @@ def convert(
|
|
|
1693
1694
|
converter._experimental_disable_per_channel = disable_per_channel
|
|
1694
1695
|
converter.unfold_batchmatmul = enable_batchmatmul_unfold
|
|
1695
1696
|
converter.representative_dataset = representative_dataset_gen
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1697
|
+
inf_type_input = None
|
|
1698
|
+
inf_type_output = None
|
|
1699
|
+
if input_quant_dtype == 'int8':
|
|
1700
|
+
inf_type_input = tf.int8
|
|
1701
|
+
elif input_quant_dtype == 'uint8':
|
|
1702
|
+
inf_type_input = tf.uint8
|
|
1701
1703
|
else:
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1704
|
+
inf_type_input = tf.int8
|
|
1705
|
+
|
|
1706
|
+
if output_quant_dtype == 'int8':
|
|
1707
|
+
inf_type_output = tf.int8
|
|
1708
|
+
elif output_quant_dtype == 'uint8':
|
|
1709
|
+
inf_type_output = tf.uint8
|
|
1710
|
+
else:
|
|
1711
|
+
inf_type_output = tf.int8
|
|
1712
|
+
converter.inference_input_type = inf_type_input
|
|
1713
|
+
converter.inference_output_type = inf_type_output
|
|
1705
1714
|
tflite_model = converter.convert()
|
|
1706
1715
|
with open(f'{output_folder_path}/{output_file_name}_full_integer_quant.tflite', 'wb') as w:
|
|
1707
1716
|
w.write(tflite_model)
|
|
@@ -2128,13 +2137,23 @@ def main():
|
|
|
2128
2137
|
'Otherwise, an error will occur during the -oiqt stage.'
|
|
2129
2138
|
)
|
|
2130
2139
|
parser.add_argument(
|
|
2131
|
-
'-
|
|
2132
|
-
'--
|
|
2140
|
+
'-iqd',
|
|
2141
|
+
'--input_quant_dtype',
|
|
2142
|
+
type=str,
|
|
2143
|
+
choices=['int8', 'uint8'],
|
|
2144
|
+
default='int8',
|
|
2145
|
+
help=\
|
|
2146
|
+
'Input dtypes when doing Full INT8 Quantization. \n' +
|
|
2147
|
+
'"int8"(default) or "uint8"'
|
|
2148
|
+
)
|
|
2149
|
+
parser.add_argument(
|
|
2150
|
+
'-oqd',
|
|
2151
|
+
'--output_quant_dtype',
|
|
2133
2152
|
type=str,
|
|
2134
2153
|
choices=['int8', 'uint8'],
|
|
2135
2154
|
default='int8',
|
|
2136
2155
|
help=\
|
|
2137
|
-
'
|
|
2156
|
+
'Output dtypes when doing Full INT8 Quantization. \n' +
|
|
2138
2157
|
'"int8"(default) or "uint8"'
|
|
2139
2158
|
)
|
|
2140
2159
|
parser.add_argument(
|
|
@@ -2584,7 +2603,8 @@ def main():
|
|
|
2584
2603
|
output_integer_quantized_tflite=args.output_integer_quantized_tflite,
|
|
2585
2604
|
quant_type=args.quant_type,
|
|
2586
2605
|
custom_input_op_name_np_data_path=custom_params,
|
|
2587
|
-
|
|
2606
|
+
input_quant_dtype=args.input_quant_dtype,
|
|
2607
|
+
output_quant_dtype=args.output_quant_dtype,
|
|
2588
2608
|
not_use_onnxsim=args.not_use_onnxsim,
|
|
2589
2609
|
not_use_opname_auto_generate=args.not_use_opname_auto_generate,
|
|
2590
2610
|
batch_size=args.batch_size,
|
onnx2tf/ops/Conv.py
CHANGED
|
@@ -14,6 +14,7 @@ from tensorflow.python.keras.layers import (
|
|
|
14
14
|
)
|
|
15
15
|
import onnx_graphsurgeon as gs
|
|
16
16
|
from onnx2tf.utils.common_functions import (
|
|
17
|
+
get_replacement_parameter,
|
|
17
18
|
get_constant_or_variable,
|
|
18
19
|
get_weights_constant_or_variable,
|
|
19
20
|
get_padding_as_op,
|
|
@@ -24,6 +25,7 @@ from onnx2tf.utils.common_functions import (
|
|
|
24
25
|
transpose_with_flexing_deterrence,
|
|
25
26
|
get_tf_model_inputs,
|
|
26
27
|
onnx_tf_tensor_validation,
|
|
28
|
+
post_process_transpose,
|
|
27
29
|
)
|
|
28
30
|
from typing import Any, Dict
|
|
29
31
|
from onnx2tf.utils.logging import *
|
|
@@ -33,6 +35,7 @@ INF_INDEX_VALUE: int = 4294967296
|
|
|
33
35
|
|
|
34
36
|
@print_node_info
|
|
35
37
|
@inverted_operation_enable_disable
|
|
38
|
+
@get_replacement_parameter
|
|
36
39
|
def make_node(
|
|
37
40
|
*,
|
|
38
41
|
graph_node: gs.Node,
|
|
@@ -932,6 +935,15 @@ def make_node(
|
|
|
932
935
|
dilations,
|
|
933
936
|
)
|
|
934
937
|
|
|
938
|
+
# Post-process transpose
|
|
939
|
+
tf_layers_dict[graph_node_output.name]['tf_node'] = \
|
|
940
|
+
post_process_transpose(
|
|
941
|
+
value_before_transpose=tf_layers_dict[graph_node_output.name]['tf_node'],
|
|
942
|
+
param_target='outputs',
|
|
943
|
+
param_name=graph_node.outputs[0].name,
|
|
944
|
+
**kwargs,
|
|
945
|
+
)
|
|
946
|
+
|
|
935
947
|
# Generation of Debug Info
|
|
936
948
|
tf_layers_dict[graph_node_output.name]['tf_node_info'] = \
|
|
937
949
|
make_tf_node_info(
|
|
@@ -5857,11 +5857,18 @@ def correction_process_for_accuracy_errors(
|
|
|
5857
5857
|
onnx_output_same_shape_counts = collections.Counter(onnx_output_shape)
|
|
5858
5858
|
if sum([1 if dim > 1 and cnt > 1 else 0 for dim, cnt in onnx_output_same_shape_counts.items()]) >= 1:
|
|
5859
5859
|
# Generate dummy op
|
|
5860
|
-
dummy_op =
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5860
|
+
dummy_op = None
|
|
5861
|
+
tensor_2_candidate_for_transpositions = list(itertools.permutations(range(len(input_tensor_2.shape))))
|
|
5862
|
+
for tensor_2_candidate_for_transposition in tensor_2_candidate_for_transpositions:
|
|
5863
|
+
try:
|
|
5864
|
+
dummy_op = tf_func(
|
|
5865
|
+
input_tensor_1,
|
|
5866
|
+
tf.transpose(a=input_tensor_2, perm=tensor_2_candidate_for_transposition),
|
|
5867
|
+
)
|
|
5868
|
+
break
|
|
5869
|
+
except Exception as ex:
|
|
5870
|
+
pass
|
|
5871
|
+
if dummy_op is not None and dummy_op.shape != tf.TensorShape(None):
|
|
5865
5872
|
tf_output_shape = [dim if dim is not None else -1 for dim in dummy_op.shape]
|
|
5866
5873
|
number_of_dim_other_than_1 = sum([1 if i != 1 else 0 for i in onnx_output_shape])
|
|
5867
5874
|
# Processing continues only if there are two or more dimensions other than 1
|
|
@@ -5889,7 +5896,7 @@ def correction_process_for_accuracy_errors(
|
|
|
5889
5896
|
tensor_1_candidate_for_transpositions = \
|
|
5890
5897
|
obtaining_an_inverted_pattern_for_brute_force_validation(tensor_shape=validation_data_1.shape)
|
|
5891
5898
|
tensor_2_candidate_for_transpositions = \
|
|
5892
|
-
|
|
5899
|
+
list(itertools.permutations(range(len(validation_data_2.shape))))
|
|
5893
5900
|
for tensor_1_candidate_for_transposition in tensor_1_candidate_for_transpositions:
|
|
5894
5901
|
for tensor_2_candidate_for_transposition in tensor_2_candidate_for_transpositions:
|
|
5895
5902
|
try:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: onnx2tf
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.26.0
|
|
4
4
|
Summary: Self-Created Tools to convert ONNX files (NCHW) to TensorFlow/TFLite/Keras format (NHWC). The purpose of this tool is to solve the massive Transpose extrapolation problem in onnx-tensorflow (onnx-tf).
|
|
5
5
|
Home-page: https://github.com/PINTO0309/onnx2tf
|
|
6
6
|
Author: Katsuya Hyodo
|
|
@@ -314,7 +314,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
|
|
|
314
314
|
docker run --rm -it \
|
|
315
315
|
-v `pwd`:/workdir \
|
|
316
316
|
-w /workdir \
|
|
317
|
-
ghcr.io/pinto0309/onnx2tf:1.
|
|
317
|
+
ghcr.io/pinto0309/onnx2tf:1.26.0
|
|
318
318
|
|
|
319
319
|
or
|
|
320
320
|
|
|
@@ -322,7 +322,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
|
|
|
322
322
|
docker run --rm -it \
|
|
323
323
|
-v `pwd`:/workdir \
|
|
324
324
|
-w /workdir \
|
|
325
|
-
docker.io/pinto0309/onnx2tf:1.
|
|
325
|
+
docker.io/pinto0309/onnx2tf:1.26.0
|
|
326
326
|
|
|
327
327
|
or
|
|
328
328
|
|
|
@@ -1529,7 +1529,8 @@ usage: onnx2tf
|
|
|
1529
1529
|
[-oiqt]
|
|
1530
1530
|
[-qt {per-channel,per-tensor}]
|
|
1531
1531
|
[-cind INPUT_NAME NUMPY_FILE_PATH MEAN STD]
|
|
1532
|
-
[-
|
|
1532
|
+
[-iqd {int8,uint8}]
|
|
1533
|
+
[-oqd {int8,uint8}]
|
|
1533
1534
|
[-nuo]
|
|
1534
1535
|
[-nuonag]
|
|
1535
1536
|
[-b BATCH_SIZE]
|
|
@@ -1686,8 +1687,12 @@ optional arguments:
|
|
|
1686
1687
|
and {input_op_name}, {numpy_file_path}, {mean}, and {std} must all be entered.
|
|
1687
1688
|
Otherwise, an error will occur during the -oiqt stage.
|
|
1688
1689
|
|
|
1689
|
-
-
|
|
1690
|
-
Input
|
|
1690
|
+
-iqd {int8,uint8}, --input_quant_dtype {int8,uint8}
|
|
1691
|
+
Input dtypes when doing Full INT8 Quantization.
|
|
1692
|
+
"int8"(default) or "uint8"
|
|
1693
|
+
|
|
1694
|
+
-oqd {int8,uint8}, --output_quant_dtype {int8,uint8}
|
|
1695
|
+
Output dtypes when doing Full INT8 Quantization.
|
|
1691
1696
|
"int8"(default) or "uint8"
|
|
1692
1697
|
|
|
1693
1698
|
-nuo, --not_use_onnxsim
|
|
@@ -2008,7 +2013,8 @@ convert(
|
|
|
2008
2013
|
output_integer_quantized_tflite: Optional[bool] = False,
|
|
2009
2014
|
quant_type: Optional[str] = 'per-channel',
|
|
2010
2015
|
custom_input_op_name_np_data_path: Optional[List] = None,
|
|
2011
|
-
|
|
2016
|
+
input_quant_dtype: Optional[str] = 'int8',
|
|
2017
|
+
output_quant_dtype: Optional[str] = 'int8',
|
|
2012
2018
|
not_use_onnxsim: Optional[bool] = False,
|
|
2013
2019
|
not_use_opname_auto_generate: Optional[bool] = False,
|
|
2014
2020
|
batch_size: Union[int, NoneType] = None,
|
|
@@ -2172,8 +2178,12 @@ convert(
|
|
|
2172
2178
|
and {input_op_name}, {numpy_file_path}, {mean}, and {std} must all be entered.
|
|
2173
2179
|
Otherwise, an error will occur during the -oiqt stage.
|
|
2174
2180
|
|
|
2175
|
-
|
|
2176
|
-
Input
|
|
2181
|
+
input_quant_dtype: Optional[str]
|
|
2182
|
+
Input dtypes when doing Full INT8 Quantization.
|
|
2183
|
+
"int8"(default) or "uint8"
|
|
2184
|
+
|
|
2185
|
+
output_quant_dtype: Optional[str]
|
|
2186
|
+
Output dtypes when doing Full INT8 Quantization.
|
|
2177
2187
|
"int8"(default) or "uint8"
|
|
2178
2188
|
|
|
2179
2189
|
not_use_onnxsim: Optional[bool]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
onnx2tf/__init__.py,sha256=
|
|
1
|
+
onnx2tf/__init__.py,sha256=7Jw_w1lXtSSYSXHYbs-Ar7MWPMylolp5t9BCT461nSA,66
|
|
2
2
|
onnx2tf/__main__.py,sha256=2RSCQ7d4lc6CwD-rlGn9UicPFg-P5du7ZD_yh-kuBEU,57
|
|
3
|
-
onnx2tf/onnx2tf.py,sha256=
|
|
3
|
+
onnx2tf/onnx2tf.py,sha256=BWsBmBW3oz4igKErTdCHgT8ouwSwdiZELfEgr3Jziks,123431
|
|
4
4
|
onnx2tf/ops/Abs.py,sha256=V7btmCG_ZvK_qJovUsguq0ZMJ349mhNQ4FHSgzP_Yuo,4029
|
|
5
5
|
onnx2tf/ops/Acos.py,sha256=Fo8YkFKuWq8Fi2xUrBdKcAH1yJ8r5pjSD0wgLttTNdk,4003
|
|
6
6
|
onnx2tf/ops/Acosh.py,sha256=ATQj2cT5JS_mTfXi0kXqJ1yzSZu5J0zHA5VjV3j7uKY,3588
|
|
@@ -26,7 +26,7 @@ onnx2tf/ops/Concat.py,sha256=CKfJbiAwP7h9sFFVyueHJCbwMkUo3NXqkTuRc8v7Tw8,31215
|
|
|
26
26
|
onnx2tf/ops/ConcatFromSequence.py,sha256=z8pNmGQRGq9cxWORW330NZS_0zsmhFudLswMyPn8AXU,3086
|
|
27
27
|
onnx2tf/ops/Constant.py,sha256=BNZLzNI4rK9kXgVWwD-2RFsDsH7mMy7AY2JSgTNXIWk,10696
|
|
28
28
|
onnx2tf/ops/ConstantOfShape.py,sha256=6eYm-niow-6fHVEyNyi81BdrVe3IbcdazCp2nySWExA,2331
|
|
29
|
-
onnx2tf/ops/Conv.py,sha256=
|
|
29
|
+
onnx2tf/ops/Conv.py,sha256=2BPHrEFWSWONDFp4Mrs8V426ybKANxUmjFscM8PXXD4,38791
|
|
30
30
|
onnx2tf/ops/ConvInteger.py,sha256=Njw7nJhfZcbo4ofC3UMry5EWxs2lRq1X370vSHIZpXw,27095
|
|
31
31
|
onnx2tf/ops/ConvTranspose.py,sha256=C7CR6m3kz0MtUBdtWrrKWZbZL7tJpGXl7Nkn3DRiEaA,15410
|
|
32
32
|
onnx2tf/ops/Cos.py,sha256=0v5ZJZRzrswVEObyxf4f0RvnWMWZA4uCEdoeq_VE31s,3608
|
|
@@ -185,13 +185,13 @@ onnx2tf/ops/_Loop.py,sha256=eo5sNfrfOnKV6_I737AWsM5LJTY9DVOxQEvhanxtP4g,11322
|
|
|
185
185
|
onnx2tf/ops/__Loop.py,sha256=ClwMcbNS4hqUtW_pzwjMa9Cqg7ONvz9aplke55A0uJ0,19704
|
|
186
186
|
onnx2tf/ops/__init__.py,sha256=jnmUWWa-3dHzBZV9bmPzXu6eoz2dumJTzO7i8JdcgSM,25
|
|
187
187
|
onnx2tf/utils/__init__.py,sha256=E9FM9He68VIASDnYp-OrxvHFVn55GzWqw2OEkCqn1zg,27
|
|
188
|
-
onnx2tf/utils/common_functions.py,sha256=
|
|
188
|
+
onnx2tf/utils/common_functions.py,sha256=35vTJfectN2lPwsVGaka_wzpZpCLJeQDmn327oVj4FA,241128
|
|
189
189
|
onnx2tf/utils/enums.py,sha256=7c5TqetqB07VjyHoxJHfLgtqBqk9ZRyUF33fPOJR1IM,1649
|
|
190
190
|
onnx2tf/utils/logging.py,sha256=yUCmPuJ_XiUItM3sZMcaMO24JErkQy7zZwVTYWAuiKg,1982
|
|
191
|
-
onnx2tf-1.
|
|
192
|
-
onnx2tf-1.
|
|
193
|
-
onnx2tf-1.
|
|
194
|
-
onnx2tf-1.
|
|
195
|
-
onnx2tf-1.
|
|
196
|
-
onnx2tf-1.
|
|
197
|
-
onnx2tf-1.
|
|
191
|
+
onnx2tf-1.26.0.dist-info/LICENSE,sha256=5v_Kxihy8i6mzHVl349ikSREaIdsl9YeUnX1KBDLD2w,1070
|
|
192
|
+
onnx2tf-1.26.0.dist-info/LICENSE_onnx-tensorflow,sha256=gK4GtS9S5YcyINu6uuNNWdo-kBClyEM4MFLFGiNTeRM,11231
|
|
193
|
+
onnx2tf-1.26.0.dist-info/METADATA,sha256=inAwjAJYSA4zbNccza_K71FR2Ut7Ai_YQBCN7dLus8o,146410
|
|
194
|
+
onnx2tf-1.26.0.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
195
|
+
onnx2tf-1.26.0.dist-info/entry_points.txt,sha256=gDPK8ToCFPKMvm8jr9xrGOkXtORJJVh4736fBEKO5k0,41
|
|
196
|
+
onnx2tf-1.26.0.dist-info/top_level.txt,sha256=WgfPiEy3f6vZ_FOpAIEA2CF3TCx1eYrhGw93Ih6b9Fw,8
|
|
197
|
+
onnx2tf-1.26.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|