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

enable DNNL Python OPs(adaptive_avg_pool2d, max_pool2d, max_pool3d) t… #7

Merged
merged 1 commit into from
May 14, 2020

Conversation

jiayisunx
Copy link
Contributor

enable DNNL Python OPs(adaptive_avg_pool2d, max_pool2d, max_pool3d) to fallback to CPU.

@jiayisunx
Copy link
Contributor Author

@EikanWang, @pinzhenx

@@ -25,7 +26,15 @@ def backward(ctx, grad_output):
class MaxPoolingFunction(Function):
@staticmethod
def forward(ctx, input, kernel_size, stride, padding, dilation, ceil_mode):
output = core.max_pooling(input, (kernel_size,), (stride,), (padding,), (dilation,), ceil_mode)
if type(kernel_size) is int:
Copy link
Contributor

@pinzhenx pinzhenx May 13, 2020

Choose a reason for hiding this comment

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

torch.nn.modules.utils._single could serve the same purpose

from torch.nn.modules.utils import _single
kernel_size = _single(kernel_size)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, thanks

if input.device.type == 'dpcpp' and core.get_auto_dnnl():
return AdaptiveAvgPool2dFunction.apply(input, output_size)
except RuntimeError:
return torch_adaptive_avg_pool2d(input, output_size)
Copy link
Contributor

@pinzhenx pinzhenx May 13, 2020

Choose a reason for hiding this comment

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

may use pass in except block to avoid duplicate fallback code?

@EikanWang
Copy link
Contributor

Please check if pass all unit test case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants