PassScopeBase¶
- class hugr.passes.scope.PassScopeBase[source]¶
Bases:
ABCAbstract superclass for concrete implementations of PassScope.
Methods
Returns whether the node may be modified by the pass.
Returns a list of nodes, in the subtree beneath root, for which the pass must preserve the observable semantics (ports, execution behaviour, linking).
Returns true if the pass should be applied recursively on the descendants of the root regions.
Return every region (every [dataflow] or [CFG] container - but excluding Module) in the Hugr to be optimized by the pass.
Returns the root of the subtree to be optimized by the pass, or none if the pass should do nothing.
- in_scope(hugr: Hugr, n: Node) InScope[source]¶
Returns whether the node may be modified by the pass.
Nodes outside the root subtree are never in scope. Nodes inside the subtree may be InScope.YES or InScope.PRESERVE_INTERFACE.
- abstractmethod preserve_interface(hugr: Hugr) Iterable[Node][source]¶
Returns a list of nodes, in the subtree beneath root, for which the pass must preserve the observable semantics (ports, execution behaviour, linking).
We include the Module in this list (if it is root) as these properties must be preserved (this rules out any other changes).
- abstractmethod recursive() bool[source]¶
Returns true if the pass should be applied recursively on the descendants of the root regions.
- regions(hugr: Hugr) Iterable[Node][source]¶
Return every region (every [dataflow] or [CFG] container - but excluding Module) in the Hugr to be optimized by the pass.
This computes all the regions to be optimized at once. In general, it is more efficient to traverse the Hugr incrementally starting from the PassScope.root instead.