Available Passes

Scalar-to-Symbol Promotion

Scalar to symbol promotion functionality.

class dace.transformation.passes.scalar_to_symbol.AttributedCallDetector

Bases: NodeVisitor

Detects calls to functions that are attributes.

visit_Call(node)
Return type:

Any

class dace.transformation.passes.scalar_to_symbol.RemoveConstantAttributes

Bases: NodeTransformer

Removes calls to functions that are attributes, if they point to a constant value for a cast.

visit_Call(node)
Return type:

Any

class dace.transformation.passes.scalar_to_symbol.ScalarToSymbolPromotion(*args, **kwargs)

Bases: Pass

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Promotes all matching transient scalars to SDFG symbols, changing all tasklets to inter-state assignments. This enables the transformed symbols to be used within states as part of memlets, and allows further transformations (such as loop detection) to use the information for optimization.

Parameters:
  • sdfg (SDFG) – The SDFG to run the pass on.

  • ignore – An optional set of strings of scalars to ignore.

  • transients_only – If False, also considers global data descriptors (e.g., arguments).

  • integers_only – If False, also considers non-integral descriptors for promotion.

Return type:

Set[str]

Returns:

Set of promoted scalars.

ignore

Fields that should not be promoted.

integers_only

Allow promotion of integer scalars only.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[str]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

transients_only

Promote only transients.

class dace.transformation.passes.scalar_to_symbol.TaskletIndirectionPromoter(in_edges, out_edges, sdfg, defined_syms)

Bases: NodeTransformer

Promotes indirect memory access in Tasklets to symbolic memlets. After visiting an AST, self.{in,out}_mapping will be filled with mappings from unique new connector names to sets of individual memlets.

visit_Subscript(node)
Return type:

Any

class dace.transformation.passes.scalar_to_symbol.TaskletPromoter(connector, symbol)

Bases: NodeTransformer

Promotes scalars to symbols in Tasklets. If connector name is used in tasklet as subscript, modifies to symbol name. If connector is used as a standard name, modify tasklet code to use symbol.

visit_Name(node)
Return type:

Any

visit_Subscript(node)
Return type:

Any

class dace.transformation.passes.scalar_to_symbol.TaskletPromoterDict(conn_to_sym)

Bases: NodeTransformer

Promotes scalars to symbols in Tasklets. If connector name is used in tasklet as subscript, modifies to symbol name. If connector is used as a standard name, modify tasklet code to use symbol.

visit_Name(node)
Return type:

Any

visit_Subscript(node)
Return type:

Any

dace.transformation.passes.scalar_to_symbol.find_promotable_scalars(sdfg, transients_only=True, integers_only=True)

Finds scalars that can be promoted to symbols in the given SDFG. Conditions for matching a scalar for symbol-promotion are as follows:

  • Size of data must be 1, it must not be a stream and must be transient.

  • Only inputs to candidate scalars must be either arrays or tasklets.

  • All tasklets that lead to it must have one statement, one output, and may have zero or more array inputs and not be in a scope.

  • Scalar must not be accessed with a write-conflict resolution.

  • Scalar must not be written to more than once in a state.

  • If scalar is not integral (i.e., int type), it must also appear in an inter-state condition to be promotable.

These conditions must apply on all occurences of the scalar in order for it to be promotable.

Parameters:
  • sdfg (SDFG) – The SDFG to query.

  • transients_only (bool) – If False, also considers global data descriptors (e.g., arguments).

  • integers_only (bool) – If False, also considers non-integral descriptors for promotion.

Return type:

Set[str]

Returns:

A set of promotable scalar names.

dace.transformation.passes.scalar_to_symbol.remove_scalar_reads(sdfg, array_names)

Removes all instances of a promoted symbol’s read accesses in an SDFG. This removes each read-only access node as well as all of its descendant edges (in memlet trees) and connectors. Descends recursively to nested SDFGs and modifies tasklets (Python and C++).

Parameters:
  • sdfg (SDFG) – The SDFG to operate on.

  • array_names (Dict[str, str]) – Mapping between scalar names to replace and their replacement symbol name.

Note:

Operates in-place on the SDFG.

dace.transformation.passes.scalar_to_symbol.remove_symbol_indirection(sdfg)

Converts indirect memory accesses that involve only symbols into explicit memlets.

Parameters:

sdfg (SDFG) – The SDFG to run the pass on.

Note:

Operates in-place.

dace.transformation.passes.scalar_to_symbol.translate_cpp_tasklet_to_python(code)

Dead Memory Elimination and Merging

class dace.transformation.passes.array_elimination.ArrayElimination(*args, **kwargs)

Bases: Pass

Merges and removes arrays and their corresponding accesses. This includes redundant array copies, unnecessary views, and duplicate access nodes.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, pipeline_results)

Removes redundant arrays and access nodes.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

  • pipeline_results (Dict[str, Any]) – 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.

Return type:

Optional[Set[str]]

Returns:

A set of removed data descriptor names, or None if nothing changed.

depends_on()

If in the context of a Pipeline, which other Passes need to run first.

Returns:

A set of Pass subclasses or objects that need to run prior to this Pass.

merge_access_nodes(state, access_nodes, condition)

Merges access nodes that follow the same conditions together to the first access node.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
remove_redundant_copies(sdfg, state, removable_data, access_nodes)

Removes access nodes that represent redundant copies and/or views.

remove_redundant_views(sdfg, state, access_nodes)

Removes access nodes that contain views, which can be represented normally by memlets. For example, slices.

report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[str]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.transient_reuse.TransientReuse(*args, **kwargs)

Bases: Pass

Reduces memory consumption by reusing allocated transient array memory. Only modifies arrays that can safely be reused.

CATEGORY: str = 'Memory Footprint Reduction'
apply_pass(sdfg, _)

Applies the pass to the given SDFG.

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

Return type:

Optional[Set[str]]

Returns:

Some object if pass was applied, or None if nothing changed.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

Dead Code Elimination

class dace.transformation.passes.dead_state_elimination.DeadStateElimination(*args, **kwargs)

Bases: Pass

Removes all unreachable states (e.g., due to a branch that will never be taken) from an SDFG.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Removes unreachable states throughout an SDFG.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

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

  • initial_symbols – If not None, sets values of initial symbols.

Return type:

Optional[Set[Union[Edge[InterstateEdge], SDFGState]]]

Returns:

A set of the removed states, or None if nothing was changed.

find_dead_states(sdfg, set_unconditional_edges=True)

Finds “dead” (unreachable) states in an SDFG. A state is deemed unreachable if it is:

  • Unreachable from the starting state

  • Conditions leading to it will always evaluate to False

  • There is another unconditional (always True) inter-state edge that leads to another state

Parameters:
  • sdfg (SDFG) – The SDFG to traverse.

  • set_unconditional_edges (bool) – If True, conditions of edges evaluated as unconditional are removed.

Return type:

Tuple[Set[SDFGState], Set[Edge[InterstateEdge]], bool]

Returns:

A 3-tuple of (unreachable states, unreachable edges, were edges annotated).

is_definitely_not_taken(edge, sdfg)

Returns True iff edge condition definitely evaluates to False.

Return type:

bool

is_definitely_taken(edge, sdfg)

Returns True iff edge condition definitely evaluates to True.

Return type:

bool

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[Union[Edge[InterstateEdge], SDFGState]]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.dead_dataflow_elimination.DeadDataflowElimination(*args, **kwargs)

Bases: Pass

Removes unused computations from SDFG states. Traverses the graph backwards, removing any computations that result in transient descriptors that are not used again. Removal propagates through scopes (maps), tasklets, and optionally library nodes.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, pipeline_results)

Removes unreachable dataflow throughout SDFG states.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

  • pipeline_results (Dict[str, Any]) – 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.

Return type:

Optional[Dict[SDFGState, Set[str]]]

Returns:

A dictionary mapping states to removed data descriptor names, or None if nothing changed.

depends_on()

If in the context of a Pipeline, which other Passes need to run first.

Return type:

Set[Type[Pass]]

Returns:

A set of Pass subclasses or objects that need to run prior to this Pass.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
remove_persistent_memory

If True, marks code with Persistent allocation lifetime as dead

report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Dict[SDFGState, Set[str]]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

skip_library_nodes

If True, does not remove library nodes if their results are unused. Otherwise removes library nodes without side effects.

dace.transformation.passes.dead_dataflow_elimination.PROTECTED_NAMES = {'__pystate'}

A set of names that are not allowed to be erased

class dace.transformation.passes.prune_symbols.RemoveUnusedSymbols(*args, **kwargs)

Bases: Pass

Prunes unused symbols from the SDFG symbol repository (sdfg.symbols). Also includes uses in Tasklets of all languages.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Propagates constants throughout the SDFG.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

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

  • initial_symbols – If not None, sets values of initial symbols.

Return type:

Optional[Set[Tuple[int, str]]]

Returns:

A set of propagated constants, or None if nothing was changed.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
recursive

Prune nested SDFGs recursively

report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[str]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

symbols

Limit considered symbols to this set

used_symbols(sdfg)
Return type:

Set[str]

Constant Propagation

class dace.transformation.passes.constant_propagation.ConstantPropagation(*args, **kwargs)

Bases: Pass

Propagates constants and symbols that were assigned to one value forward through the SDFG, reducing the number of overall symbols.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _, initial_symbols=None)

Propagates constants throughout the SDFG.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

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

  • initial_symbols (Optional[Dict[str, Any]]) – If not None, sets values of initial symbols.

Return type:

Optional[Set[str]]

Returns:

A set of propagated constants, or None if nothing was changed.

collect_constants(sdfg, initial_symbols=None)

Finds all constants and constant-assigned symbols in the SDFG for each state.

Parameters:
  • sdfg (SDFG) – The SDFG to traverse.

  • initial_symbols (Optional[Dict[str, Any]]) – If not None, sets values of initial symbols.

Return type:

Dict[SDFGState, Dict[str, Any]]

Returns:

A dictionary mapping an SDFG state to a mapping of constants and their corresponding values.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

progress

Show progress

properties()
recursive

Propagagte recursively through nested SDFGs

report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[str]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_apply(sdfg)

Fast check (O(m)) whether the pass should early-exit without traversing the SDFG.

Return type:

bool

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.optional_arrays.OptionalArrayInference(*args, **kwargs)

Bases: Pass

Infers the optional property of arrays, i.e., if they can be given None, throughout the SDFG and all nested SDFGs.

An array will be modified to optional if its previous optional property was set to None and: * it is transient; * it is in a nested SDFG and its parent array was transient; or * it is definitely (unconditionally) read or written in the SDFG.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _, parent_arrays=None)

Infers the optional property of arrays in the SDFG and its nested SDFGs.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

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

  • parent_arrays (Optional[Dict[str, bool]]) – If not None, contains values of determined arrays from the parent SDFG.

Return type:

Optional[Set[Tuple[int, str]]]

Returns:

A set of the modified array names as a 2-tuple (CFG ID, name), or None if nothing was changed.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (Set[Tuple[int, str]]) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

traverse_unconditional_states(sdfg)

Traverse SDFG and keep track of whether the state is executed unconditionally.

Return type:

Iterator[SDFGState]

Memlet Consolidation

class dace.transformation.passes.consolidate_edges.ConsolidateEdges(*args, **kwargs)

Bases: Pass

Removes extraneous edges with memlets that refer to the same data containers within the same scope.

Memlet subsets are unioned in each scope. This effectively reduces the number of connectors and allows more transformations to be performed, at the cost of losing the individual per-tasklet memlets.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Consolidates edges on the given SDFG.

Parameters:
  • sdfg (SDFG) – The SDFG to modify.

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

Return type:

Optional[int]

Returns:

Number of edges removed, or None if nothing was performed.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (int) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

State Fusion and SDFG Inlining

Contains implementations of SDFG inlining and state fusion passes.

class dace.transformation.passes.fusion_inline.FixNestedSDFGReferences(*args, **kwargs)

Bases: Pass

Fixes nested SDFG references to parent state/SDFG/node

CATEGORY: str = 'Cleanup'
apply_pass(sdfg, _)

Applies the pass to the given SDFG.

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

Return type:

Optional[int]

Returns:

Some object if pass was applied, or None if nothing changed.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (int) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.fusion_inline.FuseStates(*args, **kwargs)

Bases: Pass

Fuses all possible states of an SDFG (and all sub-SDFGs).

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Fuses all possible states of an SDFG (and all sub-SDFGs).

Parameters:

sdfg (SDFG) – The SDFG to transform.

Return type:

Optional[int]

Returns:

The total number of states fused, or None if did not apply.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

permissive

If True, ignores some race condition checks.

progress

Whether to print progress, or None for default (print after 5 seconds).

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (int) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.fusion_inline.InlineSDFGs(*args, **kwargs)

Bases: Pass

Inlines all possible nested SDFGs (and sub-SDFGs).

CATEGORY: str = 'Simplification'
apply_pass(sdfg, _)

Inlines all possible nested SDFGs (and all sub-SDFGs).

Parameters:

sdfg (SDFG) – The SDFG to transform.

Return type:

Optional[int]

Returns:

The total number of states fused, or None if did not apply.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

multistate

If True, include multi-state inlining.

permissive

If True, ignores some checks on inlining.

progress

Whether to print progress, or None for default (print after 5 seconds).

properties()
report(pass_retval)

Returns a user-readable string report based on the results of this pass.

Parameters:

pass_retval (int) – The return value from applying this pass.

Return type:

str

Returns:

A string with the user-readable report, or None if nothing to report.

should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

Analysis Passes

class dace.transformation.passes.analysis.AccessRanges(*args, **kwargs)

Bases: Pass

For each data descriptor, finds all memlets used to access it (read/write ranges).

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[str, Set[Memlet]]]

Returns:

A dictionary mapping each data descriptor name to a set of memlets.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.AccessSets(*args, **kwargs)

Bases: Pass

Evaluates memory access sets (which arrays/data descriptors are read/written in each state).

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[SDFGState, Tuple[Set[str], Set[str]]]]

Returns:

A dictionary mapping each state to a tuple of its (read, written) data descriptors.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.FindAccessNodes(*args, **kwargs)

Bases: Pass

For each data descriptor, creates a dictionary mapping states to all read and write access nodes with the given data descriptor.

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[str, Dict[SDFGState, Tuple[Set[AccessNode], Set[AccessNode]]]]]

Returns:

A dictionary mapping each data descriptor name to a dictionary keyed by states with all access nodes that use that data descriptor.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.FindAccessStates(*args, **kwargs)

Bases: Pass

For each data descriptor, creates a set of states in which access nodes of that data are used.

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[str, Set[SDFGState]]]

Returns:

A dictionary mapping each data descriptor name to states where it can be found in.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.FindReferenceSources(*args, **kwargs)

Bases: Pass

For each Reference data descriptor, finds all memlets used to set it. If a Tasklet was used to set the reference, the Tasklet is given as a source.

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[str, Set[Union[Memlet, CodeNode]]]]

Returns:

A dictionary mapping each data descriptor name to a set of memlets.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.ScalarWriteShadowScopes(*args, **kwargs)

Bases: Pass

For each scalar or array of size 1, create a dictionary mapping writes to that data container to the set of reads and writes that are dominated by that write.

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, pipeline_results)
Return type:

Dict[int, Dict[str, Dict[Optional[Tuple[SDFGState, AccessNode]], Set[Tuple[SDFGState, Union[AccessNode, InterstateEdge]]]]]]

Returns:

A dictionary mapping each data descriptor name to a dictionary, where writes to that data descriptor and the states they are contained in are mapped to the set of reads and writes (and their states) that are dominated by that write.

depends_on()

If in the context of a Pipeline, which other Passes need to run first.

Returns:

A set of Pass subclasses or objects that need to run prior to this Pass.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.StateReachability(*args, **kwargs)

Bases: Pass

Evaluates state reachability (which other states can be executed after each state).

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[SDFGState, Set[SDFGState]]]

Returns:

A dictionary mapping each state to its other reachable states.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.SymbolAccessSets(*args, **kwargs)

Bases: Pass

Evaluates symbol access sets (which symbols are read/written in each state or interstate edge).

CATEGORY: str = 'Analysis'
apply_pass(top_sdfg, _)
Return type:

Dict[int, Dict[Union[SDFGState, Edge[InterstateEdge]], Tuple[Set[str], Set[str]]]]

Returns:

A dictionary mapping each state to a tuple of its (read, written) data descriptors.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

class dace.transformation.passes.analysis.SymbolWriteScopes(*args, **kwargs)

Bases: Pass

For each symbol, create a dictionary mapping each writing interstate edge to that symbol to the set of interstate edges and states reading that symbol that are dominated by that write.

CATEGORY: str = 'Analysis'
apply_pass(sdfg, pipeline_results)

Applies the pass to the given SDFG.

Parameters:
  • sdfg (SDFG) – The SDFG to apply the pass to.

  • pipeline_results (Dict[str, Any]) – 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.

Return type:

Dict[int, Dict[str, Dict[Edge[InterstateEdge], Set[Union[Edge[InterstateEdge], SDFGState]]]]]

Returns:

Some object if pass was applied, or None if nothing changed.

depends_on()

If in the context of a Pipeline, which other Passes need to run first.

Returns:

A set of Pass subclasses or objects that need to run prior to this Pass.

modifies()

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully.

Return type:

Modifies

Returns:

A Modifies set of flags of modified elements.

properties()
should_reapply(modified)

In the context of a Pipeline, queries whether this Pass should be rerun after other passes have run and modified the SDFG.

Parameters:

modified (Modifies) – Flags specifying which elements of the SDFG were modified.

Return type:

bool

Returns:

True if this Pass should be rerun when the given elements are modified.

dace.transformation.passes.analysis.reachable_nodes(G)

Computes the reachable nodes in G.

The Simplify Pass Pipeline

class dace.transformation.passes.simplify.SimplifyPass(*args, **kwargs)

Bases: FixedPointPipeline

A pipeline that simplifies an SDFG by applying a series of simplification passes.

CATEGORY: str = 'Simplification'
apply_pass(sdfg, pipeline_results)

Applies the pipeline to the SDFG in repeated succession until the SDFG is no longer modified.

Parameters:
  • sdfg (SDFG) – The SDFG to apply the pass to.

  • pipeline_results (Dict[str, Any]) – 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.

Return type:

Optional[Dict[str, Any]]

Returns:

A dictionary of {Pass subclass name: return value} for applied passes, or None if no Passes were applied in the context of this pipeline.

apply_subpass(sdfg, p, state)

Apply a pass from the pipeline. This method is meant to be overridden by subclasses.

properties()
skip

Set of pass names to skip.

validate

Whether to validate the SDFG at the end of the pipeline.

validate_all

Whether to validate the SDFG after each pass.

verbose

Whether to print reports after every pass.

Module contents