IRON
1.0
|
Functions | |
def | ceildiv (a, b) |
tuple[Sequence[int]|None, Sequence[int]|None] | validate_and_clean_sizes_strides (Sequence[int]|None sizes, Sequence[int]|None strides, bool allow_none=False, int|None expected_dims=None) |
Sequence[int] | validate_tensor_dims (Sequence[int] tensor_dims, int|None expected_dims=None) |
int | validate_offset (int offset, Sequence[int]|None tensor_dims) |
def taplib.utils.ceildiv | ( | a, | |
b | |||
) |
A helper function to calculate ceiling division without Args: a (_type_): The dividend b (_type_): The devisor Returns: _type_: The result
tuple[Sequence[int] | None, Sequence[int] | None] taplib.utils.validate_and_clean_sizes_strides | ( | Sequence[int] | None | sizes, |
Sequence[int] | None | strides, | ||
bool | allow_none = False , |
||
int | None | expected_dims = None |
||
) |
This is a helper function to validate sizes, strides and remove any unused values from upper dimensions if possible. Args: sizes (Sequence[int] | None): The transformation strides, or None strides (Sequence[int] | None): The transformation sizes, or None allow_none (bool, optional): Allow sizes and/or strides to be None. Defaults to False. expected_dims (int | None, optional): Number of dimensions expected for both sizes and strides. Defaults to None. Raises: ValueError: Validate sizes and strides Returns: tuple[Sequence[int] | None, Sequence[int] | None]: The 'cleaned' sizes and strides.
int taplib.utils.validate_offset | ( | int | offset, |
Sequence[int] | None | tensor_dims | ||
) |
This is a helper function to validate an offset into the tensor. It primarily checks to see if the offset is a valid index to the tensor. Args: offset (int): The offset to check. tensor_dims (Sequence[int] | None): The dimensions of the tensor the offset corresponds to. Raises: ValueError: Validate the offset. Returns: int: The validated offset.
Sequence[int] taplib.utils.validate_tensor_dims | ( | Sequence[int] | tensor_dims, |
int | None | expected_dims = None |
||
) |
This is a helper function used to validate dimensions of tensors, namely be ensuring each dimension is > 0 and the dimensionality is as expected. Args: tensor_dims (Sequence[int]): Tensor dimensions to check expected_dims (int | None, optional): Expected number of dimensions. Defaults to None. Raises: ValueError: Validate the tensor dimensions Returns: Sequence[int]: The validated tensor dimensions.