onnx2tf 1.29.11__py3-none-any.whl → 1.29.12__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 CHANGED
@@ -1,3 +1,3 @@
1
1
  from onnx2tf.onnx2tf import convert, main
2
2
 
3
- __version__ = '1.29.11'
3
+ __version__ = '1.29.12'
onnx2tf/ops/MatMul.py CHANGED
@@ -444,19 +444,68 @@ def make_node(
444
444
  onnx_output_shape = [
445
445
  dim if not isinstance(dim, str) else None for dim in onnx_output_shape
446
446
  ]
447
+
448
+ def _shape_match(a_shape, b_shape):
449
+ if len(a_shape) != len(b_shape):
450
+ return False
451
+ for a_dim, b_dim in zip(a_shape, b_shape):
452
+ if a_dim is None or b_dim is None:
453
+ continue
454
+ if a_dim != b_dim:
455
+ return False
456
+ return True
457
+
458
+ # Squeeze unit dims if ONNX output rank is smaller.
459
+ if len(post_matmul_shape) > len(onnx_output_shape):
460
+ squeeze_axes = []
461
+ tmp_shape = list(post_matmul_shape)
462
+ while len(tmp_shape) > len(onnx_output_shape) and tmp_shape[-1] == 1:
463
+ squeeze_axes.append(len(tmp_shape) - 1)
464
+ tmp_shape.pop()
465
+ if squeeze_axes and len(tmp_shape) == len(onnx_output_shape) \
466
+ and _shape_match(tmp_shape, onnx_output_shape):
467
+ tf_layers_dict[graph_node_output.name]['tf_node'] = \
468
+ tf.squeeze(
469
+ input=tf_layers_dict[graph_node_output.name]['tf_node'],
470
+ axis=squeeze_axes,
471
+ )
472
+ post_matmul_shape = list(tf_layers_dict[graph_node_output.name]['tf_node'].shape)
473
+ post_matmul_shape_none_count = sum(
474
+ [1 if dim is None else 0 for dim in post_matmul_shape]
475
+ )
476
+ else:
477
+ leading_ones = 0
478
+ tmp_shape = list(post_matmul_shape)
479
+ while len(tmp_shape) > len(onnx_output_shape) and tmp_shape and tmp_shape[0] == 1:
480
+ leading_ones += 1
481
+ tmp_shape.pop(0)
482
+ if leading_ones and len(tmp_shape) == len(onnx_output_shape) \
483
+ and _shape_match(tmp_shape, onnx_output_shape):
484
+ tf_layers_dict[graph_node_output.name]['tf_node'] = \
485
+ tf.squeeze(
486
+ input=tf_layers_dict[graph_node_output.name]['tf_node'],
487
+ axis=list(range(leading_ones)),
488
+ )
489
+ post_matmul_shape = list(tf_layers_dict[graph_node_output.name]['tf_node'].shape)
490
+ post_matmul_shape_none_count = sum(
491
+ [1 if dim is None else 0 for dim in post_matmul_shape]
492
+ )
493
+
447
494
  onnx_output_shape_none_count = sum([1 if dim is None else 0 for dim in onnx_output_shape])
448
- if post_matmul_shape_none_count == onnx_output_shape_none_count:
495
+ if post_matmul_shape_none_count == onnx_output_shape_none_count \
496
+ and post_matmul_shape != list(onnx_output_shape):
449
497
  post_transpose_perm = []
450
498
  for dim in onnx_output_shape:
451
499
  idx = post_matmul_shape.index(dim)
452
500
  post_transpose_perm.append(idx)
453
501
  post_matmul_shape[idx] = -999
454
502
 
455
- tf_layers_dict[graph_node_output.name]['tf_node'] = \
456
- tf.transpose(
457
- a=tf_layers_dict[graph_node_output.name]['tf_node'],
458
- perm=post_transpose_perm,
459
- )
503
+ if len(post_transpose_perm) == len(post_matmul_shape):
504
+ tf_layers_dict[graph_node_output.name]['tf_node'] = \
505
+ tf.transpose(
506
+ a=tf_layers_dict[graph_node_output.name]['tf_node'],
507
+ perm=post_transpose_perm,
508
+ )
460
509
 
461
510
  # Post-process transpose
462
511
  tf_layers_dict[graph_node_output.name]['tf_node'] = post_process_transpose(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: onnx2tf
3
- Version: 1.29.11
3
+ Version: 1.29.12
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
  Keywords: onnx,tensorflow,tflite,keras,deep-learning,machine-learning
6
6
  Author: Katsuya Hyodo
@@ -363,7 +363,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
363
363
  docker run --rm -it \
364
364
  -v `pwd`:/workdir \
365
365
  -w /workdir \
366
- ghcr.io/pinto0309/onnx2tf:1.29.11
366
+ ghcr.io/pinto0309/onnx2tf:1.29.12
367
367
 
368
368
  or
369
369
 
@@ -371,7 +371,7 @@ Video speed is adjusted approximately 50 times slower than actual speed.
371
371
  docker run --rm -it \
372
372
  -v `pwd`:/workdir \
373
373
  -w /workdir \
374
- docker.io/pinto0309/onnx2tf:1.29.11
374
+ docker.io/pinto0309/onnx2tf:1.29.12
375
375
 
376
376
  or
377
377
 
@@ -1,4 +1,4 @@
1
- onnx2tf/__init__.py,sha256=YcIMmqFje14SgZxYSfLRHbInf0F8cWXJjfwWrwz2mxg,67
1
+ onnx2tf/__init__.py,sha256=89EgFjqomm_s1GTO1Is-NN_4IBNeGFXu31Zcmotmbes,67
2
2
  onnx2tf/__main__.py,sha256=2RSCQ7d4lc6CwD-rlGn9UicPFg-P5du7ZD_yh-kuBEU,57
3
3
  onnx2tf/onnx2tf.py,sha256=yR8aKaEn01Q8dEeYDqHIsuZuG6l5TGQniHDlPiUROx4,152238
4
4
  onnx2tf/ops/Abs.py,sha256=V7btmCG_ZvK_qJovUsguq0ZMJ349mhNQ4FHSgzP_Yuo,4029
@@ -92,7 +92,7 @@ onnx2tf/ops/LogSoftmax.py,sha256=j2nhYY7__8ViLFJVLA5tS98QEvGS1gTIW0QCdnZWUPQ,392
92
92
  onnx2tf/ops/Loop.py,sha256=I32CWoex8FMXm9KE2aomADB4jK5BzaMoAKvtPnBJy6A,14593
93
93
  onnx2tf/ops/LpNormalization.py,sha256=Uu15HgxFNXb6gNMgdTJyf0SLPaLbcbkOYqY_4hMBxNA,3153
94
94
  onnx2tf/ops/LpPool.py,sha256=96eI1FaDgW0M_USWBCHFedvtojHTLL28_lb3mcEV55A,10470
95
- onnx2tf/ops/MatMul.py,sha256=KHhRyQCyxe6845f-AOI1UJzA3rGTssG6eyKmDw0oegs,21466
95
+ onnx2tf/ops/MatMul.py,sha256=X9cQSD4BCogkDP6D4YZEZmOWnsceGL8ppN8E4kqyjB0,23926
96
96
  onnx2tf/ops/MatMulInteger.py,sha256=qHqzdJNI9SeJDbW8pR90baYCdGN6FdOez4hi9EzwXoc,6538
97
97
  onnx2tf/ops/Max.py,sha256=w5nMciO_6ApYUobHuwMGuS3xhuza7eSvKDRhvMPgAuo,3256
98
98
  onnx2tf/ops/MaxPool.py,sha256=_JC4eqBTh-qLkZCMG8RZhthRZ8D2d821zaFMWeGMEWc,15775
@@ -199,7 +199,7 @@ onnx2tf/utils/enums.py,sha256=7c5TqetqB07VjyHoxJHfLgtqBqk9ZRyUF33fPOJR1IM,1649
199
199
  onnx2tf/utils/iterative_json_optimizer.py,sha256=qqeIxWGxrhcCYk8-ebWnblnOkzDCwi-nseipHzHR_bk,10436
200
200
  onnx2tf/utils/json_auto_generator.py,sha256=OC-SfKtUg7zUxaXTAg6kT0ShzIc3ByjDa3FNp173DtA,60302
201
201
  onnx2tf/utils/logging.py,sha256=yUCmPuJ_XiUItM3sZMcaMO24JErkQy7zZwVTYWAuiKg,1982
202
- onnx2tf-1.29.11.dist-info/WHEEL,sha256=e_m4S054HL0hyR3CpOk-b7Q7fDX6BuFkgL5OjAExXas,80
203
- onnx2tf-1.29.11.dist-info/entry_points.txt,sha256=GuhvLu7ZlYECumbmoiFlKX0mFPtFi_Ti9L-E5yuQqKs,42
204
- onnx2tf-1.29.11.dist-info/METADATA,sha256=jeSTHVzVOoEkFVfyO6OVFniy_mrUfZKW9Gez1RYMkVM,154193
205
- onnx2tf-1.29.11.dist-info/RECORD,,
202
+ onnx2tf-1.29.12.dist-info/WHEEL,sha256=e_m4S054HL0hyR3CpOk-b7Q7fDX6BuFkgL5OjAExXas,80
203
+ onnx2tf-1.29.12.dist-info/entry_points.txt,sha256=GuhvLu7ZlYECumbmoiFlKX0mFPtFi_Ti9L-E5yuQqKs,42
204
+ onnx2tf-1.29.12.dist-info/METADATA,sha256=Ddf7-_nYlEjEOlH3taykx6G5ULbARSgF7cuFlj7HD_0,154193
205
+ onnx2tf-1.29.12.dist-info/RECORD,,