Skip to content

Commit 18793bf

Browse files
Fixed bug in transpose optimizer for Mul when rank=5 (#1387)
Signed-off-by: Tom Wildenhain <[email protected]>
1 parent f0b7086 commit 18793bf

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tf2onnx/optimizer/transpose_optimizer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,8 +498,9 @@ def _mul_handler(self, trans, node):
498498
# todo: apply this block if we have model case multiplier_input_id==0, and verify that.
499499
if multiplier_input_id == node.input[1]:
500500
t_p = trans.inputs[0]
501+
trans_rank = get_transpose_rank(trans)
501502
# make sure conv don't have bias set
502-
if t_p.type == "Conv" and t_p.inputs[1].is_const() and len(t_p.input) == 2:
503+
if t_p.type == "Conv" and t_p.inputs[1].is_const() and len(t_p.input) == 2 and trans_rank == 4:
503504
conv = t_p
504505
numpy_val = conv.inputs[1].get_tensor_value(as_list=False)
505506
transposed_val = np.transpose(numpy_val, (2, 3, 1, 0))

0 commit comments

Comments
 (0)