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.

default_filename = '.dace.conf'
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.

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 nondefaults() → Dict[str, Any]
static save(path=None, all: bool = False)

Saves the current configuration to a file.

Parameters:
  • path – The file to save to. If unspecified, uses default configuration file.
  • all – If False, only saves non-default configuration entries. Otherwise saves all entries.
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.config.temporary_config()

Creates a context where all configuration options changed will be reset when the context exits.

with temporary_config():
Config.set(“testing”, “serialization”, value=True) Config.set(“optimizer”, “autooptimize”, value=True) foo()

dace.data module

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

Bases: dace.data.Data

Array data descriptor. This object represents a multi-dimensional data container in SDFGs that can be accessed and modified. The definition does not contain the actual array, but rather a description of how to construct it and how it should behave.

The array definition is flexible in terms of data allocation, it allows arbitrary multidimensional, potentially symbolic shapes (e.g., an array with size N+1 x M will have shape=(N+1, M)), of arbitrary data typeclasses (dtype). The physical data layout of the array is controlled by several properties:

  • The strides property determines the ordering and layout of the dimensions — it specifies how many elements in memory are skipped whenever one element in that dimension is advanced. For example, the contiguous dimension always has a stride of 1; a C-style MxN array will have strides (N, 1), whereas a FORTRAN-style array of the same size will have (1, M). Strides can be larger than the shape, which allows post-padding of the contents of each dimension.
  • The start_offset property is a number of elements to pad the beginning of the memory buffer with. This is used to ensure that a specific index is aligned as a form of pre-padding (that element may not necessarily be the first element, e.g., in the case of halo or “ghost cells” in stencils).
  • The total_size property determines how large the total allocation size is. Normally, it is the product of the shape elements, but if pre- or post-padding is involved it may be larger.
  • alignment provides alignment guarantees (in bytes) of the first element in the allocated array. This is used by allocators in the code generator to ensure certain addresses are expected to be aligned, e.g., for vectorization.
  • Lastly, a property called offset controls the logical access of the array, i.e., what would be the first element’s index after padding and alignment. This mimics a language feature prominent in scientific languages such as FORTRAN, where one could set an array to begin with 1, or any arbitrary index. By default this is set to zero.

To summarize with an example, a two-dimensional array with pre- and post-padding looks as follows:

[xxx][          |xx]
     [          |xx]
     [          |xx]
     [          |xx]
     ---------------
     [xxxxxxxxxxxxx]

shape = (4, 10)
strides = (12, 1)
start_offset = 3
total_size = 63   [= 3 + 12 * 5]
offset = (0, 0, 0)

Notice that the last padded row does not appear in strides, but is a consequence of total_size being larger.

Apart from memory layout, other properties of Array help the data-centric transformation infrastructure make decisions about the array. allow_conflicts states that warnings should not be printed if potential conflicted acceses (e.g., data races) occur. may_alias inhibits transformations that may assume that this array does not overlap with other arrays in the same context (e.g., function).

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.

optional

Specifies whether this array may have a value of None. If False, the array must not be None. If option is not set, it is inferred by other properties and the OptionalArrayInference pass.

properties()
sizes()
start_offset

Allocation offset elements for manual alignment (pre-padding)

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

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()
set_strides_from_layout(*dimensions, alignment: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr] = 1, only_first_aligned: bool = False)

Sets the absolute strides and total size of this data descriptor, according to the given dimension ordering and alignment. :param dimensions: A sequence of integers representing a permutation

of the descriptor’s dimensions.
Parameters:
  • alignment – Padding (in elements) at the end, ensuring stride is a multiple of this number. 1 (default) means no padding.
  • only_first_aligned – If True, only the first dimension is padded with alignment. Otherwise all dimensions are.
shape

Object property of type tuple

storage

Storage location

strides_from_layout(*dimensions, alignment: Union[sympy.core.basic.Basic, dace.symbolic.SymExpr] = 1, only_first_aligned: bool = False) → Tuple[Tuple[Union[sympy.core.basic.Basic, dace.symbolic.SymExpr]], Union[sympy.core.basic.Basic, dace.symbolic.SymExpr]]

Returns the absolute strides and total size of this data descriptor, according to the given dimension ordering and alignment. :param dimensions: A sequence of integers representing a permutation

of the descriptor’s dimensions.
Parameters:
  • alignment – Padding (in elements) at the end, ensuring stride is a multiple of this number. 1 (default) means no padding.
  • only_first_aligned – If True, only the first dimension is padded with alignment. Otherwise all dimensions are.
Returns:

A 2-tuple of (tuple of strides, total size).

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.Reference(*args, **kwargs)

Bases: dace.data.Array

Data descriptor that acts as a dynamic reference of another array. It can be used just like a regular array, except that it could be set to an arbitrary array or sub-array at runtime. To set a reference, connect another access node to it and use the “set” connector. In order to enable data-centric analysis and optimizations, avoid using References as much as possible.

as_array()
properties()
validate()

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

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
optional
properties()
sizes()
start_offset
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

optional
properties()
size_string()
sizes()
start_offset
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, no_custom_desc=False)

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

dace.data.find_new_name(name: str, existing_names: Sequence[str]) → str

Returns a name that matches the given name as a prefix, but does not already exist in the given existing name set. The behavior is typically to append an underscore followed by a unique (increasing) number. If the name does not already exist in the set, it is returned as-is. :param name: The given name to find. :param existing_names: The set of existing names. :return: A new name that is not in existing_names.

dace.data.make_array_from_descriptor(descriptor: dace.data.Array, original_array: Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]], None] = None, symbols: Optional[Dict[str, Any]] = None) → Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]

Creates an array that matches the given data descriptor, and optionally copies another array to it.

Parameters:
  • descriptor – The data descriptor to create the array from.
  • original_array – An optional array to fill the content of the return value with.
  • symbols – An optional symbol mapping between symbol names and their values. Used for creating arrays with symbolic sizes.
Returns:

A NumPy-compatible array (CuPy for GPU storage) with the specified size and strides.

dace.data.make_reference_from_descriptor(descriptor: dace.data.Array, original_array: ctypes.c_void_p, symbols: Optional[Dict[str, Any]] = None) → Union[Sequence[Sequence[Sequence[Sequence[Sequence[Any]]]]], numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype], Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]], Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]], Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]], Sequence[Sequence[Sequence[Sequence[numpy.typing._array_like._SupportsArray[numpy.dtype][numpy.dtype]]]]], bool, int, float, complex, str, bytes, Sequence[Union[bool, int, float, complex, str, bytes]], Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]], Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]], Sequence[Sequence[Sequence[Sequence[Union[bool, int, float, complex, str, bytes]]]]]]

Creates an array that matches the given data descriptor from the given pointer. Shares the memory with the argument (does not create a copy).

Parameters:
  • descriptor – The data descriptor to create the array from.
  • original_array – The array whose memory the return value would be used in.
  • symbols – An optional symbol mapping between symbol names and their values. Used for referencing arrays with symbolic sizes.
Returns:

A NumPy-compatible array (CuPy for GPU storage) with the specified size and strides, sharing memory with the pointer specified in original_array.

dace.dtypes module

A module that contains various DaCe type definitions.

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

Undefined = 6
register(*args)
class dace.dtypes.DataInstrumentationType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Types of data container instrumentation providers.

No_Instrumentation = 1
Restore = 3
Save = 2
Undefined = 4
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

An enumeration.

CPU = 1

Multi-core CPU

FPGA = 3

FPGA (Intel or Xilinx)

GPU = 2

GPU (AMD or NVIDIA)

Snitch = 4

Compute Cluster (RISC-V)

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

Bases: aenum.AutoNumberEnum

Types of instrumentation providers.

FPGA = 6
GPU_Events = 5
LIKWID_Counters = 4
No_Instrumentation = 1
PAPI_Counters = 3
Timer = 2
Undefined = 7
register(*args)
class dace.dtypes.Language(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available programming languages for SDFG tasklets.

CPP = 2
MLIR = 5
OpenCL = 3
Python = 1
SystemVerilog = 4
Undefined = 6
register(*args)
class dace.dtypes.OMPScheduleType(*args, **kwds)

Bases: aenum.AutoNumberEnum

Available OpenMP shedule types for Maps with CPU-Multicore schedule.

Default = 1

OpenMP library default

Dynamic = 3

Dynamic schedule

Guided = 4

Guided schedule

Static = 2

Static schedule

Undefined = 5
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

Undefined = 17
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 = 12
GPU_Default = 7

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

GPU_Device = 8

Kernel

GPU_Persistent = 11
GPU_ThreadBlock = 9

Thread-block code

GPU_ThreadBlock_Dynamic = 10

Allows rescheduling work within a block

MPI = 3

MPI processes

SVE_Map = 6

Arm SVE

Sequential = 2

Sequential code (single-thread)

Snitch = 13
Snitch_Multicore = 14
Undefined = 15
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

SVE_Register = 12

SVE register

Snitch_L2 = 14

External memory

Snitch_SSR = 15

Memory accessed by SSR streamer

Snitch_TCDM = 13

Cluster-private memory

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

Bases: aenum.AutoNumberEnum

Available tiling types in a StripMining transformation.

CeilRange = 2
Normal = 1
NumberOfTiles = 3
Undefined = 4
register(*args)
class dace.dtypes.Typeclasses(*args, **kwds)

Bases: aenum.AutoNumberEnum

An enumeration.

Undefined = 16
bool = 1
bool_ = 2
complex128 = 15
complex64 = 14
float16 = 11
float32 = 12
float64 = 13
int16 = 4
int32 = 5
int64 = 6
int8 = 3
register(*args)
uint16 = 8
uint32 = 9
uint64 = 10
uint8 = 7
class dace.dtypes.callback(return_types, *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()
cfunc_return_type() → dace.dtypes.typeclass

Returns the typeclass of the return value of the function call.

static from_json(json_obj, context=None)
get_trampoline(pyfunc, other_arguments)
is_scalar_function() → bool

Returns True if the callback is a function that returns a scalar value (or nothing). Scalar functions are the only ones that can be used within a dace.tasklet explicitly.

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.

class dace.dtypes.compiletime

Bases: object

Data descriptor type hint signalling that argument evaluation is deferred to call time.

Example usage:

@dace.program
def example(A: dace.float64[20], constant: dace.compiletime):
    if constant == 0:
        return A + 1
    else:
        return A + 2

In the above code, constant will be replaced with its value at call time during parsing.

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.

Parameters:obj – The given object.
Returns:True iff the object implements the array interface.
dace.dtypes.is_gpu_array(obj: Any) → bool

Returns True if an object is a GPU array, i.e., implements the __cuda_array_interface__ standard (supported by Numba, CuPy, PyTorch, etc.). If the interface is supported, pointers can be directly obtained using the _array_interface_ptr function.

Parameters:obj – The given object.
Returns:True iff the object implements the CUDA 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.

class dace.dtypes.opaque(typename)

Bases: dace.dtypes.typeclass

A data type for an opaque object, useful for C bindings/libnodes, i.e., MPI_Request.

as_ctypes()

Returns the ctypes version of the typeclass.

as_numpy_dtype()
static from_json(json_obj, context=None)
to_json()
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.ptrtocupy(ptr, inner_ctype, shape)
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.string

Bases: dace.dtypes.pointer

A specialization of the string data type to improve Python/generated code marshalling. Used internally when str types are given

static from_json(json_obj, context=None)
to_json()
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.enable()
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)
static from_memlet(memlet: dace.memlet.Memlet) → dace.memlet.Memlet
get_dst_subset(edge: dace.sdfg.graph.MultiConnectorEdge, state: dace.sdfg.state.SDFGState)
get_src_subset(edge: dace.sdfg.graph.MultiConnectorEdge, state: dace.sdfg.state.SDFGState)
get_stride(sdfg: dace.sdfg.sdfg.SDFG, map: dace.sdfg.nodes.Map, dim: int = -1) → dace.symbolic.SymExpr

Returns the stride of the underlying memory when traversing a Map.

Parameters:
  • sdfg – The SDFG in which the memlet resides.
  • map – The map in which the memlet resides.
  • dim – The dimension that is incremented. By default it is the innermost.
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: dace.sdfg.graph.MultiConnectorEdge[dace.memlet.Memlet][dace.memlet.Memlet], downwards: bool = True, parent: Optional[dace.memlet.MemletTree] = None, children: Optional[List[MemletTree]] = 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.

downwards

If True, this memlet tree points downwards (rooted at the source node).

leaves() → List[dace.sdfg.graph.MultiConnectorEdge[dace.memlet.Memlet][dace.memlet.Memlet]]

Returns a list of all the leaves of this MemletTree, i.e., the innermost edges.

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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.EnumProperty(dtype, *args, **kwargs)

Bases: dace.properties.Property

class dace.properties.LambdaProperty(getter=None, setter=None, dtype: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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 the editor.

typestring()
class dace.properties.ListProperty(element_type: T, *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.OptionalSDFGReferenceProperty(getter=None, setter=None, dtype: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

Bases: dace.properties.SDFGReferenceProperty

An SDFG reference property that defaults to None if cannot be deserialized.

from_json(obj, context=None)
class dace.properties.OrderedDictProperty(getter=None, setter=None, dtype: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

Bases: typing.Generic

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

optional
optional_condition
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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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: Type[T] = 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='', optional=False, optional_condition=<function Property.<lambda>>)

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)
class dace.serialize.SerializableObject(json_obj={}, typename=None)

Bases: object

static from_json(json_obj, context=None, typename=None)
json_obj = {}
to_json()
typename = None
dace.serialize.all_properties_to_json(object_with_properties)
dace.serialize.dump(*args, **kwargs)
dace.serialize.dumps(*args, **kwargs)
dace.serialize.from_json(obj, context=None, known_type=None)
dace.serialize.get_serializer(type_name)
dace.serialize.load(*args, context=None, **kwargs)
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: Sequence[int]) → List[int]

Adds zeroes to the subset, in the indices contained in axes.

The method is mostly used to restore subsets that had their zero-indices removed (i.e., squeezed subsets). Hence, the method is called ‘unsqueeze’.

Examples (initial subset, axes -> result subset, output): - [i], [0] -> [0, i], [0] - [i], [0, 1] -> [0, 0, i], [0, 1] - [i], [0, 2] -> [0, i, 0], [0, 2] - [i], [0, 1, 2, 3] -> [0, 0, 0, 0, i], [0, 1, 2, 3] - [i], [0, 2, 3, 4] -> [0, i, 0, 0, 0], [0, 2, 3, 4] - [i], [0, 1, 1] -> [0, 0, 0, i], [0, 1, 2]

Parameters:axes – The axes where the zero-indices should be added.
Returns:A list of the actual axes where the zero-indices were added.
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, offset=True)
strides()
string_list()
to_json()
unsqueeze(axes: Sequence[int]) → List[int]

Adds 0:1 ranges to the subset, in the indices contained in axes.

The method is mostly used to restore subsets that had their length-1 ranges removed (i.e., squeezed subsets). Hence, the method is called ‘unsqueeze’.

Examples (initial subset, axes -> result subset, output): - [i:i+10], [0] -> [0:1, i], [0] - [i:i+10], [0, 1] -> [0:1, 0:1, i:i+10], [0, 1] - [i:i+10], [0, 2] -> [0:1, i:i+10, 0:1], [0, 2] - [i:i+10], [0, 1, 2, 3] -> [0:1, 0:1, 0:1, 0:1, i:i+10], [0, 1, 2, 3] - [i:i+10], [0, 2, 3, 4] -> [0:1, i:i+10, 0:1, 0:1, 0:1], [0, 2, 3, 4] - [i:i+10], [0, 1, 1] -> [0:1, 0:1, 0:1, i:i+10], [0:1, 1, 2]

Parameters:axes – The axes where the 0:1 ranges should be added.
Returns:A list of the actual axes where the 0:1 ranges were added.
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.AND

Bases: sympy.core.function.Function

default_assumptions = {}
classmethod eval(x, y)

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

@classmethod
def eval(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg.is_zero: return S.Zero
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, Mul):
        coeff, terms = arg.as_coeff_Mul(rational=True)
        if coeff is not S.One:
            return cls(coeff) * cls(terms)
class dace.symbolic.BitwiseAnd

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.BitwiseNot

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.BitwiseOpConverter

Bases: ast.NodeTransformer

Replaces C/C++ bitwise operations with functions to avoid sympification to boolean operations.

visit_BinOp(node)
visit_UnaryOp(node)
class dace.symbolic.BitwiseOr

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.BitwiseXor

Bases: sympy.core.function.Function

default_assumptions = {}
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.Is

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.IsNot

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.LeftShift

Bases: sympy.core.function.Function

default_assumptions = {}
class dace.symbolic.OR

Bases: sympy.core.function.Function

default_assumptions = {}
classmethod eval(x, y)

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

@classmethod
def eval(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg.is_zero: return S.Zero
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, Mul):
        coeff, terms = arg.as_coeff_Mul(rational=True)
        if coeff is not S.One:
            return cls(coeff) * cls(terms)
class dace.symbolic.ROUND

Bases: sympy.core.function.Function

default_assumptions = {}
classmethod eval(x)

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

@classmethod
def eval(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg.is_zero: return S.Zero
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, Mul):
        coeff, terms = arg.as_coeff_Mul(rational=True)
        if coeff is not S.One:
            return cls(coeff) * cls(terms)
class dace.symbolic.RightShift

Bases: sympy.core.function.Function

default_assumptions = {}
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_Constant(node)
visit_NameConstant(node)
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.evaluate_optional_arrays(expr, sdfg)

Evaluate Is(…) and IsNot(…) expressions for arrays.

Parameters:
  • expr – The symbolic expression to evaluate.
  • sdfg – SDFG that contains arrays.
Returns:

A simplified version of the expression.

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.

class dace.symbolic.int_ceil

Bases: sympy.core.function.Function

default_assumptions = {}
classmethod eval(x, y)

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

@classmethod
def eval(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg.is_zero: return S.Zero
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, Mul):
        coeff, terms = arg.as_coeff_Mul(rational=True)
        if coeff is not S.One:
            return cls(coeff) * cls(terms)
class dace.symbolic.int_floor

Bases: sympy.core.function.Function

default_assumptions = {}
classmethod eval(x, y)

Returns a canonical form of cls applied to arguments args.

The eval() method is called when the class cls is about to be instantiated and it should return either some simplified instance (possible of some other class), or if the class cls should be unmodified, return None.

@classmethod
def eval(cls, arg):
    if arg is S.NaN:
        return S.NaN
    if arg.is_zero: return S.Zero
    if arg.is_positive: return S.One
    if arg.is_negative: return S.NegativeOne
    if isinstance(arg, Mul):
        coeff, terms = arg.as_coeff_Mul(rational=True)
        if coeff is not S.One:
            return cls(coeff) * cls(terms)
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.safe_replace(mapping: Dict[Union[sympy.core.basic.Basic, dace.symbolic.SymExpr, str], Union[sympy.core.basic.Basic, dace.symbolic.SymExpr, str]], replace_callback: Callable[[Dict[str, str]], None], value_as_string: bool = False) → None

Safely replaces symbolic expressions that may clash with each other via a two-step replacement. For example, the mapping {M: N, N: M} would be translated to replacing {N, M} -> __dacesym_{N, M} followed by __dacesym{N, M} -> {M, N}. :param mapping: The replacement dictionary. :param replace_callback: A callable function that receives a replacement

dictionary and performs the replacement (can be unsafe).
Parameters:value_as_string – Replacement values are replaced as strings rather than symbols.
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: _ast.AST)

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

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