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

[BYOC-DNNL] Support DNNL optimal layout #10421

Merged
merged 15 commits into from
Mar 7, 2022

Conversation

crazydemo
Copy link
Contributor

This PR aims to support BYOC-DNNL run in the dnnl optimal layout. There are two changes needed to be noticed.

  • For group conv with dnnl backend, its layout need to be legalized to GOIHW first, so that it can run in optimal dnnl layout like HWOIG16g. Changes in Convolution.cc is needed to enable group conv run in GOIHW layout.
  • get_optimal_layout_for_conv and get_optimal_layout_for_deconv functions are registered in tvm.relay.contrib to query the optimal dnnl layout.

The related test cases has been added as well.

@crazydemo crazydemo force-pushed the dev-optimal_layout branch 2 times, most recently from 57e24e5 to 56ef1a1 Compare March 2, 2022 02:11
@crazydemo crazydemo force-pushed the dev-optimal_layout branch from 56ef1a1 to a9314df Compare March 2, 2022 06:02
@crazydemo crazydemo force-pushed the dev-optimal_layout branch from 329dcab to 0190376 Compare March 3, 2022 06:50
@masahi masahi self-assigned this Mar 3, 2022
// infer weight's shape for group convolution
wshape = {{param->groups, indexdiv(param->channels, param->groups),
indexdiv(dshape_nchw[1], param->groups), param->kernel_size[0],
param->kernel_size[1]}};
Copy link
Member

Choose a reason for hiding this comment

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

I'm pretty sure we already support group convolution and this one looks unusual. If this is DNNL specific, can you come up with a better name than is_group?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DNNL prefer to use GOIHWxg layout for group conv's weights. It seems that the layout cannot be transformed from OIHW to GOIHWxg directly. Because the dims are not matched for this two layout. Have this kind of transformation already been supported? If not, how about use is_dnnl_group_conv instead of is_group?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think such transform is possible now. Yeah, is_dnnl_group_conv sounds better.

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, I will change the name :)

@crazydemo crazydemo force-pushed the dev-optimal_layout branch from 0190376 to 0357162 Compare March 4, 2022 07:14
@masahi masahi merged commit 12f213a into apache:main Mar 7, 2022
ziqiangxu8457 pushed a commit to ziqiangxu8457/tvm that referenced this pull request Mar 9, 2022
* enable dnnl optimal layout for supported ops

* verfied cv models with onednnv1.7

* rebase to the latest main branch

* fix format related comments

* remove unnecessary layout transformation

* change deconv into conv_transpose

* rename some variables and functions

* simplify query_layout

* add checkes for query_layout

* fix lint

* move partition_for_dnnl from dnnl.py to test_dnnl.py

* remove unnecessary model test

* add more dnnl layout

* rename flag in convolution.cc

* enhance dnnl layout
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
* enable dnnl optimal layout for supported ops

* verfied cv models with onednnv1.7

* rebase to the latest main branch

* fix format related comments

* remove unnecessary layout transformation

* change deconv into conv_transpose

* rename some variables and functions

* simplify query_layout

* add checkes for query_layout

* fix lint

* move partition_for_dnnl from dnnl.py to test_dnnl.py

* remove unnecessary model test

* add more dnnl layout

* rename flag in convolution.cc

* enhance dnnl layout
@crazydemo crazydemo deleted the dev-optimal_layout branch April 14, 2022 03:20
liaopeiyuan added a commit to zk-ml/tachikoma that referenced this pull request Sep 19, 2022
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.

2 participants