Skip to content

Conversation

@blackkker
Copy link
Contributor

@blackkker blackkker commented Aug 19, 2022

The FInferCorrectLayout was set to ElemwiseArbitraryLayout which is for layout agnostic operators. While L2norm is a lightly-layout sensitive operator with attrs-axis. Refered to Convert Layout Pass.

.set_attr<FInferCorrectLayout>("FInferCorrectLayout", ElemwiseArbitraryLayout)

When running model, I met a situation:
%0 = layout_transform(%x, src_layout="NHWC", dst_layout="NCHW") /* ty=Tensor[(1, 64, 56, 56), float32] */;
%1 = layout_transform(%weight, src_layout="HWIO", dst_layout="OIHW") /* ty=Tensor[(64, 64, 3, 3), float32] */;
%2 = nn.conv2d(%0, %1, padding=[1, 1, 1, 1], channels=64, kernel_size=[3, 3]) /* ty=Tensor[(1, 64, 56, 56), float32] */;
%3 = nn.l2_normalize(%2, eps=0.001f, axis=[3]) /* ty=Tensor[(1, 64, 56, 56), float32] */;

The nn.l2_normalize 's axis didn't change during InferCorrectLayout. So i write a L2NormalizeInferCorrectLayout for it.
Also, add some tests.

BTW! I'm still new to cpp, please advise if there is anything inappropriate in code. Thanks!
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.

@blackkker blackkker changed the title [Relay][Layout] Add FInferCorrectLayout for L2 norm layout change. [Relay][Layout] Add FInferCorrectLayout for L2 norm layout transform. Aug 19, 2022
@blackkker
Copy link
Contributor Author

@masahi

@blackkker blackkker force-pushed the L2N_InferCorrectLayout branch from 3614f98 to d995ec7 Compare August 19, 2022 12:25
@blackkker
Copy link
Contributor Author

@tvm-bot rerun CI / Windows (pull_request)

@blackkker blackkker closed this Aug 19, 2022
@blackkker blackkker reopened this Aug 19, 2022
@blackkker blackkker force-pushed the L2N_InferCorrectLayout branch from d995ec7 to 0d39fb3 Compare August 19, 2022 16:50
@masahi
Copy link
Member

masahi commented Aug 19, 2022

@tvm-bot rerun

@blackkker blackkker closed this Aug 20, 2022
@blackkker blackkker reopened this Aug 20, 2022
@blackkker

This comment was marked as resolved.

@blackkker blackkker closed this Aug 20, 2022
@blackkker blackkker reopened this Aug 20, 2022
@blackkker blackkker closed this Aug 20, 2022
@blackkker blackkker reopened this Aug 20, 2022
@blackkker blackkker force-pushed the L2N_InferCorrectLayout branch from 76f716e to 61f499b Compare August 20, 2022 08:28
@blackkker
Copy link
Contributor Author

@tvm-bot merge

@masahi masahi merged commit 1985c01 into apache:main Aug 20, 2022
xinetzone pushed a commit to daobook/tvm that referenced this pull request Nov 25, 2022
…apache#12497)

* [Relay][Layout] FInferCorrectLayout for L2 norm layout change.

* [Relay][Layout] Test for L2 norm layout transform.

* [Relay][Layout] Re-edit test to add multi-dimensional axis list.

* Fix cpplint errors

* Use clang-format-10 rules.

* replace uint with size_t.
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