-
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
[Op] Do not override specified layout in pooling (2nd PR) #9328
Conversation
@vinx13, @comaniac, @masahi:
|
FYI - a new "out_layout" attribute is added for pooling so that this field can be used by user to specify a user-specific layout for pooling op (similar to what we have for conv op); then, in the pooling.cc file, we can based on the value of out_layout to determine whether to use & stick to the user-specified layout or to use relay caller's infer layout for pooling. |
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.
Otherwise LGTM.
Thanks for the prompt feedback.
All 3 of your suggestions make sense and I will find time to make them into the PR.
Hopefully, this time I am not going to screw up the git pull –rebase.
* Joe
From: Cody Yu ***@***.***>
Sent: Tuesday, October 19, 2021 3:09 PM
To: apache/tvm ***@***.***>
Cc: Joe Chou ***@***.***>; Author ***@***.***>
Subject: [EXT] Re: [apache/tvm] [Op] Do not override specified layout in pooling (2nd PR) (PR #9328)
External Email
________________________________
@comaniac commented on this pull request.
Otherwise LGTM.
________________________________
In src/relay/op/nn/pooling.cc<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_tvm_pull_9328-23discussion-5Fr732274127&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=qOJGnkqHVHovYYnBYzVuOUzkvFQ3j6c4fPi9Iyc0ekQ&e=>:
+ if (params->out_layout != "") {
+ // when users specify the out_layout of pooling, transforms.ConvertLayout pass will
+ // follow user's preference
+ ICHECK_EQ(params->layout, params->out_layout);
⬇️ Suggested change
- if (params->out_layout != "") {
- // when users specify the out_layout of pooling, transforms.ConvertLayout pass will
- // follow user's preference
- ICHECK_EQ(params->layout, params->out_layout);
+ if (params->out_layout != "") {
+ // when users specify the out_layout of pooling, follow user's preference.
+ ICHECK_EQ(params->layout, params->out_layout) << "Pooling input/output layouts mismatch: " << params->layout << " vs. " << params->out_layout;
________________________________
In tests/python/relay/test_pass_convert_op_layout.py<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_tvm_pull_9328-23discussion-5Fr732275775&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=p9Tev2QBahzEmthRelJ_5ZfZ04wmSV8UnNs9DEimbIs&e=>:
+ @tvm.ir.register_op_attr("nn.max_pool2d", "FTVMConvertOpLayout")
+ def convert_maxpool2d(attrs, inputs, tinfos, desired_layouts):
+ # stick by convertng layout and out_layout to use NHWC and NHWC,
+ # respectively, as specified in the transforms.ConvertLayout() function's arguments later
+ new_attrs = dict(attrs)
+ new_attrs["layout"] = str(desired_layouts[0])
+ new_attrs["out_layout"] = str(desired_layouts[0])
+ return relay.nn.max_pool2d(*inputs, **new_attrs)
We should register this to relay/op/nn/_nn.py once along with other converters such as conv2d. Otherwise users will need to manually specify this function to use the feature.
________________________________
In tests/python/relay/test_pass_convert_op_layout.py<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_tvm_pull_9328-23discussion-5Fr732278336&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=pI9YHqoLpOCITuyaT-5dO4Larr1Emt-G6YFenCPryXs&e=>:
@@ -2039,5 +2039,337 @@ def expected():
assert tvm.ir.structural_equal(a, b), "Actual = \n" + str(a)
+def test_conv_max_pool_uses_specified_convert_layout():
Better to put this test along with other existing pooling tests.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_apache_tvm_pull_9328-23pullrequestreview-2D783824550&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=LwUNrVv5yQEZGrLGk0j6SIUjicyyvj__N2uTn0SmrKc&e=>, or unsubscribe<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AM636PHJNAD42HPORL3O5FDUHXUBHANCNFSM5GKDB5YQ&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=fourqVbNZv9CB2yb2moONKwf8TEH9hZg1CUFFX-knac&e=>.
Triage notifications on the go with GitHub Mobile for iOS<https://urldefense.proofpoint.com/v2/url?u=https-3A__apps.apple.com_app_apple-2Dstore_id1477376905-3Fct-3Dnotification-2Demail-26mt-3D8-26pt-3D524675&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=xkQavsjIkg1P3x9Ba7ffv8fXckYgq_BEJVgYAA74p7c&e=> or Android<https://urldefense.proofpoint.com/v2/url?u=https-3A__play.google.com_store_apps_details-3Fid-3Dcom.github.android-26referrer-3Dutm-5Fcampaign-253Dnotification-2Demail-2526utm-5Fmedium-253Demail-2526utm-5Fsource-253Dgithub&d=DwMFaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=84zI-iH2xz28Q_xujSGbjYaq38CgcRgl_vGzCtF6TwQ&m=deTteN0zq7kQqrwuzCJQ3p2axsN9PJ7v8xQjQGIve18&s=dA-9WtyOYvlSuGQWwG1PecGytGZwkfiuyWxtWn2bN28&e=>.
|
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.
Last batch of few comments.
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.
@ccjoechou Looks like you've hit a flaky CI test, please run a new job again (rebase and push). |
@masahi: Got it and I will rebase & push to trigger a new Jenkins build & test run. |
@masahi, @vinx13: |
Yes this is a known new CI issue since this week. I've sent a PR to disable the flaky i368 test for now #9344 |
Thanks @ccjoechou @comaniac |
* [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR)
* [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR) * [Op] Do not override specified layout in pooling (2nd PR)
Thanks for contributing to TVM! Please refer to guideline https://tvm.apache.org/docs/contribute/ for useful information and tips. After the pull request is submitted, please request code reviews from Reviewers by @ them in the pull request thread.