Skip to content

Conversation

@AshkanAliabadi
Copy link
Contributor

@AshkanAliabadi AshkanAliabadi commented Nov 2, 2019

Use NNPACK for strided convolutions.

Copy link
Contributor

@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.

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

Copy link
Contributor

@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.

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

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't trace into the details but looks like nnp_convolution_output() might be able to do better batching than for-loop, or it's equivalent?
Guess it's not a big deal for mobile use case as batch size is usually small (1)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, I'll modify.

Copy link
Contributor

Choose a reason for hiding this comment

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

not used?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, good catch.

@ljk53 ljk53 self-requested a review November 5, 2019 04:37
Copy link
Contributor

@ljk53 ljk53 left a comment

Choose a reason for hiding this comment

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

Thanks!

Copy link
Contributor

@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.

@AshkanAliabadi is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Nov 10, 2019
Summary:
Use NNPACK for strided convolutions.
Pull Request resolved: pytorch/pytorch#29084

Differential Revision: D18286473

Pulled By: AshkanAliabadi

fbshipit-source-id: accdfafa2c247f2750208a7af84c9e2c0374920b
@suo
Copy link
Member

suo commented Nov 10, 2019

@suo
Copy link
Member

suo commented Nov 10, 2019

@houseroad what's the best thing to do here? Revert? Whitelist this op?

@facebook-github-bot
Copy link
Contributor

@AshkanAliabadi merged this pull request in 5ba9209.

@houseroad
Copy link
Member

Let's first unloand it to make sure we either make it backward compatible, or no existing serialized models used this op.

@AshkanAliabadi AshkanAliabadi deleted the nnpack_strided_convs branch November 10, 2019 18:50
@AshkanAliabadi AshkanAliabadi restored the nnpack_strided_convs branch November 10, 2019 18:50
@AshkanAliabadi AshkanAliabadi deleted the nnpack_strided_convs branch November 10, 2019 18:50
@AshkanAliabadi AshkanAliabadi restored the nnpack_strided_convs branch November 10, 2019 18:50
@AshkanAliabadi
Copy link
Contributor Author

This PR gives a 20-ish% performance boost for ResNet50 on mobile. NNPACK does not provide a backwards path for strided convolutions so this is the only way I am aware of that this can be implemented so backwards compatibility may not be possible. How should I check this is not used in any serialized model?

Copy link
Member

@houseroad houseroad left a comment

Choose a reason for hiding this comment

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

Sure, I am not saying this PR is not important. My point is that breaking CI is not good. Especially, IMO, there is a way to make the new API to be compatible with existing API. If we break the BC CI, 1) exiting models may break, 2) others may be confused/blocked by the noise from the broken CI.

use_c10_dispatcher: full

- func: _nnpack_spatial_convolution(Tensor input, Tensor weight, Tensor? bias, int[2] padding) -> Tensor
- func: _nnpack_spatial_convolution(Tensor input, Tensor weight, Tensor? bias, int[2] stride, int[2] padding) -> Tensor
Copy link
Member

Choose a reason for hiding this comment

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

you are changing the signature in a backward incompatible way.

Can you change it in the following way?

_nnpack_spatial_convolution(Tensor input, Tensor weight, Tensor? bias, int[2] padding,  int[2]? stride=None) -> Tensor

The new API is backward compatible with the existing API.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Definitely. Thanks for your feedback. Just to be sure, should I unland this CR first, and update this PR to contain that fix and resubmit, or, create a new patch that contains your proposed fix only and apply that to master?

Copy link
Member

Choose a reason for hiding this comment

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

I have already unlanded the PR and fixed the BC CI.

Please resubmit the PR and make the new aten function backward compatible. If you need any help on BC, feel free to ping me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants