dace.transformation.interstate package
Submodules
dace.transformation.interstate.gpu_transform_sdfg module
Contains inter-state transformations of an SDFG to run on the GPU.
- class dace.transformation.interstate.gpu_transform_sdfg.GPUTransformSDFG(*args, **kwargs)
Bases:
MultiStateTransformationImplements the GPUTransformSDFG transformation.
Transforms a whole SDFG to run on the GPU:
Acquire metadata about SDFG and arrays
Replace all non-transients with their GPU counterparts
Copy-in state from host to GPU
Copy-out state from GPU to host
Re-store Default-top/CPU_Heap transients as GPU_Global
Global tasklets are wrapped with a map of size 1
Global Maps are re-scheduled to use the GPU
Make data ready for interstate edges that use them
Re-apply simplification to get rid of extra states and transients
- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(_, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- exclude_copyin
Exclude these arrays from being copied into the device (comma-separated)
- exclude_copyout
Exclude these arrays from being copied out of the device (comma-separated)
- exclude_tasklets
Exclude these tasklets from being processed as CPU tasklets (comma-separated)
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- host_data
List of data names, the passed data are not offloaded to the GPU
- host_maps
List of map GUIDs, the passed maps are not offloaded to the GPU
- properties()
- register_trans
Make all transients inside GPU maps registers
- sequential_innermaps
Make all internal maps Sequential
- simplify
Reapply simplification after modifying graph
- skip_scalar_tasklets
If True, does not transform tasklets that manipulate (Default-stored) scalars
- toplevel_trans
Make all GPU transients top-level
dace.transformation.interstate.loop_detection module
Loop detection transformation
- class dace.transformation.interstate.loop_detection.DetectLoop(*args, **kwargs)
Bases:
PatternTransformationDetects a for-loop construct from an SDFG.
- apply(_, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- break_edges: Set[Edge[InterstateEdge]] = {}
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
ControlFlowRegion) – SDFGState object if this transformation is single-state, or ControlFlowRegion object otherwise.expr_index (
int) – The list index from PatternTransformation.expressions that was matched.sdfg (
SDFG) – If graph is an SDFGState, its parent SDFG. Otherwise should be equal to graph.permissive (
bool) – Whether transformation should run in permissive mode.
- Return type:
bool- Returns:
True if the transformation can be applied.
- continue_edges: Set[Edge[InterstateEdge]] = {}
- detect_loop(graph, multistate_loop, accept_missing_itvar=False)
Detects a loop of the form:
---------------- | v entry -> guard -> body exit ^ | ----------- Parameters:
graph (
ControlFlowRegion) – The graph to look for the loop.multistate_loop (
bool) – Whether the loop contains multiple states.
- Return type:
str|None- Returns:
The loop variable or
Noneif not detected.
- detect_rotated_loop(graph, multistate_loop, accept_missing_itvar=False, separate_latch=False)
Detects a loop of the form:
entry -> body -> latch -> exit ^ | ----------- Parameters:
graph (
ControlFlowRegion) – The graph to look for the loop.multistate_loop (
bool) – Whether the loop contains multiple states.
- Return type:
str|None- Returns:
The loop variable or
Noneif not detected.
- detect_self_loop(graph, accept_missing_itvar=False)
Detects a loop of the form:
entry -> body state -> exit ^ | ------- Parameters:
graph (
ControlFlowRegion) – The graph to look for the loop.- Return type:
str|None- Returns:
The loop variable or
Noneif not detected.
- entry_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- exit_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- classmethod expressions()
Returns a list of Graph objects that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling can_be_applied.
- See:
PatternTransformation.can_be_applied
- property first_loop_block: ControlFlowBlock
The first control flow block executed in each loop iteration.
- property inverted: bool
Whether the loop matched a pattern of an inverted (do-while style) loop.
- loop_begin
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- loop_body()
Returns a list of all control flow blocks (or states) contained in the loop.
- Return type:
List[ControlFlowBlock]
- loop_break
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- loop_condition_edge()
Returns the positive condition edge that (re-)enters the loop after the bound check.
- Return type:
- loop_exit_edge()
Returns the negative condition edge that exits the loop.
- Return type:
- loop_guard
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- loop_increment_edge()
Returns the back-edge that increments the loop induction variable.
- Return type:
- loop_information(itervar=None)
- loop_init_edge()
Returns the initialization edge of the loop (assignment to the beginning of the loop range).
- Return type:
- loop_latch
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- loop_meta_states()
Returns the non-body control-flow blocks of this loop (e.g., guard, latch).
- Return type:
List[ControlFlowBlock]
- dace.transformation.interstate.loop_detection.find_for_loop(graph, guard, entry, itervar=None)
Finds loop range from state machine.
- dace.transformation.interstate.loop_detection.find_rotated_for_loop(graph, latch, entry, itervar=None, separate_latch=False)
Finds rotated loop range from state machine.
- dace.transformation.interstate.loop_detection.rotated_loop_find_itvar(begin_inedges, latch_inedges, backedge, latch, accept_missing_itvar=False)
- Return type:
Tuple[str|None,Edge[InterstateEdge] |None]
dace.transformation.interstate.loop_to_map module
Loop to map transformation
- class dace.transformation.interstate.loop_to_map.LoopToMap(*args, **kwargs)
Bases:
MultiStateTransformationConvert a control flow loop into a dataflow map. Currently only supports the simple case where there is no overlap between inputs and outputs in the body of the loop, and where the loop body only consists of a single state.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- loop
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- properties()
- test_read_memlet(sdfg, state, edge, itersym, itervar, start, end, step, write_memlets, mmlt, src_subset)
dace.transformation.interstate.move_loop_into_map module
Moves a loop around a map into the map
- class dace.transformation.interstate.move_loop_into_map.MoveLoopIntoMap(*args, **kwargs)
Bases:
MultiStateTransformationMoves a loop around a map into the map
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- loop
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- dace.transformation.interstate.move_loop_into_map.fold(memlet_subset_ranges, itervar, lower, upper)
- dace.transformation.interstate.move_loop_into_map.offset(memlet_subset_ranges, value)
dace.transformation.interstate.loop_peeling module
Loop peeling transformation
- class dace.transformation.interstate.loop_peeling.LoopPeeling(*args, **kwargs)
Bases:
LoopUnrollSplits the first count iterations of loop into multiple, separate control flow regions (one per iteration).
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- begin
If True, peels loop from beginning (first count iterations), otherwise peels last count iterations.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- properties()
dace.transformation.interstate.loop_unroll module
Loop unroll transformation
- class dace.transformation.interstate.loop_unroll.LoopUnroll(*args, **kwargs)
Bases:
MultiStateTransformationUnrolls a for-loop into multiple individual control flow regions
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- count
Number of iterations to unroll, or zero for all iterations (loop must be constant-sized for 0)
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- inline_iterations
Whether or not to inline individual iterations’ CFGs after unrolling
- instantiate_loop_iteration(graph, loop, value, label_suffix=None)
- Return type:
- loop
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- properties()
dace.transformation.interstate.sdfg_nesting module
SDFG nesting transformation.
- class dace.transformation.interstate.sdfg_nesting.ASTRefiner(to_refine, refine_subset, sdfg, indices=None)
Bases:
NodeTransformerPython AST transformer used in
RefineNestedAccessto reduce (refine) the subscript ranges based on the specification given in the transformation.- visit_Subscript(node)
- Return type:
Subscript
- class dace.transformation.interstate.sdfg_nesting.InlineSDFG(*args, **kwargs)
Bases:
SingleStateTransformationInlines a single-state nested SDFG into a top-level SDFG.
In particular, the steps taken are:
All transient arrays become transients of the parent
If a source/sink node is one of the inputs/outputs:
Remove it
Reconnect through external edges (map/accessnode)
Replace and reoffset memlets with external data descriptor
If other nodes carry the names of inputs/outputs:
Replace data with external data descriptor
Replace and reoffset memlets with external data descriptor
If source/sink node is not connected to a source/destination, and the nested SDFG is in a scope, connect to scope with empty memlets
Remove all unused external inputs/output memlet paths
Remove isolated nodes resulting from previous step
- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(state, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFGState) – SDFGState object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The parent SDFG of the matched state.
permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- nested_sdfg
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- properties()
- class dace.transformation.interstate.sdfg_nesting.InlineTransients(*args, **kwargs)
Bases:
SingleStateTransformationInlines all transient arrays that are not used anywhere else into a nested SDFG.
- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(state, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFGState) – SDFGState object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index (
int) – The list index fromPatternTransformation.expressionsthat was matched.sdfg (
SDFG) – The parent SDFG of the matched state.permissive (
bool) – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- nsdfg
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- properties()
- class dace.transformation.interstate.sdfg_nesting.NestSDFG(*args, **kwargs)
Bases:
MultiStateTransformationImplements SDFG Nesting, taking an SDFG as an input and creating a nested SDFG node from it.
- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(_, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Return type:
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- promote_global_trans
Promotes transients to be allocated once
- properties()
- class dace.transformation.interstate.sdfg_nesting.RefineNestedAccess(*args, **kwargs)
Bases:
SingleStateTransformationReduces memlet shape when a memlet is connected to a nested SDFG, but not using all of the contents. Makes the outer memlet smaller in shape and ensures that the offsets in the nested SDFG start with zero. This helps with subsequent transformations on the outer SDFGs.
For example, in the following program:
@dace.program def func_a(y): return y[1:5] + 1 @dace.program def main(x: dace.float32[N]): return func_a(x)
The memlet pointing to
func_awill contain all ofx(x[0:N]), and it is offset toy[1:5]in the function, withy’s size beingN. After the transformation, the memlet connected to the nested SDFG offunc_awould containx[1:5]directly and the internalyarray would have a size of 4, accessed asy[0:4].- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(state, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFGState) – SDFGState object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index (
int) – The list index fromPatternTransformation.expressionsthat was matched.sdfg (
SDFG) – The parent SDFG of the matched state.permissive (
bool) – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- nsdfg
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- properties()
dace.transformation.interstate.state_elimination module
State elimination transformations
- class dace.transformation.interstate.state_elimination.EndStateElimination(*args, **kwargs)
Bases:
MultiStateTransformationEnd-state elimination removes a redundant state that has one incoming edge and no contents.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- end_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- class dace.transformation.interstate.state_elimination.FalseConditionElimination(*args, **kwargs)
Bases:
MultiStateTransformationIf a state transition condition is always false, removes edge.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFG) – SDFG object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg (
SDFG) – The SDFG in which the match was found (equal tograph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- state_a
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- state_b
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- class dace.transformation.interstate.state_elimination.HoistState(*args, **kwargs)
Bases:
SingleStateTransformationMove a state out of a nested SDFG
- apply(state, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFGState) – SDFGState object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The parent SDFG of the matched state.
permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- nsdfg
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- class dace.transformation.interstate.state_elimination.StartStateElimination(*args, **kwargs)
Bases:
MultiStateTransformationStart-state elimination removes a redundant state that has one outgoing edge and no contents. This transformation applies only to nested SDFGs.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- start_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- class dace.transformation.interstate.state_elimination.StateAssignElimination(*args, **kwargs)
Bases:
MultiStateTransformationState assign elimination removes all assignments into the final state and subsumes the assigned value into its contents.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- end_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- class dace.transformation.interstate.state_elimination.SymbolAliasPromotion(*args, **kwargs)
Bases:
MultiStateTransformationSymbolAliasPromotion moves inter-state assignments that create symbolic aliases to the previous inter-state edge according to the topological order. The purpose of this transformation is to iteratively move symbolic aliases together, so that true duplicates can be easily removed.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- first_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- second_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- class dace.transformation.interstate.state_elimination.TrueConditionElimination(*args, **kwargs)
Bases:
MultiStateTransformationIf a state transition condition is always true, removes condition from edge.
- apply(graph, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg (
SDFG) – The SDFG to apply the transformation to.- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph (
SDFG) – SDFG object in which the match was found.candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg (
SDFG) – The SDFG in which the match was found (equal tograph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- state_a
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- state_b
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
dace.transformation.interstate.state_fusion module
State fusion transformation
- class dace.transformation.interstate.state_fusion.CCDesc(first_input_nodes, first_output_nodes, second_input_nodes, second_output_nodes)
Bases:
object
- class dace.transformation.interstate.state_fusion.StateFusion(*args, **kwargs)
Bases:
MultiStateTransformationImplements the state-fusion transformation.
State-fusion takes two states that are connected through a single edge, and fuses them into one state. If permissive, also applies if potential memory access hazards are created.
- static annotates_memlets()
Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.
- apply(_, sdfg)
Applies this transformation instance on the matched pattern graph.
- Parameters:
sdfg – The SDFG to apply the transformation to.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- can_be_applied(graph, expr_index, sdfg, permissive=False)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFG object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressionsand the nodes ingraph.expr_index – The list index from
PatternTransformation.expressionsthat was matched.sdfg – The SDFG in which the match was found (equal to
graph).permissive – Whether transformation should run in permissive mode.
- Returns:
True if the transformation can be applied.
- classmethod expressions()
Returns a list of SDFG subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling
can_be_applied.
- static find_fused_components(first_cc_input, first_cc_output, second_cc_input, second_cc_output)
- Return type:
List[CCDesc]
- first_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- has_path(first_state, second_state, match_nodes, node_a, node_b)
Check for paths between the two states if they are fused.
- Return type:
bool
- static memlets_intersect(graph_a, group_a, inputs_a, graph_b, group_b, inputs_b)
Performs an all-pairs check for subset intersection on two groups of nodes. If group intersects or result is indeterminate, returns True as a precaution.
- Parameters:
graph_a (
SDFGState) – The graph in which the first set of nodes reside.group_a (
List[AccessNode]) – The first set of nodes to check.inputs_a (
bool) – If True, checks inputs of the first group.graph_b (
SDFGState) – The graph in which the second set of nodes reside.group_b (
List[AccessNode]) – The second set of nodes to check.inputs_b (
bool) – If True, checks inputs of the second group.
- Return type:
bool- Returns:
True if subsets intersect or result is indeterminate.
- second_state
Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of
PatternTransformationto represent the subgraph patterns.Example use:
class MyTransformation(SingleStateTransformation): some_map_node = PatternNode(nodes.MapEntry) array = PatternNode(nodes.AccessNode)
The two nodes can then be used in the transformation static methods (e.g.,
expressions,can_be_applied) to represent the nodes, and in the instance methods to point to the nodes in the parent SDFG.
- dace.transformation.interstate.state_fusion.top_level_nodes(state)
Module contents
This module initializes the inter-state transformations package.