Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a bug in the optimization process for arithmetic operations #686

Merged
merged 1 commit into from
Sep 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.8
ghcr.io/pinto0309/onnx2tf:1.25.9

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.8
docker.io/pinto0309/onnx2tf:1.25.9

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.8'
__version__ = '1.25.9'
21 changes: 14 additions & 7 deletions onnx2tf/utils/common_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,19 @@ def merge_two_consecutive_identical_ops_into_one(
tf_type = tf.math.divide

elif tf_func == 'Sub':
if (
if isinstance(input_tensor_1, np.ndarray) or hasattr(input_tensor_1, 'numpy'):
tf_layers_dict[graph_node_output.name]['tf_node'] = \
tf.math.subtract(
x=input_tensor_1 \
if not isinstance(input_tensor_1, np.ndarray) \
else tf.convert_to_tensor(input_tensor_1),
y=input_tensor_2 \
if not isinstance(input_tensor_2, np.ndarray) \
else tf.convert_to_tensor(input_tensor_2),
name=graph_node.name,
)
tf_type = tf.math.subtract
elif (
not isinstance(graph_node_input_1, np.ndarray) \
and 'merge_sub' in tf_layers_dict[graph_node_input_1.name] \
and tf_layers_dict[graph_node_input_1.name]['merge_sub']
Expand Down Expand Up @@ -5411,12 +5423,7 @@ def merge_two_consecutive_identical_ops_into_one(
elif next_graph_node_o_op == 'Sub':
# 8. `Add` -> `Sub` to `Single-Add` : `10 + 5 - 8 -> 10 - 3`
if isinstance(next_graph_node_input_1, np.ndarray) or hasattr(next_graph_node_input_1, 'numpy'):
if isinstance(input_tensor_1, np.ndarray) or hasattr(input_tensor_1, 'numpy'):
input_tensor_1 = (input_tensor_1 - next_graph_node_input_1)
elif isinstance(input_tensor_2, np.ndarray) or hasattr(input_tensor_2, 'numpy'):
input_tensor_2 = (input_tensor_2 - next_graph_node_input_1)
tf_layers_dict[graph_node_output.name]['merge_add'] = True
tf_type = tf.identity
tf_type = tf.math.add
elif isinstance(next_graph_node_input_2, np.ndarray) or hasattr(next_graph_node_input_2, 'numpy'):
if isinstance(input_tensor_1, np.ndarray) or hasattr(input_tensor_1, 'numpy'):
input_tensor_1 = (input_tensor_1 - next_graph_node_input_2)
Expand Down
Loading