ModelGraph
A runnable graph: the compiled form of an ONNX model or the recording trace() produces. run() binds inputs by position or by name and returns the outputs in output_names() order.
__init__
__init__(self, /, *args, **kwargs)
Initialize self. See help(type(self)) for accurate signature.
bench
benchbench(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape], options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport
bench(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape], options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport bench(self, shapes: collections.abc.Sequence[collections.abc.Sequence[int]], options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport bench(self, shapes: dict, options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport
Overloaded function.
bench(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape], options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport
bench(shapes, options=BenchOptions()) -> BenchReport
Time the graph on synthesized inputs of the given shapes: the shapes are validated as validate_shapes() does, one tensor per input is filled per options.fill on the benchmark device, options.warmup untimed runs precede options.iterations timed ones, and the report carries every timed run's milliseconds (each output synchronized before the clock stops), the summary statistics, the process's peak resident set and the device's memory counters. shapes is a list of InputShape, a list of dims in input_names() order, a dict of name to dims, or a dict of name to Tensor (the tensors are fed as they are). InvalidArgumentError on a shape the domains reject; the run's own error when a run fails.
bench(self, shapes: collections.abc.Sequence[collections.abc.Sequence[int]], options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport
bench(shapes, options=BenchOptions()) -> BenchReport
The positional form: one dims sequence per input_names() entry, that order.
bench(self, shapes: dict, options: clika_runtime._core.io.BenchOptions = BenchOptions(warmup=3, iterations=20, fill=FeedFill.Zeros, device=None, reuse_output_buffers=True, batch_axis=None, profile_dir=None)) -> clika_runtime._core.io.BenchReport
bench(shapes, options=BenchOptions()) -> BenchReport
The named form: a dict of input name to dims (synthesized inputs), or of input name to Tensor (the caller's tensors, fed as they are; their shapes are still validated).
constants
constantsconstants(self) -> dict
constants(self) -> dict
constants() -> dict[str, Tensor]
The bound constants (weights, baked values) by value name.
find_nodes
find_nodesfind_nodes(self, op_code: clika_runtime._core.graph.OpCode) -> list
find_nodes(self, op_code: clika_runtime._core.graph.OpCode) -> list
find_nodes(op_code) -> list[Node]
Every node running the operator, in execution order.
find_pattern
find_patternfind_pattern(self, pattern: clika_runtime._core.graph.Pattern) -> list
find_pattern(self, pattern: clika_runtime._core.graph.Pattern) -> list
find_pattern(pattern) -> list[Match]
Every occurrence of the pattern in this graph, in match order (non-overlapping: a node belongs to at most one occurrence); each Match lists the matched nodes in the pattern's add_node order, None for an absent optional node. A pattern predicate that raises ends the search and the error carries its message.
input_names
input_namesinput_names(self) -> list[str]
input_names(self) -> list[str]
input_names() -> list[str]
Runtime input names, declaration order; the order the positional run() binds.
input_shape_domain
input_shape_domaininput_shape_domain(self, name: str) -> clika_runtime._core.io.ShapeDomain
input_shape_domain(self, name: str) -> clika_runtime._core.io.ShapeDomain
input_shape_domain(name) -> ShapeDomain
The domain of the input named name; NotFoundError when no input carries it.
inputs
inputsinputs(self) -> list
inputs(self) -> list
inputs() -> list[tuple[str, DataType, tuple[int, ...]]]
Input slots as (name, dtype, dims) tuples; a dynamic dim reads as -1.
is_finalized
is_finalizedis_finalized(self) -> bool
is_finalized(self) -> bool
is_finalized() -> bool
True once the operators' weights are packed for serving (the default after compile() and trace()).
kv_cache_info
kv_cache_infokv_cache_info(self) -> list[clika_runtime._core.io.KVCacheLayerInfo]
kv_cache_info(self) -> list[clika_runtime._core.io.KVCacheLayerInfo]
kv_cache_info() -> list[KVCacheLayerInfo]
The attention layers' KV-cache wiring (past inputs, present outputs, heads, mask family), one entry per layer; empty for a graph without attention.
node
nodenode(self, name: str) -> object
node(self, name: str) -> object
node(name) -> Node
The node named name; KeyError when absent.
nodes
nodesnodes(self) -> list
nodes(self) -> list
nodes() -> list[Node]
Every node in execution order (graph inputs first, then the operators). Compile with optimize=False, or trace with run_transforms=False and bake=False, to read the graph as the model states it.
output_names
output_namesoutput_names(self) -> list[str]
output_names(self) -> list[str]
output_names() -> list[str]
Output names, declaration order; the order run() returns.
outputs
outputsoutputs(self) -> list
outputs(self) -> list
outputs() -> list[tuple[str, DataType, tuple[int, ...]]]
Output slots as (name, dtype, dims) tuples.
run
runrun(self, inputs: collections.abc.Sequence[clika_runtime._core.Tensor]) -> list[clika_runtime._core.Tensor]
run(self, inputs: collections.abc.Sequence[clika_runtime._core.Tensor]) -> list[clika_runtime._core.Tensor] run(self, inputs: dict) -> list[clika_runtime._core.Tensor]
Overloaded function.
run(self, inputs: collections.abc.Sequence[clika_runtime._core.Tensor]) -> list[clika_runtime._core.Tensor]
run(inputs) -> list[Tensor]
Run with positional inputs (input_names() order); returns the outputs in output_names() order.
run(self, inputs: dict) -> list[clika_runtime._core.Tensor]
run(inputs) -> list[Tensor]
Run with named inputs (dict[str, Tensor], strict); returns the outputs in output_names() order.
shape_domains
shape_domainsshape_domains(self) -> list[clika_runtime._core.io.ShapeDomain]
shape_domains(self) -> list[clika_runtime._core.io.ShapeDomain]
shape_domains() -> list[ShapeDomain]
The shapes each input admits, input_names() order: a fixed dimension is Fixed, a dynamic one compiled with a shape spec is Range, any other dynamic one is Free.
validate_shapes
validate_shapesvalidate_shapes(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape]) -> None
validate_shapes(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape]) -> None validate_shapes(self, shapes: collections.abc.Sequence[collections.abc.Sequence[int]]) -> None validate_shapes(self, shapes: dict) -> None
Overloaded function.
validate_shapes(self, shapes: collections.abc.Sequence[clika_runtime._core.io.InputShape]) -> None
validate_shapes(shapes) -> None
Check shapes against the domains: every input present once, every name an input, every rank the input's, every extent admitted. shapes is a list of InputShape, a list of dims in input_names() order, or a dict of name to dims. InvalidArgumentError names the input and the dimension that failed.
validate_shapes(self, shapes: collections.abc.Sequence[collections.abc.Sequence[int]]) -> None
validate_shapes(shapes) -> None
The positional form: one dims sequence per input_names() entry, that order.
validate_shapes(self, shapes: dict) -> None
validate_shapes(shapes) -> None
The named form: a dict of input name to dims.
visualize
visualizevisualize(self, path: str) -> None
visualize(self, path: str) -> None
visualize(path) -> None
Write a rendering of the graph's nodes and edges to path (the file suffix picks the format).