-
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
[TVMC] Improve --desired-layouts functionality #14272
Conversation
Thanks for contributing to TVM! Please refer to the contributing guidelines https://tvm.apache.org/docs/contribute/ for useful information and tips. Please request code reviews from Reviewers by @-ing them in a comment. Generated by tvm-bot |
7f8af41
to
eaca5d5
Compare
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.
Thanks @PhilippvK for exposing this functionality, overall LGTM! Just responding to your questions as well as a couple of nits:
It would make sense to specify individual kernel layouts for regular convolutions and depthwise ones. However since both are usually implemented as generalized nn.conv2d, we can not transform them individually. Are there any good workarounds for this?
One way that I can think of, although it's not very elegant, is to allow a special nn.conv2d_depthwise
parameter thorough desired_layout_ops
, then override the FTVMConvertOpLayout
function for nn.conv2d before running the pass similar to what is done here. Perhaps we can leave as a "TODO" for now and create a tracking issue for it?
The arguments of --desired-layouts have previously been checked for validity during cmdline parsing (e.g. only NCHW and NHWC are allowed) which is not possible anymore. Should I add a regular expression for that?
I believe it should be okay to leave this, especially since this will get more complex when you consider the layouts of conv3d etc. Unsupported layouts should raise an error at a later stage while running the ConvertLayout pass anyway.
Thank you for pointing that out. If I understand it correctly, we than need to run the I agree that this is far away from elegant and we should track this somewhere else... |
e0f8517
to
df17c27
Compare
Thanks for the updates, LGTM after fixing the test failures :) I believe the Before passing the Apologies for the rushed explanation, happy to help explain further in a separate conversation |
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.
LGTM! Thanks for the work on this @PhilippvK, I'll leave open for a day or so to give others a change to comment
@lhutton1 Should I rebase/squash the commits before merge? |
No need to rebase for now, and no need to squash the commits as this will be done automatically when merging |
Thanks @PhilippvK! |
@lhutton1 Followup discussion: https://discuss.tvm.apache.org/t/convertlayout-dealing-with-depthwise-convolutions/14581 |
this aims to make the
--desired-layout
argument more powerful based on the previously merged changes from #14010 (@srkreddy1238) by introducing two new features:--desired-layout
instead of only one, to specify one layout per transformed operator specified in--desired-layout-ops
. (Number of arguments has to bei either 1 or match the number of transformed operators)NHWC:HWIO
Example Usage:
tvmc compile … --desired-layout nn.max_pool2d qnn.conv2d --desired-layout-ops NCHW NHWC:HWIO
I also added unit tests for the new use-cases.
Known Limitations:
nn.conv2d
, we can not transform them individually. Are there any good workarounds for this?--desired-layouts
have previously been checked for validity during cmdline parsing (e.g. only NCHW and NHWC are allowed) which is not possible anymore. Should I add a regular expression for that?