1 #include "caffe2/operators/acos_op.h" 2 #include "caffe2/utils/eigen_utils.h" 11 bool AcosGradientFunctor<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()).rsqrt();
26 REGISTER_CPU_OPERATOR(
31 AcosFunctor<CPUContext>>);
32 REGISTER_CPU_OPERATOR(
37 AcosGradientFunctor<CPUContext>>);
42 .IdenticalTypeAndShape()
44 Calculates the arccosine of the given input tensor, element-wise. 46 .Input(0, "input",
"Input tensor")
50 "The arccosine of the input tensor computed element-wise");
52 OPERATOR_SCHEMA(AcosGradient)
55 .IdenticalTypeAndShape();
59 class GetAcosGradient :
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(Acos, GetAcosGradient);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...