dace.frontend package

Subpackages

Submodules

dace.frontend.operations module

class dace.frontend.operations.CompiledSDFGProfiler(repetitions=0, warmup=0, tqdm_leave=True, print_results=True)

Bases: object

A context manager that prints the time it takes to execute the generated SDFG code (excluding init and shutdown).

times: List[Tuple[SDFG, List[float]]]

The list of SDFGs and times for each SDFG called within the context.

dace.frontend.operations.detect_reduction_type(wcr_str, openmp=False)

Inspects a lambda function and tries to determine if it’s one of the built-in reductions that frameworks such as MPI can provide.

Parameters:
  • wcr_str – A Python string representation of the lambda function.

  • openmp – Detect additional OpenMP reduction types.

Returns:

dtypes.ReductionType if detected, dtypes.ReductionType.Custom if not detected, or None if no reduction is found.

dace.frontend.operations.elementwise(func, in_array, out_array=None)

Applies a function to each element of the array

Parameters:
  • in_array – array to apply to.

  • out_array – output array to write the result to. If None, a new array will be returned

  • func – lambda function to apply to each element.

Returns:

new array with the lambda applied to each element

dace.frontend.operations.is_op_associative(wcr_str)

Inspects a custom lambda function and tries to determine whether it is symbolically associative (disregarding data type).

Parameters:

wcr_str – A string in Python representing a lambda function.

Returns:

True if associative, False if not, None if cannot be determined.

dace.frontend.operations.is_op_commutative(wcr_str)

Inspects a custom lambda function and tries to determine whether it is symbolically commutative (disregarding data type).

Parameters:

wcr_str – A string in Python representing a lambda function.

Returns:

True if commutative, False if not, None if cannot be determined.

dace.frontend.operations.reduce(op, in_array, out_array=None, axis=None, identity=None)

Reduces an array according to a binary operation op, starting with initial value identity, over the given axis (or axes if axis is a list), to out_array.

Requires out_array with len(axis) dimensions less than in_array, or a scalar if axis is None.

Parameters:
  • op – binary operation to use for reduction.

  • in_array – array to reduce.

  • out_array – output array to write the result to. If None, a new array will be returned.

  • axis – the axis or axes to reduce over. If None, all axes will be reduced.

  • identity – intial value for the reduction. If None, uses value stored in output.

Returns:

None if out_array is given, or the newly created out_array if out_array is None.

Module contents