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

fix masked_select infer shape #33167

Merged
merged 1 commit into from
Jun 2, 2021
Merged

Conversation

ZzSean
Copy link
Contributor

@ZzSean ZzSean commented May 27, 2021

PR types

Bug fixes

PR changes

OPs

Describe

修正masked_select 在静态图下形状推导的bug,根据api描述,该op的输出只能为1-D Tensor,与输入的dims无关。
问题现象:静态图运行masked_select时,输出为2D-Tensor,如masked_select(a, mask_a).shape=[-1, -1], masked_select(b, mask_b).shape=[16, -1],两个tensor无法stack。而在动态图时,两个op的结果都应该为1D-Tensor,shape=[128]。
问题根因:masked_select的InferShape中,输出的output_dim由输入决定,但是根据api描述的使用场景,该op的输出只能为1-D Tensor,与输入的dims无关。
解决方案:修改masked_select的InferShape中对于输出的形状推导方法,使其shape在静态图下始终为-1

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor

@zhangting2020 zhangting2020 left a comment

Choose a reason for hiding this comment

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

LGTM

@zhangting2020
Copy link
Contributor

PR描述需要修改:

  1. PR描述里不要贴icafe卡片链接,外部不可见。
  2. 补充下修复前运行错误具体是什么,可以贴一段测试code,和运行前的报错。
  3. 修复后的效果:静态图compile 阶段可以打印出shape,应该是[-1]

@Xreki Xreki merged commit 9d4722c into PaddlePaddle:develop Jun 2, 2021
@ZzSean ZzSean deleted the fix_masked_select branch June 22, 2021 07:52
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.

3 participants