|
|
@ -584,6 +584,39 @@ struct SinFunctor : public BaseActivationFunctor<T> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
struct Tangent {
|
|
|
|
|
|
|
|
HOSTDEVICE T operator()(const T& val) const { return tan(val); }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
|
|
|
struct Tangent<platform::float16> {
|
|
|
|
|
|
|
|
HOSTDEVICE platform::float16 operator()(const platform::float16& val) const {
|
|
|
|
|
|
|
|
return platform::float16(tan(static_cast<float>(val)));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tangent'(x) = -Tangent(x)
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
struct TanGradFunctor : public BaseActivationFunctor<T> {
|
|
|
|
|
|
|
|
template <typename Device, typename X, typename Out, typename dOut,
|
|
|
|
|
|
|
|
typename dX>
|
|
|
|
|
|
|
|
void operator()(Device d, X x, Out out, dOut dout, dX dx) const {
|
|
|
|
|
|
|
|
dx.device(d) = dout / x.unaryExpr(Cosine<T>()).square();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static constexpr ActBwdOpFwdDeps FwdDeps() { return kDepX; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tangent(x) = tan(x)
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
|
|
|
struct TanFunctor : public BaseActivationFunctor<T> {
|
|
|
|
|
|
|
|
template <typename Device, typename X, typename Out>
|
|
|
|
|
|
|
|
void operator()(Device d, X x, Out out) const {
|
|
|
|
|
|
|
|
out.device(d) = x.unaryExpr(Tangent<T>());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
template <typename T>
|
|
|
|
struct Sinh {
|
|
|
|
struct Sinh {
|
|
|
|
HOSTDEVICE T operator()(const T& val) const { return sinh(val); }
|
|
|
|
HOSTDEVICE T operator()(const T& val) const { return sinh(val); }
|
|
|
@ -1942,6 +1975,7 @@ struct LogGradGradFunctor : public BaseActivationFunctor<T> {
|
|
|
|
__macro(ceil, Ceil, CeilFunctor, ZeroGradFunctor); \
|
|
|
|
__macro(ceil, Ceil, CeilFunctor, ZeroGradFunctor); \
|
|
|
|
__macro(floor, Floor, FloorFunctor, ZeroGradFunctor); \
|
|
|
|
__macro(floor, Floor, FloorFunctor, ZeroGradFunctor); \
|
|
|
|
__macro(cos, Cos, CosFunctor, CosGradFunctor); \
|
|
|
|
__macro(cos, Cos, CosFunctor, CosGradFunctor); \
|
|
|
|
|
|
|
|
__macro(tan, Tan, TanFunctor, TanGradFunctor); \
|
|
|
|
__macro(acos, Acos, AcosFunctor, AcosGradFunctor); \
|
|
|
|
__macro(acos, Acos, AcosFunctor, AcosGradFunctor); \
|
|
|
|
__macro(sin, Sin, SinFunctor, SinGradFunctor); \
|
|
|
|
__macro(sin, Sin, SinFunctor, SinGradFunctor); \
|
|
|
|
__macro(asin, Asin, AsinFunctor, AsinGradFunctor); \
|
|
|
|
__macro(asin, Asin, AsinFunctor, AsinGradFunctor); \
|
|
|
|