diff --git a/paddle/fluid/pybind/eager_method.cc b/paddle/fluid/pybind/eager_method.cc index 66fba92f67b83ab99e3287ac1a3833d0e98344df..1a7eb629a0eaa1069da947d35f92ce66d9b2010d 100644 --- a/paddle/fluid/pybind/eager_method.cc +++ b/paddle/fluid/pybind/eager_method.cc @@ -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 " diff --git a/python/paddle/fluid/dygraph/varbase_patch_methods.py b/python/paddle/fluid/dygraph/varbase_patch_methods.py index c97471d25f19c157c842a19d7aa2de988d812c2e..bd1ca1aa26dda856ec7d12d52206eaee0c1bea6f 100644 --- a/python/paddle/fluid/dygraph/varbase_patch_methods.py +++ b/python/paddle/fluid/dygraph/varbase_patch_methods.py @@ -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