From d8e238d1f62f3330d55206542b61e8cc9d4ecf79 Mon Sep 17 00:00:00 2001 From: jiangcheng Date: Wed, 21 Jul 2021 16:04:03 +0800 Subject: [PATCH] solve slice inplace illegal memory address bug (#34265) --- paddle/fluid/operators/slice_op.h | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/paddle/fluid/operators/slice_op.h b/paddle/fluid/operators/slice_op.h index 96b8ea11d6..658939a91f 100644 --- a/paddle/fluid/operators/slice_op.h +++ b/paddle/fluid/operators/slice_op.h @@ -391,17 +391,7 @@ class SliceGradKernel : public framework::OpKernel { } } - if (need_pad_num == 0) { - // do not need padding, pass if data address same, else copy - if (d_input->mutable_data(context.GetPlace()) == d_out->data()) { - // inplace, do not any operator, pass - } else { - framework::TensorCopy( - *d_out, context.GetPlace(), - context.template device_context(), - d_input); - } - } else if (need_pad_num == 1) { + if (need_pad_num == 1) { // only need padding one dimension, we can reduce dimension. // only the padding dimension is available for us. // How to reduce dimension(5 to 3 for example): -- GitLab