cubie.memory.array_requests

Array request and response data structures for memory management.

This module provides data structures for requesting and managing GPU memory allocations with specific shapes, data types, and memory location requirements.

Classes

ArrayRequest(shape, ...] =[, dtype])

Specification for requesting array allocation with shape, dtype, and memory location.

ArrayResponse([arr, chunks, chunk_axis])

Result of an array allocation containing arrays and chunking information.

class cubie.memory.array_requests.ArrayRequest(shape: tuple[int, ...] = (1, 1, 1), dtype=<class 'numpy.float64'>, memory: str = 'device', stride_order: tuple[str, ...] | None = None)[source]

Bases: object

Specification for requesting array allocation with shape, dtype, and memory location.

Parameters:
  • shape (tuple of int, default (1, 1, 1)) – The shape of the requested array.

  • dtype (numpy.dtype, default np.float64) – The data type for the array elements.

  • memory (str, default "device") – Memory location type. Must be one of “device”, “mapped”, “pinned”, or “managed”.

  • stride_order (tuple of str or None, default None) – The order of strides for the array dimensions. If None, will be set automatically based on shape length.

shape

The shape of the requested array.

Type:

tuple of int

dtype

The data type for the array elements.

Type:

numpy.dtype

memory

Memory location type.

Type:

str

stride_order

The order of strides for the array dimensions.

Type:

tuple of str or None

Properties
----------
size

Total size of the array in bytes.

Type:

int

Notes

When stride_order is None, it will be automatically set during initialization: - For 3D arrays: (“time”, “run”, “variable”) - For 2D arrays: (“variable”, “run”)

dtype
memory: str
shape: tuple[int, ...]
property size

Calculate the total size of the array in bytes.

Returns:

Total size in bytes including element size and shape.

Return type:

int

stride_order: tuple[str, ...] | None
class cubie.memory.array_requests.ArrayResponse(arr: dict[str, FakeCUDAArray] = NOTHING, chunks: int = NOTHING, chunk_axis: str = 'run')[source]

Bases: object

Result of an array allocation containing arrays and chunking information.

Parameters:
  • arr (dict of str to DeviceNDArrayBase, default empty dict) – Dictionary mapping array labels to allocated device arrays.

  • chunks (int, default empty dict) – Number of chunks the allocation was divided into.

  • chunk_axis (str, default "run") – The axis along which chunking was performed.

arr

Dictionary mapping array labels to allocated device arrays.

Type:

dict of str to DeviceNDArrayBase

chunks

Number of chunks the allocation was divided into.

Type:

int

chunk_axis

The axis along which chunking was performed.

Type:

str

arr: dict[str, FakeCUDAArray]
chunk_axis: str
chunks: int