Skip to content

[OpenCL] Fix a bug when running an external model with the image-loader transposing the input to NCHW #3951

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

Closed
wants to merge 1 commit into from

Conversation

shajrawi
Copy link
Contributor

Summary:
See the in-source comment for workaround information, but: We have a model we load from the outside with no-way of knowing the constant/placeholder input layout, the default assumption for 4-D tensors (images) is NHWC format which is the canonical Glow format, PNG files are in NHWC format.
Our image loader, when using the image-layout flag, transposes the image outside the Glow graph, since there's no easy way to propagate that information, weaken the OpenCL verifier, not the canonical verifier: for placeholders and constants, assume that the loader knows what it is doing and they are in the right format.

Fixes #3815

Test Plan:
ninja test

@SameerAsal
Copy link
Contributor

SameerAsal commented Dec 30, 2019

Would it be useful to propagate the layout from the loader into Glow placeholder? We can track that in an issue for now?

@shajrawi
Copy link
Contributor Author

The ideal solution would have the loader adding a transpose node to the graph instead of the way readPngImageAndPreprocess currently does things, but that's a huge architectural change

Copy link

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

@shajrawi has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link

@shajrawi merged this pull request in 37c3bd0.

@shajrawi shajrawi deleted the opencl_loader branch December 30, 2019 23:10
vdantu pushed a commit to vdantu/glow that referenced this pull request Jul 12, 2020
…osing the input to NCHW (pytorch#3951)

Summary:
See the in-source comment for workaround information, but: We have a model we load from the outside with no-way of knowing the constant/placeholder input layout, the default assumption for 4-D tensors (images) is NHWC format which is the canonical Glow format, PNG files are in NHWC format.
Our image loader, when using the `image-layout` flag, transposes the image outside the Glow graph, since there's no easy way to propagate that information, weaken the OpenCL verifier, not the canonical verifier: for placeholders and constants, assume that the loader knows what it is doing and they are in the right format.

Fixes pytorch#3815
Pull Request resolved: pytorch#3951

Test Plan: `ninja test`

Differential Revision: D19252774

Pulled By: shajrawi

fbshipit-source-id: f850c504245ee947794446b144b00df635a68497
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenCL] Convolution NHWC vs. NCHW mismatch
3 participants