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

Input shape bug in DepthwiseConv2D in NCHW format #966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
9 changes: 8 additions & 1 deletion coremltools/converters/mil/frontend/tensorflow/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,16 @@ def DepthwiseConv2dNative(context, node):

pad_type = pad_type.lower()
x = context[node.inputs[0]]
C_in = x.shape[-1]

if data_format == "NHWC":
x = _transpose_NHWC_to_NCHW(x)
C_in = x.shape[-1]
elif data_format == "NCHW":
C_in = x.shape[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know what's possible, but if data_format is neither of "NHWC" or "NCHW", then C_in will be an unbound variable


if not isinstance(C_in, int):
raise ValueError("Channel number of input node must be an integer, instead got: {}".format(C_in))

# Only the last op should have the same name as node.name
conv_name = node.name + "x" if data_format == "NHWC" else node.name
x = mb.conv(
Expand Down