-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -148,6 +148,17 @@ def test_avg_pool2d(self): | |
| avg_pool2d(x), | ||
| avg_pool2d(x.to_mkldnn()).to_dense()) | ||
|
|
||
| def test_adaptive_avg_pool2d(self): | ||
| N = torch.randint(3, 10, (1,)).item() | ||
| C = torch.randint(3, 10, (1,)).item() | ||
| x = torch.randn(N, C, 224, 224, dtype=torch.float32) * 100 | ||
|
|
||
| adaptive_avg_pool2d = torch.nn.AdaptiveAvgPool2d(7) | ||
|
|
||
| self.assertEqual( | ||
| adaptive_avg_pool2d(x), | ||
| adaptive_avg_pool2d(x.to_mkldnn()).to_dense()) | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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). |
||
|
|
||
| def test_batch_norm2d(self): | ||
| N = torch.randint(3, 10, (1,)).item() | ||
| C = torch.randint(3, 100, (1,)).item() | ||
|
|
||
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