Skip to content

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

@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

3 participants