diff --git a/paddle/operators/rowwise_add_op.cc b/paddle/operators/rowwise_add_op.cc index cc763a8cf4565f633ee31b98c2ec7cd583ad77ed..178ea3c6145e00979b4eed1de99e81d1dd587fb4 100644 --- a/paddle/operators/rowwise_add_op.cc +++ b/paddle/operators/rowwise_add_op.cc @@ -16,7 +16,7 @@ namespace paddle { namespace operators { -class RowWiseAddOp : public OperatorWithKernel { +class RowwiseAddOp : public OperatorWithKernel { protected: void InferShape(const InferShapeContext &ctx) const override { PADDLE_ENFORCE(ctx.InputSize() == 2UL, @@ -32,9 +32,9 @@ protected: } }; -class RowWiseAddOpMaker : public OpProtoAndCheckerMaker { +class RowwiseAddOpMaker : public OpProtoAndCheckerMaker { public: - RowWiseAddOpMaker(OpProto *proto, OpAttrChecker *op_checker) + RowwiseAddOpMaker(OpProto *proto, OpAttrChecker *op_checker) : OpProtoAndCheckerMaker(proto, op_checker) { AddInput("X", "The left input of row-wise add op, must be matrix"); AddInput("b", "The right input of row-wise add op, must be vector"); @@ -46,13 +46,13 @@ for i in xrange(X.shape[0]): )DOC"); } }; -class RowWiseAddGradOp : public OperatorWithKernel { +class RowwiseAddGradOp : public OperatorWithKernel { protected: void InferShape(const InferShapeContext &ctx) const override { PADDLE_ENFORCE(ctx.InputSize() == 4UL, - "RowWiseAddGrad inputs is I, O, OG, size must be 4"); + "RowwiseAddGrad inputs is I, O, OG, size must be 4"); PADDLE_ENFORCE(ctx.OutputSize() == 2, - "RowWiseAddGrad output is IG, size must be 2"); + "RowwiseAddGrad output is IG, size must be 2"); ctx.Output<Tensor>(0)->Resize(ctx.Input<Tensor>(0)->dims()); ctx.Output<Tensor>(1)->Resize(ctx.Input<Tensor>(1)->dims()); } @@ -61,10 +61,10 @@ protected: } // namespace operators } // namespace paddle -REGISTER_OP(rowwise_add, ops::RowWiseAddOp, ops::RowWiseAddOpMaker); +REGISTER_OP(rowwise_add, ops::RowwiseAddOp, ops::RowwiseAddOpMaker); REGISTER_OP_CPU_KERNEL(rowwise_add, - ops::RowWiseAddKernel<ops::CPUPlace, float>); + ops::RowwiseAddKernel<ops::CPUPlace, float>); -REGISTER_GRADIENT_OP(rowwise_add, rowwise_add_grad, ops::RowWiseAddGradOp); +REGISTER_GRADIENT_OP(rowwise_add, rowwise_add_grad, ops::RowwiseAddGradOp); REGISTER_OP_CPU_KERNEL(rowwise_add_grad, - ops::RowWiseAddGradKernel<ops::CPUPlace, float>); + ops::RowwiseAddGradKernel<ops::CPUPlace, float>); diff --git a/paddle/operators/rowwise_add_op.cu b/paddle/operators/rowwise_add_op.cu index 4b33e38ebabe853e179fe70ef7fde0a80b9050e2..f48dfeb6f2c516d8c1096885ad60dc333def6b1f 100644 --- a/paddle/operators/rowwise_add_op.cu +++ b/paddle/operators/rowwise_add_op.cu @@ -1,4 +1,4 @@ #include "paddle/operators/rowwise_add_op.h" REGISTER_OP_GPU_KERNEL(rowwise_add, - ops::RowWiseAddKernel<ops::GPUPlace, float>); + ops::RowwiseAddKernel<ops::GPUPlace, float>); diff --git a/paddle/operators/rowwise_add_op.h b/paddle/operators/rowwise_add_op.h index 940459e0f176f07e63aef828baf3f9aa599c9a2c..321f51e61d472ede6cfc923fcf2a3d45324abd23 100644 --- a/paddle/operators/rowwise_add_op.h +++ b/paddle/operators/rowwise_add_op.h @@ -19,7 +19,7 @@ namespace paddle { namespace operators { template <typename Place, typename T> -class RowWiseAddKernel : public OpKernel { +class RowwiseAddKernel : public OpKernel { public: void Compute(const ExecutionContext& context) const override { auto out = context.Output<Tensor>(0); @@ -39,7 +39,7 @@ public: }; template <typename Place, typename T> -class RowWiseAddGradKernel : public OpKernel { +class RowwiseAddGradKernel : public OpKernel { public: void Compute(const ExecutionContext& context) const override { auto XGrad = context.Output<Tensor>(0); @@ -51,7 +51,7 @@ public: auto OutGrad = EigenMatrix<T>::From(*context.Input<Tensor>(3)); EigenMatrix<T>::From(*XGrad).device(*(context.GetEigenDevice<Place>())) = OutGrad; - // const int dimension = bGrad.dimension(0); + // https://eigen.tuxfamily.org/dox/unsupported/TensorBase_8h_source.html EigenVector<T>::Flatten(*bGrad).device(*(context.GetEigenDevice<Place>())) = OutGrad.cumsum(1); // colwise add