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

Remove axis in some elementwise api #50190

Merged
merged 5 commits into from
Feb 7, 2023

Conversation

zyfncg
Copy link
Contributor

@zyfncg zyfncg commented Feb 3, 2023

PR types

Others

PR changes

APIs

Describe

elementwise系列算子中的axis目前已不再推荐使用,为了减少该类接口不规范的使用,本PR对部分elementwise接口中的axis参数进行了清理,并删除了一些不再使用的接口。

@paddle-bot
Copy link

paddle-bot bot commented Feb 3, 2023

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Comment on lines -630 to +605
if in_dygraph_mode():
return _C_ops.add_(x, y)
else:
out = _elementwise_op_in_dygraph(x, y, axis=axis, op_name=op_type)
return out
return _C_ops.add_(x, y)
Copy link
Contributor

Choose a reason for hiding this comment

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

本函数的前置逻辑,也可以删除,后续的几个函数同理

op_type = 'elementwise_add_'
axis = -1

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, thx~

# This rule is obscure, so we maybe replace it by adding new design in the future.
if is_inplaced and (
self.forward_api_name[-1] != '_'
or self.forward_api_name == 'assign_out_'
Copy link
Contributor

Choose a reason for hiding this comment

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

此处为什么要特殊处理

Why do we need this special case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个属于inplace处理机制的遗留问题,一般对于有反向的inplace接口都需要做InplaceCheck处理,但assign_out_早期没有加InplaceCheck导致现在加上就会有不兼容问题,所以暂时只能通过黑名单来跳过

Copy link
Contributor

@jiahy0825 jiahy0825 left a comment

Choose a reason for hiding this comment

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

LGTM

@zyfncg zyfncg merged commit 1dedaad into PaddlePaddle:develop Feb 7, 2023
@zyfncg zyfncg deleted the elementwise_axis branch February 7, 2023 12:39
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.

4 participants