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

Updated uva related code (#41391)

上级 1c7001e7
......@@ -1349,6 +1349,10 @@ static PyObject* tensor_method__uva(TensorObject* self, PyObject* args,
PyObject* kwargs) {
EAGER_TRY
VLOG(4) << "Running in tensor_method__uva.";
PADDLE_ENFORCE_EQ(self->tensor.is_dense_tensor(), true,
platform::errors::InvalidArgument(
"Unified virtual addressing only support "
"DenseTensor currently."));
PADDLE_ENFORCE_EQ(platform::is_cpu_place(self->tensor.inner_place()), true,
platform::errors::InvalidArgument(
"Unified virtual addressing only support "
......
......@@ -818,6 +818,21 @@ def monkey_patch_varbase():
@framework.dygraph_only
def _uva(self, device_id=0):
'''
Returns self tensor with the UVA(unified virtual addressing).
Args:
device_id(int, optional): The destination GPU device id. Default: None, means current device.
Examples:
.. code-block:: python
# required: gpu
import paddle
x = paddle.to_tensor([1, 2, 3], place=paddle.CPUPlace())
x._uva()
print(x)
'''
self._tensor_uva(device_id)
@framework.dygraph_only
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册