Skip to content

Commit 0a44b81

Browse files
Expanded doc-string of dpctl.tensor.usm_ndarray.to_device
1 parent ea4e009 commit 0a44b81

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

dpctl/tensor/_usmarray.pyx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,39 @@ cdef class usm_ndarray:
638638
res.array_namespace_ = self.array_namespace_
639639
return res
640640

641-
def to_device(self, target_device):
641+
def to_device(self, target):
642642
"""
643-
Transfer array to target device
643+
Transfers this array to specified target device.
644+
645+
:Example:
646+
.. code-block:: python
647+
648+
import dpctl
649+
import dpctl.tensor as dpt
650+
651+
x = dpt.full(10**6, 2, dtype="int64")
652+
q_prof = dpctl.SyclQueue(
653+
x.sycl_device, property="enable_profiling")
654+
# return a view with profile-enabled queue
655+
y = x.to_device(q_prof)
656+
timer = dpctl.SyclTimer()
657+
with timer(q_prof):
658+
z = y * y
659+
print(timer.dt)
660+
661+
Args:
662+
target: array API concept of target device.
663+
It can be a oneAPI filter selector string,
664+
an instance of :class:`dpctl.SyclDevice` corresponding to a
665+
non-partitioned SYCL device, an instance of
666+
:class:`dpctl.SyclQueue`, or a :class:`dpctl.tensor.Device`
667+
object returned by :attr:`dpctl.tensor.usm_array.device`.
668+
669+
Returns:
670+
A view if data copy is not required, and a copy otherwise.
671+
If copying is required, it is done by copying from the original
672+
allocation device to the host, followed by copying from host
673+
to the target device.
644674
"""
645675
cdef c_dpctl.DPCTLSyclQueueRef QRef = NULL
646676
cdef c_dpmem._Memory arr_buf

0 commit comments

Comments
 (0)