|
|
@ -36,11 +36,10 @@ class SequencePoolOpMaker : public framework::OpProtoAndCheckerMaker {
|
|
|
|
SequencePoolOpMaker(framework::OpProto* proto,
|
|
|
|
SequencePoolOpMaker(framework::OpProto* proto,
|
|
|
|
framework::OpAttrChecker* op_checker)
|
|
|
|
framework::OpAttrChecker* op_checker)
|
|
|
|
: OpProtoAndCheckerMaker(proto, op_checker) {
|
|
|
|
: OpProtoAndCheckerMaker(proto, op_checker) {
|
|
|
|
AddInput("X",
|
|
|
|
AddInput("X", "(LoDTensor), the variable-length input of SequencePoolOp");
|
|
|
|
"A float LoDTensor, the variable-length input of SequencePoolOp");
|
|
|
|
AddOutput("Out",
|
|
|
|
AddOutput(
|
|
|
|
"(Tensor), output of SequencePoolOp, which does not contain LoD "
|
|
|
|
"Out",
|
|
|
|
"infomation.");
|
|
|
|
"A float LoDTensor, the variable-length output of SequencePoolOp.");
|
|
|
|
|
|
|
|
AddAttr<int>(
|
|
|
|
AddAttr<int>(
|
|
|
|
"strategy",
|
|
|
|
"strategy",
|
|
|
|
"(int, default AVERAGE) the pooling strategy of SequencePoolOp.")
|
|
|
|
"(int, default AVERAGE) the pooling strategy of SequencePoolOp.")
|
|
|
@ -49,13 +48,13 @@ class SequencePoolOpMaker : public framework::OpProtoAndCheckerMaker {
|
|
|
|
AddComment(R"DOC(
|
|
|
|
AddComment(R"DOC(
|
|
|
|
SequencePoolOp pools features of all time-steps of each instance.
|
|
|
|
SequencePoolOp pools features of all time-steps of each instance.
|
|
|
|
|
|
|
|
|
|
|
|
For a mini-batch of 3 variable lengths sentences, containing 2, 3, and 2 time-steps:
|
|
|
|
For a mini-batch of 3 variable-length sentences, containing 2, 3, and 2 time-steps:
|
|
|
|
|
|
|
|
|
|
|
|
Assume X is a [7,M,N] float LoDTensor, and X->lod()[0] = [0, 2, 5, 7].
|
|
|
|
Assume X is a [7,M,N] LoDTensor, and X->lod()[0] = [0, 2, 5, 7], 7=2+3+2.
|
|
|
|
Besides, for the sake of simplicity, we assume M=1 and N=1,
|
|
|
|
Besides, for the sake of simplicity, we assume M=1 and N=1,
|
|
|
|
and the value of X = [[1, 3], [2, 4, 6], [5, 1]].
|
|
|
|
and the value of X = [[1, 3], [2, 4, 6], [5, 1]].
|
|
|
|
|
|
|
|
|
|
|
|
Thus, Out is a [3,1,1] float LoDTensor, but Out->lod() is nullptr.
|
|
|
|
Thus, Out is a [3,1,1] Tensor without LoD infomation.
|
|
|
|
And for different strategy, the value of Out is as follows:
|
|
|
|
And for different strategy, the value of Out is as follows:
|
|
|
|
|
|
|
|
|
|
|
|
- AVERAGE: [2, 4, 3], where 2=(1+3)/2, 4=(2+4+6)/3, 3=(5+1)/2
|
|
|
|
- AVERAGE: [2, 4, 3], where 2=(1+3)/2, 4=(2+4+6)/3, 3=(5+1)/2
|
|
|
|