iree.turbine.support

exception iree.turbine.support.ApiSequencingError
exception iree.turbine.support.GeneralError
exception iree.turbine.support.MismatchedDeviceSetClearError
exception iree.turbine.support.NoCurrentDeviceError
exception iree.turbine.support.UnknownDTypeError(dtype)
exception iree.turbine.support.UnsupportedTorchDeviceError(torch_device)
exception iree.turbine.support.UnsupportedTypeError(t: type, usage: str)
iree.turbine.support.default_trace_tensor_callback(key: str, tensor: Tensor)
iree.turbine.support.trace_tensor_callback(key: str, tensor: Tensor)
iree.turbine.support.trace_tensor_to_npy(key: str, tensor: Tensor)

conversions

iree.turbine.support.conversions.dtype_to_element_type(dtype) HalElementType
iree.turbine.support.conversions.torch_dtype_to_numpy(torch_dtype: dtype) Any
iree.turbine.support.conversions.torch_dtyped_shape_to_iree_format(shape_or_tensor: Sequence[int] | Tensor, /, dtype: dtype | None = None) str

Example: shape = [1, 2, 3] dtype = torch.bfloat16 Returns “1x2x3xbf16”

debugging

class iree.turbine.support.debugging.DebugFlags(log_level: int = 0, asserts: bool = False, runtime_trace_dir: str | None = None)
asserts: bool = False
log_level: int = 0
static parse(settings: str) DebugFlags
static parse_from_env() DebugFlags
runtime_trace_dir: str | None = None
set(part: str)

logging

class iree.turbine.support.logging.DefaultFormatter
iree.turbine.support.logging.get_logger(name: str)

tools

iree.turbine.support.tools.iree_tool_format_cli_input_arg(arg: Tensor, file_path: str | PathLike) str

Format the CLI value for an input argument. Example:

iree_tool_format_cli_input_arg(torch.empty([1,2], dtype=torch.float32), "arg0.bin")

Returns:

"1x2xf32=@arg0.bin"
iree.turbine.support.tools.iree_tool_prepare_input_args(args: Collection[Tensor], /, *, file_paths: Iterable[str | PathLike] | None = None, file_path_prefix: str | PathLike | None = None) list[str]

Write the raw contents of tensors to files without any metadata. Returns the CLI input args description.

If file_path_prefix is given, will chose a default naming for argument files. It is treated as a string prefix and not as directory. Example:

iree_tool_prepare_input_args(
    args,
    file_path_prefix="/some/path/arg",
)

returns

[
    "1x2x3xf32=@/some/path/arg0.bin",
    "4x5xi8=@/some/path/arg1.bin"
]

This results can be prefixed with --input= to arrive at the final CLI flags expected by IREE tools.

Exactly one of file_paths and file_path_prefix must be provided. Does not create parent directory(s).