未验证 提交 46371c53 编写于 作者: W Weilong Wu 提交者: GitHub

[Eager] fix set_value logic when input's dtype is different (#48519)

* [Eager] fix set_value logic when input's dtype is different

* value_tensor

* fix set_value logic when input's dtype is different
上级 4552be48
......@@ -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;
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册