dace package

Subpackages

Submodules

dace.config module

class dace.config.Config

Bases: object

Interface to the DaCe hierarchical configuration file.

static append(*key_hierarchy, value=None, autosave=False)

Appends to the current value of a given configuration entry and sets it. Example usage: Config.append(‘compiler’, ‘cpu’, ‘args’, value=’-fPIC’) :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Parameters:
  • value – The value to append.
  • autosave – If True, saves the configuration to the file after modification.
Returns:

Current configuration entry value.

static cfg_filename()

Returns the current configuration file path.

static get(*key_hierarchy)

Returns the current value of a given configuration entry. :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Returns:Configuration entry value.
static get_bool(*key_hierarchy)

Returns the current value of a given boolean configuration entry. This specialization allows more string types to be converted to boolean, e.g., due to environment variable overrides. :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Returns:Configuration entry value (as a boolean).
static get_default(*key_hierarchy)

Returns the default value of a given configuration entry. Takes into accound current operating system. :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Returns:Default configuration value.
static get_metadata(*key_hierarchy)

Returns the configuration specification of a given entry from the schema. :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Returns:Configuration specification as a dictionary.
static initialize()

Initializes configuration.

B{Note:} This function runs automatically when the module
is loaded.
static load(filename=None)

Loads a configuration from an existing file. :param filename: The file to load. If unspecified,

uses default configuration file.
static load_schema(filename=None)

Loads a configuration schema from an existing file. :param filename: The file to load. If unspecified,

uses default schema file.
static save(path=None)

Saves the current configuration to a file. :param path: The file to save to. If unspecified,

uses default configuration file.
static set(*key_hierarchy, value=None, autosave=False)

Sets the current value of a given configuration entry. Example usage: Config.set(‘profiling’, value=True) :param key_hierarchy: A tuple of strings leading to the

configuration entry. For example: (‘a’, ‘b’, ‘c’) would be configuration entry c which is in the path a->b.
Parameters:
  • value – The value to set.
  • autosave – If True, saves the configuration to the file after modification.
dace.config.set_temporary(*path, value)

Temporarily set configuration value at path to value, and reset it after the context manager exits.

Example:

print(Config.get(“compiler”, “build_type”) with set_temporary(“compiler”, “build_type”, value=”Debug”):

print(Config.get(“compiler”, “build_type”)

print(Config.get(“compiler”, “build_type”)

dace.data module

class dace.data.Array(*args, **kwargs)

Bases: dace.data.Data

Array/constant descriptor (dimensions, type and other properties).

alignment

Allocation alignment in bytes (0 uses compiler-default)

allow_conflicts

If enabled, allows more than one memlet to write to the same memory location without conflict resolution.

as_arg(with_types=True, for_call=False, name=None)

Returns a string for a C++ function signature (e.g., int *A).

clone()
covers_range(rng)
free_symbols

Returns a set of undefined symbols in this data descriptor.

classmethod from_json(json_obj, context=None)
is_equivalent(other)

Check for equivalence (shape and type) of two data descriptors.

may_alias

This pointer may alias with other pointers in the same function

offset

Initial offset to translate all indices by.

properties()
sizes()
strides

For each dimension, the number of elements to skip in order to obtain the next element in that dimension.

to_json()
total_size

The total allocated size of the array. Can be used for padding.

validate()

Validate the correctness of this object. Raises an exception on error.

class dace.data.Data(*args, **kwargs)

Bases: object

Data type descriptors that can be used as references to memory. Examples: Arrays, Streams, custom arrays (e.g., sparse matrices).

as_arg(with_types=True, for_call=False, name=None)

Returns a string for a C++ function signature (e.g., int *A).

copy()
ctype
debuginfo

Object property of type DebugInfo

dtype

Object property of type typeclass

free_symbols

Returns a set of undefined symbols in this data descriptor.

is_equivalent(other)

Check for equivalence (shape and type) of two data descriptors.

lifetime

Data allocation span

location

Full storage location identifier (e.g., rank, GPU ID)

properties()
shape

Object property of type tuple

storage

Storage location

to_json()
toplevel
transient

Object property of type bool

validate()

Validate the correctness of this object. Raises an exception on error.

veclen
class dace.data.Scalar(*args, **kwargs)

Bases: dace.data.Data

Data descriptor of a scalar value.

allow_conflicts

Object property of type bool

as_arg(with_types=True, for_call=False, name=None)

Returns a string for a C++ function signature (e.g., int *A).

clone()
covers_range(rng)
static from_json(json_obj, context=None)
is_equivalent(other)

Check for equivalence (shape and type) of two data descriptors.

offset
properties()
sizes()
strides
total_size
class dace.data.Stream(*args, **kwargs)

Bases: dace.data.Data

Stream (or stream array) data descriptor.

as_arg(with_types=True, for_call=False, name=None)

Returns a string for a C++ function signature (e.g., int *A).

buffer_size

Size of internal buffer.

clone()
covers_range(rng)
free_symbols

Returns a set of undefined symbols in this data descriptor.

classmethod from_json(json_obj, context=None)
is_equivalent(other)

Check for equivalence (shape and type) of two data descriptors.

is_stream_array()
offset

Object property of type list

properties()
size_string()
sizes()
strides
to_json()
total_size
class dace.data.View(*args, **kwargs)

Bases: dace.data.Array

Data descriptor that acts as a reference (or view) of another array. Can be used to reshape or reinterpret existing data without copying it.

To use a View, it needs to be referenced in an access node that is directly connected to another access node. The rules for deciding which access node is viewed are:

  • If there is one edge (in/out) that leads (via memlet path) to an access node, and the other side (out/in) has a different number of edges.
  • If there is one incoming and one outgoing edge, and one leads to a code node, the one that leads to an access node is the viewed data.
  • If both sides lead to access nodes, if one memlet’s data points to the view it cannot point to the viewed node.
  • If both memlets’ data are the respective access nodes, the access node at the highest scope is the one that is viewed.
  • If both access nodes reside in the same scope, the input data is viewed.

Other cases are ambiguous and will fail SDFG validation.

In the Python frontend, numpy.reshape and numpy.ndarray.view both generate Views.

as_array()
properties()
validate()

Validate the correctness of this object. Raises an exception on error.

dace.data.create_datadescriptor(obj)

Creates a data descriptor from various types of objects. @see: dace.data.Data

dace.dtypes module

A module that contains various DaCe type definitions.

class dace.dtypes.AccessType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Types of access to an AccessNode.

ReadOnly = 1
ReadWrite = 3
WriteOnly = 2
class dace.dtypes.AllocationLifetime(*args, **kwds)

Bases: aenum.AutoNumberEnum

Options for allocation span (when to allocate/deallocate) of data.

Global = 4

Allocated throughout the entire program (outer SDFG)

Persistent = 5

Allocated throughout multiple invocations (init/exit)

SDFG = 3

Allocated throughout the innermost SDFG (possibly nested)

Scope = 1

Allocated/Deallocated on innermost scope start/end

State = 2

Allocated throughout the containing state

register(*args)
class dace.dtypes.DebugInfo(start_line, start_column=0, end_line=-1, end_column=0, filename=None)

Bases: object

Source code location identifier of a node/edge in an SDFG. Used for IDE and debugging purposes.

static from_json(json_obj, context=None)
to_json()
class dace.dtypes.DeviceType(*args, **kwds)

Bases: aenum.AutoNumberEnum

CPU = 1

Multi-core CPU

FPGA = 3

FPGA (Intel or Xilinx)

GPU = 2

GPU (AMD or NVIDIA)

register(*args)
class dace.dtypes.InstrumentationType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Types of instrumentation providers. @note: Might be determined automatically in future versions.

GPU_Events = 4
No_Instrumentation = 1
PAPI_Counters = 3
Timer = 2
register(*args)
class dace.dtypes.Language(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available programming languages for SDFG tasklets.

CPP = 2
OpenCL = 3
Python = 1
SystemVerilog = 4
register(*args)
class dace.dtypes.ReductionType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Reduction types natively supported by the SDFG compiler.

Bitwise_And = 7

Bitwise AND (&)

Bitwise_Or = 9

Bitwise OR (|)

Bitwise_Xor = 11

Bitwise XOR (^)

Custom = 1

Defined by an arbitrary lambda function

Div = 16

Division (only supported in OpenMP)

Exchange = 14

Set new value, return old value

Logical_And = 6

Logical AND (&&)

Logical_Or = 8

Logical OR (||)

Logical_Xor = 10

Logical XOR (!=)

Max = 3

Maximum value

Max_Location = 13

Maximum value and its location

Min = 2

Minimum value

Min_Location = 12

Minimum value and its location

Product = 5

Product

Sub = 15

Subtraction (only supported in OpenMP)

Sum = 4

Sum

class dace.dtypes.ScheduleType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available map schedule types in the SDFG.

CPU_Multicore = 4

OpenMP

Default = 1

Scope-default parallel schedule

FPGA_Device = 11
GPU_Default = 6

Default scope schedule for GPU code. Specializes to schedule GPU_Device and GPU_Global during inference.

GPU_Device = 7

Kernel

GPU_Persistent = 10
GPU_ThreadBlock = 8

Thread-block code

GPU_ThreadBlock_Dynamic = 9

Allows rescheduling work within a block

MPI = 3

MPI processes

Sequential = 2

Sequential code (single-thread)

Unrolled = 5

Unrolled code

register(*args)
class dace.dtypes.StorageType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available data storage types in the SDFG.

CPU_Heap = 4

Host memory allocated on heap

CPU_Pinned = 3

Host memory that can be DMA-accessed from accelerators

CPU_ThreadLocal = 5

Thread-local host memory

Default = 1

Scope-default storage location

FPGA_Global = 8

Off-chip global memory (DRAM)

FPGA_Local = 9

On-chip memory (bulk storage)

FPGA_Registers = 10

On-chip memory (fully partitioned registers)

FPGA_ShiftRegister = 11

Only accessible at constant indices

GPU_Global = 6

Global memory

GPU_Shared = 7

Shared memory

Register = 2

Local data on registers, stack, or equivalent memory

register(*args)
class dace.dtypes.TilingType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available tiling types in a StripMining transformation.

CeilRange = 2
Normal = 1
NumberOfTiles = 3
register(*args)
class dace.dtypes.callback(return_type, *variadic_args)

Bases: dace.dtypes.typeclass

Looks like dace.callback([None, <some_native_type>], *types)

as_arg(name)
as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
static from_json(json_obj, context=None)
get_trampoline(pyfunc, other_arguments)
to_json()
dace.dtypes.can_access(schedule: dace.dtypes.ScheduleType, storage: dace.dtypes.StorageType)

Identifies whether a container of a storage type can be accessed in a specific schedule.

dace.dtypes.can_allocate(storage: dace.dtypes.StorageType, schedule: dace.dtypes.ScheduleType)

Identifies whether a container of a storage type can be allocated in a specific schedule. Used to determine arguments to subgraphs by the innermost scope that a container can be allocated in. For example, FPGA_Global memory cannot be allocated from within the FPGA scope, or GPU shared memory cannot be allocated outside of device-level code.

Parameters:
  • storage – The storage type of the data container to allocate.
  • schedule – The scope schedule to query.
Returns:

True if the container can be allocated, False otherwise.

dace.dtypes.deduplicate(iterable)

Removes duplicates in the passed iterable.

dace.dtypes.is_array(obj: Any) → bool

Returns True if an object implements the data_ptr(), __array_interface__ or __cuda_array_interface__ standards (supported by NumPy, Numba, CuPy, PyTorch, etc.). If the interface is supported, pointers can be directly obtained using the _array_interface_ptr function. :param obj: The given object. :return: True iff the object implements the array interface.

dace.dtypes.isallowed(var, allow_recursive=False)

Returns True if a given object is allowed in a DaCe program.

Parameters:allow_recursive – whether to allow dicts or lists containing constants.
dace.dtypes.isconstant(var)

Returns True if a variable is designated a constant (i.e., that can be directly generated in code).

dace.dtypes.ismodule(var)

Returns True if a given object is a module.

dace.dtypes.ismodule_and_allowed(var)

Returns True if a given object is a module and is one of the allowed modules in DaCe programs.

dace.dtypes.ismoduleallowed(var)

Helper function to determine the source module of an object, and whether it is allowed in DaCe programs.

dace.dtypes.json_to_typeclass(obj, context=None)
dace.dtypes.max_value(dtype: dace.dtypes.typeclass)

Get a max value literal for dtype.

dace.dtypes.min_value(dtype: dace.dtypes.typeclass)

Get a min value literal for dtype.

dace.dtypes.paramdec(dec)

Parameterized decorator meta-decorator. Enables using @decorator, @decorator(), and @decorator(…) with the same function.

class dace.dtypes.pointer(wrapped_typeclass)

Bases: dace.dtypes.typeclass

A data type for a pointer to an existing typeclass.

Example use:
dace.pointer(dace.struct(x=dace.float32, y=dace.float32)).
as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
base_type
static from_json(json_obj, context=None)
ocltype
to_json()
dace.dtypes.ptrtonumpy(ptr, inner_ctype, shape)
dace.dtypes.reduction_identity(dtype: dace.dtypes.typeclass, red: dace.dtypes.ReductionType) → Any

Returns known identity values (which we can safely reset transients to) for built-in reduction types. :param dtype: Input type. :param red: Reduction type. :return: Identity value in input type, or None if not found.

dace.dtypes.result_type_of(lhs, *rhs)

Returns the largest between two or more types (dace.types.typeclass) according to C semantics.

class dace.dtypes.struct(name, **fields_and_types)

Bases: dace.dtypes.typeclass

A data type for a struct of existing typeclasses.

Example use: dace.struct(a=dace.int32, b=dace.float64).

as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
emit_definition()
fields
static from_json(json_obj, context=None)
to_json()
class dace.dtypes.typeclass(wrapped_type)

Bases: object

An extension of types that enables their use in DaCe.

These types are defined for three reasons:
  1. Controlling DaCe types
  2. Enabling declaration syntax: dace.float32[M,N]
  3. Enabling extensions such as dace.struct and dace.vector
as_arg(name)
as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
base_type
static from_json(json_obj, context=None)
is_complex()
ocltype
to_json()
to_string()

A Numpy-like string-representation of the underlying data type.

veclen
dace.dtypes.validate_name(name)
class dace.dtypes.vector(dtype: dace.dtypes.typeclass, vector_length: int)

Bases: dace.dtypes.typeclass

A data type for a vector-type of an existing typeclass.

Example use: dace.vector(dace.float32, 4) becomes float4.

as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
base_type
ctype
ctype_unaligned
static from_json(json_obj, context=None)
ocltype
to_json()
veclen

dace.jupyter module

Jupyter Notebook support for DaCe.

dace.jupyter.isnotebook()
dace.jupyter.preamble()

dace.memlet module

class dace.memlet.Memlet(*args, **kwargs)

Bases: object

Data movement object. Represents the data, the subset moved, and the manner it is reindexed (other_subset) into the destination. If there are multiple conflicting writes, this object also specifies how they are resolved with a lambda function.

allow_oob

Bypass out-of-bounds validation

bounding_box_size()

Returns a per-dimension upper bound on the maximum number of elements in each dimension.

This bound will be tight in the case of Range.

data

Data descriptor attached to this memlet

debuginfo

Line information to track source and generated code

dst_subset
dynamic

Is the number of elements moved determined at runtime (e.g., data dependent)

free_symbols

Returns a set of symbols used in this edge’s properties.

static from_array(dataname, datadesc, wcr=None)

Constructs a Memlet that transfers an entire array’s contents. :param dataname: The name of the data descriptor in the SDFG. :param datadesc: The data descriptor object. :param wcr: The conflict resolution lambda. :type datadesc: Data

static from_json(json_obj, context=None)
is_empty() → bool

Returns True if this memlet carries no data. Memlets without data are primarily used for connecting nodes to scopes without transferring data to them.

num_accesses

Returns the total memory movement volume (in elements) of this memlet.

num_elements()

Returns the number of elements in the Memlet subset.

other_subset

Subset of elements after reindexing to the data not attached to this edge (e.g., for offsets and reshaping).

properties()
replace(repl_dict)

Substitute a given set of symbols with a different set of symbols. :param repl_dict: A dict of string symbol names to symbols with

which to replace them.
static simple(data, subset_str, wcr_str=None, other_subset_str=None, wcr_conflict=True, num_accesses=None, debuginfo=None, dynamic=False)

DEPRECATED: Constructs a Memlet from string-based expressions. :param data: The data object or name to access. :type data: Either a string of the data descriptor name or an

AccessNode.
Parameters:
  • subset_str – The subset of data that is going to be accessed in string format. Example: ‘0:N’.
  • wcr_str – A lambda function (as a string) specifying how write-conflicts are resolved. The syntax of the lambda function receives two elements: current value and new value, and returns the value after resolution. For example, summation is ‘lambda cur, new: cur + new’.
  • other_subset_str – The reindexing of subset on the other connected data (as a string).
  • wcr_conflict – If False, forces non-locked conflict resolution when generating code. The default is to let the code generator infer this information from the SDFG.
  • num_accesses – The number of times that the moved data will be subsequently accessed. If -1, designates that the number of accesses is unknown at compile time.
  • debuginfo – Source-code information (e.g., line, file) used for debugging.
  • dynamic – If True, the number of elements moved in this memlet is defined dynamically at runtime.
src_subset
subset

Subset of elements to move from the data attached to this edge.

to_json()
try_initialize(sdfg: dace.sdfg.sdfg.SDFG, state: dace.sdfg.state.SDFGState, edge: dace.sdfg.graph.MultiConnectorEdge)

Tries to initialize the internal fields of the memlet (e.g., src/dst subset) once it is added to an SDFG as an edge.

validate(sdfg, state)
volume

The exact number of elements moved using this memlet, or the maximum number if dynamic=True (with 0 as unbounded)

wcr

If set, defines a write-conflict resolution lambda function. The syntax of the lambda function receives two elements: current value and new value, and returns the value after resolution

wcr_nonatomic

If True, always generates non-conflicting (non-atomic) writes in resulting code

class dace.memlet.MemletTree(edge, parent=None, children=None)

Bases: object

A tree of memlet edges.

Since memlets can form paths through scope nodes, and since these paths can split in “OUT_*” connectors, a memlet edge can be extended to a memlet tree. The tree is always rooted at the outermost-scope node, which can mean that it forms a tree of directed edges going forward (in the case where memlets go through scope-entry nodes) or backward (through scope-exit nodes).

Memlet trees can be used to obtain all edges pertaining to a single memlet using the memlet_tree function in SDFGState. This collects all siblings of the same edge and their children, for instance if multiple inputs from the same access node are used.

root() → dace.memlet.MemletTree
traverse_children(include_self=False)

dace.properties module

class dace.properties.CodeBlock(code: Union[str, List[_ast.AST], CodeBlock], language: dace.dtypes.Language = <Language.Python: 1>)

Bases: object

Helper class that represents code blocks with language. Used in CodeProperty, implemented as a list of AST statements if language is Python, or a string otherwise.

as_string
static from_json(tmp, sdfg=None)
get_free_symbols(defined_syms: Set[str] = None) → Set[str]

Returns the set of free symbol names in this code block, excluding the given symbol names.

to_json()
class dace.properties.CodeProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that accepts code in various languages.

dtype
from_json(tmp, sdfg=None)
static from_string(string, language=None)
to_json(obj)
static to_string(obj)
class dace.properties.DataProperty(desc='', default=None, **kwargs)

Bases: dace.properties.Property

Custom Property type that represents a link to a data descriptor. Needs the SDFG to be passed as an argument to from_string and choices.

static choices(sdfg=None)
from_json(s, context=None)
static from_string(s, sdfg=None)
to_json(obj)
static to_string(obj)
typestring()
class dace.properties.DataclassProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Property that stores pydantic models or dataclasses.

from_json(d, sdfg=None)
static from_string(s)
to_json(obj)
static to_string(obj)
class dace.properties.DebugInfoProperty(**kwargs)

Bases: dace.properties.Property

Custom Property type for DebugInfo members.

allow_none
dtype
static from_string(s)
static to_string(di)
class dace.properties.DictProperty(key_type, value_type, *args, **kwargs)

Bases: dace.properties.Property

Property type for dictionaries.

from_json(data, sdfg=None)
static from_string(s)
to_json(d)
static to_string(d)
class dace.properties.LambdaProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that accepts a lambda function, with conversions to and from strings.

dtype
from_json(s, sdfg=None)
static from_string(s)
to_json(obj)
static to_string(obj)
class dace.properties.LibraryImplementationProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Property for choosing an implementation type for a library node. On the Python side it is a standard property, but can expand into a combo-box in DIODE.

typestring()
class dace.properties.ListProperty(element_type, *args, **kwargs)

Bases: dace.properties.Property

Property type for lists.

from_json(data, sdfg=None)
from_string(s)
to_json(l)
static to_string(l)
class dace.properties.OrderedDictProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Property type for ordered dicts

static from_json(obj, sdfg=None)
to_json(d)
class dace.properties.Property(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: object

Class implementing properties of DaCe objects that conform to strong typing, and allow conversion to and from strings to be edited.

static add_none_pair(dict_in)
allow_none
category
choices
default
desc
dtype
from_json
from_string
static get_property_element(object_with_properties, name)
getter
indirected
meta_to_json

Returns a function to export meta information (type, description, default value).

setter
to_json
to_string
typestring()
unmapped
exception dace.properties.PropertyError

Bases: Exception

Exception type for errors related to internal functionality of these properties.

class dace.properties.RangeProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type for dace.subsets.Range members.

dtype
static from_string(s)
static to_string(obj)
class dace.properties.ReferenceProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that represents a link to another SDFG object. Needs the SDFG to be passed as an argument to from_string.

static from_string(s, sdfg=None)
static to_string(obj)
class dace.properties.SDFGReferenceProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

from_json(obj, context=None)
to_json(obj)
class dace.properties.SetProperty(element_type, getter=None, setter=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, unmapped=False, allow_none=False, desc='', **kwargs)

Bases: dace.properties.Property

Property for a set of elements of one type, e.g., connectors.

dtype
from_json(l, sdfg=None)
static from_string(s)
to_json(l)
static to_string(l)
class dace.properties.ShapeProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that defines a shape.

dtype
from_json(d, sdfg=None)
static from_string(s)
to_json(obj)
static to_string(obj)
class dace.properties.SubsetProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that accepts any form of subset, and enables parsing strings into multiple types of subsets.

allow_none
dtype
from_json(val, sdfg=None)
static from_string(s)
to_json(val)
static to_string(val)
class dace.properties.SymbolicProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that accepts integers or Sympy expressions.

dtype
static from_string(s)
static to_string(obj)
class dace.properties.TransformationHistProperty(*args, **kwargs)

Bases: dace.properties.Property

Property type for transformation histories.

from_json(data, sdfg=None)
to_json(hist)
class dace.properties.TypeClassProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom property type for memory as defined in dace.types, e.g. dace.float32.

dtype
static from_json(obj, context=None)
static from_string(s)
to_json(obj)
static to_string(obj)
class dace.properties.TypeProperty(getter=None, setter=None, dtype=None, default=None, from_string=None, to_string=None, from_json=None, to_json=None, meta_to_json=None, choices=None, unmapped=False, allow_none=False, indirected=False, category='General', desc='')

Bases: dace.properties.Property

Custom Property type that finds a type according to the input string.

dtype
static from_json(obj, context=None)
static from_string(s)
dace.properties.indirect_properties(indirect_class, indirect_function, override=False)

A decorator for objects that provides indirect properties defined in another class.

dace.properties.indirect_property(cls, f, prop, override)
dace.properties.make_properties(cls)

A decorator for objects that adds support and checks for strongly-typed properties (which use the Property class).

dace.properties.set_property_from_string(prop, obj, string, sdfg=None, from_json=False)

Interface function that guarantees that a property will always be correctly set, if possible, by accepting all possible input arguments to from_string.

dace.serialize module

class dace.serialize.NumpySerializer

Bases: object

Helper class to load/store numpy arrays from JSON.

static from_json(json_obj, context=None)
static to_json(obj)
dace.serialize.all_properties_to_json(object_with_properties)
dace.serialize.dumps(*args, **kwargs)
dace.serialize.from_json(obj, context=None, known_type=None)
dace.serialize.get_serializer(type_name)
dace.serialize.loads(*args, context=None, **kwargs)
dace.serialize.serializable(cls)
dace.serialize.set_properties_from_json(object_with_properties, json_obj, context=None, ignore_properties=None)
dace.serialize.to_json(obj)

dace.sdfg module

dace.subsets module

class dace.subsets.Indices(indices)

Bases: dace.subsets.Subset

A subset of one element representing a single index in an N-dimensional data descriptor.

absolute_strides(global_shape)
at(i, strides)

Returns the absolute index (1D memory layout) of this subset at the given index tuple. For example, the range [2:10::2] at index 2 would return 6 (2+2*2). :param i: A tuple of the same dimensionality as subset.dims(). :param strides: The strides of the array we are subsetting. :return: Absolute 1D index at coordinate i.

bounding_box_size()
compose(other)
coord_at(i)

Returns the offseted coordinates of this subset at the given index tuple. For example, the range [2:10:2] at index 2 would return 6 (2+2*2). :param i: A tuple of the same dimensionality as subset.dims(). :return: Absolute coordinates for index i.

data_dims()
dims()
free_symbols

Returns a set of undefined symbols in this subset.

static from_json(obj, context=None)
static from_string(s)
intersection(other: dace.subsets.Indices)
intersects(other: dace.subsets.Indices)
max_element()
max_element_approx()
min_element()
min_element_approx()
ndrange()
num_elements()
num_elements_exact()
offset(other, negative, indices=None)
offset_new(other, negative, indices=None)
pop(dimensions)
pystr()
reorder(order)

Re-orders the dimensions in-place according to a permutation list. :param order: List or tuple of integers from 0 to self.dims() - 1,

indicating the desired order of the dimensions.
replace(repl_dict)
size()
size_exact()
squeeze(ignore_indices=None)
strides()
to_json()
unsqueeze(axes)
class dace.subsets.Range(ranges)

Bases: dace.subsets.Subset

Subset defined in terms of a fixed range.

absolute_strides(global_shape)

Returns a list of strides for advancing one element in each dimension. Size of the list is equal to data_dims(), which may be larger than dims() depending on tile sizes.

at(i, strides)

Returns the absolute index (1D memory layout) of this subset at the given index tuple.

For example, the range [2:10:2] at index 2 would return 6 (2+2*2).

Parameters:
  • i – A tuple of the same dimensionality as subset.dims() or subset.data_dims().
  • strides – The strides of the array we are subsetting.
Returns:

Absolute 1D index at coordinate i.

bounding_box_size()

Returns the size of a bounding box around this range.

compose(other)
coord_at(i)

Returns the offseted coordinates of this subset at the given index tuple.

For example, the range [2:10:2] at index 2 would return 6 (2+2*2).

Parameters:i – A tuple of the same dimensionality as subset.dims() or subset.data_dims().
Returns:Absolute coordinates for index i (length equal to data_dims(), may be larger than dims()).
data_dims()
static dim_to_string(d, t=1)
dims()
free_symbols

Returns a set of undefined symbols in this subset.

static from_array(array: dace.data.Data)

Constructs a range that covers the full array given as input.

static from_indices(indices: dace.subsets.Indices)
static from_json(obj, context=None)
static from_string(string)
intersects(other: dace.subsets.Range)
max_element()
max_element_approx()
min_element()
min_element_approx()
ndrange()
static ndslice_to_string(slice, tile_sizes=None)
static ndslice_to_string_list(slice, tile_sizes=None)
num_elements()
num_elements_exact()
offset(other, negative, indices=None)
offset_new(other, negative, indices=None)
pop(dimensions)
pystr()
reorder(order)

Re-orders the dimensions in-place according to a permutation list. :param order: List or tuple of integers from 0 to self.dims() - 1,

indicating the desired order of the dimensions.
replace(repl_dict)
size(for_codegen=False)

Returns the number of elements in each dimension.

size_exact()

Returns the number of elements in each dimension.

squeeze(ignore_indices=None)
strides()
string_list()
to_json()
unsqueeze(axes)
class dace.subsets.Subset

Bases: object

Defines a subset of a data descriptor.

at(i, strides)

Returns the absolute index (1D memory layout) of this subset at the given index tuple.

For example, the range [2:10:2] at index 2 would return 6 (2+2*2).

Parameters:
  • i – A tuple of the same dimensionality as subset.dims() or subset.data_dims().
  • strides – The strides of the array we are subsetting.
Returns:

Absolute 1D index at coordinate i.

coord_at(i)

Returns the offseted coordinates of this subset at the given index tuple.

For example, the range [2:10:2] at index 2 would return 6 (2+2*2).

Parameters:i – A tuple of the same dimensionality as subset.dims() or subset.data_dims().
Returns:Absolute coordinates for index i (length equal to data_dims(), may be larger than dims()).
covers(other)

Returns True if this subset covers (using a bounding box) another subset.

free_symbols

Returns a set of undefined symbols in this subset.

offset(other, negative, indices=None)
offset_new(other, negative, indices=None)
dace.subsets.bounding_box_union(subset_a: dace.subsets.Subset, subset_b: dace.subsets.Subset) → dace.subsets.Range

Perform union by creating a bounding-box of two subsets.

dace.subsets.intersects(subset_a: dace.subsets.Subset, subset_b: dace.subsets.Subset) → Optional[bool]

Returns True if two subsets intersect, False if they do not, or None if the answer cannot be determined.

Parameters:
  • subset_a – The first subset.
  • subset_b – The second subset.
Returns:

True if subsets intersect, False if not, None if indeterminate.

dace.subsets.union(subset_a: dace.subsets.Subset, subset_b: dace.subsets.Subset) → dace.subsets.Subset

Compute the union of two Subset objects. If the subsets are not of the same type, degenerates to bounding-box union. :param subset_a: The first subset. :param subset_b: The second subset. :return: A Subset object whose size is at least the union of the two

inputs. If union failed, returns None.

dace.symbolic module

class dace.symbolic.DaceSympyPrinter(arrays, *args, **kwargs)

Bases: sympy.printing.str.StrPrinter

Several notational corrections for integer math and C++ translation that sympy.printing.cxxcode does not provide.

class dace.symbolic.SymExpr(main_expr: Union[str, SymExpr], approx_expr: Union[str, SymExpr, None] = None)

Bases: object

Symbolic expressions with support for an overapproximation expression.

approx
expr
match(*args, **kwargs)
subs(repldict)
class dace.symbolic.SympyAwarePickler

Bases: _pickle.Pickler

Custom Pickler class that safely saves SymPy expressions with function definitions in expressions (e.g., int_ceil).

persistent_id(obj)
class dace.symbolic.SympyAwareUnpickler

Bases: _pickle.Unpickler

Custom Unpickler class that safely restores SymPy expressions with function definitions in expressions (e.g., int_ceil).

persistent_load(pid)
class dace.symbolic.SympyBooleanConverter

Bases: ast.NodeTransformer

Replaces boolean operations with the appropriate SymPy functions to avoid non-symbolic evaluation.

visit_BoolOp(node)
visit_Compare(node: _ast.Compare)
visit_UnaryOp(node)
dace.symbolic.contains_sympy_functions(expr)

Returns True if expression contains Sympy functions.

dace.symbolic.equalize_symbol(sym: sympy.core.expr.Expr) → sympy.core.expr.Expr

If a symbol or symbolic expressions has multiple symbols with the same name, it substitutes them with the last symbol (as they appear in s.free_symbols).

dace.symbolic.equalize_symbols(a: sympy.core.expr.Expr, b: sympy.core.expr.Expr) → Tuple[sympy.core.expr.Expr, sympy.core.expr.Expr]

If the 2 input expressions use different symbols but with the same name, it substitutes the symbols of the second expressions with those of the first expression.

dace.symbolic.evaluate(expr: Union[sympy.core.basic.Basic, int, float], symbols: Dict[Union[dace.symbolic.symbol, str], Union[int, float]]) → Union[int, float, numpy.number]

Evaluates an expression to a constant based on a mapping from symbols to values. :param expr: The expression to evaluate. :param symbols: A mapping of symbols to their values. :return: A constant value based on expr and symbols.

dace.symbolic.free_symbols_and_functions(expr: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr, str]) → Set[str]
dace.symbolic.inequal_symbols(a: Union[sympy.core.expr.Expr, Any], b: Union[sympy.core.expr.Expr, Any]) → bool

Compares 2 symbolic expressions and returns True if they are not equal.

dace.symbolic.is_sympy_userfunction(expr)

Returns True if the expression is a SymPy function.

dace.symbolic.issymbolic(value, constants=None)

Returns True if an expression is symbolic with respect to its contents and a given dictionary of constant values.

dace.symbolic.overapproximate(expr)

Takes a sympy expression and returns its maximal possible value in specific cases.

dace.symbolic.pystr_to_symbolic

Takes a Python string and converts it into a symbolic expression.

dace.symbolic.resolve_symbol_to_constant(symb, start_sdfg)

Tries to resolve a symbol to constant, by looking up into SDFG’s constants, following nested SDFGs hierarchy if necessary. :param symb: symbol to resolve to constant :param start_sdfg: starting SDFG :return: the constant value if the symbol is resolved, None otherwise

dace.symbolic.simplify
dace.symbolic.simplify_ext(expr)

An extended version of simplification with expression fixes for sympy. :param expr: A sympy expression. :return: Simplified version of the expression.

dace.symbolic.swalk(expr, enter_functions=False)

Walk over a symbolic expression tree (similar to ast.walk). Returns an iterator that yields the values and recurses into functions, if specified.

class dace.symbolic.symbol

Bases: sympy.core.symbol.Symbol

Defines a symbolic expression. Extends SymPy symbols with DaCe-related information.

add_constraints(constraint_list)
check_constraints(value)
constraints
default_assumptions = {}
get()
get_or_return(uninitialized_ret)
is_initialized()
s_currentsymbol = 0
set(value)
set_constraints(constraint_list)
dace.symbolic.symbol_name_or_value(val)

Returns the symbol name if symbol, otherwise the value as a string.

dace.symbolic.symbols_in_ast(tree)

Walks an AST and finds all names, excluding function names.

dace.symbolic.symlist(values)

Finds symbol dependencies of expressions.

dace.symbolic.sympy_divide_fix(expr)

Fix SymPy printouts where integer division such as “tid/2” turns into “.5*tid”.

dace.symbolic.sympy_intdiv_fix(expr)

Fix for SymPy printing out reciprocal values when they should be integral in “ceiling/floor” sympy functions.

dace.symbolic.sympy_numeric_fix(expr)

Fix for printing out integers as floats with “.00000000”. Converts the float constants in a given expression to integers.

dace.symbolic.sympy_to_dace(exprs, symbol_map=None)

Convert all sympy.Symbol`s to DaCe symbols, according to `symbol_map.

dace.symbolic.symstr(sym, arrayexprs: Optional[Set[str]] = None) → str

Convert a symbolic expression to a C++ compilable expression. :param sym: Symbolic expression to convert. :param arrayexprs: Set of names of arrays, used to convert SymPy

user-functions back to array expressions.
Returns:C++-compilable expression.
dace.symbolic.symtype(expr)

Returns the inferred symbol type from a symbolic expression.

dace.symbolic.symvalue(val)

Returns the symbol value if it is a symbol.

Module contents

class dace.DaceModule

Bases: module