-
Notifications
You must be signed in to change notification settings - Fork 5.7k
【BIT】square Tensor.square support 0-size #72385
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
base: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: 苍天荒 <1903374751@qq.com>
你的PR提交成功,感谢你对开源项目的贡献! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DEFINE_CPU_ACTIVATION_KERNEL 对应的 ActivationImpl
DEFINE_GPU_ACTIVATION_KERNEL 对应的 ActivationGPUImpl
DEFINE_XPU_ACTIVATION_KERNEL 对应的 ActivationXPUImpl
paddle/phi/kernels/cpu/activation_grad_kernel.cc 几个宏对应的 ActivationGradImpl
以及对应GPU的 ActivationGradGPUImp,XPU的ActivationGradXPUImpl都应该修改。
修改后,相应的activation API应该同时加单测,同时复测。
if (x.value().numel() == 0) { | ||
dev_ctx.template Alloc<T>(out->mutable_value()); | ||
return; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
当把常规的activation修改后,这里应该就不用修改了。因为下面调用了常规的activation Kernel。
Sorry to inform you that f53db94's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
PR Category
Execute Infrastructure
PR Types
New features
Description
square Tensor.square支持0-Size。
修改历程介绍如下:
这个api本身就已经支持0-size,故在kernal中加入了拦截,在op中添加了单测
前向修复:
a. 在Paddle代码中检索def isclose,发现isclose的核心实现调用的是_C_ops的square
b. 以_C_ops的square在paddle/phi/ops/yaml中检索,发现square的InferMeta函数使用到:
UnchangedInferMeta
c. 在代码中检索UnchangedInferMeta,并检查其dims(shape)的推导是否正确(是正确的)
d. 在paddle/phi/kernels中检索square,找全所有square的实现Kernel。发现共有1个涉及square的文件,为:
Paddle/paddle/phi/kernels/selected_rows/activation_kernel.cc
加入以下代码,实现0-size情况的拦截
添加单测:
在/test_activation_op.py中添加0 size tensor输入的单测: