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

test=develop (#17984)

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.
上级 9d6640ff
......@@ -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.
先完成此消息的编辑!
想要评论请 注册