1 #include "caffe2/operators/normalize_l1_op.h" 3 #include "caffe2/core/tensor.h" 7 template <
typename T,
class Context>
8 void NormalizeL1Op<T, Context>::DoNormalize(
14 using InnerStride = Eigen::InnerStride<Eigen::Dynamic>;
16 Eigen::Map<Eigen::Matrix<T, 1, Eigen::Dynamic>, 0, InnerStride>;
17 using ConstStridedVec =
18 Eigen::Map<const Eigen::Matrix<T, 1, Eigen::Dynamic>, 0, InnerStride>;
20 for (
int i = 0; i < n; ++i) {
21 auto base = (i / sf) * sf * m + (i % sf);
22 ConstStridedVec xVec(xData + base, 1, m, InnerStride(sf));
23 auto norm = xVec.template lpNorm<1>();
25 StridedVec yVec(yData + base, 1, m, InnerStride(sf));
31 REGISTER_CPU_OPERATOR(NormalizeL1, NormalizeL1Op<float, CPUContext>);
32 OPERATOR_SCHEMA(NormalizeL1)
35 .Arg(
"axis",
"axis to normalize")
37 Given a matrix, apply L1-normalization along the specified axis. A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...