Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions paddle/phi/kernels/funcs/activation_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4322,11 +4322,11 @@ struct CudaSqrtFunctor : public BaseActivationFunctor<T> {

template <typename T>
struct CudaSqrtGradFunctor : public BaseActivationFunctor<T> {
T one_half = static_cast<T>(0.5f);
T two = static_cast<T>(2);

// dx = dout * 0.5 / out
// dx = dout / (2 * out)
__device__ __forceinline__ T operator()(const T dout, const T out) const {
return one_half * dout / out;
return dout / (two * out);
}

static constexpr ActBwdOpFwdDeps FwdDeps() {
Expand Down Expand Up @@ -4413,7 +4413,7 @@ struct CudaRsqrtGradFunctor : public BaseActivationFunctor<T> {
const T arg_out) const {
MPType dout = static_cast<MPType>(arg_dout);
MPType out = static_cast<MPType>(arg_out);
return static_cast<T>(minus_one_half * dout * out * out * out);
return static_cast<T>(minus_one_half * dout * (out * out * out));
}

static constexpr ActBwdOpFwdDeps FwdDeps() {
Expand Down
Loading