diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 8649f88d48d1dc245a658accff621cdafa886cc4..74c66bfb0ac7002be71346baaefd1fa48d31a33c 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -1104,27 +1104,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 {