-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Add mkldnn support for adaptive_avg_pool2d #19818
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
Conversation
3d5e91a to
8911a99
Compare
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bddppq has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bddppq has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
8911a99 to
b6f75bc
Compare
wanchaol
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. minor questions.
| - func: mkldnn_adaptive_avg_pool2d(Tensor self, int[2] output_size) -> Tensor | ||
| dispatch: | ||
| MkldnnCPU: mkldnn_adaptive_avg_pool2d | ||
| requires_tensor: True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might miss some context here. What's the meaning of this option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the codegen script to insert code to unwrap a variable to a tensor before passing the input to the kernel:
https://github.com/pytorch/pytorch/blob/de19eee/tools/autograd/gen_variable_type.py#L869-L870
https://github.com/pytorch/pytorch/blob/de19eee/tools/autograd/gen_variable_type.py#L954
|
|
||
| self.assertEqual( | ||
| adaptive_avg_pool2d(x), | ||
| adaptive_avg_pool2d(x.to_mkldnn()).to_dense()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it mean that everytime we call mkldnn ops we are required to call to_dense ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not every op, but every chunk of ops (in this case the unittest is only testing one op so yeah it's calling to_dense after each op to convert the mkldnn tensor to dense tensor so that we can compare with the regular dense kernel's output).
basically one needs to do:
to_mkldnn -> mkldnn_op1 -> mkldnn_op2 ... -> mkldnn_opn -> to_dense
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bddppq has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: AdaptiveAvgPool2d is used in torchvision resnet models https://github.com/pytorch/vision/blob/9a481d0/torchvision/models/resnet.py#L145 Fixes #19797 Pull Request resolved: pytorch/pytorch#19818 Differential Revision: D15112777 Pulled By: bddppq fbshipit-source-id: 6c9b29c805d28356cda49c10c2cd3ce9d7a8b3f5
Summary: AdaptiveAvgPool2d is used in torchvision resnet models https://github.com/pytorch/vision/blob/9a481d0/torchvision/models/resnet.py#L145 Fixes pytorch#19797 Pull Request resolved: pytorch#19818 Differential Revision: D15112777 Pulled By: bddppq fbshipit-source-id: 6c9b29c805d28356cda49c10c2cd3ce9d7a8b3f5
AdaptiveAvgPool2d is used in torchvision resnet models https://github.com/pytorch/vision/blob/9a481d0/torchvision/models/resnet.py#L145
Fixes #19797