提交 af760eac 编写于 作者: K kexinzhao 提交者: Yi Wang

polish op from e to f (#5357)

上级 c5c02437
...@@ -22,7 +22,7 @@ class ElementwiseAddOpMaker : public ElementwiseOpMaker { ...@@ -22,7 +22,7 @@ class ElementwiseAddOpMaker : public ElementwiseOpMaker {
ElementwiseAddOpMaker(framework::OpProto* proto, ElementwiseAddOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: ElementwiseOpMaker(proto, op_checker) { : ElementwiseOpMaker(proto, op_checker) {
SetComment("add", "Out = X + Y"); SetComment("Add", "$Out = X + Y$");
AddComment(comment_); AddComment(comment_);
} }
}; };
......
...@@ -22,7 +22,7 @@ class ElementwiseDivOpMaker : public ElementwiseOpMaker { ...@@ -22,7 +22,7 @@ class ElementwiseDivOpMaker : public ElementwiseOpMaker {
ElementwiseDivOpMaker(framework::OpProto* proto, ElementwiseDivOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: ElementwiseOpMaker(proto, op_checker) { : ElementwiseOpMaker(proto, op_checker) {
SetComment("Div", "Out = X / Y"); SetComment("Div", "$Out = X / Y$");
AddComment(comment_); AddComment(comment_);
} }
}; };
......
...@@ -23,7 +23,7 @@ class ElementwiseMulOpMaker : public ElementwiseOpMaker { ...@@ -23,7 +23,7 @@ class ElementwiseMulOpMaker : public ElementwiseOpMaker {
ElementwiseMulOpMaker(framework::OpProto* proto, ElementwiseMulOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: ElementwiseOpMaker(proto, op_checker) { : ElementwiseOpMaker(proto, op_checker) {
SetComment("Mul", "Out = X ⊙ Y"); SetComment("Mul", "$Out = X \\odot\\ Y$");
AddComment(comment_); AddComment(comment_);
} }
}; };
......
...@@ -46,37 +46,42 @@ class ElementwiseOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -46,37 +46,42 @@ class ElementwiseOpMaker : public framework::OpProtoAndCheckerMaker {
ElementwiseOpMaker(framework::OpProto* proto, ElementwiseOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: OpProtoAndCheckerMaker(proto, op_checker) { : OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", R"DOC( AddInput("X", "(Tensor) The first input tensor of elementwise op");
The first input of elementwise op, it's a tensor of any dimensions. AddInput("Y", "(Tensor) The second input tensor of elementwise op");
)DOC"); AddOutput("Out", "The output of elementwise op");
AddInput("Y", R"DOC(
The sencond input of elementwise op, it's a tensor and it's dimensions
must be small or equal to X's dimensions.
)DOC");
AddAttr<int>("axis", AddAttr<int>("axis",
R"DOC( "(int, default -1) The starting dimension index "
When the shape(Y) does not equal the shape(X),Y will be broadcasted "for broadcasting Y onto X")
to match the shape of X and axis should be dimension index Y in X
)DOC")
.SetDefault(-1) .SetDefault(-1)
.EqualGreaterThan(-1); .EqualGreaterThan(-1);
AddOutput("Out", "The output of elementwise op");
comment_ = R"DOC( comment_ = R"DOC(
Limited elementwise {name} operator.The equation is: Out = {equation}. Limited Elementwise {name} Operator.
1. The shape of Y should be same with X or
2. Y's shape is a subset of X. The equation is:
Y will be broadcasted to match the shape of X and axis should be dimension index Y in X.
{equation}
example:
shape(X) = (2, 3, 4, 5), shape(Y) = (,) X is a tensor of any dimension and the dimensions of tensor Y must be smaller than
shape(X) = (2, 3, 4, 5), shape(Y) = (5,) or equal to the dimensions of X.
shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5)
shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1 There are two cases for this operator:
shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0 1. The shape of Y is same with X;
2. The shape of Y is a subset of X.
For case 2:
Y will be broadcasted to match the shape of X and axis should be
the starting dimension index for broadcasting Y onto X.
example:
shape(X) = (2, 3, 4, 5), shape(Y) = (,)
shape(X) = (2, 3, 4, 5), shape(Y) = (5,)
shape(X) = (2, 3, 4, 5), shape(Y) = (4, 5)
shape(X) = (2, 3, 4, 5), shape(Y) = (3, 4), with axis=1
shape(X) = (2, 3, 4, 5), shape(Y) = (2), with axis=0
Both the input X and Y can carry the LoD (Level of Details) information, Both the input X and Y can carry the LoD (Level of Details) information,
or not. But the output only shares the LoD with input X. or not. But the output only shares the LoD information with input X.
)DOC"; )DOC";
AddComment(comment_); AddComment(comment_);
} }
......
...@@ -22,7 +22,7 @@ class ElementwiseSubOpMaker : public ElementwiseOpMaker { ...@@ -22,7 +22,7 @@ class ElementwiseSubOpMaker : public ElementwiseOpMaker {
ElementwiseSubOpMaker(framework::OpProto* proto, ElementwiseSubOpMaker(framework::OpProto* proto,
framework::OpAttrChecker* op_checker) framework::OpAttrChecker* op_checker)
: ElementwiseOpMaker(proto, op_checker) { : ElementwiseOpMaker(proto, op_checker) {
SetComment("Sub", "Out = X - Y"); SetComment("Sub", "$Out = X - Y$");
AddComment(comment_); AddComment(comment_);
} }
}; };
......
...@@ -59,8 +59,13 @@ class FeedOpInfoMaker : public framework::OpProtoAndCheckerMaker { ...@@ -59,8 +59,13 @@ class FeedOpInfoMaker : public framework::OpProtoAndCheckerMaker {
: OpProtoAndCheckerMaker(proto, op_checker) { : OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", "The input of feed op"); AddInput("X", "The input of feed op");
AddOutput("Out", "The output of feed op"); AddOutput("Out", "The output of feed op");
AddComment("feed op, it should not be configured by users directly"); AddAttr<int>("col", "(int) The column of feed");
AddAttr<int>("col", "column of feed"); AddComment(R"DOC(
Feed Operator.
It should not be configured by users directly.
)DOC");
} }
}; };
......
...@@ -66,8 +66,13 @@ class FetchOpInfoMaker : public framework::OpProtoAndCheckerMaker { ...@@ -66,8 +66,13 @@ class FetchOpInfoMaker : public framework::OpProtoAndCheckerMaker {
: OpProtoAndCheckerMaker(proto, op_checker) { : OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", "The input of fetch op"); AddInput("X", "The input of fetch op");
AddOutput("Out", "The output of fetch op"); AddOutput("Out", "The output of fetch op");
AddComment("fetch op, it should not be configured by users directly"); AddAttr<int>("col", "(int) The column of fetch");
AddAttr<int>("col", "column of fetch"); AddComment(R"DOC(
Fetch Operator.
It should not be configured by users directly.
)DOC");
} }
}; };
} // namespace operators } // namespace operators
......
...@@ -70,11 +70,16 @@ class FillConstantBatchSizeLikeOpMaker ...@@ -70,11 +70,16 @@ class FillConstantBatchSizeLikeOpMaker
"with the specified value"); "with the specified value");
AddAttr<std::vector<int>>("shape", "(vector<int>) The shape of the output"); AddAttr<std::vector<int>>("shape", "(vector<int>) The shape of the output");
AddAttr<int>("dim_idx", AddAttr<int>("dim_idx",
"(int, default 0) the index of batch size dimension") "(int, default 0) The index of batch size dimension")
.SetDefault(0); .SetDefault(0);
AddAttr<float>("value", "(float, default 0) The value to be filled") AddAttr<float>("value", "(float, default 0) The value to be filled")
.SetDefault(0.0f); .SetDefault(0.0f);
AddComment(R"DOC(Fill up a variable with specified constant value.)DOC"); AddComment(R"DOC(
FillConstantBatchSizeLike Operator.
Fill up a variable with specified constant value.
)DOC");
} }
}; };
} // namespace operators } // namespace operators
......
...@@ -54,7 +54,12 @@ class FillConstantOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -54,7 +54,12 @@ class FillConstantOpMaker : public framework::OpProtoAndCheckerMaker {
AddOutput("Out", AddOutput("Out",
"(Tensor) Tensor of specified shape will be filled " "(Tensor) Tensor of specified shape will be filled "
"with the specified value"); "with the specified value");
AddComment(R"DOC(Fill up a variable with specified constant value.)DOC"); AddComment(R"DOC(
FillConstantBatchSizeLike Operator.
Fill up a variable with specified constant value.
)DOC");
} }
}; };
} // namespace operators } // namespace operators
......
...@@ -37,11 +37,13 @@ class FillZerosLikeOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -37,11 +37,13 @@ class FillZerosLikeOpMaker : public framework::OpProtoAndCheckerMaker {
framework::OpAttrChecker *op_checker) framework::OpAttrChecker *op_checker)
: framework::OpProtoAndCheckerMaker(proto, op_checker) { : framework::OpProtoAndCheckerMaker(proto, op_checker) {
AddInput("X", "The input of fill-zeros-like op."); AddInput("X", "The input of fill-zeros-like op.");
AddOutput("Y", "The varibale will be filled up with zeros."); AddOutput("Y", "The variable will be filled up with zeros.");
AddComment(R"DOC( AddComment(R"DOC(
Fill up a vriable with zeros. FillZerosLike Operator.
Fill up a variable with zeros.
The output will have the same size as the input.
The output will have the same size with input.
)DOC"); )DOC");
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册