提交 49a59421 编写于 作者: W wanghaox

fix some typos

...@@ -90,11 +90,11 @@ class SequenceSliceOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -90,11 +90,11 @@ class SequenceSliceOpMaker : public framework::OpProtoAndCheckerMaker {
"a vector<int> to describe the length of every input sequence for " "a vector<int> to describe the length of every input sequence for "
"sub sequence item."); "sub sequence item.");
AddOutput("Out", AddOutput("Out",
"(LoDTensor), The output of SequenceSliceOp."); "(LoDTensor), the output of SequenceSliceOp.");
AddComment(R"DOC( AddComment(R"DOC(
Sequence slice operator Sequence slice operator
The operator crop a subsequence from given sequence with given start offset and subsequence length. The operator crops a subsequence from given sequence with given start offset and subsequence length.
It only supports sequence (LoD Tensor with level number is 1). It only supports sequence (LoD Tensor with level number is 1).
- Case: - Case:
X = [[a1, a2; X = [[a1, a2;
...@@ -109,7 +109,7 @@ It only supports sequence (LoD Tensor with level number is 1). ...@@ -109,7 +109,7 @@ It only supports sequence (LoD Tensor with level number is 1).
b1, b2] b1, b2]
[e1, e2]] [e1, e2]]
LoD(Out) = {{0, 2, 3}}; Dims(Out) = (3, 2) LoD(Out) = {{0, 2, 3}}; Dims(Out) = (3, 2)
NOTE: The length of the input, offset and length should be the same. The offset start from 0. NOTE: The first dimension size of input, the size of offset and Length, should be equal. The offset start from 0.
)DOC"); )DOC");
} }
}; };
......
...@@ -83,7 +83,8 @@ class SequenceSliceOpKernel : public framework::OpKernel<T> { ...@@ -83,7 +83,8 @@ class SequenceSliceOpKernel : public framework::OpKernel<T> {
PADDLE_ENFORCE_LT( PADDLE_ENFORCE_LT(
lod[0][i] + offset_data[i] + length_data[i], lod[0][i] + offset_data[i] + length_data[i],
lod[0][i + 1], lod[0][i + 1],
"The target tensor's length overflow")} "The target tensor's length overflow")
}
out->mutable_data<T>(ctx.GetPlace()); out->mutable_data<T>(ctx.GetPlace());
auto out_lod = SequenceSliceLoD(*in, offset_data, length_data); auto out_lod = SequenceSliceLoD(*in, offset_data, length_data);
...@@ -140,6 +141,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> { ...@@ -140,6 +141,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> {
auto lod = in->lod(); auto lod = in->lod();
auto out_lod = out_grad->lod(); auto out_lod = out_grad->lod();
if (x_grad) {
x_grad->mutable_data<T>(ctx.GetPlace()); x_grad->mutable_data<T>(ctx.GetPlace());
math::SetConstant<Place, T> set_zero; math::SetConstant<Place, T> set_zero;
set_zero(ctx.device_context(), x_grad, static_cast<T>(0)); set_zero(ctx.device_context(), x_grad, static_cast<T>(0));
...@@ -163,6 +165,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> { ...@@ -163,6 +165,7 @@ class SequenceSliceGradOpKernel : public framework::OpKernel<T> {
x_grad_t.data<T>()); x_grad_t.data<T>());
} }
} }
}
}; };
} // namespace operators } // namespace operators
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册