Skip to content

Commit cc9d274

Browse files
committed
Use exception:: directive to document exceptions instead of data::
1 parent 4cd4481 commit cc9d274

File tree

1 file changed

+43
-39
lines changed

1 file changed

+43
-39
lines changed

doc/reference/exceptions.rst

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,71 @@
11
.. _routines.exceptions:
22

3+
.. py:module:: dpnp.exceptions
4+
35
Exceptions and Warnings
46
=======================
57

68
General exceptions used by DPNP. Note that some exceptions may be module
79
specific, such as linear algebra errors.
810

9-
.. currentmodule:: dpnp.exceptions
10-
1111
Exceptions
1212
----------
1313

14-
.. data:: AxisError
14+
.. exception:: AxisError
15+
16+
Given when an axis is invalid.
17+
18+
.. exception:: DLPackCreationError
1519

16-
Given when an axis is invalid.
20+
Given when constructing DLPack capsule from either :class:`dpnp.ndarray` or
21+
:class:`dpctl.tensor.usm_ndarray` based on a USM allocation
22+
on a partitioned SYCL device.
1723

18-
.. data:: DLPackCreationError
24+
.. rubric:: Examples
1925

20-
Given when constructing DLPack capsule from either :class:`dpnp.ndarray` or
21-
:class:`dpctl.tensor.usm_ndarray` based on a USM allocation
22-
on a partitioned SYCL device.
26+
.. code-block:: python
2327
24-
.. rubric:: Examples
28+
>>> import dpnp as np
29+
>>> import dpctl
30+
>>> dev = dpctl.SyclDevice('cpu')
31+
>>> sdevs = dev.create_sub_devices(partition=[1, 1])
32+
>>> q = dpctl.SyclQueue(sdevs[0])
33+
>>> x = np.ones(10, sycl_queue=q)
34+
>>> np.from_dlpack(x)
35+
Traceback (most recent call last):
36+
...
37+
DLPackCreationError: to_dlpack_capsule: DLPack can only export arrays based on USM allocations bound to a default platform SYCL context
2538
26-
.. code-block:: python
39+
.. exception:: ExecutionPlacementError
2740

28-
>>> import dpnp as np
29-
>>> import dpctl
30-
>>> dev = dpctl.SyclDevice('cpu')
31-
>>> sdevs = dev.create_sub_devices(partition=[1, 1])
32-
>>> q = dpctl.SyclQueue(sdevs[0])
33-
>>> x = np.ones(10, sycl_queue=q)
34-
>>> np.from_dlpack(x)
35-
Traceback (most recent call last):
36-
...
37-
DLPackCreationError: to_dlpack_capsule: DLPack can only export arrays based on USM allocations bound to a default platform SYCL context
41+
Given when execution placement target can not be unambiguously determined
42+
from input arrays. Make sure that input arrays are associated with the same
43+
:class:`dpctl.SyclQueue`, or migrate data to the same
44+
:class:`dpctl.SyclQueue` using :meth:`dpnp.ndarray.to_device` method.
3845

39-
.. data:: ExecutionPlacementError
46+
.. exception:: SyclContextCreationError
4047

41-
Given when execution placement target can not be unambiguously determined
42-
from input arrays. Make sure that input arrays are associated with the same
43-
:class:`dpctl.SyclQueue`, or migrate data to the same
44-
:class:`dpctl.SyclQueue` using :meth:`dpnp.ndarray.to_device` method.
48+
Given when :class:`dpctl.SyclContext` instance could not be created.
4549

46-
.. data:: SyclContextCreationError
50+
.. exception:: SyclDeviceCreationError
4751

48-
Given when :class:`dpctl.SyclContext` instance could not be created.
52+
Given when :class:`dpctl.SyclDevice` instance could not be created.
4953

50-
.. data:: SyclDeviceCreationError
54+
.. exception:: SyclQueueCreationError
5155

52-
Given when :class:`dpctl.SyclDevice` instance could not be created.
56+
Given when :class:`dpctl.SyclQueue` instance could not be created.
57+
The creation can fail if the filter string is invalid, or the backend or
58+
device type values are not supported.
5359

54-
.. data:: SyclQueueCreationError
60+
.. exception:: USMAllocationError
5561

56-
Given when :class:`dpctl.SyclQueue` instance could not be created.
57-
The creation can fail if the filter string is invalid, or the backend or
58-
device type values are not supported.
62+
Given when Unified Shared Memory (USM) allocation call returns a null
63+
pointer, signaling a failure to perform the allocation.
64+
Some common reasons for allocation failure are:
5965

60-
.. data:: USMAllocationError
66+
* insufficient free memory to perform the allocation request
67+
* allocation size exceeds the maximum supported by targeted backend
6168

62-
Given when Unified Shared Memory (USM) allocation call returns a null
63-
pointer, signaling a failure to perform the allocation.
64-
Some common reasons for allocation failure are:
6569

66-
* insufficient free memory to perform the allocation request
67-
* allocation size exceeds the maximum supported by targeted backend
70+
.. automodule:: dpnp.exceptions
71+
:no-index:

0 commit comments

Comments
 (0)