You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 62bde8f
Browse filesBrowse the repository at this point in the historyBrowse files
Tests and docs for the ArrayLibrary family; enum lookups by name see new libraries
Tests are regrouped by what they test (libraries, devices, conversion,
memory type, toy library) with shared fake modules; tests of deleted modules
are removed. Adds the toy-library test (one class gives lookup, MemoryType
member, decorator and conversion), the light-import and plan-without-devices
subprocess tests, and conversion record and counter tests.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|`name`| The registered name, the `MemoryType` value and the decorator name. | required |
120
+
|`import_name`| Top-level module to import; objects from it belong to the library. |`name`|
121
+
|`display_name`| Name used in messages. |`name`|
122
+
|`module_aliases`| Other top-level module names whose objects belong to the library (JAX: `jaxlib`). |`()`|
123
+
|`import_environment`| Environment variables set, if unset, before the first import and in child processes. |`()`|
124
+
|`oom_messages`| Lower-case text that marks an out-of-memory error message. |`()`|
125
+
|`oom_exception_paths`| Attribute paths from the module to its out-of-memory exception classes. |`()`|
126
+
127
+
Every library defines three methods asked for by `ArrayLibrary` itself:
128
+
129
+
-`device_of(data)`: the device holding the array. It never returns `None`.
130
+
-`_to_host(data)`: the array as a NumPy array.
131
+
-`_scale_dtype(result, target_dtype)`: convert the dtype, rescaling float
132
+
intensities into the integer range where the library does that.
133
+
134
+
## Role parents
135
+
136
+
Inherit each role the library plays. The abstract methods are the ones the
137
+
class must define.
138
+
139
+
| Parent | The library... | Abstract methods |
140
+
|---|---|---|
141
+
|`HostDevices`| keeps arrays in main memory. |`_wrap_host_array(data)`, `_move_to_host(data)`|
142
+
|`AcceleratorDevices`| can keep arrays on numbered accelerators. |`_accelerator_count()`, `_accelerator_scope(device)`, `_move_to_accelerator(data, device)`, `_upload(data, device)`|
143
+
|`CudaLibrary`| is an `AcceleratorDevices` library with its own CUDA streams and a memory cache to release. | those of `AcceleratorDevices`, plus `stream_scope(stream)`, `current_device()`, `_free_cached_memory()`|
144
+
|`DLPackImport`| can wrap another library's buffer through DLPack. |`_import_dlpack(payload)`|
145
+
|`DLPackProtocolExport`| has arrays with the standard DLPack export methods on every device. | none |
146
+
|`NvidiaWheelLibraries`| loads CUDA from the `nvidia-*` wheels; child processes get their library directories on the search path. | none |
147
+
|`MutableArrays`| has the NumPy array API and arrays that can be changed in place; supplies `_scale_dtype` and in-place plane normalisation. |`_rescales_into(target_dtype)`|
148
+
149
+
Methods with a default worth knowing:
150
+
151
+
-`HostDevices._host_scope()`: the block in which new arrays are created in
152
+
main memory. The default does nothing; TensorFlow and JAX override it.
153
+
-`AcceleratorDevices._activate_accelerator(device)`: select a device for the
0 commit comments