1 #include "caffe2/operators/atan_op.h" 2 #include "caffe2/utils/eigen_utils.h" 11 bool AtanGradientFunctor<CPUContext>::Forward(
12 const std::vector<int>& X_dims,
13 const std::vector<int>& ,
18 const int size = std::accumulate(
19 X_dims.cbegin(), X_dims.cend(), 1, std::multiplies<int>());
20 ConstEigenVectorArrayMap<T> dY_arr(dY, size);
21 ConstEigenVectorArrayMap<T> X_arr(X, size);
22 EigenVectorMap<T>(dX, size) = dY_arr / (
T(1) + X_arr.square());
26 REGISTER_CPU_OPERATOR(
31 AtanFunctor<CPUContext>>);
32 REGISTER_CPU_OPERATOR(
37 AtanGradientFunctor<CPUContext>>);
42 .IdenticalTypeAndShape()
44 Calculates the arctangent of the given input tensor, element-wise. 46 .Input(0, "input",
"Input tensor")
50 "The arctangent of the input tensor computed element-wise");
52 OPERATOR_SCHEMA(AtanGradient)
55 .IdenticalTypeAndShape();
59 class GetAtanGradient :
public GradientMakerBase {
60 using GradientMakerBase::GradientMakerBase;
61 std::vector<OperatorDef> GetGradientDefs()
override {
62 return SingleGradientDef(
65 std::vector<std::string>{I(0), GO(0)},
66 std::vector<std::string>{GI(0)});
72 REGISTER_GRADIENT(Atan, GetAtanGradient);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...