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:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- 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()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
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:
MultiStateTransformation
Implements the FPGATransformState transformation.
- apply(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- 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
.
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- 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:
MultiStateTransformation
Implements 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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- 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
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- 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:
PatternTransformation
Detects 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.
- 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.
- 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:
Optional
[str
]- Returns:
The loop variable or
None
if 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:
Optional
[str
]- Returns:
The loop variable or
None
if 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:
Optional
[str
]- Returns:
The loop variable or
None
if 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
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.
- 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
- 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
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_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
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_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
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_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
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_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.
- Parameters:
- Return type:
Optional
[Tuple
[AnyStr
,Tuple
[Union
[Basic
,SymExpr
],Union
[Basic
,SymExpr
],Union
[Basic
,SymExpr
]],Tuple
[List
[SDFGState
],SDFGState
]]]- 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_detection.find_rotated_for_loop(graph, latch, entry, itervar=None, separate_latch=False)
Finds rotated loop range from state machine.
- Parameters:
- Return type:
Optional
[Tuple
[AnyStr
,Tuple
[Union
[Basic
,SymExpr
],Union
[Basic
,SymExpr
],Union
[Basic
,SymExpr
]],Tuple
[List
[SDFGState
],SDFGState
]]]- 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_detection.rotated_loop_find_itvar(begin_inedges, latch_inedges, backedge, latch, accept_missing_itvar=False)
- Return type:
Tuple
[Optional
[str
],Optional
[Edge
[InterstateEdge
]]]
dace.transformation.interstate.loop_to_map module
Loop to map transformation
- class dace.transformation.interstate.loop_to_map.LoopToMap(*args, **kwargs)
Bases:
DetectLoop
,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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- itervar
The name of the iteration variable (optional).
- properties()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- 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:
DetectLoop
,MultiStateTransformation
Moves a loop around a map into the map
- apply(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- 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:
LoopUnroll
Splits the first count iterations of a state machine for-loop into multiple, separate states.
- 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.expressions
and the nodes ingraph
.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.
- properties()
dace.transformation.interstate.loop_unroll module
Loop unroll transformation
- class dace.transformation.interstate.loop_unroll.LoopUnroll(*args, **kwargs)
Bases:
DetectLoop
,MultiStateTransformation
Unrolls a state machine for-loop into multiple states
- 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.expressions
and the nodes ingraph
.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.
- count
Number of iterations to unroll, or zero for all iterations (loop must be constant-sized for 0)
- instantiate_loop(sdfg, loop_states, loop_subgraph, itervar, value, state_suffix=None)
- 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:
NodeTransformer
Python AST transformer used in
RefineNestedAccess
to 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:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFGState object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.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.
- 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()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- class dace.transformation.interstate.sdfg_nesting.InlineTransients(*args, **kwargs)
Bases:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFGState object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.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.
- 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()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- class dace.transformation.interstate.sdfg_nesting.NestSDFG(*args, **kwargs)
Bases:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- 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()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- class dace.transformation.interstate.sdfg_nesting.RefineNestedAccess(*args, **kwargs)
Bases:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFGState object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.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.
- 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()
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
dace.transformation.interstate.state_elimination module
State elimination transformations
- class dace.transformation.interstate.state_elimination.EndStateElimination(*args, **kwargs)
Bases:
MultiStateTransformation
End-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.expressions
and the nodes ingraph
.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.
- 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:
MultiStateTransformation
If 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.expressions
and the nodes ingraph
.expr_index – The list index from
PatternTransformation.expressions
that 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
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:
SingleStateTransformation
Move a state out of a nested SDFG
- apply(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
Returns True if this transformation can be applied on the candidate matched subgraph.
- Parameters:
graph – SDFGState object in which the match was found.
candidate – A mapping between node IDs returned from
PatternTransformation.expressions
and the nodes ingraph
.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.
- 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.
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- class dace.transformation.interstate.state_elimination.StartStateElimination(*args, **kwargs)
Bases:
MultiStateTransformation
Start-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.expressions
and the nodes ingraph
.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.
- 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:
MultiStateTransformation
State 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.expressions
and the nodes ingraph
.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.
- 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:
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(*args, **kwargs)
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.
- apply_pass(*args, **kwargs)
Applies the pass to the given SDFG.
- Parameters:
sdfg – The SDFG to apply the pass to.
pipeline_results – If in the context of a
Pipeline
, a dictionary that is populated with prior Pass results as{Pass subclass name: returned object from pass}
. If not run in a pipeline, an empty dictionary is expected.
- Returns:
Some object if pass was applied, or None if nothing changed.
- apply_pattern(*args, **kwargs)
Applies this transformation on the given SDFG, using the transformation instance to find the right control flow graph object (based on control flow graph ID), and applying memlet propagation as necessary.
- Parameters:
append – If True, appends the transformation to the SDFG transformation history.
annotate – If True, applies memlet propagation as necessary.
- Returns:
A transformation-defined return value, which could be used to pass analysis data out, or nothing.
- apply_to(*args, **kwargs)
Applies this transformation to a given subgraph, defined by a set of nodes. Raises an error if arguments are invalid or transformation is not applicable.
The subgraph is defined by the where dictionary, where each key is taken from the PatternNode fields of the transformation. For example, applying MapCollapse on two maps can pe performed as follows:
` MapCollapse.apply_to(sdfg, outer_map_entry=map_a, inner_map_entry=map_b) `
- Parameters:
sdfg – The SDFG to apply the transformation to.
options – A set of parameters to use for applying the transformation.
expr_index – The pattern expression index to try to match with.
verify – Check that can_be_applied returns True before applying.
annotate – Run memlet propagation after application if necessary.
permissive – Apply transformation in permissive mode.
save – Save transformation as part of the SDFG file. Set to False if composing transformations.
where – A dictionary of node names (from the transformation) to nodes in the SDFG or a single state.
- can_be_applied(*args, **kwargs)
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.expressions
and the nodes ingraph
.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.
- 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.
- setup_match(*args, **kwargs)
Sets the transformation to a given subgraph pattern.
- Parameters:
cfg_id – A unique ID of the SDFG.
state_id – The node ID of the SDFG state, if applicable. If transformation does not operate on a single state, the value should be -1.
subgraph – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.
expr_index – The list index from PatternTransformation.expressions that was matched.
override – If True, accepts the subgraph dictionary as-is (mostly for internal use).
options – An optional dictionary of transformation properties
- Raises:
TypeError – When transformation is not subclass of PatternTransformation.
TypeError – When state_id is not instance of int.
TypeError – When subgraph is not a dict of {PatternNode: int}.
- class dace.transformation.interstate.state_elimination.TrueConditionElimination(*args, **kwargs)
Bases:
MultiStateTransformation
If 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.expressions
and the nodes ingraph
.expr_index – The list index from
PatternTransformation.expressions
that 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
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, first_output_nodes, second_input_nodes, second_output_nodes)
Bases:
object
- class dace.transformation.interstate.state_fusion.StateFusion(*args, **kwargs)
Bases:
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.
- 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.expressions
and the nodes ingraph
.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.
- 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
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, 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
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.top_level_nodes(state)
Module contents
This module initializes the inter-state transformations package.