From f7616d713ef96a0fd32cba9f1688a95d74968adf Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Wed, 26 Oct 2022 15:17:14 +0800 Subject: [PATCH] fix slice bug (#47349) --- paddle/fluid/pybind/eager_method.cc | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index b70e127d39..07978fc053 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -1169,27 +1169,11 @@ static PyObject* tensor_method__setitem_eager_tensor(TensorObject* self, "please check the type of tensor.")); } - if (!value_tensor_tmp.initialized()) { -#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) - SetTensorFromPyArray( - static_cast(value_tensor_tmp.impl().get()), - value, - platform::Place(platform::CUDAPlace(0)), - false); -#else - SetTensorFromPyArray( - static_cast(value_tensor_tmp.impl().get()), - value, - platform::Place(platform::CPUPlace()), - false); -#endif - } else { - SetTensorFromPyArray( - static_cast(value_tensor_tmp.impl().get()), - value, - value_tensor_tmp.place(), - false); - } + SetTensorFromPyArray( + static_cast(value_tensor_tmp.impl().get()), + value, + self->tensor.place(), + false); value_tensor = value_tensor_tmp; } else { -- GitLab