elasticai.creator.ir_transforms.move_to_submodules#
Module Contents#
Classes#
Functions#
Move all occurences of pattern into sub implementations. |
API#
- class elasticai.creator.ir_transforms.move_to_submodules.PatternNode(name: str, data: dict[str, elasticai.creator.ir.base.Attribute])[source]#
Bases:
elasticai.creator.ir.Node- types: set[str]#
None
- elasticai.creator.ir_transforms.move_to_submodules.build_sequential_pattern(*pattern: tuple[str, set[str]]) elasticai.creator.ir.Implementation[elasticai.creator.ir_transforms.move_to_submodules.PatternNode, elasticai.creator.ir.Edge][source]#
- elasticai.creator.ir_transforms.move_to_submodules.move_pattern_to_subimpls(original: elasticai.creator.ir.Implementation, pattern: elasticai.creator.ir.Implementation[elasticai.creator.ir_transforms.move_to_submodules.PatternNode, elasticai.creator.ir.Edge], basename: str, replacement_data_fn: collections.abc.Callable[[elasticai.creator.ir.Implementation], dict[str, elasticai.creator.ir.Attribute]], extracted_data_fn: collections.abc.Callable[[elasticai.creator.ir.Implementation], dict[str, dict[str, elasticai.creator.ir.Attribute]]] = lambda _: ...) list[elasticai.creator.ir.Implementation][source]#
Move all occurences of pattern into sub implementations.
Each pattern match will be replaced by a single node with a name derived from the basename. For each match, we build a new implementation with the nodes and edges of the match.
- Parameters:
original – the original implementation
pattern – Each node has a set of types that will be used as match constraints. Use “any” to match any type. The special node names
"start"and"end"are considered interface nodes and will not be replaced.basename – the base name for the new nodes
replacement_data_fn – a function that takes the matched implementation and returns a dictionary of attributes for the newly created node.
extracted_data_fn – a function that takes the matched implementation and returns a dictionary of node names and their data for the extracted implementation. Use the names from the pattern to identify nodes.