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

support more dim for mul op npu #34546

Merged

Conversation

houj04
Copy link
Contributor

@houj04 houj04 commented Aug 2, 2021

PR types

New features

PR changes

OPs

Describe

在NPU环境下跑PaddleHub的resnet50_vd_animals模型的时候,会报错说mul算子不支持某些类型的输入,报dim不支持。具体是:

x.shape=1, 2048, 1, 1 y.shape=2048, 7979 x_num_col_dims=1 y_num_col_dims=1

所以修改了代码,把原先代码逻辑中dims的x->dims().size() == 3的情况,进行了扩大,改成了>=3,这样那个跑不过的模型就能跑过了。

单测可以跑过,并且确定在执行单测的时候,mul_op的状态不是missing。

图片

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 2, 2021

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

Copy link
Contributor

@pangyoki pangyoki left a comment

Choose a reason for hiding this comment

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

请补充单测通过的截图、并使用GLOG_vmodule=operator=4 ctest -R test_mul_op_npu -VV给出NPU上执行mul op的截图

sum_2 = paddle.add(c, d)
result = paddle.fluid.layers.mul(sum_1, sum_2)

fc_1 = fluid.layers.fc(input=result, size=8)
Copy link
Contributor

Choose a reason for hiding this comment

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

fc操作移到mul操作之前,才能检测出mul_grad计算反向时结果是否正确。
因为只有fc中有参数,mulfc前面时,即使mul_grad计算错误,参数更新也不会有问题。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@pangyoki pangyoki 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

@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 for skip_check_grad_ci

@pangyoki pangyoki merged commit 2aedf16 into PaddlePaddle:develop Aug 3, 2021
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