1 #include "caffe2/operators/normalize_l1_op.h" 3 #include "caffe2/core/tensor.h" 4 #include "caffe2/utils/eigen_utils.h" 8 template <
typename T,
class Context>
9 void NormalizeL1Op<T, Context>::DoNormalize(
15 using InnerStride = Eigen::InnerStride<Eigen::Dynamic>;
17 Eigen::Map<Eigen::Matrix<T, 1, Eigen::Dynamic>, 0, InnerStride>;
18 using ConstStridedVec =
19 Eigen::Map<const Eigen::Matrix<T, 1, Eigen::Dynamic>, 0, InnerStride>;
21 for (
int i = 0; i < n; ++i) {
22 auto base = (i / sf) * sf * m + (i % sf);
23 ConstStridedVec xVec(xData + base, 1, m, InnerStride(sf));
24 auto norm = xVec.template lpNorm<1>();
26 StridedVec yVec(yData + base, 1, m, InnerStride(sf));
32 REGISTER_CPU_OPERATOR(NormalizeL1, NormalizeL1Op<float, CPUContext>);
33 OPERATOR_SCHEMA(NormalizeL1)
36 .Arg(
"axis",
"axis to normalize")
38 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 ...