Transform
A graph transform: what ModelGraph.optimize() runs. A factory in clika_runtime.graph.transforms returns one of the runtime's own (transforms.fusion_driver()), and Transform(name, fn, runs_after) or the transforms.transform decorator makes one from a Python function. Two of the runtime's own compare equal when they name the same transform; one made from a function equals itself and the copies optimize() reports only. The handle keeps fn alive as long as it, a list or a report holding it lives.
kind (property)
Which transform the handle names: TransformKind.User for one made from a function.
name (property)
The transform's name: the spelling of its factory for one of the runtime's own ('fusion_driver' for transforms.fusion_driver()), the name it was given for one made from a function.
__init__
__init____init__(self, name: str, fn: object | None, runs_after: collections.abc.Sequence[clika_runtime._core.graph.Transform] = []) -> None
init(self, name: str, fn: object | None, runs_after: collections.abc.Sequence[clika_runtime._core.graph.Transform] = []) -> None
Transform(name, fn, runs_after=()) -> Transform
A transform written in Python, which ModelGraph.optimize() runs beside the runtime's own at its place in the list, once per iteration. fn(graph) gets the ModelGraph being optimized, edits it through the graph edits and returns None; it counts as changing the graph when one of its edits did. Inside fn the graph refuses optimize(), finalize() and to(), and an edit from another thread. An exception fn raises ends the run: optimize() raises that same exception, with the graph as optimize() found it. runs_after lists the transforms, the runtime's own or other Python ones, that it must follow in any list holding both. Raises InvalidArgumentError for an empty name, the name of one of the runtime's transforms, and a runs_after entry that is another transform of the same name, and TypeError for an fn that cannot be called.