Skip to content

Conversation

@sandyhouse
Copy link

@sandyhouse sandyhouse commented Feb 10, 2021

PR types

Bug fixes

PR changes

APIs

Describe

fix the bug in expand_v2 op.

Paddle框架在编译期使用-1表示未知维度值,如batch size的值。expand_v2 OP使用-1表示保持相应维度地维度值不变。例如,b = expand(a, shape=[4, -1, 2]), 假设a.shape = [2, 3, 2], 则b.shape = [4, 3, 2]。

当expand的shape参数列表中包含var是,例如,c = expand(a, shape=[temp_var, 3, 2])是,expand在编译期会将expand OP的expand_shape属性var对应的值设置为-1, 上例中expand_shape的属性值为[-1, 3, 2]。那么编译期c.shape = [2, 3, 2]。
当temp_var表示未知维度值时,和期望的结果不符,期望的结果是c.shape = [-1, 3, 2]。

本pr在编译器将temp_var对应的维度值设置为-1,表示编译期未知维度,解决上述问题。

@paddle-bot-old
Copy link

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

@paddle-bot-old
Copy link

Sorry to inform you that f5d0d58's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Feb 20, 2021
@PaddlePaddle PaddlePaddle unlocked this conversation Feb 20, 2021
Copy link
Contributor

@wangxicoding wangxicoding left a comment

Choose a reason for hiding this comment

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

LGTM

for idx, shape in enumerate(list_expand_shape):
if isinstance(shape, Variable):
attrs_expand_shape.append(-1)
attrs_expand_shape.append(-2)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里最好也加一个注释,并对应c++哪个文件op代码

Copy link
Author

Choose a reason for hiding this comment

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

c++端有对应的解释。这个地方也确实应该加一个注释;稍后提一个新pr添加。

@sandyhouse sandyhouse requested a review from chalsliu February 24, 2021 09:56
@sandyhouse sandyhouse merged commit a373aa7 into PaddlePaddle:develop Feb 24, 2021
sandyhouse pushed a commit to sandyhouse/Paddle that referenced this pull request Feb 25, 2021
@sandyhouse sandyhouse deleted the fix_expand_op branch March 8, 2022 09:59
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