@@ -30,7 +30,7 @@ data structures and automatically dispatch operations to the underlying namespac
30
30
instead of relying on NumPy.
31
31
32
32
At this stage, this support is **considered experimental ** and must be enabled
33
- explicitly as explained in the following .
33
+ explicitly by the ` array_api_dispatch ` configuration. See below for details .
34
34
35
35
.. note ::
36
36
Currently, only `array-api-strict `, `cupy `, and `PyTorch ` are known to work
@@ -45,7 +45,13 @@ and how it facilitates interoperability between array libraries:
45
45
Example usage
46
46
=============
47
47
48
- Here is an example code snippet to demonstrate how to use `CuPy
48
+ The configuration `array_api_dispatch=True ` needs to be set to `True ` to enable array
49
+ API support. We recommend setting this configuration globally to ensure consistent
50
+ behaviour and prevent accidental mixing of array namespaces.
51
+ Note that we set it with :func: `config_context ` below to avoid having to call
52
+ :func: `set_config(array_api_dispatch=False) ` at the end of every code snippet
53
+ that uses the array API.
54
+ The example code snippet below demonstrates how to use `CuPy
49
55
<https://cupy.dev/> `_ to run
50
56
:class: `~discriminant_analysis.LinearDiscriminantAnalysis ` on a GPU::
51
57
@@ -82,8 +88,7 @@ transfers an estimator attributes from Array API to a ndarray::
82
88
PyTorch Support
83
89
---------------
84
90
85
- PyTorch Tensors are supported by setting `array_api_dispatch=True ` and passing in
86
- the tensors directly::
91
+ PyTorch Tensors can also be passed directly::
87
92
88
93
>>> import torch
89
94
>>> X_torch = torch.asarray(X_np, device="cuda", dtype=torch.float32)
0 commit comments