elasticai.creator.ir.datagraph_rewriting#
Module Contents#
Classes#
Use a simple constraint over |
|
Specifies how |
|
API#
- class elasticai.creator.ir.datagraph_rewriting.Pattern[source]#
Bases:
typing.Protocol- abstract property graph: elasticai.creator.ir.datagraph_rewriting.DataGraph#
- property interface: collections.abc.Collection[str]#
- class elasticai.creator.ir.datagraph_rewriting.StdPattern(graph: elasticai.creator.ir.datagraph_rewriting.DataGraph, node_constraint: collections.abc.Callable[[elasticai.creator.ir.datagraph.Node, elasticai.creator.ir.datagraph.Node], bool], interface: collections.abc.Collection[str])[source]#
Bases:
elasticai.creator.ir.datagraph_rewriting.PatternUse a simple constraint over
Nodes to find all matching subgraphs.This pattern ignores the registry, so you cannot analyse attributes of other graphs that nodes might refer to. Thus, all information your pattern matching needs, needs to be present in the graph under match already. As this is often the case, the pattern is provided as
StdPattern.If you need more control, implement your own pattern.
Initialization
- property graph: elasticai.creator.ir.datagraph_rewriting.DataGraph#
- property interface: collections.abc.Collection[str]#
- class elasticai.creator.ir.datagraph_rewriting.PatternRuleSpec(pattern: elasticai.creator.ir.datagraph_rewriting.Pattern, replacement_fn: elasticai.creator.ir.datagraph_rewriting.Rule)[source]#
Specifies how
PatternRuleshould create a newDataGraphfrom an existing one.It consists of
a pattern to match in the original DataGraph.
a replacement to apply when the pattern is matched. The
PatternRulewill use thereplacement_fnfunction to create a newDataGraph. The function receives the matched part of the DataGraph as an argument, so you can build the replacement based on the parameters found in your matched pattern. The node names in this matched subimplementation are remapped from the original graph to the pattern graph, so you can access the data dictionary using the names from the pattern graph. E.g., if the pattern specifies a node'conv'you can acces the data of the original DataGraph that this node corresponds to usingmatched.nodes['conv'].data.an interface that specifies which nodes are part of the pattern and of the replacement, nodes that are part of the interface are neither replaced nor initialized. Instead they are used to connect the pattern and the replacement.
Initialization
- property interface: collections.abc.Collection[str]#
- class elasticai.creator.ir.datagraph_rewriting.PatternRule(spec: elasticai.creator.ir.datagraph_rewriting.PatternRuleSpec)[source]#
Initialization