ccjoechou commented on pull request #9328:
URL: https://github.com/apache/tvm/pull/9328#issuecomment-947145571
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=>.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]