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 bug in transpose optimizer for mul of conv with multiple consumers #1528

Merged
merged 2 commits into from
May 20, 2021
Merged
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: 3 additions & 1 deletion tf2onnx/optimizer/transpose_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,9 @@ def _mul_handler(self, trans, node):
t_p = trans.inputs[0]
trans_rank = get_transpose_rank(trans)
# make sure conv don't have bias set
if t_p.type == "Conv" and t_p.inputs[1].is_const() and len(t_p.input) == 2 and trans_rank == 4:
can_opt = t_p.type == "Conv" and t_p.inputs[1].is_const() and len(t_p.input) == 2 and trans_rank == 4
can_opt = can_opt and self._nodes_has_single_consumer_node([t_p])
if can_opt:
conv = t_p
numpy_val = conv.inputs[1].get_tensor_value(as_list=False)
transposed_val = np.transpose(numpy_val, (2, 3, 1, 0))
Expand Down