diff --git a/paddle/fluid/operators/activation_op.h b/paddle/fluid/operators/activation_op.h index 289cc70392a3fd7e22e212edab4d7ef59b6ad0f9..bc7def61b2e249d3fa5e8b1d915b86f50beaf77b 100644 --- a/paddle/fluid/operators/activation_op.h +++ b/paddle/fluid/operators/activation_op.h @@ -1184,9 +1184,9 @@ struct ELUFunctor : public BaseActivationFunctor { template void operator()(Device d, X x, Out out) const { - out.device(d) = x.cwiseMax(static_cast(0)) + - (static_cast(alpha) * (x.exp() - static_cast(1))) - .cwiseMin(static_cast(0)); + out.device(d) = + (x < static_cast(0)) + .select(static_cast(alpha) * (x.exp() - static_cast(1)), x); } };