coreai¶
CoreAI high-level Python API.
coreai.runtime¶
CoreAI Runtime.
- final class coreai.runtime.InferenceFunction¶
Represents a function in a model.
- property desc: InferenceFunctionDescriptor¶
The descriptor for this function.
- final class coreai.runtime.NDArray(data: np.ndarray[Any, Any] | torch.Tensor | list[Any], backing: StorageKind = StorageKind.BYTES)¶
Represent a multi-dimensional array.
- property dtype: str¶
The type of scalars in the array.
- classmethod from_descriptor(descriptor: NDArrayDescriptor) Self¶
Allocates an NDArray from an NDArrayDescriptor.
Will have the correct shape, dtype, and alignment.
- numpy() ndarray[Any, Any]¶
Return the array as a NumPy array.
Standard dtypes (e.g. float32, int8) return a zero-copy view that shares the backing buffer and preserves strides via DLPack. For bfloat16 / float8 dtypes, which DLPack may not support depending on the NumPy version, it falls back to the buffer protocol: C-contiguous arrays return a zero-copy view, non-contiguous arrays (e.g. a transpose) return a copy gathered in C order. Sub-byte dtypes (int2, int4, …) are always unpacked into a new array.
- property shape: tuple[int, ...]¶
The shape of the array.
- property strides: tuple[int, ...]¶
The strides, in elements (not bytes).
Describes the distance, in elements, between consecutive values along a given dimension.
- class coreai.runtime.SpecializationOptions¶
Options for configuring model specialization.
- property allowed_compute_unit_kinds: list[ComputeUnitKind]¶
Get the allowed compute unit kinds for this specialization.
- classmethod cpu_only() SpecializationOptions¶
Specialization options restricted to CPU only.
- classmethod default() SpecializationOptions¶
Default specialization options.
- classmethod from_preferred_compute_unit_kind(compute_unit_kind: ComputeUnitKind) SpecializationOptions¶
Create specialization options with a specific preferred compute unit kind.
- static is_supported() bool¶
Whether delegate specialization is available on this platform and setup.
Returns
Trueon macOS with env var USE_OS_COREAI=1 (because the in-package Core AI runtime doesn’t support delegates). Unlike the constructors below, this never raises, so callers can use it to gate or skip cleanly before attempting to build options.
- property preferred_compute_unit_kind: ComputeUnitKind | None¶
Get the preferred compute unit for this specialization.
- with_debug(*, enabled: bool) SpecializationOptions¶
Return a new SpecializationOptions instance with debugging toggled.
- class coreai.runtime.StorageKind(value)¶
Backing buffer type for NDArray.
Python analogue for CoreAI.NDArrayDescriptor.StorageKind.