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

[NNAPI] Handle binary ops combining NHWC+NCHW in some cases #48812

Closed
wants to merge 12 commits into from

Conversation

dreiss
Copy link
Contributor

@dreiss dreiss commented Dec 3, 2020

Stack from ghstack:

Summary:
This came up in a squeeze-and-excitation model. Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T. To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: D25317939

Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

[ghstack-poisoned]
dreiss added a commit that referenced this pull request Dec 3, 2020
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

ghstack-source-id: 6e67e44e59e6386504d28db0b78d9dcc395e9154
Pull Request resolved: #48812
@dr-ci
Copy link

dr-ci bot commented Dec 3, 2020

💊 CI failures summary and remediations

As of commit ccd0856 (more details on the Dr. CI page):


  • 1/1 failures possibly* introduced in this PR
    • 1/1 non-scanned failure(s)

This comment was automatically generated by Dr. CI (expand for details).Follow this link to opt-out of these comments for your Pull Requests.

Please report bugs/suggestions to the (internal) Dr. CI Users group.

Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
@github-actions
Copy link

github-actions bot commented Feb 8, 2021

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
Stale pull requests will automatically be closed 30 days after being marked Stale

@github-actions github-actions bot added the Stale label Feb 8, 2021

out_oper = oper._replace(dim_order=DimOrder.CHANNELS_LAST)

inputs = [None] * 2
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason to create a [None, None] list and then replacing values vs just creating inputs = [in_id, self.add_immediate_int_vector([0, 2, 3, 1])?

(same with outputs)

Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
Summary:
This came up in a squeeze-and-excitation model.  Starting with an NHWC
tensor T, we perform a mean operation across H and W, giving an NxC
tensor, which (after some fully connected layers) is reshaped to
NxCx1x1, then multiplied with T.  To handle this, we detect the specific
case of a binary op with one NHWC input and one contiguous input with
H,W == 1,1 and allow the op to be applied (after transposing the
contiguous input).

Test Plan:
Unit test.

Differential Revision: [D25317939](https://our.internmc.facebook.com/intern/diff/D25317939)

[ghstack-poisoned]
@facebook-github-bot
Copy link
Contributor

@dreiss merged this pull request in 476c597.

@facebook-github-bot facebook-github-bot deleted the gh/dreiss/87/head branch April 10, 2021 14:17
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.

None yet

3 participants