Available Passes

Scalar-to-Symbol Promotion

Scalar to symbol promotion functionality.

class dace.transformation.passes.scalar_to_symbol.AttributedCallDetector

Bases: ast.NodeVisitor

Detects calls to functions that are attributes.

visit_Call(node: _ast.Call) → Any
class dace.transformation.passes.scalar_to_symbol.RemoveConstantAttributes

Bases: ast.NodeTransformer

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

visit_Call(node: _ast.Call) → Any
class dace.transformation.passes.scalar_to_symbol.ScalarToSymbolPromotion(ignore: Union[Set[str], NoneType] = None, transients_only: bool = True, integers_only: bool = True)

Bases: dace.transformation.pass_pipeline.Pass

apply_pass(sdfg: dace.sdfg.sdfg.SDFG, _: Dict[Any, Any]) → Set[str]

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. :param sdfg: The SDFG to run the pass on. :param ignore: An optional set of strings of scalars to ignore. :param transients_only: If False, also considers global data descriptors (e.g., arguments). :param integers_only: If False, also considers non-integral descriptors for promotion. :return: Set of promoted scalars.

ignore = None
integers_only = True
modifies() → dace.transformation.pass_pipeline.Modifies

Which elements of the SDFG (e.g., memlets, state structure) are modified by this pass, if run successfully. :return: A Modifies set of flags of modified elements.

transients_only = True
class dace.transformation.passes.scalar_to_symbol.TaskletIndirectionPromoter(in_edges: Dict[str, dace.memlet.Memlet], out_edges: Dict[str, dace.memlet.Memlet], sdfg: dace.sdfg.sdfg.SDFG, defined_syms: Set[str])

Bases: ast.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: _ast.Subscript) → Any
class dace.transformation.passes.scalar_to_symbol.TaskletPromoter(connector: str, symbol: str)

Bases: ast.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: _ast.Name) → Any
visit_Subscript(node: _ast.Subscript) → Any
class dace.transformation.passes.scalar_to_symbol.TaskletPromoterDict(conn_to_sym: Dict[str, str])

Bases: ast.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: _ast.Name) → Any
visit_Subscript(node: _ast.Subscript) → Any
dace.transformation.passes.scalar_to_symbol.find_promotable_scalars(sdfg: dace.sdfg.sdfg.SDFG, transients_only: bool = True, integers_only: bool = True) → Set[str]

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 – The SDFG to query.
  • transients_only – If False, also considers global data descriptors (e.g., arguments).
  • integers_only – If False, also considers non-integral descriptors for promotion.
Returns:

A set of promotable scalar names.

dace.transformation.passes.scalar_to_symbol.promote_scalars_to_symbols(sdfg: dace.sdfg.sdfg.SDFG, ignore: Optional[Set[str]] = None, transients_only: bool = True, integers_only: bool = True) → Set[str]

DEPRECATED. Use pass directly instead. 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 – 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.
Returns:

Set of promoted scalars.

Note:

Operates in-place.

dace.transformation.passes.scalar_to_symbol.remove_scalar_reads(sdfg: dace.sdfg.sdfg.SDFG, array_names: Dict[str, str])

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++). :param sdfg: The SDFG to operate on. :param array_names: 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: dace.sdfg.sdfg.SDFG)

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

Parameters:sdfg – The SDFG to run the pass on.
Note:Operates in-place.
dace.transformation.passes.scalar_to_symbol.translate_cpp_tasklet_to_python(code: str)

Module contents