Skip to content

Commit 90d841a

Browse files
committed
Add some more implementation notes
1 parent d7b4111 commit 90d841a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

docs/dev/implementation-notes.md

+14
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,17 @@ identical PyTorch uses a similar layout in `array_api_compat/torch/`, but it
4747
differs enough from NumPy/CuPy that very few common wrappers for those
4848
libraries are reused. Dask is close to NumPy in behavior and so most Dask
4949
functions also reuse the NumPy/CuPy common wrappers.
50+
51+
Occasionally, a wrapper implementation will need to reference another wrapper
52+
implementation, rather than the base `xp` version. The easiest way to do this
53+
is to call `array_namespace`, like
54+
55+
```py
56+
wrapped_xp = array_namespace(x)
57+
wrapped_xp.wrapped_func(...)
58+
```
59+
60+
Also, if there is a very minor difference required for wrapping, say, CuPy and
61+
NumPy, they can still use a common implementation in `common/_aliases.py` and
62+
use the `is_*_namespace()` or `is_*_function()` [helper
63+
functions](../helper-functions.rst) to branch as necessary.

0 commit comments

Comments
 (0)