irx.builtins.collections.tensor
irx.builtins.collections.tensor
Source: packages/irx/src/irx/builtins/collections/tensor.py
title: Tensor layout helpers layered on the builtin tensor runtime.
summary: >-
Define IRx's backend-neutral Tensor metadata helpers on top of the canonical
buffer/view substrate and the Arrow C++ backed tensor runtime.Functions
tensor_element_count(layout: TensorLayout) -> int
title: Return the logical element count for one layout.
parameters:
layout:
type: TensorLayout
returns:
type: inttensor_default_strides(shape: tuple[int, ...], item_size_bytes: int, *, order: TensorOrder=TensorOrder.C) -> tuple[int, ...]
title: Return canonical byte strides for one contiguous Tensor shape.
parameters:
shape:
type: tuple[int, Ellipsis]
item_size_bytes:
type: int
order:
type: TensorOrder
returns:
type: tuple[int, Ellipsis]tensor_is_c_contiguous(layout: TensorLayout, item_size_bytes: int) -> bool
title: Return whether one layout matches canonical C-order strides.
parameters:
layout:
type: TensorLayout
item_size_bytes:
type: int
returns:
type: booltensor_is_f_contiguous(layout: TensorLayout, item_size_bytes: int) -> bool
title: Return whether one layout matches canonical Fortran-order strides.
parameters:
layout:
type: TensorLayout
item_size_bytes:
type: int
returns:
type: boolvalidate_tensor_layout(layout: TensorLayout) -> tuple[str, ...]
title: Validate one static Tensor layout.
parameters:
layout:
type: TensorLayout
returns:
type: tuple[str, Ellipsis]tensor_byte_bounds(layout: TensorLayout) -> tuple[int, int] | None
title: Return the minimum and maximum element-start byte offsets.
summary: >-
The result is relative to the underlying data pointer. None means the
logical layout has zero extent and therefore addresses no elements.
parameters:
layout:
type: TensorLayout
returns:
type: tuple[int, int] | Nonetensor_primitive_type_name(type_: astx.DataType | None) -> str | None
title: Return the builtin primitive storage name for one Tensor element.
parameters:
type_:
type: astx.DataType | None
returns:
type: str | Nonetensor_element_size_bytes(type_: astx.DataType | None) -> int | None
title: Return the byte width for one Tensor element type.
parameters:
type_:
type: astx.DataType | None
returns:
type: int | Nonetensor_buffer_dtype(type_: astx.DataType | None) -> BufferHandle | None
title: Return the canonical buffer dtype handle for one Tensor element.
parameters:
type_:
type: astx.DataType | None
returns:
type: BufferHandle | Nonetensor_buffer_view_metadata(*, data: BufferHandle, owner: BufferHandle, dtype: BufferHandle, layout: TensorLayout, ownership: BufferOwnership, mutability: BufferMutability, has_validity_bitmap: bool=False) -> BufferViewMetadata
title: Bridge one Tensor layout into canonical buffer/view metadata.
parameters:
data:
type: BufferHandle
owner:
type: BufferHandle
dtype:
type: BufferHandle
layout:
type: TensorLayout
ownership:
type: BufferOwnership
mutability:
type: BufferMutability
has_validity_bitmap:
type: bool
returns:
type: BufferViewMetadatatensor_element_size_bytes_from_dtype(dtype: BufferHandle) -> int | None
title: Return the byte width for one canonical primitive dtype handle.
parameters:
dtype:
type: BufferHandle
returns:
type: int | NoneClasses
TensorOrder(str, Enum)
title: Canonical contiguous layout order for Tensor helpers.TensorLayout
title: Static Tensor layout metadata.
summary: >-
Represent the logical rank, shape, strides, and byte offset of one Tensor
value without duplicating the lower-level storage machinery.
attributes:
shape:
type: tuple[int, Ellipsis]
strides:
type: tuple[int, Ellipsis]
offset_bytes:
type: intMethods
ndim(self) -> int
title: Return the rank encoded by the layout.
returns:
type: int