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(_, 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 in graph.

  • 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()

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(_, 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 in graph.

  • 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.

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:

  1. Acquire metadata about SDFG and arrays

  2. Replace all non-transients with their GPU counterparts

  3. Copy-in state from host to GPU

  4. Copy-out state from GPU to host

  5. Re-store Default-top/CPU_Heap transients as GPU_Global

  6. Global tasklets are wrapped with a map of size 1

  7. Global Maps are re-scheduled to use the GPU

  8. Make data ready for interstate edges that use them

  9. Re-apply simplification to get rid of extra states and transients

static annotates_memlets()

Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.

apply(_, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph – SDFG object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • 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

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 – SDFGState object if this transformation is single-state, or SDFG object otherwise.

  • 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, guard, entry, itervar=None)

Finds loop range from state machine.

Parameters:
  • guard (SDFGState) – State from which the outgoing edges detect whether to exit the loop or not.

  • entry (SDFGState) – First state in the loop “body”.

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_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(_, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFGState) – SDFG object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • expr_index (int) – The list index from PatternTransformation.expressions that was matched.

  • sdfg (SDFG) – The SDFG in which the match was found (equal to graph).

  • permissive (bool) – Whether transformation should run in permissive mode.

Returns:

True if the transformation can be applied.

itervar

The name of the iteration variable (optional).

properties()
test_read_memlet(sdfg, state, edge, itersym, itervar, start, end, step, write_memlets, mmlt, src_subset)

dace.transformation.interstate.move_loop_into_map module

Moves a loop around a map into the map

class dace.transformation.interstate.move_loop_into_map.MoveLoopIntoMap(*args, **kwargs)

Bases: DetectLoop, MultiStateTransformation

Moves a loop around a map into the map

apply(_, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph – SDFG object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • 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.

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(_, 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 in graph.

  • 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(_, 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 in graph.

  • 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:

  1. All transient arrays become transients of the parent

  2. If a source/sink node is one of the inputs/outputs:

    1. Remove it

    2. Reconnect through external edges (map/accessnode)

    3. Replace and reoffset memlets with external data descriptor

  3. If other nodes carry the names of inputs/outputs:

    1. Replace data with external data descriptor

    2. Replace and reoffset memlets with external data descriptor

  4. 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

  5. Remove all unused external inputs/output memlet paths

  6. Remove isolated nodes resulting from previous step

static annotates_memlets()

Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.

apply(state, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFGState) – SDFGState object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • 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()
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(state, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFGState) – SDFGState object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • expr_index (int) – The list index from PatternTransformation.expressions that was matched.

  • sdfg (SDFG) – The parent SDFG of the matched state.

  • permissive (bool) – Whether transformation should run in permissive mode.

Returns:

True if the transformation can be applied.

classmethod expressions()

Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling can_be_applied.

nsdfg

Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of 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.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(_, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Return type:

NestedSDFG

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 in graph.

  • 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()
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 of x (x[0:N]), and it is offset to y[1:5] in the function, with y’s size being N. After the transformation, the memlet connected to the nested SDFG of func_a would contain x[1:5] directly and the internal y array would have a size of 4, accessed as y[0:4].

static annotates_memlets()

Indicates whether the transformation annotates the edges it creates or modifies with the appropriate memlets. This determines whether to apply memlet propagation after the transformation.

apply(state, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFGState) – SDFGState object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • expr_index (int) – The list index from PatternTransformation.expressions that was matched.

  • sdfg (SDFG) – The parent SDFG of the matched state.

  • permissive (bool) – Whether transformation should run in permissive mode.

Returns:

True if the transformation can be applied.

classmethod expressions()

Returns a list of SDFG state subgraphs that will be matched in the subgraph isomorphism phase. Used as a pre-pass before calling can_be_applied.

nsdfg

Static field wrapper of a node or an SDFG state that designates it as part of a subgraph pattern. These objects are used in subclasses of 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()

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(_, 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 in graph.

  • 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(_, 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 in graph.

  • expr_index – The list index from PatternTransformation.expressions that was matched.

  • sdfg (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.

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(state, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFGState) – SDFGState object in which the match was found.

  • candidate – A mapping between node IDs returned from PatternTransformation.expressions and the nodes in graph.

  • 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.

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(_, 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 in graph.

  • 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(_, 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 in graph.

  • 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(_, 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 in graph.

  • 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.

class dace.transformation.interstate.state_elimination.TrueConditionElimination(*args, **kwargs)

Bases: MultiStateTransformation

If a state transition condition is always true, removes condition from edge.

apply(_, sdfg)

Applies this transformation instance on the matched pattern graph.

Parameters:

sdfg (SDFG) – The SDFG to apply the transformation to.

Returns:

A transformation-defined return value, which could be used to pass analysis data out, or nothing.

can_be_applied(graph, expr_index, sdfg, permissive=False)

Returns True if this transformation can be applied on the candidate matched subgraph.

Parameters:
  • graph (SDFG) – SDFG object in which the match was found.

  • candidate – 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.

  • sdfg (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.

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 in graph.

  • 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.