Skip to main content

TracedGraph

The result of :func:trace: the recorded graph as :attr:graph, the structure of the traced inputs and outputs, and the graph's own surface (run, input_names, output_names, nodes, ...) reachable directly on this object.

run takes the flattened tensor inputs positionally (a list) or by name (a dict) and returns the graph's output list; calling the object takes the traced input structure and returns the traced output structure.

in_spec (property)​

The pytree structure of the traced (args, kwargs); None when the trace ran against a signature alone.

out_spec (property)​

The pytree structure of the traced result.

__init__​

__init__(self, graph: '_io.ModelGraph', in_spec: 'TreeSpec | None', outputs: '_Outputs') -> 'None'

Initialize self. See help(type(self)) for accurate signature.

run​

run(self, inputs: 'Sequence[Tensor] | Mapping[str, Tensor]') -> 'list[Tensor]'

run(inputs) -> list[Tensor]

Run the traced graph on flat tensor inputs and return its flat outputs: a sequence feeds the inputs in signature order, a mapping feeds them by input name. __call__ is the structured form.