Skip to content

Commit

Permalink
[Eager] fix set_value logic when input's dtype is different (#48519)
Browse files Browse the repository at this point in the history
* [Eager] fix set_value logic when input's dtype is different

* value_tensor

* fix set_value logic when input's dtype is different
  • Loading branch information
veyron95 authored Dec 4, 2022
1 parent 4552be4 commit 46371c5
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion paddle/fluid/pybind/eager_method.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1227,7 +1227,6 @@ static PyObject* tensor_method__setitem_eager_tensor(TensorObject* self,
Py_TYPE(value_obj)));
}
}

{
// Release gil and do tracing
py::gil_scoped_release release;
Expand All @@ -1242,6 +1241,9 @@ static PyObject* tensor_method__setitem_eager_tensor(TensorObject* self,
self->tensor.name(), self->tensor, amp_dtype, "set_value");
value_tensor = egr::EagerAmpAutoCast(
value_tensor.name(), value_tensor, amp_dtype, "set_value");
if (self->tensor.dtype() != value_tensor.dtype()) {
value_tensor = cast_ad_func(value_tensor, self->tensor.dtype());
}
}
self->tensor = set_value__dygraph_function(
self->tensor, value_tensor, {}, {}, {}, attrs);
Expand Down

0 comments on commit 46371c5

Please sign in to comment.