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.
lite
wawltor 6 years ago committed by GitHub
parent 9d6640ff44
commit 2ae8decc90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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,

Loading…
Cancel
Save