Skip to content
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

[Tensorflow] Fix conv2d_transpose for NHWC layout #14546

Merged
merged 7 commits into from
Apr 14, 2023
Merged

[Tensorflow] Fix conv2d_transpose for NHWC layout #14546

merged 7 commits into from
Apr 14, 2023

Conversation

jikechao
Copy link
Contributor

@jikechao jikechao commented Apr 9, 2023

If "data_format" == "NHWC", the kernel_layout for conv2d_transpose should be "HWOI" rather than "HWIO".

If "data_format" == "NHWC", the kernel_layout should be "HWOI" rather than "HWIO".
@tvm-bot
Copy link
Collaborator

tvm-bot commented Apr 9, 2023

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.

  • No users to tag found in teams: tensorflow See #10317 for details

Generated by tvm-bot

@jikechao
Copy link
Contributor Author

jikechao commented Apr 9, 2023

As we can see in frontend about conv2d_transpose
, the kernel_layout for conv2d_transpose was set as "HWOI" when the data_layout='NHWC', while the Tensorflow frontend set the kernel_layout='HWIO' mistankenly. I submitted this PR to fix it.

@leandron @vvchernov Please help me review this PR. Thanks!

@yongwww
Copy link
Member

yongwww commented Apr 9, 2023

@jikechao it would be good to add test cases for this fix

@vvchernov
Copy link
Contributor

Hello @jikechao! Good fix. It looks like misprinting or thoughtless ctr+c, ctr+v from conv condition. I agree with @yongwww CI test is needed to check it

@jikechao
Copy link
Contributor Author

jikechao commented Apr 11, 2023

@yongwww @vvchernov Thanks for your review.
I tried to construct a test case to trigger this bug but failed. By analyzing the source code, I found that the wrong logic statement is in a dead code. Specifically, when the op_name=='conv2d_transpose' and layout='NHWC', the layout was reset to 'NCHW' in this line: https://github.com/apache/tvm/blob/main/python/tvm/relay/frontend/tensorflow_ops.py#:~:text=if%20opname%20%3D%3D%20%22conv_transpose%22%20and,%22data_format%22%5D%20%3D%20%22NCHW%22

Thus, the condition if attr["data_format"] == "NHWC" always be False.
I deleted the wrong logic in the dead code. Please help me review it again. Thanks!

@echuraev
Copy link
Contributor

@jikechao Thank you for your PR.

Specifically, when the op_name=='conv2d_transpose' and layout='NHWC', the layout was reset to 'NCHW' in this line: https://github.com/apache/tvm/blob/main/python/tvm/relay/frontend/tensorflow_ops.py#:~:text=if%20opname%20%3D%3D%20%22conv_transpose%22%20and,%22data_format%22%5D%20%3D%20%22NCHW%22

The link in your previous message is broken and doesn't highlight any line in the code. Also, could you please add a unit test for your changes?

@vvchernov
Copy link
Contributor

Hello @jikechao! Thank you! You are right about condition fix, but it is still needed CI test to check that it works ok now and prevent further issue around it.

@jikechao
Copy link
Contributor Author

@echuraev Indeed, this link can't redirect to the highlight place by clicking it directly. As a workaround, you can open this link by copying this link and past it into a new browser window.

I'll add a unit test sooner!

Copy link
Contributor

@vvchernov vvchernov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@echuraev echuraev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks. Please fix CI and then it can be merged.

@jikechao
Copy link
Contributor Author

jikechao commented Apr 14, 2023

@echuraev CI fixed, could you help me merge this PR?

@echuraev
Copy link
Contributor

@jikechao Thank you for your work :)

@echuraev echuraev merged commit 62f9b1d into apache:main Apr 14, 2023
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.

5 participants