Skip to content

Commit

Permalink
Merge pull request #675 from PINTO0309/fix_undef_expand
Browse files Browse the repository at this point in the history
Automatic accuracy compensation `Expand`, `BatchNormalization`, `Gather`
  • Loading branch information
PINTO0309 authored Jul 25, 2024
2 parents 3ce052d + 67f4663 commit 1377d69
Show file tree
Hide file tree
Showing 6 changed files with 567 additions and 55 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -299,15 +299,15 @@ Video speed is adjusted approximately 50 times slower than actual speed.
docker run --rm -it \
-v `pwd`:/workdir \
-w /workdir \
ghcr.io/pinto0309/onnx2tf:1.25.6
ghcr.io/pinto0309/onnx2tf:1.25.7

or

# Authentication is not required for pulls from Docker Hub.
docker run --rm -it \
-v `pwd`:/workdir \
-w /workdir \
docker.io/pinto0309/onnx2tf:1.25.6
docker.io/pinto0309/onnx2tf:1.25.7

or

Expand Down
2 changes: 1 addition & 1 deletion onnx2tf/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from onnx2tf.onnx2tf import convert, main

__version__ = '1.25.6'
__version__ = '1.25.7'
30 changes: 20 additions & 10 deletions onnx2tf/ops/AveragePool.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,14 @@ def make_node(
[list(i) for i in zip(tf_pads[:len(tf_pads) // 2], tf_pads[len(tf_pads) // 2:])] + \
[[0, 0]]

padded_tensor = tf.pad(
tensor=input_tensor,
paddings=tf_pads,
mode='CONSTANT',
)
if spatial_size == 1 and kernel_shape[0] > input_tensor_shape[1]:
padded_tensor = input_tensor
else:
padded_tensor = tf.pad(
tensor=input_tensor,
paddings=tf_pads,
mode='CONSTANT',
)

else:
padded_tensor = input_tensor
Expand Down Expand Up @@ -306,11 +309,18 @@ def make_node(
# Generation of TF OP
tf_op_type = None
if len(kernel_shape) == 1:
pooled_tensor = AveragePooling1D(
pool_size=kernel_shape,
strides=strides,
padding=tf_pad_mode.upper(),
)(padded_tensor)
if kernel_shape[0] > padded_tensor.shape[1]:
pooled_tensor = AveragePooling1D(
pool_size=[padded_tensor.shape[1]],
strides=[padded_tensor.shape[1]],
padding=tf_pad_mode.upper(),
)(padded_tensor)
else:
pooled_tensor = AveragePooling1D(
pool_size=kernel_shape,
strides=strides,
padding=tf_pad_mode.upper(),
)(padded_tensor)
tf_op_type = AveragePooling1D

elif len(kernel_shape) == 2:
Expand Down
Loading

0 comments on commit 1377d69

Please sign in to comment.