Caffe2 - C++ API
A deep learning, cross platform ML framework
elementwise_div_op.cc
1 #include "caffe2/operators/elementwise_op.h"
2 
3 namespace caffe2 {
4 
5 // See the operations supported here:
6 // https://eigen.tuxfamily.org/dox-devel/group__QuickRefPage.html
7 #define EIGEN_DIV(x, y) ((x) / (y))
8 EIGEN_FUNCTOR(Div, EIGEN_DIV, NumericTypes, SameTypeAsInput);
9 #undef EIGEN_DIV
10 
11 void ElementWiseDivide(
12  CPUContext& /* unused context */,
13  const int n,
14  float* dXdata,
15  float* dYdata,
16  const float* dZdata,
17  const float* Ydata,
18  const float* Zdata) {
19  ConstEigenVectorArrayMap<float> dZdataVec(dZdata, n);
20  ConstEigenVectorArrayMap<float> YdataVec(Ydata, n);
21  ConstEigenVectorArrayMap<float> ZdataVec(Zdata, n);
22  EigenVectorArrayMap<float>(dXdata, n) = dZdataVec / YdataVec;
23  EigenVectorArrayMap<float>(dYdata, n) = - (dZdataVec * ZdataVec) / YdataVec;
24 }
25 
26 REGISTER_CPU_OPERATOR(DivGradient, DivGradientOp<CPUContext>);
27 }
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...