aitune.torch.artifact
Translate Torch graph metadata into deployment-neutral artifact records.
Module Contents
Functions
Data
API
Return the single directly representable logical batch axis, if known.
Capture one recorded Torch call as portable deployment input values.
A recorded sample follows the module’s Python call signature, while an exported
executable can expose a different input order or different names. This function
uses GraphSpec locators to read the original tensors, reorders them to match
the executable, and stores their shape and flattened values in TensorSample
records. The result contains no Torch objects, so it can be kept in a deployment
artifact and later converted to input formats such as Perf Analyzer JSON.
By default, the result uses the input order and original tensor names stored in
GraphSpec. A backend whose executable selects or reorders named inputs can
provide recorded_names. Positional formats such as PT2 instead provide
metadata_indices and use artifact_names for their final public names.
The two explicit selection methods are mutually exclusive.
Parameters:
GraphSpec — Recorded graph metadata containing tensor names and locators.
Sample — Original module call represented as (args, kwargs).
Recorded graph input names in executable order.
Graph input positions in executable order.
Final executable names for the selected inputs. Recorded names are used when this is omitted.
Returns: tuple[ TensorSample , ...]
Portable input samples in executable order.
Raises:
ValueError: If selection is ambiguous, an input cannot be found, names and selected inputs have different lengths, or a selected value is not a tensor.
Create ordered bounded tensor specs from a recorded Torch graph.
Backends whose executable retains exporter names select tensors with
recorded_names. Backends with a positional ABI can instead select metadata by
index and provide their finalized artifact_names. Selection methods are
mutually exclusive so an adapter cannot accidentally combine two orderings.