Skip to content

Commit da24ba3

Browse files
Docstring edits for array creation functions.
1 parent 100aba9 commit da24ba3

File tree

4 files changed

+416
-325
lines changed

4 files changed

+416
-325
lines changed

dpctl/tensor/_copy_utils.py

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -116,31 +116,31 @@ def from_numpy(np_ary, /, *, device=None, usm_type="device", sycl_queue=None):
116116
:class:`numpy.ndarray`.
117117
118118
Args:
119-
arg (array-like): An instance of input convertible to
120-
:class:`numpy.ndarray`
119+
arg:
120+
Input convertible to :class:`numpy.ndarray`
121121
device (object): array API specification of device where the
122122
output array is created. Device can be specified by a
123123
a filter selector string, an instance of
124124
:class:`dpctl.SyclDevice`, an instance of
125125
:class:`dpctl.SyclQueue`, or an instance of
126-
:class:`dpctl.tensor.Device`. If the value is `None`,
126+
:class:`dpctl.tensor.Device`. If the value is ``None``,
127127
returned array is created on the default-selected device.
128-
Default: `None`.
128+
Default: ``None``
129129
usm_type (str): The requested USM allocation type for the
130-
output array. Recognized values are `"device"`, `"shared"`,
131-
or `"host"`.
130+
output array. Recognized values are ``"device"``,
131+
``"shared"``, or ``"host"``
132132
sycl_queue (:class:`dpctl.SyclQueue`, optional):
133133
A SYCL queue that determines output array allocation device
134134
as well as execution placement of data movement operations.
135-
The `device` and `sycl_queue` arguments
135+
The ``device`` and ``sycl_queue`` arguments
136136
are equivalent. Only one of them should be specified. If both
137137
are provided, they must be consistent and result in using the
138-
same execution queue. Default: `None`.
138+
same execution queue. Default: ``None``
139139
140140
The returned array has the same shape, and the same data type kind.
141141
If the device does not support the data type of input array, a
142142
closest support data type of the same kind may be returned, e.g.
143-
input array of type `float16` may be upcast to `float32` if the
143+
input array of type ``float16`` may be upcast to ``float32`` if the
144144
target device does not support 16-bit floating point type.
145145
"""
146146
q = normalize_queue_device(sycl_queue=sycl_queue, device=device)
@@ -151,7 +151,7 @@ def to_numpy(usm_ary, /):
151151
"""
152152
to_numpy(usm_ary)
153153
154-
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
154+
Copies content of :class:`dpctl.tensor.usm_ndarray` instance ``usm_ary``
155155
into :class:`numpy.ndarray` instance of the same shape and same data type.
156156
157157
Args:
@@ -160,7 +160,7 @@ def to_numpy(usm_ary, /):
160160
Returns:
161161
:class:`numpy.ndarray`:
162162
An instance of :class:`numpy.ndarray` populated with content of
163-
`usm_ary`
163+
``usm_ary``
164164
"""
165165
return _copy_to_numpy(usm_ary)
166166

@@ -169,7 +169,7 @@ def asnumpy(usm_ary):
169169
"""
170170
asnumpy(usm_ary)
171171
172-
Copies content of :class:`dpctl.tensor.usm_ndarray` instance `usm_ary`
172+
Copies content of :class:`dpctl.tensor.usm_ndarray` instance ``usm_ary``
173173
into :class:`numpy.ndarray` instance of the same shape and same data
174174
type.
175175
@@ -179,7 +179,7 @@ def asnumpy(usm_ary):
179179
Returns:
180180
:class:`numpy.ndarray`:
181181
An instance of :class:`numpy.ndarray` populated with content
182-
of `usm_ary`
182+
of ``usm_ary``
183183
"""
184184
return _copy_to_numpy(usm_ary)
185185

@@ -508,22 +508,28 @@ def copy(usm_ary, /, *, order="K"):
508508
509509
Args:
510510
ary (usm_ndarray):
511-
Input array.
512-
order ({"C", "F", "A", "K"}, optional):
513-
Controls the memory layout of the output array.
511+
Input array
512+
order (``"C"``, ``"F"``, ``"A"``, ``"K"``, optional):
513+
Controls the memory layout of the output array
514514
Returns:
515515
usm_ndarray:
516516
A copy of the input array.
517517
518-
Memory layout of the copy is controlled by `order` keyword,
519-
following NumPy's conventions. The `order` keywords can be
518+
Memory layout of the copy is controlled by ``order`` keyword,
519+
following NumPy's conventions. The ``order`` keywords can be
520520
one of the following:
521521
522-
- "C": C-contiguous memory layout
523-
- "F": Fortran-contiguous memory layout
524-
- "A": Fortran-contiguous if the input array is also Fortran-contiguous,
525-
otherwise C-contiguous
526-
- "K": match the layout of `usm_ary` as closely as possible.
522+
.. list-table::
523+
524+
* - ``"C"``
525+
- C-contiguous memory layout
526+
* - ``"F"``
527+
- Fortran-contiguous memory layout
528+
* - ``"A"``
529+
- Fortran-contiguous if the input array is also Fortran-contiguous,
530+
otherwise C-contiguous
531+
* - ``"K"``
532+
- match the layout of ``usm_ary`` as closely as possible.
527533
528534
"""
529535
if len(order) == 0 or order[0] not in "KkAaCcFf":

0 commit comments

Comments
 (0)