Skip to content

Commit 49d7396

Browse files
committed
fix bug at add_padding
sometimes, tf can work out input shape of conv while fails to get shape of conv's output
1 parent c428664 commit 49d7396

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tf2onnx/onnx_opset/nn.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,8 @@ def add_padding(ctx, node, kernel_shape, strides, dilations=None, spatial=2):
150150
input_shape = spatial_map(input_shape, constants.NHWC_TO_NCHW)
151151
output_shape = spatial_map(output_shape, constants.NHWC_TO_NCHW)
152152
# calculate pads
153-
if any(input_shape[i + 2] == -1 or output_shape[i + 2] == -1 for i in range(spatial)):
153+
if any(input_shape[i + 2] == -1 or output_shape[i + 2] == -1 for i in range(spatial)) \
154+
or any(output_shape[i + 2] == -1 for i in range(spatial)):
154155
logger.debug("node %s has unknown dim %d for pads calculation, fallback to auto_pad",
155156
node.name, input_shape)
156157
node.set_attr("auto_pad", "SAME_UPPER")

0 commit comments

Comments
 (0)