Skip to content

Commit

Permalink
【Hackathon No.56 57 58 59】sparse elementwise add sub mul div (#41857)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsq7474741 committed Jun 23, 2022
1 parent 3be36a8 commit e3d94fc
Show file tree
Hide file tree
Showing 15 changed files with 1,979 additions and 0 deletions.
1 change: 1 addition & 0 deletions paddle/phi/kernels/activation_kernel.h
Expand Up @@ -71,6 +71,7 @@ DECLARE_ACTIVATION_KERNEL(Log1p)
DECLARE_ACTIVATION_KERNEL(Round)
DECLARE_ACTIVATION_KERNEL(Floor)
DECLARE_ACTIVATION_KERNEL(Ceil)
DECLARE_ACTIVATION_KERNEL(Negative)

DECLARE_ACTIVATION_KERNEL_WITH_ONE_ATTRS(LeakyRelu, alpha)
DECLARE_ACTIVATION_KERNEL_WITH_ONE_ATTRS(ThresholdedRelu, threshold)
Expand Down
10 changes: 10 additions & 0 deletions paddle/phi/kernels/cpu/activation_kernel.cc
Expand Up @@ -89,6 +89,7 @@ DEFINE_CPU_ACTIVATION_KERNEL(Log1p, Log1pFunctor)
DEFINE_CPU_ACTIVATION_KERNEL(Round, RoundFunctor)
DEFINE_CPU_ACTIVATION_KERNEL(Floor, FloorFunctor)
DEFINE_CPU_ACTIVATION_KERNEL(Ceil, CeilFunctor)
DEFINE_CPU_ACTIVATION_KERNEL(Negative, NegativeFunctor)

DEFINE_CPU_ACT_KERNEL_WITH_ONE_ATTRS(LeakyRelu, LeakyReluFunctor, alpha)
DEFINE_CPU_ACT_KERNEL_WITH_ONE_ATTRS(ThresholdedRelu,
Expand Down Expand Up @@ -182,6 +183,15 @@ PD_REGISTER_ACTIVATION_KERNEL(swish, SwishKernel)
PD_REGISTER_ACTIVATION_KERNEL(round, RoundKernel)
PD_REGISTER_ACTIVATION_KERNEL(floor, FloorKernel)
PD_REGISTER_ACTIVATION_KERNEL(ceil, CeilKernel)
PD_REGISTER_KERNEL(negative,
CPU,
ALL_LAYOUT,
phi::NegativeKernel,
float,
double,
int16_t,
int,
int64_t) {}
PD_REGISTER_ACTIVATION_KERNEL(celu, CeluKernel)
PD_REGISTER_KERNEL(
pow, CPU, ALL_LAYOUT, phi::PowKernel, float, double, int, int64_t) {}
8 changes: 8 additions & 0 deletions paddle/phi/kernels/funcs/activation_functor.h
Expand Up @@ -1814,6 +1814,14 @@ struct CeilFunctor : public BaseActivationFunctor<T> {
}
};

template <typename T>
struct NegativeFunctor : public BaseActivationFunctor<T> {
template <typename Device, typename X, typename Out>
void operator()(Device d, X x, Out out) const {
out.device(d) = -x;
}
};

template <typename T>
struct ZeroGradFunctor : public BaseActivationFunctor<T> {
template <typename Device,
Expand Down

0 comments on commit e3d94fc

Please sign in to comment.