未验证 提交 fe43b2ee 编写于 作者: W wawltor 提交者: GitHub

Fix bug in sequence_unpad op when allocating the output memory

Fix #17955
Fix bug in sequence_unpad op, when allocate the output memory do not match actual memory, check memory failed. Fix this bug by allocating the output memeory in correct code position.
上级 25fb7c31
......@@ -33,7 +33,6 @@ class SequenceUnpadOpKernel : public framework::OpKernel<T> {
auto* x_t = ctx.Input<LoDTensor>("X");
auto* len_t = ctx.Input<LoDTensor>("Length");
auto* out_t = ctx.Output<LoDTensor>("Out");
out_t->mutable_data<T>(ctx.GetPlace());
const int64_t* seq_len_ptr = nullptr;
if (platform::is_gpu_place(ctx.GetPlace())) {
......@@ -67,6 +66,9 @@ class SequenceUnpadOpKernel : public framework::OpKernel<T> {
}
out_t->Resize(framework::make_ddim(out_dims_vec));
// after set the lod of output, allocate the memory
out_t->mutable_data<T>(ctx.GetPlace());
int64_t padded_length = x_t->dims()[1];
math::UnpaddingLoDTensorFunctor<DeviceContext, T>()(
ctx.template device_context<DeviceContext>(), *x_t, out_t,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册