-
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
[microTVM] Improve code reuse in Corstone300 conv2d tests #13051
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 |
When reorganizing the tests, I noticed there was duplicate code in tests besides the
|
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 @guberti. LGTM. I added a few minor comments
kernel_layout = tvm.testing.parameter("HWOI") | ||
schedule_name = tvm.testing.parameter("depthwise_conv2d_nhwc_dsp.arm_cpu") | ||
dilation = parameter(1) | ||
data_layout = parameter("NHWC") |
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.
the data_shape
is always in NHWC layout. should we rename the data_layout
to in_layout
to avoid any confusion?
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.
I'd prefer to keep the name data_shape
, as it's the name used by relay.op.nn.conv2d
. However, I added a comment clarifying this to test_generalized_conv2d.py
.
kernel_layout = tvm.testing.parameter("OIHW") | ||
schedule_name = tvm.testing.parameter("depthwise_conv2d_nchw_oihw_dsp.arm_cpu") | ||
dilation = parameter(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.
nit: remove new line. there are a couple more in other files too.
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.
I prefer the newline to separate "computation" parameters from "layout" parameters, and IMO it helps with readability. I could be convinced otherwise, though.
When I was working on adding corstone to the platforms supported by the project API, we talked about migrating from this test structure and use Project API for these tests too. But then the fvp transport layer was not as stable as we have hoped for, and we didn't continue that work at that time. One argument in favor of creating a more abstract class is that it makes it easier to change the test structure. |
Thanks for the review @mkatanbaf! I'm a big fan of the current test runner and of the It is possible we change the test structure in the future though - your argument makes sense. Creating a more abstract class is probably OOS for this PR, but I'd be open to it in the future. |
@guberti the problem with current test setup is that we cannot test it on hardware out of the box. So ideally we want to move to project API for corstone so we have the same standard API for testing Zephyr/Arduino/Corstone300 or any other microtvm platform with ARM chip. |
@mehrdadh thanks for explaining, that makes sense. Tests should pass now, would you mind reviewing and merging? |
ee6096c
to
2ffad17
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 @guberti, LGTM
# Our x86 depthwise implementation only supports HWOI with NHWC, so we need to change our | ||
# kernel layout to work around this. We can't just change the whole thing to HWIO or | ||
# something else, as then group conv2d would not work. Eventually, we should switch to using | ||
# TensorFlow to create the reference output so we can ensure our implementation is right. |
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.
can you file a bug for this and link to it from this comment?
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.
Done, see #13137. I also link to it from the comment.
51c96eb
to
6a12eca
Compare
6a12eca
to
fed35c2
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.
@guberti @mkatanbaf @areusch thanks!
This PR is merged now.
* Add support for out_layout to tensordot schedules and tests * Move shared conv2d test logic into new file * Rework depthwise and grouped convolutions to use common logic * Linting and bugfixes * Fix tests * Fix depthwise and grouped tests * More linting fixes * Address code review comments * Fix unit tests * Address code review comments from Andrew * Fix imports
* Add support for out_layout to tensordot schedules and tests * Move shared conv2d test logic into new file * Rework depthwise and grouped convolutions to use common logic * Linting and bugfixes * Fix tests * Fix depthwise and grouped tests * More linting fixes * Address code review comments * Fix unit tests * Address code review comments from Andrew * Fix imports
* Add support for out_layout to tensordot schedules and tests * Move shared conv2d test logic into new file * Rework depthwise and grouped convolutions to use common logic * Linting and bugfixes * Fix tests * Fix depthwise and grouped tests * More linting fixes * Address code review comments * Fix unit tests * Address code review comments from Andrew * Fix imports
This pull request contains two changes:
Adds support for specifying an
out_layout
to theTensordot
-based convolution schedules for Arm Cortex-M. This is useful, as when compiling models like MobileNetV1, we will want to alternate between NHWC and NCHW layers (see this comment for more).Re-organizes the Corstone300 tests for regular, grouped, and depthwise conv2d to use a shared base class. This removes a lot of code re-use that used to exist in
tests/python/relay/strategy/arm_cpu
.I chose to make these changes as one PR instead of two, since I had to change some of the testing logic to support the
out_layout
parameter (and copying that into four places would be kinda gross). Would love a look from @mkatanbaf!