Skip to content

Commit

Permalink
fix slice bug (PaddlePaddle#47349)
Browse files Browse the repository at this point in the history
  • Loading branch information
wanghuancoder committed Oct 26, 2022
1 parent 85094bc commit e914ee2
Showing 1 changed file with 5 additions and 21 deletions.
26 changes: 5 additions & 21 deletions paddle/fluid/pybind/eager_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<phi::DenseTensor*>(value_tensor_tmp.impl().get()),
value,
platform::Place(platform::CUDAPlace(0)),
false);
#else
SetTensorFromPyArray(
static_cast<phi::DenseTensor*>(value_tensor_tmp.impl().get()),
value,
platform::Place(platform::CPUPlace()),
false);
#endif
} else {
SetTensorFromPyArray(
static_cast<phi::DenseTensor*>(value_tensor_tmp.impl().get()),
value,
value_tensor_tmp.place(),
false);
}
SetTensorFromPyArray(
static_cast<phi::DenseTensor*>(value_tensor_tmp.impl().get()),
value,
self->tensor.place(),
false);

value_tensor = value_tensor_tmp;
} else {
Expand Down

0 comments on commit e914ee2

Please sign in to comment.