dace.transformation.interstate package¶
Submodules¶
dace.transformation.interstate.fpga_transform_sdfg module¶
Contains inter-state transformations of an SDFG to run on an FPGA.
-
class
dace.transformation.interstate.fpga_transform_sdfg.
FPGATransformSDFG
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Implements the FPGATransformSDFG transformation, which takes an entire SDFG and transforms it into an FPGA-capable 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
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
¶ If True, transient arrays that are fully internal are pulled out so that they can be allocated on the host.
-
properties
()¶
-
static
dace.transformation.interstate.fpga_transform_state module¶
Contains inter-state transformations of an SDFG to run on an FPGA.
-
class
dace.transformation.interstate.fpga_transform_state.
FPGATransformState
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Implements the FPGATransformState transformation.
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
¶ 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
PatternTransformation
to 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.fpga_transform_state.
fpga_update
(sdfg, state, depth)¶
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:
dace.transformation.transformation.MultiStateTransformation
Implements the GPUTransformSDFG transformation.
Transforms a whole SDFG to run on the GPU: Steps of the full GPU transform
- 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: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
.
-
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:
dace.transformation.transformation.PatternTransformation
Detects a for-loop construct from an SDFG.
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFGState object if this transformation is
single-state, or SDFG object otherwise.Parameters: - expr_index – The list index from PatternTransformation.expressions that was matched.
- sdfg – If graph is an SDFGState, its parent SDFG. Otherwise should be equal to graph.
- permissive – Whether transformation should run in permissive mode.
Returns: True if the transformation can be applied.
-
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
PatternTransformation
to 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
-
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
PatternTransformation
to 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_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
PatternTransformation
to 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.loop_detection.
find_for_loop
(sdfg: dace.sdfg.sdfg.SDFG, guard: dace.sdfg.state.SDFGState, entry: dace.sdfg.state.SDFGState, itervar: Optional[str] = None) → Optional[Tuple[AnyStr, Tuple[Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], Union[sympy.core.basic.Basic, dace.symbolic.SymExpr]], Tuple[List[dace.sdfg.state.SDFGState], dace.sdfg.state.SDFGState]]]¶ Finds loop range from state machine. :param guard: State from which the outgoing edges detect whether to exit
the loop or not.Parameters: entry – First state in the loop “body”. Returns: - (iteration variable, (start, end, stride),
- (start_states[], last_loop_state)), or None if proper
for-loop was not detected.
end
is inclusive.
dace.transformation.interstate.loop_to_map module¶
Loop to map transformation
-
class
dace.transformation.interstate.loop_to_map.
LoopToMap
(*args, **kwargs)¶ Bases:
dace.transformation.interstate.loop_detection.DetectLoop
,dace.transformation.transformation.MultiStateTransformation
Convert 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
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.state.SDFGState, expr_index: int, sdfg: dace.sdfg.sdfg.SDFG, permissive: bool = False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
itervar
¶ The name of the iteration variable (optional).
-
properties
()¶
-
test_read_memlet
(sdfg: dace.sdfg.sdfg.SDFG, itersym: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], itervar: str, start: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], end: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], step: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], write_memlets: Dict[str, List[dace.memlet.Memlet]], mmlt: dace.memlet.Memlet, src_subset: dace.subsets.Range)¶
-
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:
dace.transformation.interstate.loop_detection.DetectLoop
,dace.transformation.transformation.MultiStateTransformation
Moves a loop around a map into the map
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
-
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 unroll transformation
-
class
dace.transformation.interstate.loop_peeling.
LoopPeeling
(*args, **kwargs)¶ Bases:
dace.transformation.interstate.loop_unroll.LoopUnroll
Splits the first count iterations of a state machine for-loop into multiple, separate states.
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
properties
()¶
-
dace.transformation.interstate.loop_unroll module¶
Loop unroll transformation
-
class
dace.transformation.interstate.loop_unroll.
LoopUnroll
(*args, **kwargs)¶ Bases:
dace.transformation.interstate.loop_detection.DetectLoop
,dace.transformation.transformation.MultiStateTransformation
Unrolls a state machine for-loop into multiple states
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
count
¶ Number of iterations to unroll, or zero for all iterations (loop must be constant-sized for 0)
-
instantiate_loop
(sdfg: dace.sdfg.sdfg.SDFG, loop_states: List[dace.sdfg.state.SDFGState], loop_subgraph: dace.sdfg.graph.SubgraphView, itervar: str, value: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr], state_suffix=None)¶
-
properties
()¶
-
dace.transformation.interstate.sdfg_nesting module¶
SDFG nesting transformation.
-
class
dace.transformation.interstate.sdfg_nesting.
ASTRefiner
(to_refine: str, refine_subset: dace.subsets.Subset, sdfg: dace.sdfg.sdfg.SDFG, indices: Set[int] = None)¶ Bases:
ast.NodeTransformer
Python AST transformer used in
RefineNestedAccess
to reduce (refine) the subscript ranges based on the specification given in the transformation.-
visit_Subscript
(node: _ast.Subscript) → _ast.Subscript¶
-
-
class
dace.transformation.interstate.sdfg_nesting.
InlineSDFG
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.SingleStateTransformation
Inlines 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: dace.sdfg.state.SDFGState, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.state.SDFGState, expr_index, sdfg, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFGState object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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:
dace.transformation.transformation.SingleStateTransformation
Inlines 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: dace.sdfg.state.SDFGState, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.state.SDFGState, expr_index: int, sdfg: dace.sdfg.sdfg.SDFG, permissive: bool = False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFGState object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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
()¶
-
static
-
class
dace.transformation.interstate.sdfg_nesting.
NestSDFG
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Implements 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: dace.sdfg.sdfg.SDFG) → dace.sdfg.nodes.NestedSDFG¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
()¶
-
static
-
class
dace.transformation.interstate.sdfg_nesting.
RefineNestedAccess
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.SingleStateTransformation
Reduces 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_a
will 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_a
would containx[1:5]
directly and the internaly
array 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: dace.sdfg.state.SDFGState, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.state.SDFGState, expr_index: int, sdfg: dace.sdfg.sdfg.SDFG, permissive: bool = False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFGState object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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
()¶
-
static
dace.transformation.interstate.state_elimination module¶
State elimination transformations
-
class
dace.transformation.interstate.state_elimination.
ConstantPropagation
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Removes constant assignments in interstate edges and replaces them in successor states.
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph, expr_index, sdfg: dace.sdfg.sdfg.SDFG, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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.
DeadStateElimination
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Dead state elimination removes an unreachable state and all of its dominated states.
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.sdfg.SDFG, expr_index, sdfg: dace.sdfg.sdfg.SDFG, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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.
EndStateElimination
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
End-state elimination removes a redundant state that has one incoming edge and no contents.
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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:
dace.transformation.transformation.MultiStateTransformation
If a state transition condition is always false, removes edge.
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.sdfg.SDFG, expr_index, sdfg: dace.sdfg.sdfg.SDFG, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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
PatternTransformation
to 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:
dace.transformation.transformation.SingleStateTransformation
Move a state out of a nested SDFG
-
apply
(state: dace.sdfg.state.SDFGState, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.state.SDFGState, expr_index, sdfg, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFGState object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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:
dace.transformation.transformation.MultiStateTransformation
Start-state elimination removes a redundant state that has one outgoing edge and no contents. This transformation applies only to nested SDFGs.
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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:
dace.transformation.transformation.MultiStateTransformation
State assign elimination removes all assignments into the final state and subsumes the assigned value into its contents.
-
apply
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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:
dace.transformation.transformation.MultiStateTransformation
SymbolAliasPromotion 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
(_, sdfg)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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
PatternTransformation
to 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:
dace.transformation.transformation.MultiStateTransformation
If a state transition condition is always true, removes condition from edge.
-
apply
(_, sdfg: dace.sdfg.sdfg.SDFG)¶ Applies this transformation instance on the matched pattern graph. :param sdfg: The SDFG to apply the transformation to. :return: A transformation-defined return value, which could be used
to pass analysis data out, or nothing.
-
can_be_applied
(graph: dace.sdfg.sdfg.SDFG, expr_index, sdfg: dace.sdfg.sdfg.SDFG, permissive=False)¶ Returns True if this transformation can be applied on the candidate matched subgraph. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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
PatternTransformation
to 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
PatternTransformation
to 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: Set[dace.sdfg.nodes.AccessNode], first_output_nodes: Set[dace.sdfg.nodes.AccessNode], second_input_nodes: Set[dace.sdfg.nodes.AccessNode], second_output_nodes: Set[dace.sdfg.nodes.AccessNode])¶ Bases:
object
-
class
dace.transformation.interstate.state_fusion.
StateFusion
(*args, **kwargs)¶ Bases:
dace.transformation.transformation.MultiStateTransformation
Implements 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. :param sdfg: The SDFG to apply the transformation to. :return: 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. :param graph: SDFG object in which the match was found. :param candidate: A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.Parameters: - expr_index – The list index from
PatternTransformation.expressions
that 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.
- expr_index – The list index from
-
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) → List[dace.transformation.interstate.state_fusion.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
PatternTransformation
to 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: dace.sdfg.state.SDFGState, second_state: dace.sdfg.state.SDFGState, match_nodes: Dict[dace.sdfg.nodes.AccessNode, dace.sdfg.nodes.AccessNode], node_a: dace.sdfg.nodes.Node, node_b: dace.sdfg.nodes.Node) → bool¶ Check for paths between the two states if they are fused.
-
static
memlets_intersect
(graph_a: dace.sdfg.state.SDFGState, group_a: List[dace.sdfg.nodes.AccessNode], inputs_a: bool, graph_b: dace.sdfg.state.SDFGState, group_b: List[dace.sdfg.nodes.AccessNode], inputs_b: bool) → bool¶ 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. :param graph_a: The graph in which the first set of nodes reside. :param group_a: The first set of nodes to check. :param inputs_a: If True, checks inputs of the first group. :param graph_b: The graph in which the second set of nodes reside. :param group_b: The second set of nodes to check. :param inputs_b: If True, checks inputs of the second group. :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
PatternTransformation
to 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.
-
static
-
dace.transformation.interstate.state_fusion.
top_level_nodes
(state: dace.sdfg.state.SDFGState)¶
dace.transformation.interstate.transient_reuse module¶
Module contents¶
This module initializes the inter-state transformations package.