Skip to content

More docstring edits #1636

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 27 commits into from
Apr 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e4e8c92
Fix docstrings for functions in program/_program.pyx
oleksandr-pavlyk Apr 5, 2024
b1ab254
Edits docstrings for functions in dpctl.utils namespace
oleksandr-pavlyk Apr 5, 2024
100aba9
Docstring changes for usm_ndarray
oleksandr-pavlyk Apr 5, 2024
da24ba3
Docstring edits for array creation functions.
oleksandr-pavlyk Apr 5, 2024
dcee243
Changed docstrings for select_*_device per changes in SYCL spec
oleksandr-pavlyk Apr 6, 2024
4562db9
Update to properties and methods of SyclDevice
oleksandr-pavlyk Apr 6, 2024
e11146c
Edits to docstring of SyclDevice.create_sub_devices
oleksandr-pavlyk Apr 8, 2024
6dc33ce
Fixed indentation in SyclDevice docstring
oleksandr-pavlyk Apr 9, 2024
88b83b2
Fixed indents in SyclEvent class
oleksandr-pavlyk Apr 9, 2024
4a11004
Fixed indents in SyclPlatform docstring
oleksandr-pavlyk Apr 9, 2024
94293ce
Corrected indents in docstring of SyclQueue class
oleksandr-pavlyk Apr 9, 2024
8e2f1f4
Fix indentation in item list to resolve Sphinx warnings
oleksandr-pavlyk Apr 9, 2024
629f6e2
Fix indents for docstring of SyclTimer, populated docstring for dt me…
oleksandr-pavlyk Apr 9, 2024
ae33ff6
thi -> this typo fixed
oleksandr-pavlyk Apr 9, 2024
67466d4
Corrected indents for SyclContext class docstrings
oleksandr-pavlyk Apr 9, 2024
20de762
Fix typos found during review
oleksandr-pavlyk Apr 9, 2024
f8b27aa
Another round of review changes
oleksandr-pavlyk Apr 9, 2024
d3343cf
Use sycl:: namespace for nd_range for max_work_group_sizes* properties
oleksandr-pavlyk Apr 9, 2024
e85eb4e
Edits per PR review
oleksandr-pavlyk Apr 10, 2024
9d00c03
Edits per PR review
oleksandr-pavlyk Apr 10, 2024
af77217
Fixed typo and grammar in docstrings caught in review
oleksandr-pavlyk Apr 10, 2024
49046c7
Fixed typos foundn in review
oleksandr-pavlyk Apr 10, 2024
df39f8c
Clarified type of input arguments, that it can be list or tuple
oleksandr-pavlyk Apr 10, 2024
e398caa
Fixed item list indentations in docstrings from dpctl.utils
oleksandr-pavlyk Apr 10, 2024
dd46535
Docstring edits for _array_api
oleksandr-pavlyk Apr 11, 2024
19f8059
Fixed docstrings of inspection API class and methods
oleksandr-pavlyk Apr 11, 2024
e3bc17f
More fixes in _array_api, missed in previous commit
oleksandr-pavlyk Apr 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ per-file-ignores =
dpctl/tensor/numpy_usm_shared.py: F821
dpctl/tests/_cython_api.pyx: E999, E225, E227, E402
dpctl/utils/_compute_follows_data.pyx: E999, E225, E227
dpctl/utils/_onetrace_context.py: E501, W505
dpctl/tensor/_array_api.py: E501, W505
examples/cython/sycl_buffer/syclbuffer/_buffer_example.pyx: E999, E225, E402
examples/cython/usm_memory/blackscholes/blackscholes.pyx: E999, E225, E226, E402
examples/cython/use_dpctl_sycl/use_dpctl_sycl/_cython_api.pyx: E999, E225, E226, E402
176 changes: 96 additions & 80 deletions dpctl/_sycl_context.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,68 +100,68 @@ cdef class SyclContext(_SyclContext):

There are multiple ways to create a :class:`dpctl.SyclContext` object:

- Invoking the constructor with no arguments creates a context using
the default selector.
- Invoking the constructor with no arguments creates a context using
the default selector.

:Example:
.. code-block:: python
:Example:
.. code-block:: python

import dpctl
import dpctl

# Create a SyclContext for default-selected device
ctx = dpctl.SyclContext()
print(ctx.get_devices())
# Create a SyclContext for default-selected device
ctx = dpctl.SyclContext()
print(ctx.get_devices())

- Invoking the constructor with a specific filter string that creates a
context for the device corresponding to the filter string.
- Invoking the constructor with a specific filter string that creates a
context for the device corresponding to the filter string.

:Example:
.. code-block:: python
:Example:
.. code-block:: python

import dpctl
import dpctl

# Create SyclContext for a gpu device
ctx = dpctl.SyclContext("gpu")
d = ctx.get_devices()[0]
assert(d.is_gpu)
# Create SyclContext for a gpu device
ctx = dpctl.SyclContext("gpu")
d = ctx.get_devices()[0]
assert(d.is_gpu)

- Invoking the constructor with a :class:`dpctl.SyclDevice` object
creates a context for that device.
- Invoking the constructor with a :class:`dpctl.SyclDevice` object
creates a context for that device.

:Example:
.. code-block:: python
:Example:
.. code-block:: python

import dpctl
import dpctl

# Create a level zero gpu device
d = dpctl.SyclDevice("level_zero:gpu")
ctx = dpctl.SyclContext(d)
d = ctx.get_devices()[0]
assert(d.is_gpu)
# Create a level zero gpu device
d = dpctl.SyclDevice("level_zero:gpu")
ctx = dpctl.SyclContext(d)
d = ctx.get_devices()[0]
assert(d.is_gpu)

- Invoking the constructor with a list of :class:`dpctl.SyclDevice`
objects creates a common context for all the devices. This
constructor call is especially useful when creation a context for
multiple sub-devices.
- Invoking the constructor with a list of :class:`dpctl.SyclDevice`
objects creates a common context for all the devices. This
constructor call is especially useful when creation a context for
multiple sub-devices.

:Example:
.. code-block:: python
:Example:
.. code-block:: python

import dpctl
import dpctl

# Create a CPU device using the opencl driver
cpu_d = dpctl.SyclDevice("opencl:cpu")
# Partition the CPU device into sub-devices with two cores each.
sub_devices = cpu_d.create_sub_devices(partition=2)
# Create a context common to all the sub-devices.
ctx = dpctl.SyclContext(sub_devices)
assert(len(ctx.get_devices) == len(sub_devices))

- Invoking the constructor with a named ``PyCapsule`` with name
**"SyclContextRef"** that carries a pointer to a ``sycl::context``
object. The capsule will be renamed upon successful consumption
to ensure one-time use. A new named capsule can be constructed by
using :func:`dpctl.SyclContext._get_capsule` method.
# Create a CPU device using the opencl driver
cpu_d = dpctl.SyclDevice("opencl:cpu")
# Partition the CPU device into sub-devices with two cores each.
sub_devices = cpu_d.create_sub_devices(partition=2)
# Create a context common to all the sub-devices.
ctx = dpctl.SyclContext(sub_devices)
assert(len(ctx.get_devices) == len(sub_devices))

- Invoking the constructor with a named ``PyCapsule`` with name
**"SyclContextRef"** that carries a pointer to a ``sycl::context``
object. The capsule will be renamed upon successful consumption
to ensure one-time use. A new named capsule can be constructed by
using :func:`dpctl.SyclContext._get_capsule` method.

Args:
arg (optional): Defaults to ``None``.
Expand All @@ -170,21 +170,24 @@ cdef class SyclContext(_SyclContext):
named ``PyCapsule`` called **"SyclContextRef"**.

Raises:
MemoryError: If the constructor could not allocate necessary
temporary memory.
SyclContextCreationError: If the :class:`dpctl.SyclContext` object
creation failed.
TypeError: If the list of :class:`dpctl.SyclDevice` objects was empty,
or the input capsule contained a null pointer or could not
be renamed.
MemoryError:
If the constructor could not allocate necessary
temporary memory.
SyclContextCreationError:
If the :class:`.SyclContext` object creation failed.
TypeError:
If the list of :class:`dpctl.SyclDevice` objects was empty,
or the input capsule contained a null pointer or could not
be renamed.

"""
@staticmethod
cdef SyclContext _create(DPCTLSyclContextRef ctxt):
"""
Calls DPCTLContext_Delete(ctxt).
Calls ``DPCTLContext_Delete(ctxt)``.

Users should pass a copy if they intend to keep the argument ctxt alive.
Users should pass a copy if they intend to keep the argument
``ctxt`` alive.
"""
cdef _SyclContext ret = <_SyclContext>_SyclContext.__new__(_SyclContext)
_init_helper(ret, ctxt)
Expand Down Expand Up @@ -335,22 +338,24 @@ cdef class SyclContext(_SyclContext):
:class:`dpctl.SyclContext` instance.

Returns:
:obj:`bool`: ``True`` if the two :class:`dpctl.SyclContext` objects
point to the same ``DPCTLSyclContextRef`` object, otherwise
``False``.
bool:
``True`` if the two :class:`dpctl.SyclContext` objects
point to the same ``DPCTLSyclContextRef`` object, otherwise
``False``.
"""
return DPCTLContext_AreEq(self._ctxt_ref, ctxt.get_context_ref())

def __eq__(self, other):
"""
Returns True if the :class:`dpctl.SyclContext` argument has the
Returns ``True`` if the :class:`dpctl.SyclContext` argument has the
same underlying ``DPCTLSyclContextRef`` object as this
:class:`dpctl.SyclContext` instance.

Returns:
:obj:`bool`: ``True`` if the two :class:`dpctl.SyclContext` objects
point to the same ``DPCTLSyclContextRef`` object, otherwise
``False``.
:obj:`bool`:
``True`` if the two :class:`dpctl.SyclContext` objects
point to the same ``DPCTLSyclContextRef`` object, otherwise
``False``.
"""
if isinstance(other, SyclContext):
return self.equals(<SyclContext> other)
Expand All @@ -361,6 +366,10 @@ cdef class SyclContext(_SyclContext):
"""
Returns a hash value by hashing the underlying ``sycl::context`` object.

Returns:
int:
Hash value.

"""
return DPCTLContext_Hash(self._ctxt_ref)

Expand All @@ -373,9 +382,10 @@ cdef class SyclContext(_SyclContext):
``size_t``.

Returns:
:obj:`int`: The address of the ``DPCTLSyclContextRef`` object
used to create this :class:`dpctl.SyclContext` cast to a
``size_t``.
int:
The address of the ``DPCTLSyclContextRef`` object
used to create this :class:`dpctl.SyclContext` cast to a
``size_t``.
"""
return <size_t>self._ctxt_ref

Expand All @@ -385,12 +395,14 @@ cdef class SyclContext(_SyclContext):
:class:`dpctl.SyclContext` instance.

Returns:
:obj:`list`: A :obj:`list` of :class:`dpctl.SyclDevice` objects
that belong to this context.
list:
A :obj:`list` of :class:`dpctl.SyclDevice` objects
that belong to this context.

Raises:
ValueError: If the ``DPCTLContext_GetDevices`` call returned
``NULL`` instead of a ``DPCTLDeviceVectorRef`` object.
ValueError:
If the ``DPCTLContext_GetDevices`` call returned
``NULL`` instead of a ``DPCTLDeviceVectorRef`` object.
"""
cdef DPCTLDeviceVectorRef DVRef = DPCTLContext_GetDevices(
self.get_context_ref()
Expand All @@ -415,11 +427,13 @@ cdef class SyclContext(_SyclContext):
:class:`dpctl.SyclContext` instance.

Returns:
:obj:`int`: Number of devices associated with the context.
int:
Number of devices associated with the context.

Raises:
ValueError: If ``DPCTLContext_DeviceCount`` led to a
failure.
ValueError:
If ``DPCTLContext_DeviceCount`` call led to a
failure.
"""
cdef size_t num_devs = DPCTLContext_DeviceCount(self.get_context_ref())
if num_devs:
Expand Down Expand Up @@ -454,8 +468,8 @@ cdef class SyclContext(_SyclContext):
print(ctx2)

Returns:
:obj:`str`: A string representation of the
:class:`dpctl.SyclContext` object.
str:
A string representation of this :class:`.SyclContext` instance.

"""
cdef size_t n = self.device_count
Expand All @@ -477,13 +491,15 @@ cdef class SyclContext(_SyclContext):
of scope.

Returns:
:class:`pycapsule`: A capsule object storing a copy of the
``sycl::context`` pointer belonging to thus
:class:`dpctl.SyclContext` instance.
:class:`pycapsule`:
A capsule object storing a copy of the
``sycl::context`` pointer belonging to thus
:class:`dpctl.SyclContext` instance.

Raises:
ValueError: If the ``DPCTLContext_Copy`` fails to copy the
``sycl::context`` pointer.
ValueError:
If the ``DPCTLContext_Copy`` fails to copy the
``sycl::context`` pointer.
"""
cdef DPCTLSyclContextRef CRef = NULL
CRef = DPCTLContext_Copy(self._ctxt_ref)
Expand Down
Loading