Skip to content

Commit 2dffe32

Browse files
authored
[Cherry-pick] solve slice inplace illegal memory address bug (#34265) #34473
SliceGradKernel的need_pad_num == 0判断有问题,直接跳过导致没有分配合适的空间,删去该判断逻辑后运行就正常了。
1 parent 384372f commit 2dffe32

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

paddle/fluid/operators/slice_op.h

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -468,17 +468,7 @@ class SliceGradKernel : public framework::OpKernel<T> {
468468
}
469469
}
470470

471-
if (need_pad_num == 0) {
472-
// do not need padding, pass if data address same, else copy
473-
if (d_input->mutable_data<T>(context.GetPlace()) == d_out->data<T>()) {
474-
// inplace, do not any operator, pass
475-
} else {
476-
framework::TensorCopy(
477-
*d_out, context.GetPlace(),
478-
context.template device_context<platform::DeviceContext>(),
479-
d_input);
480-
}
481-
} else if (need_pad_num == 1) {
471+
if (need_pad_num == 1) {
482472
// only need padding one dimension, we can reduce dimension.
483473
// only the padding dimension is available for us.
484474
// How to reduce dimension(5 to 3 for example):

0 commit comments

Comments
 (0)