-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fix x86 depthwise conv2d alter_op_layout #3264
Conversation
@@ -415,7 +415,8 @@ def _alter_conv2d_layout(attrs, inputs, tinfo, F): | |||
|
|||
dtype = data.dtype | |||
out_dtype = dtype if out_dtype in ("same", "") else out_dtype | |||
is_depthwise = groups == in_channel and groups == out_channel | |||
kshape = get_const_tuple(kernel.shape) | |||
is_depthwise = groups == kshape[0] and kshape[1] == 1 |
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.
do we need to check kernel layout?
0a6a274
to
39c622e
Compare
topi/python/topi/x86/conv2d.py
Outdated
@@ -415,11 +415,15 @@ def _alter_conv2d_layout(attrs, inputs, tinfo, F): | |||
|
|||
dtype = data.dtype | |||
out_dtype = dtype if out_dtype in ("same", "") else out_dtype | |||
is_depthwise = groups == in_channel and groups == out_channel | |||
|
|||
# only optimize for NCHW | |||
if layout != 'NCHW': |
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.
if layout != 'NCHW': | |
if layout != 'NCHW' or attrs["kernel_layout"] != "OIHW": |
and remove the assert below.
Thanks @kevinthesun ! |
* Fix x86 depthwise conv2d alter_op_layout * Small fix * Add test case * Fix test * Assert kernel layout * Minor fix * Add get_shape function * Minor change
* Fix x86 depthwise conv2d alter_op_layout * Small fix * Add test case * Fix test * Assert kernel layout * Minor fix * Add get_shape function * Minor change
@kevinthesun Looks like this PR makes autotvm to "skips depthwise_conv2d_nchw workloads for llvm x86_64" |
Issue: #3557 |
Fix x86 depthwise conv2d alter_op_layout. Related discussion topic: https://discuss.tvm.ai/t/x86-relay-auto-tune-mobilefacenet-error-using-relay/2508/22