@@ -38,10 +38,9 @@ class SequenceConvOp : public framework::OperatorWithKernel {
3838 auto  filter_dims = ctx->GetInputDim (" Filter" 
3939 PADDLE_ENFORCE (in_dims.size () == 2  && filter_dims.size () == 2 ,
4040 " Input(X, Filter) should be 2-D tensor." 
41-  PADDLE_ENFORCE (
42-  filter_dims[0 ] == context_length && filter_dims[1 ] == in_dims[1 ],
43-  " Filter's shape should be (context_length x " 
44-  " number_of_input_features)." 
41+  PADDLE_ENFORCE (filter_dims[0 ] == context_length * in_dims[1 ],
42+  " Filter's height should be context_length * " 
43+  " number_of_input_features ." 
4544
4645 if  (padding_trainable) {
4746 PADDLE_ENFORCE (
@@ -66,8 +65,9 @@ class SequenceConvOp : public framework::OperatorWithKernel {
6665 " and 'context_length'." 
6766 }
6867
69-  in_dims[1 ] = 1 ;
68+  in_dims[1 ] = filter_dims[ 1 ] ;
7069 ctx->SetOutputDim (" Out" 
70+  ctx->ShareLoD (" X" " Out" 
7171 }
7272};
7373
@@ -101,35 +101,51 @@ class SequenceConvOpMaker : public framework::OpProtoAndCheckerMaker {
101101 SequenceConvOpMaker (framework::OpProto* proto,
102102 framework::OpAttrChecker* op_checker)
103103 : OpProtoAndCheckerMaker(proto, op_checker) {
104-  AddInput (" X" 
105-  " (A float LoDTensor) the input of SequenceConvOp, a vector of " 
106-  " 2-D matrix of size (minibatch, number_of_input_features)." 
104+  AddInput (
105+  " X" 
106+  " (LoDTensor) the input(X) is a LodTensor, which support " 
107+  " variable-time length input sequence. The underlying tensor in " 
108+  " this LoDTensor is a matrix with shape (T, D), where, T is the " 
109+  " total time steps in this mini-batch, D is the input feature size." 
107110 AddInput (" PaddingData" 
108-  " (Tensor) the input of SequenceConvOp, a vector of " 
109-  " 2-D matrix of size (up_pad + down_pad, " 
110-  " number_of_input_features). " 
111+  " (Tensor, optional) the input(PaddingData) is an optional " 
112+  " parameter, and it is learnable. " 
113+  " This is a tensor with shape (N, D), where N is the " 
114+  " top_pad + bottom_pad, D is the input feature size. In order to " 
115+  " ensure the equal length of sequence before and after " 
116+  " convolution, it is necessary to fill the top and bottom of each " 
117+  " sequence according to context_length, context_stride and " 
118+  " context_start" 
111119 .AsDispensable ();
112120 AddInput (" Filter" 
113-  " (Tensor) the input of SequenceConvOp, a vector of " 
114-  " 2-D matrix of size (context_length x number_of_input_features)." 
115-  AddOutput (" Out" 
116-  " (A float LoDTensor) the output of SequenceConvOp, a vector " 
117-  " of 2-D matrix of size (minibatch, 1)." 
121+  " (Tensor) the input(Filter) is an learnable parameter." 
122+  " This is a tensor with shape (N, D), where N is the " 
123+  " context_length, D is the output feature size." 
124+  AddOutput (
125+  " Out" 
126+  " (LoDTensor) the output(Out) is a LodTensor, which support " 
127+  " variable-time length output sequence. The underlying tensor in " 
128+  " this LoDTensor is a matrix with shape (T, D), where, T is the " 
129+  " total time steps in this mini-batch, D is the output feature size." 
118130
119131 AddAttr<bool >(" padding_trainable" 
120132 " (bool, default false) the padding data of SequenceConvOp " 
121133 " is trainable or not." 
122134 .SetDefault (false );
123135 AddAttr<int >(" context_length" 
124-  " (int, default 3) the context_length of SequenceConvOp." 
136+  " (int, default 3) the context_length of SequenceConvOp is the " 
137+  " height of the convolution kernel." 
125138 .SetDefault (3 )
126139 .GreaterThan (0 );
127140 AddAttr<int >(" context_start" 
128-  " (int, default 0) the context_start of SequenceConvOp." 
141+  " (int, default 0) the context_start of SequenceConvOp " 
142+  " represents the beginning of the convolution of the number of " 
143+  " rows of sequence, which can be negative." 
129144 .SetDefault (0 );
130145 AddAttr<int >(" context_stride" 
131-  " (int, default 1) the context_stride of SequenceConvOp. " 
132-  " Currently, sequence_project_op only support " 
146+  " (int, default 1) the context_stride of SequenceConvOp " 
147+  " represents the step length of convolution. " 
148+  " Currently, SequenceConvOp only supports" 
133149 " context_stride=1." 
134150 .SetDefault (1 )
135151 .GreaterThan (0 );
@@ -139,14 +155,10 @@ class SequenceConvOpMaker : public framework::OpProtoAndCheckerMaker {
139155 context_length time-steps of each instance. 
140156 The convolution operation calculates the output based on the input, filter 
141157 and strides, paddings parameters. The size of each dimension of the 
142-  parameters is checked in the infer-shape. 
143- 
144- Example: 
145-  Input: 
146-  X shape: (minibatch, number_of_input_features) 
147-  Filter shape: (context_length, number_of_input_features) 
148-  Output: 
149-  Out shape: (minibatch, 1) 
158+  parameters is checked in the infer-shape. In order to ensure the equal 
159+  length of sequence before and after convolution, it is necessary to fill 
160+  the top and bottom of each sequence according to context_length, 
161+  context_stride and context_start. 
150162 )DOC"  );
151163 }
152164};
0 commit comments