Skip to content

Conversation

@ooooo-create
Copy link
Contributor

@ooooo-create ooooo-create commented Jul 29, 2025

PR Category

Operator Mechanism

PR Types

Bug fixes

Description

#73714

Fix wrong reciprocal result when meets complex dtype

@paddle-bot
Copy link

paddle-bot bot commented Jul 29, 2025

你的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.

@paddle-bot paddle-bot bot added the contributor External developers label Jul 29, 2025
@ooooo-create ooooo-create changed the title [Complex] Fix wrong complex result when meets complex dtype [Complex] Fix wrong reciprocal result when meets complex dtype Jul 29, 2025
@ooooo-create
Copy link
Contributor Author

/re-run all-failed

@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jul 30, 2025
Copy link
Contributor

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

@Malone-AI Malone-AI left a comment

Choose a reason for hiding this comment

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

What about extracting shared CPU/GPU code?
Like this one

template <typename T> __host__ __device__ __forceinline__ ComplexType<T> reciprocal_complex_kernel( const ComplexType<T>& val) { auto both_inf = [](T real, T imag) { return (isinf(real) && isinf(imag)); }; auto either_inf = [](T real, T imag) { return isinf(real) || isinf(imag); }; auto either_nan = [](T real, T imag) { return isnan(real) || isnan(imag); }; if (either_nan(val.real, val.imag) || both_inf(val.real, val.imag)) { T quiet_nan = std::numeric_limits<T>::quiet_NaN(); return ComplexType<T>(quiet_nan, quiet_nan); } else if (either_inf(val.real, val.imag)) { return ComplexType<T>{static_cast<T>(0), static_cast<T>(0)}; } return static_cast<ComplexType<T>>(1.0) / val; } template <typename T> struct Reciprocal { HOSTDEVICE ComplexType<T> operator()(const ComplexType<T>& val) const { return reciprocal_complex_kernel(val); } }; template <typename T> struct CudaReciprocalFunctor<ComplexType<T>> : public BaseActivationFunctor<ComplexType<T>> { __device__ __forceinline__ ComplexType<T> operator()( const ComplexType<T> x) const { return reciprocal_complex_kernel(x); } };
@luotao1 luotao1 merged commit 6b610ee into PaddlePaddle:develop Jul 31, 2025
73 of 74 checks passed
@luotao1
Copy link
Contributor

luotao1 commented Jul 31, 2025

What about extracting shared CPU/GPU code?

@Malone-AI, you can create a new PR to extract shared CPU/GPU code.

@ooooo-create ooooo-create deleted the reciprocal_fix branch September 29, 2025 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers HappyOpenSource 快乐开源活动issue与PR

4 participants