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

Conversation

DwayneDuane
Copy link
Contributor

In the DepthwiseConv2dNative method, there appears to be a hard coded assumption of channel_last ordering when extracting the channel depth of the input node. This causes conversion to fail in channel_first mode. For instance, in channel_first mode x.shape can evaluate to (is0, 48, is5, is6), and C_in gets assigned is6, which causes a crash later.

@aseemw
Copy link
Collaborator

aseemw commented Oct 16, 2020

Hi @DwayneDuane , thanks for the change. However, I see that its causing failures on existing tests.
Also , could you add a unit test, that fails without this change but passes with it?

@DwayneDuane
Copy link
Contributor Author

@aseemw I'm not an expert of Gitlab CI/CD, but the unit test errors do not appear to be related to my changes. I see errors like:
InvalidArchiveError('Error with archive /Users/gitlab/miniconda3/pkgs/ca-certificates-2020.10.14-0.conda. You probably need to delete and re-download or re-create this file. Message from libarchive was:\n\nFile is not a zip file')
or
Reinitialized existing Git repository in /Users/gitlab/builds/esohtQ6e/0/zach_nation/coremltools/.git/ fatal: the remote end hung up unexpectedly
Looks more like a network or CI/CD pipeline setup problem.

@aseemw
Copy link
Collaborator

aseemw commented Oct 20, 2020

I see errors that seem related to this change as well:
in TestSeparableConv

469        if C_in % groups != 0:
470            msg = "# of input channels {} not divisible by groups {}"
471>           raise ValueError(msg.format(C_in, groups))
472E           ValueError: # of input channels 2 not divisible by groups 12
473../../envs/coremltools-py2.7/lib/python2.7/site-packages/coremltools/converters/mil/mil/ops/defs/conv.py:116: ValueError

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants