From 5e5815b1b26f12248b064cbb9792991f4f46fc8d Mon Sep 17 00:00:00 2001 From: Tal Ben-Nun Date: Thu, 6 Jan 2022 16:57:46 +0100 Subject: [PATCH] Coarsening -> Simplification --- .github/workflows/general-ci.yml | 16 ++++---- README.md | 2 +- dace/config_schema.yml | 6 +-- dace/frontend/python/README.md | 6 +-- dace/frontend/python/newast.py | 14 +++---- dace/frontend/python/parser.py | 35 +++++++++-------- dace/frontend/tensorflow/tensorflow.py | 2 +- dace/libraries/blas/nodes/gemv.py | 6 +-- dace/sdfg/nodes.py | 2 +- dace/sdfg/sdfg.py | 15 ++++---- dace/transformation/__init__.py | 2 +- dace/transformation/auto/auto_optimize.py | 14 +++---- dace/transformation/dataflow/gpu_transform.py | 2 +- dace/transformation/dataflow/merge_arrays.py | 6 +-- .../dataflow/prune_connectors.py | 4 +- .../dataflow/redundant_array.py | 12 +++--- .../interstate/gpu_transform_sdfg.py | 10 ++--- .../interstate/multistate_inline.py | 2 +- .../transformation/interstate/sdfg_nesting.py | 3 +- .../interstate/state_elimination.py | 6 +-- .../transformation/interstate/state_fusion.py | 2 +- dace/transformation/transformation.py | 28 +++++++------- samples/distributed/explicit/jacobi_2d.py | 6 +-- samples/distributed/explicit/poly_gemm.py | 4 +- samples/distributed/explicit/poly_gemm_bc.py | 4 +- samples/distributed/explicit/poly_gesummv.py | 4 +- samples/distributed/implicit/poly_gemm.py | 8 ++-- samples/distributed/implicit/poly_gesummv.py | 8 ++-- samples/instrumentation/tuning.py | 2 +- samples/sdfg_api/control_flow.py | 2 +- samples/sdfg_api/jagged_arrays.py | 2 +- samples/sdfg_api/state_fusion.py | 2 +- tests/buffer_tiling_test.py | 2 +- tests/chained_nested_tasklet_test.py | 2 +- tests/codegen/allocation_lifetime_test.py | 6 +-- tests/codegen/control_flow_detection_test.py | 2 +- tests/codegen/sve/common.py | 2 +- tests/codegen/transient_same_name_test.py | 2 +- tests/control_flow_test.py | 4 +- tests/cuda_test.sh | 2 +- tests/enumerator_test.py | 6 +-- tests/halfvec_cudatest.py | 2 +- tests/inline_external_edges_test.py | 2 +- tests/inline_noncontig_dim_test.py | 4 +- tests/inline_nonsink_access_test.py | 4 +- tests/inline_symbol_test.py | 2 +- tests/inlining_test.py | 10 ++--- tests/instrumentation_test.py | 2 +- tests/library/linalg_cholesky_test.py | 2 +- tests/library/linalg_inv_test.py | 2 +- tests/library/linalg_solve_test.py | 2 +- tests/mapreduce_test.py | 4 +- tests/mpi_test.sh | 2 +- tests/nest_subgraph_test.py | 2 +- tests/nested_symbol_test.py | 8 ++-- tests/npbench/atax_test.py | 2 +- tests/npbench/cholesky_test.py | 2 +- tests/npbench/covariance_test.py | 4 +- tests/npbench/fdtd_2d_test.py | 2 +- tests/npbench/floyd_warshall_test.py | 2 +- tests/npbench/jacobi_2d_test.py | 2 +- tests/npbench/lu_test.py | 2 +- tests/npbench/nussinov_test.py | 4 +- tests/npbench/syrk_test.py | 2 +- tests/numpy/copies_and_views_test.py | 2 +- tests/numpy/rgf_exhaustivetest.py | 6 +-- tests/python_frontend/augassign_wcr_test.py | 10 ++--- .../callback_autodetect_test.py | 2 +- .../constant_and_keyword_args_test.py | 4 +- .../multiple_nested_sdfgs_test.py | 2 +- .../python_frontend/test_propagate_strict.py | 6 +-- tests/schedule_inference_test.py | 2 +- tests/sdfg/free_symbols_test.py | 6 +-- tests/sdfg/scalar_to_symbol_test.py | 38 +++++++++---------- tests/state_propagation_test.py | 12 +++--- tests/strict_after_load_test.py | 4 +- tests/symbol_dependent_transients_test.py | 20 +++++----- tests/symbol_mapping_replace_test.py | 2 +- tests/tile_twice_test.py | 2 +- tests/transformations/apply_to_test.py | 8 ++-- .../deduplicate_access_test.py | 10 ++--- .../transformations/double_buffering_test.py | 2 +- .../transformations/loop_manipulation_test.py | 12 +++--- tests/transformations/map_collapse_test.py | 4 +- .../transformations/map_distribution_test.py | 2 +- tests/transformations/map_interchange_test.py | 2 +- .../mapfusion_data_races_test.py | 2 +- tests/transformations/mapfusion_fpga_test.py | 4 +- tests/transformations/mapfusion_test.py | 8 ++-- .../nested_copies_among_connectors.py | 12 +++--- .../redundant_copy_data_races_test.py | 2 +- tests/transformations/redundant_copy_test.py | 14 +++---- .../redundant_reshape_views_test.py | 6 +-- .../transformations/redundant_slices_test.py | 8 ++-- .../transformations/state_elimination_test.py | 4 +- tests/transformations/state_fusion_test.py | 10 ++--- .../state_fusion_twowrites_test.py | 2 +- .../subgraph_fusion/complex_test.py | 2 +- .../create_out_transient_test.py | 4 +- .../subgraph_fusion/disjoint_test.py | 6 +-- .../invariant_dimension_test.py | 2 +- .../subgraph_fusion/parallel_test.py | 2 +- .../subgraph_fusion/reduction_fuse_test.py | 2 +- .../subgraph_fusion/reduction_test.py | 4 +- .../subgraph_fusion/smax_test.py | 6 +-- .../subgraph_fusion/tiling_pool_test.py | 4 +- .../subgraph_fusion/tiling_stencil_test.py | 4 +- .../sve/sve_vectorization_test.py | 16 ++++---- .../sve/vector_inference_test.py | 18 ++++----- tests/transformations/tasklet_fusion_test.py | 6 +-- .../tiling_number_of_tiles_test.py | 2 +- .../tiling_vectorization_test.py | 2 +- tests/transformations/vectorization_test.py | 4 +- .../view_redundant_array_test.py | 8 ++-- tests/transformations/warp_tiling_test.py | 4 +- tutorials/spmv.ipynb | 8 ++-- tutorials/transformations.ipynb | 16 ++++---- 117 files changed, 344 insertions(+), 341 deletions(-) diff --git a/.github/workflows/general-ci.yml b/.github/workflows/general-ci.yml index 463248ec72..afa7097b8f 100644 --- a/.github/workflows/general-ci.yml +++ b/.github/workflows/general-ci.yml @@ -12,7 +12,7 @@ jobs: strategy: matrix: python-version: [3.7,'3.10'] - coarsening: [0,1,autoopt] + simplify: [0,1,autoopt] steps: - uses: actions/checkout@v2 @@ -43,12 +43,12 @@ jobs: export DACE_testing_serialization=1 export DACE_cache=unique export DACE_optimizer_interface=" " - if [ "${{ matrix.coarsening }}" = "autoopt" ]; then - export DACE_optimizer_automatic_dataflow_coarsening=1 + if [ "${{ matrix.simplify }}" = "autoopt" ]; then + export DACE_optimizer_automatic_simplification=1 export DACE_optimizer_autooptimize=1 echo "Auto-optimization heuristics" else - export DACE_optimizer_automatic_dataflow_coarsening=${{ matrix.coarsening }} + export DACE_optimizer_automatic_simplification=${{ matrix.simplify }} fi pytest -n auto --cov-report=xml --cov=dace --tb=short -m "not gpu and not verilator and not tensorflow and not mkl and not sve and not papi and not mlir and not lapack and not fpga and not mpi" codecov @@ -59,12 +59,12 @@ jobs: export DACE_testing_serialization=1 export DACE_cache=unique export DACE_optimizer_interface=" " - if [ "${{ matrix.coarsening }}" = "autoopt" ]; then - export DACE_optimizer_automatic_dataflow_coarsening=1 + if [ "${{ matrix.simplify }}" = "autoopt" ]; then + export DACE_optimizer_automatic_simplification=1 export DACE_optimizer_autooptimize=1 echo "Auto-optimization heuristics" else - export DACE_optimizer_automatic_dataflow_coarsening=${{ matrix.coarsening }} + export DACE_optimizer_automatic_simplification=${{ matrix.simplify }} fi pytest -n 1 --cov-report=xml --cov=dace --tb=short -m "lapack" codecov @@ -74,7 +74,7 @@ jobs: export NOSTATUSBAR=1 export DACE_testing_serialization=1 export DACE_cache=single - export DACE_optimizer_automatic_dataflow_coarsening=${{ matrix.coarsening }} + export DACE_optimizer_automatic_simplification=${{ matrix.simplify }} export PYTHON_BINARY="coverage run --source=dace --parallel-mode" ./tests/polybench_test.sh ./tests/xform_test.sh diff --git a/README.md b/README.md index c2413ed2ec..bb276cefa6 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,7 @@ FPGA programming: SDFG interactive transformation: * `DACE_optimizer_transform_on_call` (default: False): Uses the transformation command line interface every time a `@dace` function is called. * `DACE_optimizer_interface` (default: `dace.transformation.optimizer.SDFGOptimizer`): Controls the SDFG optimization process if `transform_on_call` is enabled. By default, uses the transformation command line interface. - * `DACE_optimizer_automatic_dataflow_coarsening` (default: True): If False, skips automatic dataflow coarsening in the Python frontend (see transformations tutorial for more information). + * `DACE_optimizer_automatic_simplification` (default: True): If False, skips automatic simplification in the Python frontend (see transformations tutorial for more information). Profiling: * `DACE_profiling` (default: False): Enables profiling measurement of the DaCe program runtime in milliseconds. Produces a log file and prints out median runtime. diff --git a/dace/config_schema.yml b/dace/config_schema.yml index 94f1dd79f6..d5800ea576 100644 --- a/dace/config_schema.yml +++ b/dace/config_schema.yml @@ -86,12 +86,12 @@ required: title: Save intermediate SDFGs description: Save SDFG files after every transformation. - automatic_dataflow_coarsening: + automatic_simplification: type: bool default: true - title: Automatic dataflow coarsening + title: Automatic SDFG simplification description: > - Automatically performs dataflow coarsening on programs. + Automatically performs SDFG simplification on programs. detect_control_flow: type: bool diff --git a/dace/frontend/python/README.md b/dace/frontend/python/README.md index fd6719c4e5..32c49a5719 100644 --- a/dace/frontend/python/README.md +++ b/dace/frontend/python/README.md @@ -44,9 +44,9 @@ There is also upcoming support for NumPy ufuncs. You may preview ufunc support w ## Known Issues -### Issues when automatic dataflow coarsening is enabled +### Issues when automatic simplification is enabled -When automatic dataflow coarsening is enabled, SDFGs created using the +When automatic simplification is enabled, SDFGs created using the Python-Frontend are automatically transformed using: - InlineSDFG - EndStateElimination @@ -67,4 +67,4 @@ ranges, leading to RW/WR/WW dependencies, InlineSDFG and StateFusion may violate - When there are sequential dependencies between statements due to updating a loop variable, StateFusion may erroneously lead to concurrent execution of those statements (see [#315](https://github.com/spcl/dace/issues/315)). -Temporary workaround: Disable the automatic dataflow coarsening flag in the configuration file `.dace.conf`. +Temporary workaround: Disable the automatic simplification pass flag in the configuration file `.dace.conf`. diff --git a/dace/frontend/python/newast.py b/dace/frontend/python/newast.py index a6c47c6a55..043d4a3b49 100644 --- a/dace/frontend/python/newast.py +++ b/dace/frontend/python/newast.py @@ -138,14 +138,14 @@ def parse_dace_program(name: str, argtypes: Dict[str, data.Data], constants: Dict[str, Any], closure: SDFGClosure, - coarsen: Optional[bool] = None, + simplify: Optional[bool] = None, save=True) -> SDFG: """ Parses a `@dace.program` function into an SDFG. :param src_ast: The AST of the Python program to parse. :param visitor: A ProgramVisitor object returned from ``preprocess_dace_program``. :param closure: An object that contains the @dace.program closure. - :param coarsen: If True, dataflow coarsening will be performed. + :param simplify: If True, simplification pass will be performed. :param save: If True, saves source mapping data for this SDFG. :return: A 2-tuple of SDFG and its reduced (used) closure. """ @@ -158,7 +158,7 @@ def parse_dace_program(name: str, scope_arrays=argtypes, scope_vars={}, closure=closure, - coarsen=coarsen) + simplify=simplify) sdfg, _, _, _ = visitor.parse_program(preprocessed_ast.preprocessed_ast.body[0]) sdfg.set_sourcecode(preprocessed_ast.src, 'python') @@ -959,7 +959,7 @@ def __init__(self, closure: SDFGClosure = None, nested: bool = False, tmp_idx: int = 0, - coarsen: Optional[bool] = None): + simplify: Optional[bool] = None): """ ProgramVisitor init method Arguments: @@ -972,7 +972,7 @@ def __init__(self, scope_arrays {Dict[str, data.Data]} -- Scope arrays scope_vars {Dict[str, str]} -- Scope variables closure {SDFGClosure} -- The closure of this program - coarsen {bool} -- Whether to apply dataflow coarsening after parsing nested dace programs + simplify {bool} -- Whether to apply simplification pass after parsing nested dace programs Keyword Arguments: nested {bool} -- True, if SDFG is nested (default: {False}) @@ -991,7 +991,7 @@ def __init__(self, self.globals = global_vars self.closure = closure self.nested = nested - self.coarsen = coarsen + self.simplify = simplify # Keeps track of scope arrays, numbers, variables and accesses self.scope_arrays = OrderedDict() @@ -3248,7 +3248,7 @@ def _parse_sdfg_call(self, funcname: str, func: Union[SDFG, SDFGConvertible], no if isinstance(fcopy, DaceProgram): fcopy.signature = copy.deepcopy(func.signature) - sdfg = fcopy.to_sdfg(*fargs, **fkwargs, coarsen=self.coarsen, save=False) + sdfg = fcopy.to_sdfg(*fargs, **fkwargs, simplify=self.simplify, save=False) else: sdfg = fcopy.__sdfg__(*fargs, **fkwargs) diff --git a/dace/frontend/python/parser.py b/dace/frontend/python/parser.py index 2590aeb69e..8a643f0b27 100644 --- a/dace/frontend/python/parser.py +++ b/dace/frontend/python/parser.py @@ -181,7 +181,7 @@ def _auto_optimize(self, sdfg: SDFG, symbols: Dict[str, int] = None) -> SDFG: from dace.transformation.auto import auto_optimize as autoopt return autoopt.auto_optimize(sdfg, self.device, symbols=symbols) - def to_sdfg(self, *args, coarsen=None, save=False, validate=False, use_cache=False, **kwargs) -> SDFG: + def to_sdfg(self, *args, simplify=None, save=False, validate=False, use_cache=False, **kwargs) -> SDFG: """ Parses the DaCe function into an SDFG. """ if use_cache: # Update global variables with current closure @@ -204,7 +204,7 @@ def to_sdfg(self, *args, coarsen=None, save=False, validate=False, use_cache=Fal entry = self._cache.get(cachekey) return entry.sdfg - sdfg = self._parse(args, kwargs, coarsen=coarsen, save=save, validate=validate) + sdfg = self._parse(args, kwargs, simplify=simplify, save=save, validate=validate) if use_cache: # Add to cache @@ -213,11 +213,11 @@ def to_sdfg(self, *args, coarsen=None, save=False, validate=False, use_cache=Fal return sdfg def __sdfg__(self, *args, **kwargs) -> SDFG: - return self._parse(args, kwargs, coarsen=None, save=False, validate=False) + return self._parse(args, kwargs, simplify=None, save=False, validate=False) - def compile(self, *args, coarsen=None, save=False, **kwargs): + def compile(self, *args, simplify=None, save=False, **kwargs): """ Convenience function that parses and compiles a DaCe program. """ - sdfg = self._parse(args, kwargs, coarsen=coarsen, save=save) + sdfg = self._parse(args, kwargs, simplify=simplify, save=save) # Invoke auto-optimization as necessary if Config.get_bool('optimizer', 'autooptimize') or self.auto_optimize: @@ -383,7 +383,7 @@ def __call__(self, *args, **kwargs): return result - def _parse(self, args, kwargs, coarsen=None, save=False, validate=False) -> SDFG: + def _parse(self, args, kwargs, simplify=None, save=False, validate=False) -> SDFG: """ Try to parse a DaceProgram object and return the `dace.SDFG` object that corresponds to it. @@ -391,7 +391,7 @@ def _parse(self, args, kwargs, coarsen=None, save=False, validate=False) -> SDFG decorator). :param args: The given arguments to the function. :param kwargs: The given keyword arguments to the function. - :param coarsen: Whether to apply dataflow coarsening or not (None + :param simplify: Whether to apply simplification pass or not (None uses configuration-defined value). :param save: If True, saves the generated SDFG to ``_dacegraphs/program.sdfg`` after parsing. @@ -403,18 +403,18 @@ def _parse(self, args, kwargs, coarsen=None, save=False, validate=False) -> SDFG from dace.transformation import helpers as xfh # Obtain DaCe program as SDFG - sdfg, cached = self._generate_pdp(args, kwargs, coarsen=coarsen) + sdfg, cached = self._generate_pdp(args, kwargs, simplify=simplify) - # Apply dataflow coarsening automatically - if not cached and (coarsen == True or - (coarsen is None and Config.get_bool('optimizer', 'automatic_dataflow_coarsening'))): + # Apply simplification pass automatically + if not cached and (simplify == True or + (simplify is None and Config.get_bool('optimizer', 'automatic_simplification'))): # Promote scalars to symbols as necessary promoted = scal2sym.promote_scalars_to_symbols(sdfg) if Config.get_bool('debugprint') and len(promoted) > 0: print('Promoted scalars {%s} to symbols.' % ', '.join(p for p in sorted(promoted))) - sdfg.coarsen_dataflow() + sdfg.simplify() # Split back edges with assignments and conditions to allow richer # control flow detection in code generation @@ -619,11 +619,11 @@ def load_precompiled_sdfg(self, path: str, *args, **kwargs) -> None: # Update SDFG cache with the SDFG and compiled version self._cache.add(cachekey, csdfg.sdfg, csdfg) - def _generate_pdp(self, args, kwargs, coarsen=None) -> SDFG: + def _generate_pdp(self, args, kwargs, simplify=None) -> SDFG: """ Generates the parsed AST representation of a DaCe program. :param args: The given arguments to the program. :param kwargs: The given keyword arguments to the program. - :param coarsen: Whether to apply dataflow coarsening when parsing + :param simplify: Whether to apply simplification pass when parsing nested dace programs. :return: A 2-tuple of (parsed SDFG object, was the SDFG retrieved from cache). @@ -690,7 +690,12 @@ def _generate_pdp(self, args, kwargs, coarsen=None) -> SDFG: cached = True else: cached = False - sdfg = newast.parse_dace_program(self.name, parsed_ast, argtypes, self.dec_kwargs, closure, coarsen=coarsen) + sdfg = newast.parse_dace_program(self.name, + parsed_ast, + argtypes, + self.dec_kwargs, + closure, + simplify=simplify) # Set SDFG argument names, filtering out constants sdfg.arg_names = [a for a in self.argnames if a in argtypes] diff --git a/dace/frontend/tensorflow/tensorflow.py b/dace/frontend/tensorflow/tensorflow.py index 922b550132..1bfcf10586 100644 --- a/dace/frontend/tensorflow/tensorflow.py +++ b/dace/frontend/tensorflow/tensorflow.py @@ -329,7 +329,7 @@ def train( print("Adding connectors") self.graph.fill_scope_connectors() - # self.graph.coarsen_dataflow(validate=False) + # self.graph.simplify(validate=False) if gpu: self.graph.apply_gpu_transformations() diff --git a/dace/libraries/blas/nodes/gemv.py b/dace/libraries/blas/nodes/gemv.py index a9e4eedf7e..e10bbeb714 100644 --- a/dace/libraries/blas/nodes/gemv.py +++ b/dace/libraries/blas/nodes/gemv.py @@ -832,10 +832,10 @@ def _gemTv_pblas(_A: dtype[m, n], _x: dtype[m], _y: dtype[n]): # in ValueError: Node type "BlockCyclicScatter" not supported for # promotion if transA: - sdfg = _gemTv_pblas.to_sdfg(coarsen=False) + sdfg = _gemTv_pblas.to_sdfg(simplify=False) else: - sdfg = _gemNv_pblas.to_sdfg(coarsen=False) - sdfg.coarsen_dataflow() + sdfg = _gemNv_pblas.to_sdfg(simplify=False) + sdfg.simplify() return sdfg diff --git a/dace/sdfg/nodes.py b/dace/sdfg/nodes.py index f514fed3f0..a13df81c04 100644 --- a/dace/sdfg/nodes.py +++ b/dace/sdfg/nodes.py @@ -489,7 +489,7 @@ class NestedSDFG(CodeNode): no_inline = Property(dtype=bool, desc="If True, this nested SDFG will not be inlined during " - "dataflow coarsening", + "simplification", default=False) unique_name = Property(dtype=str, desc="Unique name of the SDFG", default="") diff --git a/dace/sdfg/sdfg.py b/dace/sdfg/sdfg.py index 92485db0e1..7f07db71bf 100644 --- a/dace/sdfg/sdfg.py +++ b/dace/sdfg/sdfg.py @@ -1896,18 +1896,17 @@ def is_valid(self) -> bool: def apply_strict_transformations(self, validate=True, validate_all=False): """ - This method is DEPRECATED in favor of ``coarsen_dataflow``. + This method is DEPRECATED in favor of ``simplify``. Applies safe transformations (that will surely increase the performance) on the SDFG. For example, this fuses redundant states (safely) and removes redundant arrays. B{Note:} This is an in-place operation on the SDFG. """ - warnings.warn('SDFG.apply_strict_transformations is deprecated, use SDFG.coarsen_dataflow instead.', - DeprecationWarning) - return self.coarsen_dataflow(validate, validate_all) + warnings.warn('SDFG.apply_strict_transformations is deprecated, use SDFG.simplify instead.', DeprecationWarning) + return self.simplify(validate, validate_all) - def coarsen_dataflow(self, validate=True, validate_all=False): + def simplify(self, validate=True, validate_all=False): """ Applies safe transformations (that will surely increase the performance) on the SDFG. For example, this fuses redundant states (safely) and removes redundant arrays. @@ -1919,7 +1918,7 @@ def coarsen_dataflow(self, validate=True, validate_all=False): from dace.transformation.dataflow import RedundantReadSlice, RedundantWriteSlice from dace.sdfg import utils as sdutil # This is imported here to avoid an import loop - from dace.transformation.transformation import coarsening_transformations + from dace.transformation.transformation import simplification_transformations # First step is to apply multi-state inline, before any state fusion can # occur @@ -1930,7 +1929,7 @@ def coarsen_dataflow(self, validate=True, validate_all=False): validate=validate, permissive=False, validate_all=validate_all) - self.apply_transformations_repeated(coarsening_transformations(), + self.apply_transformations_repeated(simplification_transformations(), validate=validate, permissive=False, validate_all=validate_all) @@ -2141,7 +2140,7 @@ def apply_gpu_transformations(self, states=None, validate=True, validate_all=Fal generate GPU code. :note: It is recommended to apply redundant array removal transformation after this transformation. Alternatively, - you can coarsen_dataflow() after this transformation. + you can simplify() after this transformation. :note: This is an in-place operation on the SDFG. """ # Avoiding import loops diff --git a/dace/transformation/__init__.py b/dace/transformation/__init__.py index ab6fdf0be9..bd5e42ce8a 100644 --- a/dace/transformation/__init__.py +++ b/dace/transformation/__init__.py @@ -1,2 +1,2 @@ -from .transformation import (coarsening_transformations, SingleStateTransformation, MultiStateTransformation, +from .transformation import (simplification_transformations, SingleStateTransformation, MultiStateTransformation, SubgraphTransformation, ExpandTransformation) diff --git a/dace/transformation/auto/auto_optimize.py b/dace/transformation/auto/auto_optimize.py index 9c6a6e78b3..948b110d8f 100644 --- a/dace/transformation/auto/auto_optimize.py +++ b/dace/transformation/auto/auto_optimize.py @@ -54,7 +54,7 @@ def greedy_fuse(graph_or_subgraph: GraphViewType, debugprint = config.Config.get_bool('debugprint') if isinstance(graph_or_subgraph, SDFG): # If we have an SDFG, recurse into graphs - graph_or_subgraph.coarsen_dataflow(validate_all=validate_all) + graph_or_subgraph.simplify(validate_all=validate_all) # MapFusion for trivial cases graph_or_subgraph.apply_transformations_repeated(MapFusion, validate_all=validate_all) # recurse into graphs @@ -441,7 +441,7 @@ def auto_optimize(sdfg: SDFG, """ Runs a basic sequence of transformations to optimize a given SDFG to decent performance. In particular, performs the following: - * Dataflow coarsening + * Simplify * Auto-parallelization (loop-to-map) * Greedy application of SubgraphFusion * Tiled write-conflict resolution (MapTiling -> AccumulateTransient) @@ -462,11 +462,11 @@ def auto_optimize(sdfg: SDFG, """ debugprint = config.Config.get_bool('debugprint') - # Dataflow coarsening and loop parallelization + # Simplification and loop parallelization transformed = True sdfg.apply_transformations_repeated(TrivialMapElimination, validate=validate, validate_all=validate_all) while transformed: - sdfg.coarsen_dataflow(validate=False, validate_all=validate_all) + sdfg.simplify(validate=False, validate_all=validate_all) for s in sdfg.sdfg_list: xfh.split_interstate_edges(s) l2ms = sdfg.apply_transformations_repeated((LoopToMap, RefineNestedAccess), @@ -475,17 +475,17 @@ def auto_optimize(sdfg: SDFG, transformed = l2ms > 0 # Collapse maps and eliminate trivial dimensions - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated(MapCollapse, validate=False, validate_all=validate_all) # Apply GPU transformations and set library node implementations if device == dtypes.DeviceType.GPU: sdfg.apply_gpu_transformations() - sdfg.coarsen_dataflow() + sdfg.simplify() # fuse subgraphs greedily - sdfg.coarsen_dataflow() + sdfg.simplify() greedy_fuse(sdfg, device=device, validate_all=validate_all) diff --git a/dace/transformation/dataflow/gpu_transform.py b/dace/transformation/dataflow/gpu_transform.py index b36a7f1639..7e49bf0c44 100644 --- a/dace/transformation/dataflow/gpu_transform.py +++ b/dace/transformation/dataflow/gpu_transform.py @@ -103,4 +103,4 @@ def apply(self, graph: SDFGState, sdfg: SDFG): transformation.apply(nsdfg_node.sdfg, nsdfg_node.sdfg) # Inline back as necessary - sdfg.coarsen_dataflow() + sdfg.simplify() diff --git a/dace/transformation/dataflow/merge_arrays.py b/dace/transformation/dataflow/merge_arrays.py index b2bc52f88d..b415f9427d 100644 --- a/dace/transformation/dataflow/merge_arrays.py +++ b/dace/transformation/dataflow/merge_arrays.py @@ -6,7 +6,7 @@ from dace.sdfg.propagation import propagate_memlet -class InMergeArrays(transformation.SingleStateTransformation, transformation.DataflowCoarseningTransformation): +class InMergeArrays(transformation.SingleStateTransformation, transformation.SimplifyPass): """ Merge duplicate arrays connected to the same scope entry. """ array1 = transformation.PatternNode(nodes.AccessNode) @@ -109,7 +109,7 @@ def apply(self, graph, sdfg): union_inner_edges=True) -class OutMergeArrays(transformation.SingleStateTransformation, transformation.DataflowCoarseningTransformation): +class OutMergeArrays(transformation.SingleStateTransformation, transformation.SimplifyPass): """ Merge duplicate arrays connected to the same scope entry. """ array1 = transformation.PatternNode(nodes.AccessNode) @@ -208,7 +208,7 @@ def apply(self, graph, sdfg): union_inner_edges=True) -class MergeSourceSinkArrays(transformation.SingleStateTransformation, transformation.DataflowCoarseningTransformation): +class MergeSourceSinkArrays(transformation.SingleStateTransformation, transformation.SimplifyPass): """ Merge duplicate arrays that are source/sink nodes. """ array1 = transformation.PatternNode(nodes.AccessNode) diff --git a/dace/transformation/dataflow/prune_connectors.py b/dace/transformation/dataflow/prune_connectors.py index 1dd4717936..5e4f82d201 100644 --- a/dace/transformation/dataflow/prune_connectors.py +++ b/dace/transformation/dataflow/prune_connectors.py @@ -10,7 +10,7 @@ @properties.make_properties -class PruneConnectors(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class PruneConnectors(pm.SingleStateTransformation, pm.SimplifyPass): """ Removes unused connectors from nested SDFGs, as well as their memlets in the outer scope, replacing them with empty memlets if necessary. @@ -116,7 +116,7 @@ def apply(self, state: SDFGState, sdfg: SDFG): break -class PruneSymbols(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class PruneSymbols(pm.SingleStateTransformation, pm.SimplifyPass): """ Removes unused symbol mappings from nested SDFGs, as well as internal symbols if necessary. diff --git a/dace/transformation/dataflow/redundant_array.py b/dace/transformation/dataflow/redundant_array.py index 803bf4f9c1..bddbf43d84 100644 --- a/dace/transformation/dataflow/redundant_array.py +++ b/dace/transformation/dataflow/redundant_array.py @@ -161,7 +161,7 @@ def compose_and_push_back(first, second, dims=None, popped=None): ############################################################################## -class RedundantArray(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class RedundantArray(pm.SingleStateTransformation, pm.SimplifyPass): """ Implements the redundant array removal transformation, applied when a transient array is copied to and from (to another array), but never used anywhere else. """ @@ -560,7 +560,7 @@ def apply(self, graph, sdfg): pass -class RedundantSecondArray(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class RedundantSecondArray(pm.SingleStateTransformation, pm.SimplifyPass): """ Implements the redundant array removal transformation, applied when a transient array is copied from and to (from another array), but never used anywhere else. This transformation removes the second @@ -890,7 +890,7 @@ def apply(self, graph: SDFGState, sdfg: SDFG): graph.remove_node(in_array) -class SqueezeViewRemove(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class SqueezeViewRemove(pm.SingleStateTransformation, pm.SimplifyPass): in_array = pm.PatternNode(nodes.AccessNode) out_array = pm.PatternNode(nodes.AccessNode) @@ -969,7 +969,7 @@ def apply(self, state: SDFGState, sdfg: SDFG): pass -class UnsqueezeViewRemove(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class UnsqueezeViewRemove(pm.SingleStateTransformation, pm.SimplifyPass): in_array = pm.PatternNode(nodes.AccessNode) out_array = pm.PatternNode(nodes.AccessNode) @@ -1083,7 +1083,7 @@ def _sliced_dims(adesc: data.Array, vdesc: data.View) -> typing.List[int]: return [adesc.strides.index(s) for s in vdesc.strides] -class RedundantReadSlice(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class RedundantReadSlice(pm.SingleStateTransformation, pm.SimplifyPass): """ Detects patterns of the form Array -> View(Array) and removes the View if it is a slice. """ @@ -1215,7 +1215,7 @@ def apply(self, graph, sdfg): pass -class RedundantWriteSlice(pm.SingleStateTransformation, pm.DataflowCoarseningTransformation): +class RedundantWriteSlice(pm.SingleStateTransformation, pm.SimplifyPass): """ Detects patterns of the form View(Array) -> Array and removes the View if it is a slice. """ diff --git a/dace/transformation/interstate/gpu_transform_sdfg.py b/dace/transformation/interstate/gpu_transform_sdfg.py index 6903a738f7..d341c17012 100644 --- a/dace/transformation/interstate/gpu_transform_sdfg.py +++ b/dace/transformation/interstate/gpu_transform_sdfg.py @@ -24,7 +24,7 @@ class GPUTransformSDFG(transformation.MultiStateTransformation): 5. Global tasklets are wrapped with a map of size 1 6. Global Maps are re-scheduled to use the GPU 7. Make data ready for interstate edges that use them - 8. Re-apply dataflow coarsening to get rid of extra states and + 8. Re-apply simplification to get rid of extra states and transients """ @@ -39,7 +39,7 @@ class GPUTransformSDFG(transformation.MultiStateTransformation): dtype=bool, default=True) - coarsen = Property(desc='Reapply dataflow coarsening after modifying graph', dtype=bool, default=True) + simplify = Property(desc='Reapply simplification after modifying graph', dtype=bool, default=True) exclude_copyin = Property(desc="Exclude these arrays from being copied into the device " "(comma-separated)", @@ -312,8 +312,8 @@ def apply(self, _, sdfg: sd.SDFG): memlet.Memlet.from_array(dst_array.data, dst_array.desc(sdfg))) ####################################################### - # Step 8: Dataflow coarsening - if not self.coarsen: + # Step 8: Simplify + if not self.simplify: return - sdfg.coarsen_dataflow() + sdfg.simplify() diff --git a/dace/transformation/interstate/multistate_inline.py b/dace/transformation/interstate/multistate_inline.py index 3c8581dafb..66dce03b8a 100644 --- a/dace/transformation/interstate/multistate_inline.py +++ b/dace/transformation/interstate/multistate_inline.py @@ -22,7 +22,7 @@ @make_properties -class InlineMultistateSDFG(transformation.SingleStateTransformation, transformation.DataflowCoarseningTransformation): +class InlineMultistateSDFG(transformation.SingleStateTransformation, transformation.SimplifyPass): """ Inlines a multi-state nested SDFG into a top-level SDFG. This only happens if the state has the nested SDFG node isolated (i.e., only containing it diff --git a/dace/transformation/interstate/sdfg_nesting.py b/dace/transformation/interstate/sdfg_nesting.py index 5b8e593a5d..7b0d1de23c 100644 --- a/dace/transformation/interstate/sdfg_nesting.py +++ b/dace/transformation/interstate/sdfg_nesting.py @@ -25,7 +25,7 @@ @make_properties -class InlineSDFG(transformation.SingleStateTransformation, transformation.DataflowCoarseningTransformation): +class InlineSDFG(transformation.SingleStateTransformation, transformation.SimplifyPass): """ Inlines a single-state nested SDFG into a top-level SDFG. In particular, the steps taken are: @@ -1063,7 +1063,6 @@ def expressions(cls): def can_be_applied(self, graph, expr_index, sdfg, permissive=False): return True - def apply(self, _, sdfg: SDFG): outer_sdfg = sdfg nested_sdfg = dc(sdfg) diff --git a/dace/transformation/interstate/state_elimination.py b/dace/transformation/interstate/state_elimination.py index 58c604c1a7..e5b1015a9a 100644 --- a/dace/transformation/interstate/state_elimination.py +++ b/dace/transformation/interstate/state_elimination.py @@ -10,7 +10,7 @@ from dace.transformation import transformation -class EndStateElimination(transformation.MultiStateTransformation, transformation.DataflowCoarseningTransformation): +class EndStateElimination(transformation.MultiStateTransformation, transformation.SimplifyPass): """ End-state elimination removes a redundant state that has one incoming edge and no contents. @@ -123,7 +123,7 @@ def _assignments_to_consider(sdfg, edge): return assignments_to_consider -class StateAssignElimination(transformation.MultiStateTransformation, transformation.DataflowCoarseningTransformation): +class StateAssignElimination(transformation.MultiStateTransformation, transformation.SimplifyPass): """ State assign elimination removes all assignments into the final state and subsumes the assigned value into its contents. @@ -219,7 +219,7 @@ def _alias_assignments(sdfg, edge): return assignments_to_consider -class SymbolAliasPromotion(transformation.MultiStateTransformation, transformation.DataflowCoarseningTransformation): +class SymbolAliasPromotion(transformation.MultiStateTransformation, transformation.SimplifyPass): """ SymbolAliasPromotion moves inter-state assignments that create symbolic aliases to the previous inter-state edge according to the topological order. diff --git a/dace/transformation/interstate/state_fusion.py b/dace/transformation/interstate/state_fusion.py index 7865c50789..0e8221cc1b 100644 --- a/dace/transformation/interstate/state_fusion.py +++ b/dace/transformation/interstate/state_fusion.py @@ -30,7 +30,7 @@ def top_level_nodes(state: SDFGState): return state.scope_children()[None] -class StateFusion(transformation.MultiStateTransformation, transformation.DataflowCoarseningTransformation): +class StateFusion(transformation.MultiStateTransformation, transformation.SimplifyPass): """ Implements the state-fusion transformation. State-fusion takes two states that are connected through a single edge, diff --git a/dace/transformation/transformation.py b/dace/transformation/transformation.py index 6ea8f62fbe..5ba264b3a9 100644 --- a/dace/transformation/transformation.py +++ b/dace/transformation/transformation.py @@ -13,8 +13,8 @@ * Library node expansions (extending ExpandTransformation): An internal class used for tracking how library nodes are expanded. -Some transformations are included in the SDFG Dataflow Coarsening pass. In order to declare a transformation as part -of the dataflow coarsening pass, it should also extend the ``DataflowCoarseningTransformation`` mixin. +Some transformations are included in the SDFG simplification pass. In order to declare a transformation as part +of the simplification pass, it should also extend the ``SimplifyPass`` mixin. """ import abc @@ -403,9 +403,9 @@ def expressions(cls): methods' documentation. :seealso: PatternNode - :note: Some transformations are included in the SDFG Dataflow Coarsening pass. In order to declare a - transformation as part of the dataflow coarsening pass, it should also extend the - ``DataflowCoarseningTransformation`` mixin. + :note: Some transformations are included in the SDFG simplification pass. In order to declare a + transformation as part of the simplification pass, it should also extend the + ``SimplifyPass`` mixin. """ @classmethod @abc.abstractmethod @@ -462,9 +462,9 @@ def expressions(cls): methods' documentation. :seealso: PatternNode - :note: Some transformations are included in the SDFG Dataflow Coarsening pass. In order to declare a - transformation as part of the dataflow coarsening pass, it should also extend the - ``DataflowCoarseningTransformation`` mixin. + :note: Some transformations are included in the SDFG simplification pass. In order to declare a + transformation as part of the simplification pass, it should also extend the + ``SimplifyPass`` mixin. """ @classmethod @abc.abstractmethod @@ -491,11 +491,11 @@ def can_be_applied(self, graph: SDFG, expr_index: int, sdfg: SDFG, permissive: b pass -class DataflowCoarseningTransformation: +class SimplifyPass: """ - Mixin that includes the given PatternTransformation in the SDFG Dataflow Coarsening pass. This transformation + Mixin that includes the given PatternTransformation in the SDFG simplification pass. This transformation will be automatically applied throughout the SDFG in non-permissive mode as the graph is constructed, or when - ``sdfg.coarsen_dataflow()`` is called. + ``sdfg.simplify()`` is called. """ pass @@ -798,7 +798,7 @@ def from_json(json_obj: Dict[str, Any], context: Dict[str, Any] = None) -> 'Subg return ret -def coarsening_transformations() -> List[Type[PatternTransformation]]: - """ :return: List of all registered dataflow coarsening transformations. +def simplification_transformations() -> List[Type[PatternTransformation]]: + """ :return: List of all registered simplification transformations. """ - return list(DataflowCoarseningTransformation.__subclasses__()) + return list(SimplifyPass.__subclasses__()) diff --git a/samples/distributed/explicit/jacobi_2d.py b/samples/distributed/explicit/jacobi_2d.py index 9564ae6d8c..6e897801a1 100644 --- a/samples/distributed/explicit/jacobi_2d.py +++ b/samples/distributed/explicit/jacobi_2d.py @@ -154,11 +154,11 @@ def setup_func(rank): A, B = setup_func(rank) mpi_sdfg = None - mpi_sdfg = jacobi_2d_dist.to_sdfg(coarsen=False) + mpi_sdfg = jacobi_2d_dist.to_sdfg(simplify=False) if rank == 0: - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated([MapFusion]) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: diff --git a/samples/distributed/explicit/poly_gemm.py b/samples/distributed/explicit/poly_gemm.py index 43c1e1472e..7747e8182a 100644 --- a/samples/distributed/explicit/poly_gemm.py +++ b/samples/distributed/explicit/poly_gemm.py @@ -123,8 +123,8 @@ def setup_func(rank): mpi_sdfg = None if rank == 0: - mpi_sdfg = gemm_distr2.to_sdfg(coarsen=False) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg = gemm_distr2.to_sdfg(simplify=False) + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: diff --git a/samples/distributed/explicit/poly_gemm_bc.py b/samples/distributed/explicit/poly_gemm_bc.py index a476c313a1..72042d7eff 100644 --- a/samples/distributed/explicit/poly_gemm_bc.py +++ b/samples/distributed/explicit/poly_gemm_bc.py @@ -162,8 +162,8 @@ def setup_func(rank): mpi_sdfg = None if rank == 0: - mpi_sdfg = gemm_distr3.to_sdfg(coarsen=False) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg = gemm_distr3.to_sdfg(simplify=False) + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: diff --git a/samples/distributed/explicit/poly_gesummv.py b/samples/distributed/explicit/poly_gesummv.py index 5bafa4fbc4..947cbc4352 100644 --- a/samples/distributed/explicit/poly_gesummv.py +++ b/samples/distributed/explicit/poly_gesummv.py @@ -119,8 +119,8 @@ def setup_func(rank): mpi_sdfg = None if rank == 0: - mpi_sdfg = gesummv_distr2.to_sdfg(coarsen=False) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg = gesummv_distr2.to_sdfg(simplify=False) + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: diff --git a/samples/distributed/implicit/poly_gemm.py b/samples/distributed/implicit/poly_gemm.py index 8c0eeaf0d3..0d1ef5a6c9 100644 --- a/samples/distributed/implicit/poly_gemm.py +++ b/samples/distributed/implicit/poly_gemm.py @@ -44,13 +44,13 @@ def init_data(NI, NJ, NK, datatype): size = comm.Get_size() if rank == 0: - mpi_sdfg = gemm.to_sdfg(coarsen=False) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg = gemm.to_sdfg(simplify=False) + mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated(ElementWiseArrayOperation2D) mpi_sdfg.expand_library_nodes() - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated(RedundantComm2D) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() diff --git a/samples/distributed/implicit/poly_gesummv.py b/samples/distributed/implicit/poly_gesummv.py index 0b7cf39767..51c9862739 100644 --- a/samples/distributed/implicit/poly_gesummv.py +++ b/samples/distributed/implicit/poly_gesummv.py @@ -51,14 +51,14 @@ def init_data(N, datatype): size = comm.Get_size() if rank == 0: - mpi_sdfg = gesummv.to_sdfg(coarsen=False) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg = gesummv.to_sdfg(simplify=False) + mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated(ElementWiseArrayOperation2D) mpi_sdfg.apply_transformations_repeated(ElementWiseArrayOperation) mpi_sdfg.expand_library_nodes() - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_sdfg.apply_transformations_repeated(RedundantComm2D) - mpi_sdfg.coarsen_dataflow() + mpi_sdfg.simplify() mpi_func = mpi_sdfg.compile() comm.Barrier() if rank > 0: diff --git a/samples/instrumentation/tuning.py b/samples/instrumentation/tuning.py index 768d88d561..879caebb34 100644 --- a/samples/instrumentation/tuning.py +++ b/samples/instrumentation/tuning.py @@ -33,7 +33,7 @@ def test_configuration(a_trans: bool, b_trans: bool, a_padding: int, b_padding: # Convert the program to an SDFG to enable instrumentation sdfg = matmult.to_sdfg() # Remove extraneous states - sdfg.coarsen_dataflow() + sdfg.simplify() # Instrument state that runs in the loop above state = next(s for s in sdfg.nodes() if len(s.nodes()) > 0) diff --git a/samples/sdfg_api/control_flow.py b/samples/sdfg_api/control_flow.py index 8ed2673145..ce4f4bbb9c 100644 --- a/samples/sdfg_api/control_flow.py +++ b/samples/sdfg_api/control_flow.py @@ -71,7 +71,7 @@ def endstate(state): sdfg.validate() # Fuses redundant states and removes unnecessary transient arrays -sdfg.coarsen_dataflow() +sdfg.simplify() ###################################### if __name__ == '__main__': diff --git a/samples/sdfg_api/jagged_arrays.py b/samples/sdfg_api/jagged_arrays.py index 6a9f001ccb..402cc1451d 100644 --- a/samples/sdfg_api/jagged_arrays.py +++ b/samples/sdfg_api/jagged_arrays.py @@ -49,7 +49,7 @@ sdfg.validate() # Fuses redundant states and removes unnecessary transient arrays -sdfg.coarsen_dataflow() +sdfg.simplify() ###################################### if __name__ == '__main__': diff --git a/samples/sdfg_api/state_fusion.py b/samples/sdfg_api/state_fusion.py index 093dedef27..aa6e73f181 100644 --- a/samples/sdfg_api/state_fusion.py +++ b/samples/sdfg_api/state_fusion.py @@ -42,7 +42,7 @@ def mystate(state, src, dst): sdfg.validate() # Fuses redundant states and removes unnecessary transient arrays -sdfg.coarsen_dataflow() +sdfg.simplify() ###################################### if __name__ == '__main__': diff --git a/tests/buffer_tiling_test.py b/tests/buffer_tiling_test.py index 5a39fe8657..64936cb65f 100644 --- a/tests/buffer_tiling_test.py +++ b/tests/buffer_tiling_test.py @@ -73,7 +73,7 @@ def _semantic_eq(tile_sizes, program): sdfg = program.to_sdfg() sdfg.name = f"{sdfg.name}_{'_'.join(map(str, tile_sizes))}" - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg(w3=w3, w5=w5, A=A, B=B1, I=A.shape[0], J=A.shape[1]) count = sdfg.apply_transformations(BufferTiling, options={'tile_sizes': tile_sizes}) diff --git a/tests/chained_nested_tasklet_test.py b/tests/chained_nested_tasklet_test.py index 96f734cc1b..797fb4fc48 100644 --- a/tests/chained_nested_tasklet_test.py +++ b/tests/chained_nested_tasklet_test.py @@ -90,7 +90,7 @@ def test_nested_sdfg(): print("Difference:", diff) assert diff <= 1e-5 - mysdfg.coarsen_dataflow() + mysdfg.simplify() mysdfg(A=input, B=output, N=N) diff --git a/tests/codegen/allocation_lifetime_test.py b/tests/codegen/allocation_lifetime_test.py index 0e58287ae9..1a38983193 100644 --- a/tests/codegen/allocation_lifetime_test.py +++ b/tests/codegen/allocation_lifetime_test.py @@ -149,7 +149,7 @@ def test_persistent_transpose(A: dace.float64[5, 3]): sdfg = test_persistent_transpose.to_sdfg() sdfg.expand_library_nodes() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_gpu_transformations() for _, _, arr in sdfg.arrays_recursive(): @@ -277,7 +277,7 @@ def top(a: dace.float64[20]): tmp = dace.ndarray([20], dace.float64, lifetime=dace.AllocationLifetime.Persistent) return incall(a, tmp) - sdfg = top.to_sdfg(coarsen=False) + sdfg = top.to_sdfg(simplify=False) a = np.random.rand(20) ref = a.copy() @@ -296,7 +296,7 @@ def nestpers(a): def toppers(a: dace.float64[20]): return nestpers(a) - sdfg = toppers.to_sdfg(coarsen=False) + sdfg = toppers.to_sdfg(simplify=False) for _, _, arr in sdfg.arrays_recursive(): if arr.transient: arr.lifetime = dace.AllocationLifetime.Persistent diff --git a/tests/codegen/control_flow_detection_test.py b/tests/codegen/control_flow_detection_test.py index 4b9c3dd6df..1cae061033 100644 --- a/tests/codegen/control_flow_detection_test.py +++ b/tests/codegen/control_flow_detection_test.py @@ -61,7 +61,7 @@ def looptest(): i += 2 return A - sdfg: dace.SDFG = looptest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = looptest.to_sdfg(simplify=True) if dace.Config.get_bool('optimizer', 'detect_control_flow'): assert 'for (' in sdfg.generate_code()[0].code diff --git a/tests/codegen/sve/common.py b/tests/codegen/sve/common.py index b0883f0ea0..922fe6791a 100644 --- a/tests/codegen/sve/common.py +++ b/tests/codegen/sve/common.py @@ -5,7 +5,7 @@ def vectorize(program): - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) sdfg.apply_transformations(SVEVectorization) return sdfg diff --git a/tests/codegen/transient_same_name_test.py b/tests/codegen/transient_same_name_test.py index f11da70a09..7d799a33a7 100644 --- a/tests/codegen/transient_same_name_test.py +++ b/tests/codegen/transient_same_name_test.py @@ -21,7 +21,7 @@ def outer_scope(A: dace.float64[3, 3], B: dace.float64[3, 3]): def test_regression_transient_not_allocated(): inp = np.zeros((3, 3)).astype(np.float64) - sdfg: dace.SDFG = outer_scope.to_sdfg(coarsen=False) + sdfg: dace.SDFG = outer_scope.to_sdfg(simplify=False) result = np.zeros_like(inp) sdfg(A=inp.copy(), B=result) diff --git a/tests/control_flow_test.py b/tests/control_flow_test.py index 491228607c..2308799e56 100644 --- a/tests/control_flow_test.py +++ b/tests/control_flow_test.py @@ -78,13 +78,13 @@ def test_function_in_condition(): def test_2d_access(): - print("Running without dataflow coarsening...") + print("Running without simplification...") A = np.random.rand(4, 2) expected = A.copy() expected[0, 0] = 100.0 if expected[1, 1] < 0.5 else -100.0 # arr2dtest(A) - sdfg = arr2dtest.to_sdfg(coarsen=False) + sdfg = arr2dtest.to_sdfg(simplify=False) sdfg(A=A) assert np.allclose(A, expected) diff --git a/tests/cuda_test.sh b/tests/cuda_test.sh index f348278741..2eb5c4423d 100755 --- a/tests/cuda_test.sh +++ b/tests/cuda_test.sh @@ -9,7 +9,7 @@ PYTHON_BINARY="${PYTHON_BINARY:-python3}" DACE_debugprint="${DACE_debugprint:-0}" DACE_optimizer_transform_on_call=${DACE_optimizer_transform_on_call:-1} -DACE_optimizer_automatic_dataflow_coarsening=${DACE_optimizer_automatic_dataflow_coarsening:-1} +DACE_optimizer_automatic_simplification=${DACE_optimizer_automatic_simplification:-1} ERRORS=0 FAILED_TESTS="" TESTS=0 diff --git a/tests/enumerator_test.py b/tests/enumerator_test.py index b7982f66ff..d598f73487 100644 --- a/tests/enumerator_test.py +++ b/tests/enumerator_test.py @@ -57,7 +57,7 @@ def test_greedy(map_splits): ret = np.zeros([w, h], dtype=np.float32) sdfg = p1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] sdfg.apply_transformations_repeated(ReduceExpansion) @@ -85,7 +85,7 @@ def test_connected(map_splits): ret = np.zeros([w, h], dtype=np.float32) sdfg = p1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] sdfg.apply_transformations_repeated(ReduceExpansion) @@ -114,7 +114,7 @@ def test_brute_force(map_splits): ret = np.zeros([w, h], dtype=np.float32) sdfg = p1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] sdfg.apply_transformations_repeated(ReduceExpansion) diff --git a/tests/halfvec_cudatest.py b/tests/halfvec_cudatest.py index 207989fa20..8772d6b24d 100644 --- a/tests/halfvec_cudatest.py +++ b/tests/halfvec_cudatest.py @@ -27,7 +27,7 @@ def halftest(A: dace.float16[N], B: dace.float16[N]): A = np.random.rand(24).astype(np.float16) B = np.random.rand(24).astype(np.float16) sdfg = halftest.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_gpu_transformations() # Apply vectorization on each map and count applied diff --git a/tests/inline_external_edges_test.py b/tests/inline_external_edges_test.py index f839602994..87a3d2ba6a 100644 --- a/tests/inline_external_edges_test.py +++ b/tests/inline_external_edges_test.py @@ -37,7 +37,7 @@ def test(): L = np.random.rand(2).astype(np.float32) M = np.random.rand(2).astype(np.float32) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg(L=L, M=M) expected = np.array([2.0, 2.0, 7.0, 7.0]) diff --git a/tests/inline_noncontig_dim_test.py b/tests/inline_noncontig_dim_test.py index f2b0e52e3d..ebde830f83 100644 --- a/tests/inline_noncontig_dim_test.py +++ b/tests/inline_noncontig_dim_test.py @@ -38,11 +38,11 @@ def test(): sdfg(A=input, B=output) diff1 = np.linalg.norm(output - input * 5) - print("Difference (without dataflow coarsening):", diff1) + print("Difference (without simplification):", diff1) output = np.zeros(shape=(2, 3, 4), dtype=np.float32) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg(A=input, B=output) diff2 = np.linalg.norm(output - input * 5) print("Difference:", diff2) diff --git a/tests/inline_nonsink_access_test.py b/tests/inline_nonsink_access_test.py index d0f4cf7448..2b657af564 100644 --- a/tests/inline_nonsink_access_test.py +++ b/tests/inline_nonsink_access_test.py @@ -51,7 +51,7 @@ def test_same_shape(): B = np.random.rand(1).astype(np.float32) sdfg = make_sdfg([1], [1], '0', '0') - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.save('_dacegraphs/program.sdfg') sdfg(A=A, B=B) @@ -70,7 +70,7 @@ def test_different_shape(): B = np.random.rand(20, 3).astype(np.float32) sdfg = make_sdfg([20, 3], [60], '1, 0', '3') - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg(A=A, B=B) diff --git a/tests/inline_symbol_test.py b/tests/inline_symbol_test.py index 7e27903aac..76b115125c 100644 --- a/tests/inline_symbol_test.py +++ b/tests/inline_symbol_test.py @@ -15,7 +15,7 @@ def inline_symbol(D: dace.float32[E, F]): def test_inline_symbol(): - sdfg = inline_symbol.to_sdfg(coarsen=False) + sdfg = inline_symbol.to_sdfg(simplify=False) oldval = dace.Config.get_bool('experimental', 'validate_undefs') dace.Config.set('experimental', 'validate_undefs', value=True) sdfg.validate() diff --git a/tests/inlining_test.py b/tests/inlining_test.py index dea88eb99f..c9fad1df89 100644 --- a/tests/inlining_test.py +++ b/tests/inlining_test.py @@ -59,8 +59,8 @@ def test_regression_reshape_unsqueeze(): def test_reshape_unsqueeze(A: dace.float64[3, 3], B: dace.float64[9]): nsdfg(input=A, output=B) - sdfg = test_reshape_unsqueeze.to_sdfg(coarsen=False) - sdfg.coarsen_dataflow() + sdfg = test_reshape_unsqueeze.to_sdfg(simplify=False) + sdfg.simplify() sdfg.validate() a = np.random.rand(3, 3) @@ -107,7 +107,7 @@ def test_empty_memlets(): state.add_edge(nsdfg1_node, None, nsdfg2_node, None, dace.Memlet()) sdfg.validate() - sdfg.coarsen_dataflow() + sdfg.simplify() def test_multistate_inline(): @@ -120,7 +120,7 @@ def nested(A: dace.float64[20]): def outerprog(A: dace.float64[20]): nested(A) - sdfg = outerprog.to_sdfg(coarsen=True) + sdfg = outerprog.to_sdfg(simplify=True) from dace.transformation.interstate import InlineMultistateSDFG sdfg.apply_transformations(InlineMultistateSDFG) assert sdfg.number_of_nodes() in (4, 5) @@ -144,7 +144,7 @@ def outerprog(A: dace.float64[20]): for i in range(5): nested(A) - sdfg = outerprog.to_sdfg(coarsen=True) + sdfg = outerprog.to_sdfg(simplify=True) from dace.transformation.interstate import InlineMultistateSDFG sdfg.apply_transformations(InlineMultistateSDFG) assert sdfg.number_of_nodes() in (7, 8) diff --git a/tests/instrumentation_test.py b/tests/instrumentation_test.py index c6d856c0e4..ef844ea472 100644 --- a/tests/instrumentation_test.py +++ b/tests/instrumentation_test.py @@ -33,7 +33,7 @@ def onetest(instrumentation: dace.InstrumentationType, size=128): sdfg: dace.SDFG = slowmm.to_sdfg() sdfg.name = f"instrumentation_test_{instrumentation.name}" - sdfg.coarsen_dataflow() + sdfg.simplify() # Set instrumentation both on the state and the map for node, state in sdfg.all_nodes_recursive(): diff --git a/tests/library/linalg_cholesky_test.py b/tests/library/linalg_cholesky_test.py index 9892aba172..38b0a07d8c 100644 --- a/tests/library/linalg_cholesky_test.py +++ b/tests/library/linalg_cholesky_test.py @@ -47,7 +47,7 @@ def test_cholesky(implementation, dtype, storage): sdfg = make_sdfg(implementation, dtype, storage) if implementation == 'cuSolverDn': sdfg.apply_gpu_transformations() - sdfg.coarsen_dataflow() + sdfg.simplify() np_dtype = getattr(np, dtype.to_string()) cholesky_sdfg = sdfg.compile() diff --git a/tests/library/linalg_inv_test.py b/tests/library/linalg_inv_test.py index 95ee823a48..1cec374f8e 100644 --- a/tests/library/linalg_inv_test.py +++ b/tests/library/linalg_inv_test.py @@ -263,7 +263,7 @@ def test_inv(implementation, dtype, size, shape, overwrite, getri): sdfg = make_sdfg(implementation, dtype, id, in_shape, out_shape, in_subset_str, out_subset_str, overwrite, getri) if implementation == 'cuSolverDn': sdfg.apply_gpu_transformations() - sdfg.coarsen_dataflow() + sdfg.simplify() try: inv_sdfg = sdfg.compile() except (CompilerConfigurationError, CompilationError): diff --git a/tests/library/linalg_solve_test.py b/tests/library/linalg_solve_test.py index e7bf0b4698..ccd4543947 100644 --- a/tests/library/linalg_solve_test.py +++ b/tests/library/linalg_solve_test.py @@ -107,7 +107,7 @@ def test_solve(implementation, dtype, size, shape): sdfg = make_sdfg(implementation, dtype, id, in_shape, out_shape, in_subset_str, out_subset_str) if implementation == 'cuSolverDn': sdfg.apply_gpu_transformations() - sdfg.coarsen_dataflow() + sdfg.simplify() solve_sdfg = sdfg.compile() A0 = np.zeros(in_shape, dtype=dtype) diff --git a/tests/mapreduce_test.py b/tests/mapreduce_test.py index e557082736..81a6490614 100644 --- a/tests/mapreduce_test.py +++ b/tests/mapreduce_test.py @@ -152,7 +152,7 @@ def onetest(program): C_regression = A @ B sdfg = program.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations([MapFusion, MapWCRFusion]) sdfg(A=A, B=B, C=C, M=M, N=N, K=K) @@ -280,7 +280,7 @@ def test_histogram(): hist = np.zeros([BINS], dtype=np.uint32) sdfg = histogram.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations(MapReduceFusion) sdfg(A=A, hist=hist, H=H, W=W) diff --git a/tests/mpi_test.sh b/tests/mpi_test.sh index 0ff563510e..0692dcc2d6 100755 --- a/tests/mpi_test.sh +++ b/tests/mpi_test.sh @@ -7,7 +7,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" PYTHONPATH=$SCRIPTPATH/.. DACE_debugprint="${DACE_debugprint:-0}" -DACE_optimizer_automatic_dataflow_coarsening=${DACE_optimizer_automatic_dataflow_coarsening:-1} +DACE_optimizer_automatic_simplification=${DACE_optimizer_automatic_simplification:-1} ERRORS=0 FAILED_TESTS="" TESTS=0 diff --git a/tests/nest_subgraph_test.py b/tests/nest_subgraph_test.py index 5674047de1..271c54f42b 100644 --- a/tests/nest_subgraph_test.py +++ b/tests/nest_subgraph_test.py @@ -59,7 +59,7 @@ def multiply(a: dace.float32[N]): a *= 2 a *= 3 - sdfg = multiply.to_sdfg(coarsen=True) + sdfg = multiply.to_sdfg(simplify=True) for state in sdfg.nodes(): if any(isinstance(node, Tasklet) for node in state.nodes()): break diff --git a/tests/nested_symbol_test.py b/tests/nested_symbol_test.py index 74646e01e0..ac3f794300 100644 --- a/tests/nested_symbol_test.py +++ b/tests/nested_symbol_test.py @@ -32,7 +32,7 @@ def test_nested_symbol(): def test_nested_symbol_dynamic(): - if not dace.Config.get_bool('optimizer', 'automatic_dataflow_coarsening'): + if not dace.Config.get_bool('optimizer', 'automatic_simplification'): warnings.warn("Test disabled (missing allocation lifetime support)") return @@ -56,7 +56,7 @@ def scalarg(A: dace.float64[20], scal: dace.float64): s2 = scal + 1 symarg(A, N=s2) - sdfg = scalarg.to_sdfg(coarsen=False) + sdfg = scalarg.to_sdfg(simplify=False) A = np.random.rand(20) sc = 5.0 @@ -75,7 +75,7 @@ def symarg(A: dace.float64[20]): def scalarg(A: dace.float64[20], arr: dace.float64[2]): symarg(A, N=arr[1]) - sdfg = scalarg.to_sdfg(coarsen=False) + sdfg = scalarg.to_sdfg(simplify=False) A = np.random.rand(20) sc = np.array([2.0, 3.0]) @@ -101,7 +101,7 @@ def funct(field, dt): rdt = 1.0 / dt inner(field, rdt) - sdfg = funct.to_sdfg(np.random.randn(10, ), 1.0, coarsen=False) + sdfg = funct.to_sdfg(np.random.randn(10, ), 1.0, simplify=False) sdfg(np.random.randn(10, ), 1.0) diff --git a/tests/npbench/atax_test.py b/tests/npbench/atax_test.py index ef4c871b63..06a3405ee6 100644 --- a/tests/npbench/atax_test.py +++ b/tests/npbench/atax_test.py @@ -49,7 +49,7 @@ def run_atax(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/cholesky_test.py b/tests/npbench/cholesky_test.py index 7b06f6d737..25b2b9c8c3 100644 --- a/tests/npbench/cholesky_test.py +++ b/tests/npbench/cholesky_test.py @@ -66,7 +66,7 @@ def run_cholesky(device_type: dace.dtypes.DeviceType): sdfg(A=A, N=N) elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/covariance_test.py b/tests/npbench/covariance_test.py index f5bc4d7cee..2686892cac 100644 --- a/tests/npbench/covariance_test.py +++ b/tests/npbench/covariance_test.py @@ -88,8 +88,8 @@ def run_covariance(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = covariance_kernel.to_sdfg(coarsen=False) - sdfg.coarsen_dataflow() + sdfg = covariance_kernel.to_sdfg(simplify=False) + sdfg.simplify() applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/fdtd_2d_test.py b/tests/npbench/fdtd_2d_test.py index 785fe024e1..d109f1b9bd 100644 --- a/tests/npbench/fdtd_2d_test.py +++ b/tests/npbench/fdtd_2d_test.py @@ -68,7 +68,7 @@ def run_fdtd_2d(device_type: dace.dtypes.DeviceType): sdfg(ex=ex, ey=ey, hz=hz, _fict_=_fict_, TMAX=TMAX, NX=NX, NY=NY) elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) sdfg.apply_transformations_repeated([MapFusion]) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/floyd_warshall_test.py b/tests/npbench/floyd_warshall_test.py index 1f81d305d4..57719d707c 100644 --- a/tests/npbench/floyd_warshall_test.py +++ b/tests/npbench/floyd_warshall_test.py @@ -61,7 +61,7 @@ def run_floyd_warshall(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) # sdfg.apply_transformations_repeated([MapFusion]) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/jacobi_2d_test.py b/tests/npbench/jacobi_2d_test.py index 73c9880c03..8d6aac63a9 100644 --- a/tests/npbench/jacobi_2d_test.py +++ b/tests/npbench/jacobi_2d_test.py @@ -50,7 +50,7 @@ def run_jacobi_2d(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) sdfg.apply_transformations_repeated([MapFusion]) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/lu_test.py b/tests/npbench/lu_test.py index e3f93d6b80..76989d7747 100644 --- a/tests/npbench/lu_test.py +++ b/tests/npbench/lu_test.py @@ -70,7 +70,7 @@ def run_lu(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = lu_kernel.to_sdfg(coarsen=True) + sdfg = lu_kernel.to_sdfg(simplify=True) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/nussinov_test.py b/tests/npbench/nussinov_test.py index a6131d22a3..a4ecef5705 100644 --- a/tests/npbench/nussinov_test.py +++ b/tests/npbench/nussinov_test.py @@ -95,12 +95,12 @@ def run_nussinov(device_type: dace.dtypes.DeviceType): if device_type in {dace.dtypes.DeviceType.CPU, dace.dtypes.DeviceType.GPU}: # Parse the SDFG and apply autopot sdfg = kernel.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() dace_res = sdfg(seq=seq, N=N) elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/npbench/syrk_test.py b/tests/npbench/syrk_test.py index 1fcfd7cac5..84005da73f 100644 --- a/tests/npbench/syrk_test.py +++ b/tests/npbench/syrk_test.py @@ -66,7 +66,7 @@ def run_syrk(device_type: dace.dtypes.DeviceType): elif device_type == dace.dtypes.DeviceType.FPGA: # Parse SDFG and apply FPGA friendly optimization - sdfg = kernel.to_sdfg(coarsen=True) + sdfg = kernel.to_sdfg(simplify=True) applied = sdfg.apply_transformations([FPGATransformSDFG]) assert applied == 1 diff --git a/tests/numpy/copies_and_views_test.py b/tests/numpy/copies_and_views_test.py index cef4ddc629..d7aa7b85f3 100644 --- a/tests/numpy/copies_and_views_test.py +++ b/tests/numpy/copies_and_views_test.py @@ -142,7 +142,7 @@ def selfcopy(q: dace.float64[128, 128, 80]): for j in range(1, 4): nested(q, i, j) - sdfg = selfcopy.to_sdfg(coarsen=False) + sdfg = selfcopy.to_sdfg(simplify=False) found_copy = False for s in sdfg.all_sdfgs_recursive(): found_copy |= any( diff --git a/tests/numpy/rgf_exhaustivetest.py b/tests/numpy/rgf_exhaustivetest.py index d7415e865c..15ce459a9a 100644 --- a/tests/numpy/rgf_exhaustivetest.py +++ b/tests/numpy/rgf_exhaustivetest.py @@ -156,8 +156,8 @@ def rgf_dense(HD: dace.complex128[N, BS, BS], HE: dace.complex128[N, BS, BS], HF if __name__ == '__main__': print("=== Generating SDFG ===") - sdfg = rgf_dense.to_sdfg(coarsen=False) - print("=== Applying dataflow coarsening ===") - sdfg.coarsen_dataflow() + sdfg = rgf_dense.to_sdfg(simplify=False) + print("=== Applying simplification pass ===") + sdfg.simplify() print("=== Compiling ===") sdfg.compile() diff --git a/tests/python_frontend/augassign_wcr_test.py b/tests/python_frontend/augassign_wcr_test.py index 00f3ff7893..511ec8f3a6 100644 --- a/tests/python_frontend/augassign_wcr_test.py +++ b/tests/python_frontend/augassign_wcr_test.py @@ -46,7 +46,7 @@ def test_augassign_wcr(): B = np.empty((10, ), dtype=np.int32) W = np.random.randint(2, size=(10, ), dtype=np.bool_) - test_sdfg = augassign_wcr.to_sdfg(coarsen=False) + test_sdfg = augassign_wcr.to_sdfg(simplify=False) wcr_count = 0 for sdfg in test_sdfg.sdfg_list: for state in sdfg.nodes(): @@ -66,7 +66,7 @@ def test_augassign_wcr2(): C = np.zeros((10, ), dtype=np.int32) W = np.random.randint(2, size=(10, 10, 10), dtype=np.bool_) - test_sdfg = augassign_wcr2.to_sdfg(coarsen=False) + test_sdfg = augassign_wcr2.to_sdfg(simplify=False) wcr_count = 0 for sdfg in test_sdfg.sdfg_list: for state in sdfg.nodes(): @@ -89,7 +89,7 @@ def test_augassign_wcr3(): ind = np.random.randint(0, 10, size=(10, ), dtype=np.int32) W = np.random.randint(2, size=(10, 10, 10), dtype=np.bool_) - test_sdfg = augassign_wcr3.to_sdfg(coarsen=False) + test_sdfg = augassign_wcr3.to_sdfg(simplify=False) wcr_count = 0 for sdfg in test_sdfg.sdfg_list: for state in sdfg.nodes(): @@ -111,7 +111,7 @@ def test_augassign_no_wcr(): def no_wcr(A: dace.int32[5, 5, 5]): A[2, 3, :] += A[3, 2, :] - sdfg = no_wcr.to_sdfg(coarsen=False) + sdfg = no_wcr.to_sdfg(simplify=False) sdfg.save('test.sdfg') for e, _ in sdfg.all_edges_recursive(): if hasattr(e.data, 'wcr'): @@ -129,7 +129,7 @@ def test_augassign_no_wcr2(): def no_wcr(A: dace.int32[5, 5, 5]): A[2, 3, 1:4] += A[2:5, 1, 4] - sdfg = no_wcr.to_sdfg(coarsen=False) + sdfg = no_wcr.to_sdfg(simplify=False) sdfg.save('test.sdfg') for e, _ in sdfg.all_edges_recursive(): if hasattr(e.data, 'wcr'): diff --git a/tests/python_frontend/callback_autodetect_test.py b/tests/python_frontend/callback_autodetect_test.py index a4b7e694cc..bd4844d585 100644 --- a/tests/python_frontend/callback_autodetect_test.py +++ b/tests/python_frontend/callback_autodetect_test.py @@ -299,7 +299,7 @@ def same_name_nested(): call_b() call_a() - sdfg = same_name_nested.to_sdfg(coarsen=False) + sdfg = same_name_nested.to_sdfg(simplify=False) assert list(sdfg.arrays.keys()) == ['__pystate'] same_name_nested() diff --git a/tests/python_frontend/constant_and_keyword_args_test.py b/tests/python_frontend/constant_and_keyword_args_test.py index aef505e58f..ba3f9a1f37 100644 --- a/tests/python_frontend/constant_and_keyword_args_test.py +++ b/tests/python_frontend/constant_and_keyword_args_test.py @@ -357,7 +357,7 @@ def conditional_val(A: dace.float64[20], val: dace.constant): A[:] = 1 # Ensure condition was folded - sdfg = conditional_val.to_sdfg(val=np.int64(3), coarsen=True) + sdfg = conditional_val.to_sdfg(val=np.int64(3), simplify=True) assert sdfg.number_of_nodes() == 1 a = np.random.rand(20) @@ -379,7 +379,7 @@ def conditional_val(A: dace.float64[20], val: dace.constant): A[:] = 1 # Ensure condition was folded - sdfg = conditional_val.to_sdfg(val=3, coarsen=True) + sdfg = conditional_val.to_sdfg(val=3, simplify=True) assert sdfg.number_of_nodes() == 1 a = np.random.rand(20) diff --git a/tests/python_frontend/multiple_nested_sdfgs_test.py b/tests/python_frontend/multiple_nested_sdfgs_test.py index e650739db0..64f3d205b5 100644 --- a/tests/python_frontend/multiple_nested_sdfgs_test.py +++ b/tests/python_frontend/multiple_nested_sdfgs_test.py @@ -65,7 +65,7 @@ def multiple_nested_sdfgs(input: dace.float32[2, 2], output: dace.float32[2, 2]) out_tmp_div_sum(out_tmp=out_tmp, tmp_sum=tmp_sum, output=output) - sdfg = multiple_nested_sdfgs.to_sdfg(coarsen=False) + sdfg = multiple_nested_sdfgs.to_sdfg(simplify=False) state = sdfg.nodes()[-1] for n in state.nodes(): if isinstance(n, dace.sdfg.nodes.AccessNode): diff --git a/tests/python_frontend/test_propagate_strict.py b/tests/python_frontend/test_propagate_strict.py index 8880c5c0e7..3f7cc4b8bf 100644 --- a/tests/python_frontend/test_propagate_strict.py +++ b/tests/python_frontend/test_propagate_strict.py @@ -1,5 +1,5 @@ # Copyright 2019-2021 ETH Zurich and the DaCe authors. All rights reserved. -""" Test that the coarsen argument to to_sdfg is propagated when parsing calls to other dace programs """ +""" Test that the simplify argument to to_sdfg is propagated when parsing calls to other dace programs """ import dace @@ -20,10 +20,10 @@ def propagate_strict(X: dace.int32[2, 2]): def test_propagate_strict(): - strict_sdfg = propagate_strict.to_sdfg(coarsen=True) + strict_sdfg = propagate_strict.to_sdfg(simplify=True) assert len(list(strict_sdfg.all_sdfgs_recursive())) == 1 - non_strict_sdfg = propagate_strict.to_sdfg(coarsen=False) + non_strict_sdfg = propagate_strict.to_sdfg(simplify=False) assert len(list(non_strict_sdfg.all_sdfgs_recursive())) > 1 diff --git a/tests/schedule_inference_test.py b/tests/schedule_inference_test.py index cc433e51b1..3648d1a1fa 100644 --- a/tests/schedule_inference_test.py +++ b/tests/schedule_inference_test.py @@ -12,7 +12,7 @@ def nested_call(A: dace.float64[3, 3]): def simple_schedule_inference(A: dace.float64[3, 3]): return nested_call(A) - sdfg: dace.SDFG = simple_schedule_inference.to_sdfg(coarsen=False) + sdfg: dace.SDFG = simple_schedule_inference.to_sdfg(simplify=False) infer_types.infer_connector_types(sdfg) diff --git a/tests/sdfg/free_symbols_test.py b/tests/sdfg/free_symbols_test.py index 15772e229c..81a8c03a20 100644 --- a/tests/sdfg/free_symbols_test.py +++ b/tests/sdfg/free_symbols_test.py @@ -26,7 +26,7 @@ def fsymtest_multistate(A: dace.float32[20, N]): def test_single_state(): sdfg: dace.SDFG = fsymtest.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 1 state = sdfg.node(0) assert state.free_symbols == {'M', 'N', 'K'} @@ -53,7 +53,7 @@ def test_state_subgraph(): def test_sdfg(): sdfg: dace.SDFG = fsymtest_multistate.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() # Test each state separately for state in sdfg.nodes(): assert (state.free_symbols == {'k', 'N', 'M', 'L'} or state.free_symbols == set()) @@ -63,7 +63,7 @@ def test_sdfg(): def test_constants(): sdfg: dace.SDFG = fsymtest_multistate.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.add_constant('K', 5) sdfg.add_constant('L', 20) diff --git a/tests/sdfg/scalar_to_symbol_test.py b/tests/sdfg/scalar_to_symbol_test.py index 20e481f780..30776ec1c9 100644 --- a/tests/sdfg/scalar_to_symbol_test.py +++ b/tests/sdfg/scalar_to_symbol_test.py @@ -33,7 +33,7 @@ def testprog1(A: dace.float32[20, 20], scal: dace.float32): j += 1 i += j - sdfg: dace.SDFG = testprog1.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog1.to_sdfg(simplify=False) scalars = scalar_to_symbol.find_promotable_scalars(sdfg) assert 'i' in scalars assert 'j' in scalars @@ -46,7 +46,7 @@ def testprog2(A: dace.float64[20, 20]): j = 5 A[:] += j - sdfg: dace.SDFG = testprog2.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog2.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'j'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) sdfg.apply_transformations_repeated(isxf.StateFusion) @@ -92,7 +92,7 @@ def testprog3(A: dace.float32[20, 20]): """ kout >> k - sdfg: dace.SDFG = testprog3.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog3.to_sdfg(simplify=False) scalars = scalar_to_symbol.find_promotable_scalars(sdfg) assert scalars == {'i'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) @@ -115,7 +115,7 @@ def testprog4(A: dace.float64[20, 20]): j = 5 A[:] = j - sdfg: dace.SDFG = testprog4.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog4.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'j'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) sdfg.apply_transformations_repeated(isxf.StateFusion) @@ -182,7 +182,7 @@ def testprog6(A: dace.float64[20, 20]): if j >= 0.0: A[:] += j - sdfg: dace.SDFG = testprog6.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog6.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'j'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) sdfg.apply_transformations_repeated(isxf.StateFusion) @@ -213,7 +213,7 @@ def testprog7(A: dace.float64[20, 20]): out = inp A[:] += j - sdfg: dace.SDFG = testprog7.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog7.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'j'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) sdfg.apply_transformations_repeated(isxf.StateFusion) @@ -260,10 +260,10 @@ def testprog8(A: dace.float32[20, 20]): A += i i += 2 - sdfg: dace.SDFG = testprog8.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog8.to_sdfg(simplify=False) assert 'i' in scalar_to_symbol.find_promotable_scalars(sdfg) scalar_to_symbol.promote_scalars_to_symbols(sdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() # TODO: LoopDetection does not apply to loops with a multi-state guard # assert sdfg.apply_transformations_repeated(LoopTester) == 1 @@ -284,12 +284,12 @@ def testprog9(A: dace.float32[20, 20]): k += 1 i += 2 - sdfg: dace.SDFG = testprog9.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog9.to_sdfg(simplify=False) scalars = scalar_to_symbol.find_promotable_scalars(sdfg) assert 'i' in scalars assert 'k' in scalars scalar_to_symbol.promote_scalars_to_symbols(sdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() # TODO: LoopDetection does not apply to loops with a multi-state guard # xfh.split_interstate_edges(sdfg) # assert sdfg.apply_transformations_repeated(LoopTester) == 3 @@ -322,12 +322,12 @@ def testprog10(A: dace.float64[2, 3, 4, 5], B: dace.float64[4]): b1 >> B[m] b2 >> B[m + 2] - sdfg: dace.SDFG = testprog10.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog10.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'i', 'j', 'k'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) for cursdfg in sdfg.all_sdfgs_recursive(): scalar_to_symbol.remove_symbol_indirection(cursdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 assert all(e.data.subset.num_elements() == 1 for e in sdfg.node(0).edges() @@ -356,10 +356,10 @@ def testprog11(A: dace.float64[10]): a[ii] = ii a[ii + 1] = ii + 1 - sdfg: dace.SDFG = testprog11.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog11.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'i'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 @@ -387,12 +387,12 @@ def testprog12(A: dace.float64[10]): aout[ii + 1] = ii + 1; ''' - sdfg: dace.SDFG = testprog12.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog12.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'i'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) assert all('i' in e.data.free_symbols for e in sdfg.sink_nodes()[0].edges()) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 # Check result @@ -416,10 +416,10 @@ def testprog13(A: dace.float64[20, 20], scal: dace.int32): out >> A(1)[:, :] out[i, s] = a[s, i] - sdfg: dace.SDFG = testprog13.to_sdfg(coarsen=False) + sdfg: dace.SDFG = testprog13.to_sdfg(simplify=False) assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'i'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() # [A,scal->Tasklet->A] assert sdfg.number_of_nodes() == 1 @@ -474,7 +474,7 @@ def test_nested_promotion_connector(with_subscript): # Promotion assert scalar_to_symbol.find_promotable_scalars(sdfg) == {'scal'} scalar_to_symbol.promote_scalars_to_symbols(sdfg) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 assert sdfg.node(0).number_of_nodes() == 3 diff --git a/tests/state_propagation_test.py b/tests/state_propagation_test.py index 899ed8a7e1..ac4393a58d 100644 --- a/tests/state_propagation_test.py +++ b/tests/state_propagation_test.py @@ -56,7 +56,7 @@ def conditional_full_merge(a, b, c): c = 1 c += 1 - sdfg = conditional_full_merge.to_sdfg(coarsen=False) + sdfg = conditional_full_merge.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. @@ -125,7 +125,7 @@ def while_inside_for(a): while j < 20: a += 5 - sdfg = while_inside_for.to_sdfg(coarsen=False) + sdfg = while_inside_for.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. @@ -188,7 +188,7 @@ def for_with_nested_full_merge_branch(a): else: a += 1 - sdfg = for_with_nested_full_merge_branch.to_sdfg(coarsen=False) + sdfg = for_with_nested_full_merge_branch.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. @@ -330,7 +330,7 @@ def while_with_nested_full_merge_branch(a): else: a += 1 - sdfg = while_with_nested_full_merge_branch.to_sdfg(coarsen=False) + sdfg = while_with_nested_full_merge_branch.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. @@ -400,7 +400,7 @@ def nested_3_symbolic(a): for k in range(K): a += 5 - sdfg = nested_3_symbolic.to_sdfg(coarsen=False) + sdfg = nested_3_symbolic.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. @@ -481,7 +481,7 @@ def nested_3(A): for k in range(i, j): A[k, j] += 5 - sdfg = nested_3.to_sdfg(coarsen=False) + sdfg = nested_3.to_sdfg(simplify=False) propagate_states(sdfg) # Check start state. diff --git a/tests/strict_after_load_test.py b/tests/strict_after_load_test.py index 203fcf2a52..54b1ffb08d 100644 --- a/tests/strict_after_load_test.py +++ b/tests/strict_after_load_test.py @@ -10,10 +10,10 @@ def strict_after_load(A: dace.float32[10, 20], B: dace.float32[10, 20]): def test(): - sdfg = strict_after_load.to_sdfg(coarsen=False) + sdfg = strict_after_load.to_sdfg(simplify=False) sdfg.save(os.path.join('_dacegraphs', 'before.sdfg')) sdfg = dace.SDFG.from_file(os.path.join('_dacegraphs', 'before.sdfg')) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.compile() diff --git a/tests/symbol_dependent_transients_test.py b/tests/symbol_dependent_transients_test.py index 18f4eea1cb..f718abf379 100644 --- a/tests/symbol_dependent_transients_test.py +++ b/tests/symbol_dependent_transients_test.py @@ -66,7 +66,7 @@ def test_symbol_dependent_heap_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_heap_array") - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -81,7 +81,7 @@ def test_symbol_dependent_register_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_register_array", storage=dace.dtypes.StorageType.Register) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -96,7 +96,7 @@ def test_symbol_dependent_threadlocal_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_threadlocal_array", storage=dace.dtypes.StorageType.CPU_ThreadLocal) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -111,7 +111,7 @@ def test_symbol_dependent_cpu_view(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_cpu_view", isview=True) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -127,7 +127,7 @@ def test_symbol_dependent_gpu_global_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_gpu_global_array", storage=dace.dtypes.StorageType.GPU_Global) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -143,7 +143,7 @@ def test_symbol_dependent_pinned_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_pinned_array", storage=dace.dtypes.StorageType.CPU_Pinned) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -162,7 +162,7 @@ def test_symbol_dependent_gpu_view(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_gpu_view", storage=dace.dtypes.StorageType.GPU_Global, isview=True) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -178,7 +178,7 @@ def test_symbol_dependent_fpga_global_array(): A = np.random.randn(10, 10, 10) B = np.ndarray(10, dtype=np.float64) sdfg = _make_sdfg("symbol_dependent_fpga_global_array", storage=dace.dtypes.StorageType.FPGA_Global) - # Compile manually to avoid dataflow coarsening + # Compile manually to avoid simplification sdfg_exec = sdfg.compile() sdfg_exec(A=A, B=B, N=10) del sdfg_exec @@ -198,8 +198,8 @@ def symbol_dependent_array_in_map(A: dace.float32[10]): out[i] = np.sum(tmp) return out - # Compile manually to avoid dataflow coarsening - sdfg = symbol_dependent_array_in_map.to_sdfg(coarsen=False) + # Compile manually to avoid simplification + sdfg = symbol_dependent_array_in_map.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(interstate.StateFusion) sdfg.apply_transformations_repeated(interstate.InlineSDFG) # NOTE: Temporary fix for issue with symbols/free_symbols diff --git a/tests/symbol_mapping_replace_test.py b/tests/symbol_mapping_replace_test.py index 88574a4fee..cd47320bf1 100644 --- a/tests/symbol_mapping_replace_test.py +++ b/tests/symbol_mapping_replace_test.py @@ -27,7 +27,7 @@ def outer(A, inp1: float, inp2: float): def test_symbol_mapping_replace(): - with dace.config.set_temporary('optimizer', 'automatic_dataflow_coarsening', value=True): + with dace.config.set_temporary('optimizer', 'automatic_simplification', value=True): A = np.ones((10, 10, 10)) ref = A.copy() b = 2.0 diff --git a/tests/tile_twice_test.py b/tests/tile_twice_test.py index b2438e4084..0910c541cc 100644 --- a/tests/tile_twice_test.py +++ b/tests/tile_twice_test.py @@ -12,7 +12,7 @@ def tile_twice_test(a: dace.float64[200]): def test(): sdfg = tile_twice_test.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations(MapTiling, options={'tile_sizes': (5, )}) for i, match in enumerate(match_patterns(sdfg, MapTiling, states=[sdfg.node(0)])): if i == 0: # Match the first map again diff --git a/tests/transformations/apply_to_test.py b/tests/transformations/apply_to_test.py index 6291d51e48..5c7583a8bd 100644 --- a/tests/transformations/apply_to_test.py +++ b/tests/transformations/apply_to_test.py @@ -15,7 +15,7 @@ def dbladd(A: dace.float64[100, 100], B: dace.float64[100, 100]): def test_applyto_pattern(): sdfg = dbladd.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() # Since there is only one state (thanks to StateFusion), we can use the # first one in the SDFG @@ -26,7 +26,7 @@ def test_applyto_pattern(): mult_exit = next(n for n in state.nodes() if isinstance(n, dace.nodes.MapExit) and n.label == '_Mult__map') # Same goes for the addition entry add_entry = next(n for n in state.nodes() if isinstance(n, dace.nodes.MapEntry) and n.label == '_Add__map') - # Since all redundant arrays have been removed by dataflow coarsening, + # Since all redundant arrays have been removed by simplification pass, # we can get the only transient array that remains in the graph transient = next(aname for aname, desc in sdfg.arrays.items() if desc.transient) access_node = next(n for n in state.nodes() if isinstance(n, dace.nodes.AccessNode) and n.data == transient) @@ -36,7 +36,7 @@ def test_applyto_pattern(): def test_applyto_enumerate(): sdfg = dbladd.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() # Construct subgraph pattern pattern = sdutil.node_path_graph(dace.nodes.MapExit, dace.nodes.AccessNode, dace.nodes.MapEntry) @@ -49,7 +49,7 @@ def test_applyto_enumerate(): def test_applyto_subgraph(): sdfg = dbladd.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.node(0) # Apply to subgraph SubgraphFusion.apply_to(sdfg, state.nodes()) diff --git a/tests/transformations/deduplicate_access_test.py b/tests/transformations/deduplicate_access_test.py index 530aba3b3e..0c88a5423d 100644 --- a/tests/transformations/deduplicate_access_test.py +++ b/tests/transformations/deduplicate_access_test.py @@ -72,7 +72,7 @@ def datest(A: dace.float64[N, N], B: dace.float64[N, N]): out >> B[i, j] B[i, j] = inp1 + inp2 - sdfg: dace.SDFG = datest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = datest.to_sdfg(simplify=True) nodes_before = sdfg.node(0).number_of_nodes() assert sdfg.apply_transformations(DeduplicateAccess) == 1 nodes_after = sdfg.node(0).number_of_nodes() @@ -114,7 +114,7 @@ def datest(A: dace.float64[N, N], B: dace.float64[N, N]): out >> B[i, j] B[i, j] = inp[0] + inp[1] + inp[2] + inp[3] + inp[4] - sdfg: dace.SDFG = datest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = datest.to_sdfg(simplify=True) assert sdfg.apply_transformations(DeduplicateAccess) == 1 @@ -143,7 +143,7 @@ def datest(A: dace.float64[N, N], B: dace.float64[N, N]): out >> B[i, j] B[i, j] = (inp[0] + inp[1] + inp[2]) / 12.0 - sdfg: dace.SDFG = datest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = datest.to_sdfg(simplify=True) nodes_before = sdfg.node(0).number_of_nodes() assert sdfg.apply_transformations(DeduplicateAccess) == 1 # Check that the subset is contiguous by checking how many nodes are added @@ -188,14 +188,14 @@ def datest(A: dace.float64[N, N], B: dace.float64[N, N]): B[i, j] = (inp[0] + inp[1] + inp[2]) / 3.0 # j contiguous dimension - sdfg: dace.SDFG = datest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = datest.to_sdfg(simplify=True) nodes_before = sdfg.node(0).number_of_nodes() assert sdfg.apply_transformations(DeduplicateAccess) == 1 nodes_after = sdfg.node(0).number_of_nodes() assert nodes_after == nodes_before + 2 # i contiguous dimension - sdfg: dace.SDFG = datest.to_sdfg(coarsen=True) + sdfg: dace.SDFG = datest.to_sdfg(simplify=True) sdfg.arrays['A'].strides = [1, N] nodes_before = sdfg.node(0).number_of_nodes() assert sdfg.apply_transformations(DeduplicateAccess) == 1 diff --git a/tests/transformations/double_buffering_test.py b/tests/transformations/double_buffering_test.py index 1749e70a21..cddb0f42ab 100644 --- a/tests/transformations/double_buffering_test.py +++ b/tests/transformations/double_buffering_test.py @@ -35,7 +35,7 @@ def test_double_buffering(): print('Difference (before):', diff) # Apply local storage transformation on inner map (last two transformations) - sdfg.coarsen_dataflow() + sdfg.simplify() for i in range(2): for match in reversed(list(match_patterns(sdfg, InLocalStorage, states=[sdfg.node(0)]))): match.apply(sdfg.node(0), sdfg) diff --git a/tests/transformations/loop_manipulation_test.py b/tests/transformations/loop_manipulation_test.py index feee0a495d..dbeed91464 100644 --- a/tests/transformations/loop_manipulation_test.py +++ b/tests/transformations/loop_manipulation_test.py @@ -26,11 +26,11 @@ def regression(A, B): def test_unroll(): sdfg: dace.SDFG = tounroll.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 4 sdfg.apply_transformations(LoopUnroll) assert len(sdfg.nodes()) == (5 + 2) - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 1 A = np.random.rand(20) B = np.random.rand(20) @@ -46,11 +46,11 @@ def test_unroll(): def test_peeling_start(): sdfg: dace.SDFG = tounroll.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 4 sdfg.apply_transformations(LoopPeeling, dict(count=2)) assert len(sdfg.nodes()) == 6 - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 4 A = np.random.rand(20) B = np.random.rand(20) @@ -66,11 +66,11 @@ def test_peeling_start(): def test_peeling_end(): sdfg: dace.SDFG = tounroll.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 4 sdfg.apply_transformations(LoopPeeling, dict(count=2, begin=False)) assert len(sdfg.nodes()) == 6 - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(sdfg.nodes()) == 4 A = np.random.rand(20) B = np.random.rand(20) diff --git a/tests/transformations/map_collapse_test.py b/tests/transformations/map_collapse_test.py index e485b0e8bd..b33b367c29 100644 --- a/tests/transformations/map_collapse_test.py +++ b/tests/transformations/map_collapse_test.py @@ -19,7 +19,7 @@ def tocollapse(A: dace.float64[3, 3], B: dace.float64[2, 2]): def test_mapcollapse_tree(): sdfg: dace.SDFG = tocollapse.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.validate() assert sdfg.apply_transformations(MapCollapse) == 1 sdfg.validate() @@ -27,7 +27,7 @@ def test_mapcollapse_tree(): def test_mapcollapse_consolidated(): sdfg: dace.SDFG = tocollapse.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() consolidate_edges(sdfg) sdfg.validate() assert sdfg.apply_transformations(MapCollapse) == 1 diff --git a/tests/transformations/map_distribution_test.py b/tests/transformations/map_distribution_test.py index e80d6477c9..0a65e20eca 100644 --- a/tests/transformations/map_distribution_test.py +++ b/tests/transformations/map_distribution_test.py @@ -25,7 +25,7 @@ def test_eao_mpi(): raise ValueError("This test is supposed to be run with at least two processes!") for r in range(0, commsize): if r == rank: - mpi_sdfg = eao_mpi.to_sdfg(coarsen=True) + mpi_sdfg = eao_mpi.to_sdfg(simplify=True) mpi_sdfg.apply_transformations(ElementWiseArrayOperation) mpi_exec = mpi_sdfg.compile() comm.Barrier() diff --git a/tests/transformations/map_interchange_test.py b/tests/transformations/map_interchange_test.py index 73ed86a4af..45c7831e74 100644 --- a/tests/transformations/map_interchange_test.py +++ b/tests/transformations/map_interchange_test.py @@ -24,7 +24,7 @@ def test_map_interchange(): dace.Config.set('experimental', 'validate_undefs', value=True) sdfg = miprog.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.validate() # Apply map interchange diff --git a/tests/transformations/mapfusion_data_races_test.py b/tests/transformations/mapfusion_data_races_test.py index 9fc96b0021..328ad510e9 100644 --- a/tests/transformations/mapfusion_data_races_test.py +++ b/tests/transformations/mapfusion_data_races_test.py @@ -13,7 +13,7 @@ def rw_data_race(A: dace.float32[10, 10], B: dace.float32[10, 10]): def test_rw_data_race(): - sdfg = rw_data_race.to_sdfg(coarsen=True) + sdfg = rw_data_race.to_sdfg(simplify=True) sdfg.apply_transformations_repeated(MapFusion) map_entry_nodes = [n for n, _ in sdfg.all_nodes_recursive() if isinstance(n, nodes.MapEntry)] assert (len(map_entry_nodes) > 1) diff --git a/tests/transformations/mapfusion_fpga_test.py b/tests/transformations/mapfusion_fpga_test.py index ccfb63830f..2991d7b42c 100644 --- a/tests/transformations/mapfusion_fpga_test.py +++ b/tests/transformations/mapfusion_fpga_test.py @@ -9,7 +9,7 @@ @fpga_test() def test_multiple_fusions_fpga(): sdfg = multiple_fusions.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.apply_transformations_repeated(MapFusion) >= 2 assert sdfg.apply_transformations_repeated(FPGATransformSDFG) == 1 A = np.random.rand(10, 20).astype(np.float32) @@ -29,7 +29,7 @@ def test_fusion_with_transient_fpga(): A = np.random.rand(2, 20) expected = A * A * 2 sdfg = fusion_with_transient.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.apply_transformations_repeated(MapFusion) >= 2 assert sdfg.apply_transformations_repeated(FPGATransformSDFG) == 1 sdfg(A=A) diff --git a/tests/transformations/mapfusion_test.py b/tests/transformations/mapfusion_test.py index 7dc3eb8e49..0a1863b767 100644 --- a/tests/transformations/mapfusion_test.py +++ b/tests/transformations/mapfusion_test.py @@ -69,7 +69,7 @@ def fusion_chain(A: dace.float32[10, 20], B: dace.float32[10, 20]): def test_fusion_simple(): sdfg = fusion.to_sdfg() sdfg.save(os.path.join('_dacegraphs', 'before1.sdfg')) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated(MapFusion) sdfg.save(os.path.join('_dacegraphs', 'after1.sdfg')) @@ -88,7 +88,7 @@ def test_multiple_fusions(): num_nodes_before = len([node for state in sdfg.nodes() for node in state.nodes()]) sdfg.save(os.path.join('_dacegraphs', 'before2.sdfg')) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated(MapFusion) sdfg.save(os.path.join('_dacegraphs', 'after2.sdfg')) @@ -115,7 +115,7 @@ def test_multiple_fusions(): def test_fusion_chain(): sdfg = fusion_chain.to_sdfg() sdfg.save(os.path.join('_dacegraphs', 'before3.sdfg')) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations(MapFusion) num_nodes_before = len([node for state in sdfg.nodes() for node in state.nodes()]) sdfg.apply_transformations(MapFusion) @@ -157,7 +157,7 @@ def test_fusion_with_transient(): A = np.random.rand(2, 20) expected = A * A * 2 sdfg = fusion_with_transient.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations(MapFusion) sdfg(A=A) assert np.allclose(A, expected) diff --git a/tests/transformations/nested_copies_among_connectors.py b/tests/transformations/nested_copies_among_connectors.py index 4658627e2e..655de8f89d 100644 --- a/tests/transformations/nested_copies_among_connectors.py +++ b/tests/transformations/nested_copies_among_connectors.py @@ -4,9 +4,9 @@ from dace.transformation import dataflow, interstate, subgraph from dace.transformation.interstate import InlineSDFG -from dace.transformation.transformation import coarsening_transformations +from dace.transformation.transformation import simplification_transformations -xforms = coarsening_transformations() +xforms = simplification_transformations() xforms.remove(InlineSDFG) @@ -22,7 +22,7 @@ def inconn_self_copy(A: dace.int32[5, 5]): loop_body(A, B) return B - sdfg = inconn_self_copy.to_sdfg(coarsen=False) + sdfg = inconn_self_copy.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(xforms) sdfg.save('test_pre_is.sdfg') sdfg.apply_transformations(InlineSDFG) @@ -51,7 +51,7 @@ def outconn_self_copy(A: dace.int32[5, 5]): loop_body(A, B) return B - sdfg = outconn_self_copy.to_sdfg(coarsen=False) + sdfg = outconn_self_copy.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(xforms) sdfg.save('test_pre_is.sdfg') sdfg.apply_transformations(InlineSDFG) @@ -81,7 +81,7 @@ def in_out_inconn_copy(A: dace.int32[5, 5]): loop_body(A, B) return B - sdfg = in_out_inconn_copy.to_sdfg(coarsen=False) + sdfg = in_out_inconn_copy.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(xforms) sdfg.save('test_pre_is.sdfg') sdfg.apply_transformations(InlineSDFG) @@ -117,7 +117,7 @@ def intermediate_copies(A: dace.int32[5, 5]): loop_body(A, B) return B - sdfg = intermediate_copies.to_sdfg(coarsen=False) + sdfg = intermediate_copies.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(xforms) sdfg.save('test_pre_is.sdfg') sdfg.apply_transformations(InlineSDFG) diff --git a/tests/transformations/redundant_copy_data_races_test.py b/tests/transformations/redundant_copy_data_races_test.py index 8df46b8969..212fb3c89e 100644 --- a/tests/transformations/redundant_copy_data_races_test.py +++ b/tests/transformations/redundant_copy_data_races_test.py @@ -12,7 +12,7 @@ def rw_data_race(A: dace.float32[10, 10]): def test_rw_data_race(): - sdfg = rw_data_race.to_sdfg(coarsen=True) + sdfg = rw_data_race.to_sdfg(simplify=True) access_nodes = [n for n, _ in sdfg.all_nodes_recursive() if isinstance(n, nodes.AccessNode)] assert (len(access_nodes) > 2) diff --git a/tests/transformations/redundant_copy_test.py b/tests/transformations/redundant_copy_test.py index 90f906c5a1..89af619eb5 100644 --- a/tests/transformations/redundant_copy_test.py +++ b/tests/transformations/redundant_copy_test.py @@ -27,7 +27,7 @@ def test_out(): state.add_edge(C, None, trans, "_inp", sdfg.make_array_memlet("C")) state.add_edge(trans, "_out", D, None, sdfg.make_array_memlet("D")) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated(RedundantArrayCopying) assert len(state.nodes()) == 3 assert B not in state.nodes() @@ -68,7 +68,7 @@ def test_out_success(): state.add_memlet_path(t, mx, E, memlet=dace.Memlet.simple("E", "i, j, k"), src_conn='__out') sdfg.validate() - sdfg.coarsen_dataflow() + sdfg.simplify() arrays, views = 0, 0 for n in state.nodes(): if isinstance(n, dace.nodes.AccessNode): @@ -112,7 +112,7 @@ def test_out_failure_subset_mismatch(): state.add_nedge(B, C, dace.Memlet.simple("B", "0:3, 2", other_subset_str="1, 2, 0:3, 4")) sdfg.validate() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(state.nodes()) == 3 assert B in state.nodes() @@ -133,7 +133,7 @@ def test_out_failure_no_overlap(): state.add_nedge(B, C, dace.Memlet.simple("B", "0:3, 2", other_subset_str="1, 2, 0:3, 4")) sdfg.validate() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(state.nodes()) == 3 assert B in state.nodes() @@ -154,7 +154,7 @@ def test_out_failure_partial_overlap(): state.add_nedge(B, C, dace.Memlet.simple("B", "4:7, 6", other_subset_str="1, 2, 0:3, 4")) sdfg.validate() - sdfg.coarsen_dataflow() + sdfg.simplify() assert len(state.nodes()) == 3 assert B in state.nodes() @@ -179,7 +179,7 @@ def test_in(): state.add_edge(B, None, C, None, sdfg.make_array_memlet("B")) state.add_edge(C, None, D, None, sdfg.make_array_memlet("C")) - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated(RedundantArrayCopyingIn) assert len(state.nodes()) == 3 assert C not in state.nodes() @@ -262,7 +262,7 @@ def conv2d(input: dace.float32[N, H, W, C_in], weights: dace.float32[K, K, C_in, def test_conv2d(): - sdfg = conv2d.to_sdfg(coarsen=True) + sdfg = conv2d.to_sdfg(simplify=True) access_nodes = [ n for n, _ in sdfg.all_nodes_recursive() if isinstance(n, nodes.AccessNode) and not isinstance(sdfg.arrays[n.data], dace.data.View) diff --git a/tests/transformations/redundant_reshape_views_test.py b/tests/transformations/redundant_reshape_views_test.py index a606c426e2..1fd582e2d3 100644 --- a/tests/transformations/redundant_reshape_views_test.py +++ b/tests/transformations/redundant_reshape_views_test.py @@ -24,7 +24,7 @@ def test_inline_reshape_views_work(A: dace.float64[9], B: dace.float64[9]): result[:] = np.reshape(nested_add1(A, B), [9]) return nested_add1(result, B) - sdfg = test_inline_reshape_views_work.to_sdfg(coarsen=True) + sdfg = test_inline_reshape_views_work.to_sdfg(simplify=True) arrays = 0 views = 0 @@ -49,9 +49,9 @@ def test_inline_reshape_views_work(A: dace.float64[3, 3], B: dace.float64[9]): return np.transpose(result_reshaped) - sdfg = test_inline_reshape_views_work.to_sdfg(coarsen=False) + sdfg = test_inline_reshape_views_work.to_sdfg(simplify=False) sdfg.expand_library_nodes() - sdfg.coarsen_dataflow() + sdfg.simplify() if __name__ == "__main__": diff --git a/tests/transformations/redundant_slices_test.py b/tests/transformations/redundant_slices_test.py index ecc47cac3f..a66378090a 100644 --- a/tests/transformations/redundant_slices_test.py +++ b/tests/transformations/redundant_slices_test.py @@ -22,7 +22,7 @@ def jacobi1d_half(TMAX: dace.int32, A: dace.float32[12], B: dace.float32[12]): def test_read_slice(): - sdfg = jacobi1d_half.to_sdfg(coarsen=False) + sdfg = jacobi1d_half.to_sdfg(simplify=False) num_views_before = _count_views(sdfg) if num_views_before != 3: warnings.Warn("Incorrect number of Views detected. Please ensure that " @@ -39,7 +39,7 @@ def jacobi1d_half2(TMAX: dace.int32, A: dace.float32[12, 12, 12], B: dace.float3 def test_read_slice2(): - sdfg = jacobi1d_half2.to_sdfg(coarsen=False) + sdfg = jacobi1d_half2.to_sdfg(simplify=False) num_views_before = _count_views(sdfg) if num_views_before != 3: warnings.Warn("Incorrect number of Views detected. Please ensure that " @@ -56,7 +56,7 @@ def write_slice(A: dace.float32[10]): def test_write_slice(): - sdfg = write_slice.to_sdfg(coarsen=False) + sdfg = write_slice.to_sdfg(simplify=False) num_views_before = _count_views(sdfg) if num_views_before == 0: warnings.Warn("Incorrect number of Views detected. Please ensure that " @@ -77,7 +77,7 @@ def write_slice2(A: dace.float32[10, 10, 10]): def test_write_slice2(): - sdfg = write_slice2.to_sdfg(coarsen=False) + sdfg = write_slice2.to_sdfg(simplify=False) num_views_before = _count_views(sdfg) if num_views_before == 0: warnings.Warn("Incorrect number of Views detected. Please ensure that " diff --git a/tests/transformations/state_elimination_test.py b/tests/transformations/state_elimination_test.py index 7592e8120a..5e72dedad4 100644 --- a/tests/transformations/state_elimination_test.py +++ b/tests/transformations/state_elimination_test.py @@ -10,7 +10,7 @@ def test_eliminate_end_state(): state3 = sdfg.add_state() sdfg.add_edge(state1, state2, dace.InterstateEdge(assignments=dict(k=1))) sdfg.add_edge(state2, state3, dace.InterstateEdge(assignments=dict(k='k + 1'))) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 @@ -36,7 +36,7 @@ def test_state_assign_elimination(): # Applying transformations again should yield one state assert sdfg.apply_transformations_repeated(StateAssignElimination) == 1 - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.number_of_nodes() == 1 assert str(sdfg.nodes()[-1].edges()[0].data.subset) == '2' diff --git a/tests/transformations/state_fusion_test.py b/tests/transformations/state_fusion_test.py index 370db4f609..1bfda78803 100644 --- a/tests/transformations/state_fusion_test.py +++ b/tests/transformations/state_fusion_test.py @@ -160,7 +160,7 @@ def state_fusion_test(A: dace.int32[20, 20]): tmp = A + 2 A[:] = tmp + 3 - sdfg = state_fusion_test.to_sdfg(coarsen=False) + sdfg = state_fusion_test.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(StateFusion) assert len(sdfg.nodes()) == 1 @@ -176,7 +176,7 @@ def state_fusion_test(A: dace.int32[N, N]): A[0:N - 1, :] = 1 A[N - 1, :] = 2 - sdfg = state_fusion_test.to_sdfg(coarsen=False) + sdfg = state_fusion_test.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(StateFusion) assert len(sdfg.nodes()) == 1 @@ -193,7 +193,7 @@ def state_fusion_test(A: dace.int32[N, N], B: dace.int32[N, N]): A[:, 5:N] = 1 B[:, 3:6] = A[:, 0:3] - sdfg = state_fusion_test.to_sdfg(coarsen=False) + sdfg = state_fusion_test.to_sdfg(simplify=False) sdfg.apply_transformations_repeated(StateFusion) assert len(sdfg.nodes()) == 1 @@ -373,8 +373,8 @@ def func(A: dace.float64[128, 128], B: dace.float64[128, 128]): ao >> A[i, j] ao = 2 * ai - sdfg = func.to_sdfg(coarsen=False) - sdfg.coarsen_dataflow() + sdfg = func.to_sdfg(simplify=False) + sdfg.simplify() assert sdfg.number_of_nodes() == 2 diff --git a/tests/transformations/state_fusion_twowrites_test.py b/tests/transformations/state_fusion_twowrites_test.py index 5a16adce1e..0d8cfcaace 100644 --- a/tests/transformations/state_fusion_twowrites_test.py +++ b/tests/transformations/state_fusion_twowrites_test.py @@ -59,7 +59,7 @@ def test_sftw(): A = np.random.rand(20) expected = 2 * A + 7 sdfg = sftw.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() # Ensure almost all states were fused assert len(sdfg.nodes()) == 2 diff --git a/tests/transformations/subgraph_fusion/complex_test.py b/tests/transformations/subgraph_fusion/complex_test.py index f04644b7c7..a1b52fb29f 100644 --- a/tests/transformations/subgraph_fusion/complex_test.py +++ b/tests/transformations/subgraph_fusion/complex_test.py @@ -130,7 +130,7 @@ def _test_quantitatively(sdfg, graph): def test_complex(): sdfg = subgraph_fusion_complex.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() _test_quantitatively(sdfg, sdfg.nodes()[0]) diff --git a/tests/transformations/subgraph_fusion/create_out_transient_test.py b/tests/transformations/subgraph_fusion/create_out_transient_test.py index 284c58906d..8c41e70d77 100644 --- a/tests/transformations/subgraph_fusion/create_out_transient_test.py +++ b/tests/transformations/subgraph_fusion/create_out_transient_test.py @@ -88,7 +88,7 @@ def _test_quantitatively(sdfg, graph): def test_out_transient1(): # non-transient sdfg = program1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] _test_quantitatively(sdfg, graph) @@ -96,7 +96,7 @@ def test_out_transient1(): def test_out_transient2(): # transient sdfg = program2.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] _test_quantitatively(sdfg, graph) diff --git a/tests/transformations/subgraph_fusion/disjoint_test.py b/tests/transformations/subgraph_fusion/disjoint_test.py index 8c561a441f..b8122d30a0 100644 --- a/tests/transformations/subgraph_fusion/disjoint_test.py +++ b/tests/transformations/subgraph_fusion/disjoint_test.py @@ -81,7 +81,7 @@ def disjoint_test_3(A: dace.float64[M]): def test_p1(): sdfg = disjoint_test_1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] assert len(sdfg.nodes()) == 1 A = np.random.rand(M.get(), 2).astype(np.float64) @@ -106,7 +106,7 @@ def test_p1(): def test_p2(): sdfg = disjoint_test_2.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] assert len(sdfg.nodes()) == 1 @@ -117,7 +117,7 @@ def test_p2(): def test_p3(): sdfg = disjoint_test_3.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] assert len(sdfg.nodes()) == 1 diff --git a/tests/transformations/subgraph_fusion/invariant_dimension_test.py b/tests/transformations/subgraph_fusion/invariant_dimension_test.py index 476d8f5444..ed8be8a4f6 100644 --- a/tests/transformations/subgraph_fusion/invariant_dimension_test.py +++ b/tests/transformations/subgraph_fusion/invariant_dimension_test.py @@ -126,7 +126,7 @@ def _test_quantitatively(sdfg, graph): def test_invariant_dim(): sdfg = invariant_dimension.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] fix_sdfg(sdfg, graph) _test_quantitatively(sdfg, graph) diff --git a/tests/transformations/subgraph_fusion/parallel_test.py b/tests/transformations/subgraph_fusion/parallel_test.py index 16230b41ff..4d65650217 100644 --- a/tests/transformations/subgraph_fusion/parallel_test.py +++ b/tests/transformations/subgraph_fusion/parallel_test.py @@ -67,7 +67,7 @@ def test_p1(): R.set(25) sdfg = subgraph_fusion_parallel.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] A = np.random.rand(N.get()).astype(np.float64) diff --git a/tests/transformations/subgraph_fusion/reduction_fuse_test.py b/tests/transformations/subgraph_fusion/reduction_fuse_test.py index 4feb4bd885..dabc428660 100644 --- a/tests/transformations/subgraph_fusion/reduction_fuse_test.py +++ b/tests/transformations/subgraph_fusion/reduction_fuse_test.py @@ -38,7 +38,7 @@ def reduction_test_3(A: dace.float64[M, N], B: dace.float64[M, N], C: dace.float @pytest.mark.parametrize(["in_transient", "out_transient"], settings) def test_p3(in_transient, out_transient): sdfg = reduction_test_3.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] A = np.random.rand(M.get(), N.get()).astype(np.float64) B = np.random.rand(M.get(), N.get()).astype(np.float64) diff --git a/tests/transformations/subgraph_fusion/reduction_test.py b/tests/transformations/subgraph_fusion/reduction_test.py index 20489f84f3..0839c67e6e 100644 --- a/tests/transformations/subgraph_fusion/reduction_test.py +++ b/tests/transformations/subgraph_fusion/reduction_test.py @@ -46,7 +46,7 @@ def reduction_test_2(A: dace.float64[M, N], B: dace.float64[M, N], C: dace.float @pytest.mark.parametrize(["in_transient", "out_transient"], settings) def test_p1(in_transient, out_transient): sdfg = reduction_test_1.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] for node in state.nodes(): if isinstance(node, dace.libraries.standard.nodes.Reduce): @@ -79,7 +79,7 @@ def test_p1(in_transient, out_transient): @pytest.mark.parametrize(["in_transient", "out_transient"], settings) def test_p2(in_transient, out_transient): sdfg = reduction_test_2.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() state = sdfg.nodes()[0] A = np.random.rand(M.get(), N.get()).astype(np.float64) B = np.random.rand(M.get(), N.get()).astype(np.float64) diff --git a/tests/transformations/subgraph_fusion/smax_test.py b/tests/transformations/subgraph_fusion/smax_test.py index 8d072a835f..1cf0da7aec 100644 --- a/tests/transformations/subgraph_fusion/smax_test.py +++ b/tests/transformations/subgraph_fusion/smax_test.py @@ -76,7 +76,7 @@ def get_partition(sdfg, graph): def test_2fuse(): sdfg = softmax.to_sdfg() sdfg.name = 'softmax_2part' - sdfg.coarsen_dataflow() + sdfg.simplify() X_in = np.random.rand(H.get(), B.get(), SN.get(), SM.get()).astype(np.float32) csdfg = sdfg.compile() @@ -100,7 +100,7 @@ def test_2fuse(): def test_1fuse(): sdfg = softmax.to_sdfg() sdfg.name = 'softmax_fused' - sdfg.coarsen_dataflow() + sdfg.simplify() X_in = np.random.rand(H.get(), B.get(), SN.get(), SM.get()).astype(np.float32) csdfg = sdfg.compile() @@ -125,7 +125,7 @@ def test_1fuse(): def test_1fuse(): sdfg = softmax.to_sdfg() sdfg.name = 'softmax_fused' - sdfg.coarsen_dataflow() + sdfg.simplify() X_in = np.random.rand(H.get(), B.get(), SN.get(), SM.get()).astype(np.float32) csdfg = sdfg.compile() diff --git a/tests/transformations/subgraph_fusion/tiling_pool_test.py b/tests/transformations/subgraph_fusion/tiling_pool_test.py index 5a0dac8894..f2688a0a6c 100644 --- a/tests/transformations/subgraph_fusion/tiling_pool_test.py +++ b/tests/transformations/subgraph_fusion/tiling_pool_test.py @@ -65,7 +65,7 @@ def invoke_stencil(tile_size, offset=False, unroll=False): sdfg = stencil_offset.to_sdfg() else: sdfg = stencil.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] # baseline @@ -88,7 +88,7 @@ def invoke_stencil(tile_size, offset=False, unroll=False): csdfg(A=A, B=B2, N=N) del csdfg - sdfg.coarsen_dataflow() + sdfg.simplify() subgraph = SubgraphView(graph, [n for n in graph.nodes()]) sf = SubgraphFusion(subgraph) assert sf.can_be_applied(sdfg, subgraph) diff --git a/tests/transformations/subgraph_fusion/tiling_stencil_test.py b/tests/transformations/subgraph_fusion/tiling_stencil_test.py index df27065fda..f8559a8898 100644 --- a/tests/transformations/subgraph_fusion/tiling_stencil_test.py +++ b/tests/transformations/subgraph_fusion/tiling_stencil_test.py @@ -105,7 +105,7 @@ def invoke_stencil(tile_size, offset=False, unroll=False, view=False): sdfg = stencil_offset.to_sdfg() else: sdfg = stencil.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() graph = sdfg.nodes()[0] if view: @@ -133,7 +133,7 @@ def invoke_stencil(tile_size, offset=False, unroll=False, view=False): del csdfg assert np.allclose(B1, B2) - sdfg.coarsen_dataflow() + sdfg.simplify() subgraph = SubgraphView(graph, [n for n in graph.nodes()]) sf = SubgraphFusion(subgraph) assert sf.can_be_applied(sdfg, subgraph) diff --git a/tests/transformations/sve/sve_vectorization_test.py b/tests/transformations/sve/sve_vectorization_test.py index eaa3584aed..a85267cf00 100644 --- a/tests/transformations/sve/sve_vectorization_test.py +++ b/tests/transformations/sve/sve_vectorization_test.py @@ -31,7 +31,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) assert sdfg.apply_transformations(SVEVectorization) == 1 @@ -44,7 +44,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i * i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # [i * i] has a stride of 2i + 1 which is not constant (cannot be vectorized) assert sdfg.apply_transformations(SVEVectorization) == 0 @@ -58,7 +58,7 @@ def program(A: dace.float32[N, N], B: dace.float32[N, N]): b >> B[i, i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # [i, i] has a stride of N + 1, so it is perfectly fine assert sdfg.apply_transformations(SVEVectorization) == 1 @@ -72,7 +72,7 @@ def program(A: dace.complex64[N], B: dace.complex64[N]): b >> B[i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # Complex datatypes are currently not supported by the codegen assert sdfg.apply_transformations(SVEVectorization) == 0 @@ -86,7 +86,7 @@ def program(A: dace.float32[N], B: dace.int32[1]): b >> B(-1, lambda x, y: x + y)[0] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # Complex datatypes are currently not supported by the codegen assert sdfg.apply_transformations(SVEVectorization) == 1 @@ -101,7 +101,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[j] b = a_vec - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) sdfg.apply_transformations(SVEVectorization) # i is constant in the vectorized map @@ -121,7 +121,7 @@ def program(A, B): b = a S_out >> B - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # Stream push is possible assert sdfg.apply_transformations(SVEVectorization) == 1 @@ -137,6 +137,6 @@ def program(A, B): b >> B[i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) # Stream pop is not implemented yet assert sdfg.apply_transformations(SVEVectorization) == 0 diff --git a/tests/transformations/sve/vector_inference_test.py b/tests/transformations/sve/vector_inference_test.py index 0e5d99cc49..12539d47bf 100644 --- a/tests/transformations/sve/vector_inference_test.py +++ b/tests/transformations/sve/vector_inference_test.py @@ -53,7 +53,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = a - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) assert is_vector_connector(inf, 'a', True) assert is_vector_connector(inf, 'b', False) @@ -68,7 +68,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = 0.0 # looks like b is a scalar (but isn't) - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) assert is_vector_connector(inf, 'a', True) @@ -91,7 +91,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = x_in - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) assert is_vector_connector(inf, 'a', True) @@ -116,7 +116,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = x_in - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) # Except for b every connector is scalar @@ -143,7 +143,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = x_in - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) # Again except for b every connector is scalar @@ -169,7 +169,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): b >> B[i] b = x_in - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) with pytest.raises(vector_inference.VectorInferenceException): vectorize(sdfg) @@ -195,7 +195,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): # The challenge here is that one Tasklet writes a vector into an Array access node # But the other Tasklet then reads a scalar from it (is okay because its an Array) - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) assert not is_vector_connector(inf, 'a', True) @@ -226,7 +226,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): # x_in, y_in and z_in are vectors - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vectorize(sdfg) assert is_vector_connector(inf, 'a', True) @@ -257,7 +257,7 @@ def program(A: dace.float32[N], B: dace.float32[N]): # This is an artificial constraint test where z_in wants scal as # a scalar instead of a vector - sdfg = program.to_sdfg(coarsen=True) + sdfg = program.to_sdfg(simplify=True) inf = vector_inference.VectorInferenceGraph(sdfg, sdfg.start_state, find_map_entry(sdfg), -1) inf.set_constraint((find_tasklet_by_connector(sdfg, 'z_in'), 'z_in', True), vector_inference.InferenceNode.Scalar) diff --git a/tests/transformations/tasklet_fusion_test.py b/tests/transformations/tasklet_fusion_test.py index d8cc4fd2b9..07938972c8 100644 --- a/tests/transformations/tasklet_fusion_test.py +++ b/tests/transformations/tasklet_fusion_test.py @@ -2,7 +2,7 @@ import numpy as np import dace from dace import dtypes -from dace.transformation import coarsening_transformations +from dace.transformation import simplification_transformations from dace.transformation.dataflow import SimpleTaskletFusion import pytest @@ -60,8 +60,8 @@ def _make_sdfg(l: str = 'Python'): @pytest.mark.parametrize("l", [pytest.param('Python'), pytest.param('CPP')]) def test_map_with_tasklets(l: str): sdfg = _make_sdfg(l) - coarsening_reduced = [xf for xf in coarsening_transformations() if xf.__name__ != 'SimpleTaskletFusion'] - sdfg.apply_transformations_repeated(coarsening_reduced) + simplify_reduced = [xf for xf in simplification_transformations() if xf.__name__ != 'SimpleTaskletFusion'] + sdfg.apply_transformations_repeated(simplify_reduced) num = sdfg.apply_transformations_repeated(SimpleTaskletFusion) assert (num == 4) func = sdfg.compile() diff --git a/tests/transformations/tiling_number_of_tiles_test.py b/tests/transformations/tiling_number_of_tiles_test.py index b171448ce6..2228988a5d 100644 --- a/tests/transformations/tiling_number_of_tiles_test.py +++ b/tests/transformations/tiling_number_of_tiles_test.py @@ -27,7 +27,7 @@ def test_tiling_number_of_tiles(): Y = np.random.rand(size) Z = np.copy(Y) sdfg = axpy.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations(StripMining, options=[{'tile_size': '16', 'tiling_type': dace.TilingType.NumberOfTiles}]) sdfg(A=A, X=X, Y=Y, N=size) assert np.allclose(Y, A * X + Z) diff --git a/tests/transformations/tiling_vectorization_test.py b/tests/transformations/tiling_vectorization_test.py index ff6267a0c9..e042c77f7e 100644 --- a/tests/transformations/tiling_vectorization_test.py +++ b/tests/transformations/tiling_vectorization_test.py @@ -28,7 +28,7 @@ def test_tiling_vectorization(): Z = aligned_ndarray(np.zeros_like(Y)) sdfg = multiply.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations([StripMining, Vectorization], options=[{ 'tile_size': str(vector_len) diff --git a/tests/transformations/vectorization_test.py b/tests/transformations/vectorization_test.py index 58cbd794ee..ef3089b355 100644 --- a/tests/transformations/vectorization_test.py +++ b/tests/transformations/vectorization_test.py @@ -50,7 +50,7 @@ def test_vectorization_uneven(): sdfg(A=A, N=20) assert np.allclose(A, result) - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.apply_transformations(Vectorization, options={'vector_len': 2}) == 1 assert 'vec' in sdfg.generate_code()[0].code @@ -61,7 +61,7 @@ def test_vectorization_uneven(): def test_vectorization_postamble(): sdfg: dace.SDFG = tovec_sym.to_sdfg() - sdfg.coarsen_dataflow() + sdfg.simplify() assert sdfg.apply_transformations(Vectorization) == 1 assert 'vec' in sdfg.generate_code()[0].code csdfg = sdfg.compile() diff --git a/tests/transformations/view_redundant_array_test.py b/tests/transformations/view_redundant_array_test.py index 324658dcb3..1e3233b5a4 100644 --- a/tests/transformations/view_redundant_array_test.py +++ b/tests/transformations/view_redundant_array_test.py @@ -21,7 +21,7 @@ def test_redundant_array_removal(A: dace.float64[9], B: dace.float64[3]): data_accesses = { n.data - for n, _ in test_redundant_array_removal.to_sdfg(coarsen=True).all_nodes_recursive() + for n, _ in test_redundant_array_removal.to_sdfg(simplify=True).all_nodes_recursive() if isinstance(n, dace.nodes.AccessNode) } assert "A_reshaped" not in data_accesses @@ -41,7 +41,7 @@ def test_broken_matmul(A: dace.float64[8, 2, 4], B: dace.float64[4, 3]): sdfg = test_broken_matmul.to_sdfg() sdfg.expand_library_nodes() sdfg.apply_gpu_transformations() - sdfg.coarsen_dataflow() + sdfg.simplify() A = np.random.rand(8, 2, 4).astype(np.float64) B = np.random.rand(4, 3).astype(np.float64) @@ -69,7 +69,7 @@ def test_redundant_array_1_into_2_dims(copy_subset, nonstrict): copy_state.add_edge(copy_state.add_read("T"), None, copy_state.add_write("O"), None, sdfg.make_array_memlet(copy_subset)) - sdfg.coarsen_dataflow() + sdfg.simplify() if nonstrict: sdfg.apply_transformations_repeated(RedundantArray, permissive=True) @@ -101,7 +101,7 @@ def test_redundant_array_2_into_1_dim(copy_subset, nonstrict): copy_state.add_edge(copy_state.add_read("T"), None, copy_state.add_write("O"), None, sdfg.make_array_memlet(copy_subset)) - sdfg.coarsen_dataflow() + sdfg.simplify() if nonstrict: sdfg.apply_transformations_repeated(RedundantArray, permissive=True) diff --git a/tests/transformations/warp_tiling_test.py b/tests/transformations/warp_tiling_test.py index 661cacf0d6..24ff7ab925 100644 --- a/tests/transformations/warp_tiling_test.py +++ b/tests/transformations/warp_tiling_test.py @@ -32,14 +32,14 @@ def softmax(x): @pytest.mark.gpu def test_warp_softmax(vector_length=1): # Get SDFG - sdfg = softmax_fwd.to_sdfg(coarsen=True) + sdfg = softmax_fwd.to_sdfg(simplify=True) # Apply transformations sdfg.apply_transformations_repeated(ReduceExpansion) MultiExpansion.apply_to(sdfg, sdfg.node(0).nodes()) SubgraphFusion.apply_to(sdfg, sdfg.node(0).nodes()) sdfg.expand_library_nodes() - sdfg.coarsen_dataflow() + sdfg.simplify() sdfg.apply_transformations_repeated([TrivialMapElimination, MapFusion]) sdfg.apply_transformations(GPUTransformSDFG) assert sdfg.apply_transformations(WarpTiling) == 1 diff --git a/tutorials/spmv.ipynb b/tutorials/spmv.ipynb index c21f4f07e2..6a6d9b7d9f 100644 --- a/tutorials/spmv.ipynb +++ b/tutorials/spmv.ipynb @@ -193,11 +193,11 @@ " return next((n, s) for n, s in sdfg.all_nodes_recursive()\n", " if isinstance(n, dace.nodes.MapEntry) and n.label == name)\n", "\n", - "# Parse the program to an SDFG with dataflow coarsening\n", - "cpu_sdfg = spmv.to_sdfg(coarsen=True)\n", + "# Parse the program to an SDFG with simplification\n", + "cpu_sdfg = spmv.to_sdfg(simplify=True)\n", "# Transform the loop over the i-variable to a Map\n", "cpu_sdfg.apply_transformations(LoopToMap, {'itervar': 'i'})\n", - "cpu_sdfg.coarsen_dataflow()\n", + "cpu_sdfg.simplify()\n", "# Fuse the multiplication Map (`vals * x[cols]`) with the reduction (`dace.reduce`)\n", "cpu_sdfg.apply_transformations(MapReduceFusion)\n", "# Fuse the above (multiplication) Map with the indirection Map (`x[cols]`)\n", @@ -210,7 +210,7 @@ " second_map_entry=sme)\n", "# Remove trivial Tasklet\n", "cpu_sdfg.apply_transformations(TrivialTaskletElimination)\n", - "cpu_sdfg.coarsen_dataflow()\n", + "cpu_sdfg.simplify()\n", "# Since the outer Map iterates over the i-variable, all the WCRs on `y[i]` are\n", "# executed by a single thread. Therefore, we do not need to use atomics.\n", "for e, _ in cpu_sdfg.all_edges_recursive():\n", diff --git a/tutorials/transformations.ipynb b/tutorials/transformations.ipynb index 8428686e03..17c39ebda2 100644 --- a/tutorials/transformations.ipynb +++ b/tutorials/transformations.ipynb @@ -8,9 +8,9 @@ "\n", "Apart from modifying graphs manually using the SDFG API, you can also define more complex behavior that matches certain patterns in SDFGs and makes changes. This behavior is expressed in classes called `Transformation`s. Transformations are a powerful tool to optimize applications in DaCe. You can go from naive code to state-of-the-art performance using only transformations.\n", "\n", - "There are two general types of transformations: **pattern-matching transformations** (extending the `Transformation` class) and **subgraph transformations** (extending the `SubgraphTransformation` class). The former is based on one or more specific subgraph expressions, and the latter can be applied to any subgraph that passes the conditions. Internally, there are two methods to a Transformation: `can_be_applied`, which returns True if it can be applied on a given subgraph; and `apply`, which modifies the graph using the SDFG API. Some transformations run automatically on each graph (as part of the dataflow coarsening pass), and others have to be called manually. \n", + "There are two general types of transformations: **pattern-matching transformations** (extending the `Transformation` class) and **subgraph transformations** (extending the `SubgraphTransformation` class). The former is based on one or more specific subgraph expressions, and the latter can be applied to any subgraph that passes the conditions. Internally, there are two methods to a Transformation: `can_be_applied`, which returns True if it can be applied on a given subgraph; and `apply`, which modifies the graph using the SDFG API. Some transformations run automatically on each graph (as part of the simplification pass), and others have to be called manually. \n", "\n", - "You can find a list of the built-in standard transformations [here](https://spcldace.readthedocs.io/en/latest/source/dace.transformation.html). While these transformations cover many use-cases, they cannot cover everything (for example, domain-specific behavior). Thus, Transformations are easily extensible and [below](#Creating-New-Transformations) we show how to register a new one. You can register your transformations to be pattern-based, subgraph-based, coarsening, or not, upon defining a new class.\n", + "You can find a list of the built-in standard transformations [here](https://spcldace.readthedocs.io/en/latest/source/dace.transformation.html). While these transformations cover many use-cases, they cannot cover everything (for example, domain-specific behavior). Thus, Transformations are easily extensible and [below](#Creating-New-Transformations) we show how to register a new one. You can register your transformations to be pattern-based, subgraph-based, or not, upon defining a new class.\n", "\n", "This tutorial will deal with the different ways transformations can be applied on code:\n", "\n", @@ -72,7 +72,7 @@ "\n", "The easiest way to apply a transformation is to import the Transformation subclass and call `apply_transformations` or `apply_transformations_repeated` on the SDFG. The methods accept a transformation or a list of transformations, their parameters, and other parameters (for more info, see its [documentation](https://spcldace.readthedocs.io/en/latest/source/dace.sdfg.html#dace.sdfg.sdfg.SDFG.apply_transformations)).\n", "\n", - "To demonstrate transformations, we will first show the raw SDFG of `dbladd`, without dataflow coarsening:" + "To demonstrate transformations, we will first show the raw SDFG of `dbladd`, without simplification:" ] }, { @@ -101,7 +101,7 @@ } ], "source": [ - "sdfg = dbladd.to_sdfg(coarsen=False)\n", + "sdfg = dbladd.to_sdfg(simplify=False)\n", "sdfg" ] }, @@ -184,7 +184,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "Now that the dataflow aspects of the graph are clearer, it is easy to see that the `dbl` array is redundant. One of the dataflow coarsening transformations in the DaCe standard library deals with redundant array copies when one array is transient and unused anywhere else. To invoke this transformation, we can either import it directly, or simply try to apply all dataflow coarsening transformations. Note that this happens automatically when a Python function is defined without our special `coarsen=False` argument:" + "Now that the dataflow aspects of the graph are clearer, it is easy to see that the `dbl` array is redundant. One of the simplification pass transformations in the DaCe standard library deals with redundant array copies when one array is transient and unused anywhere else. To invoke this transformation, we can either import it directly, or simply try to apply all simplification transformations. Note that this happens automatically when a Python function is defined without our special `simplify=False` argument:" ] }, { @@ -213,7 +213,7 @@ } ], "source": [ - "sdfg.coarsen_dataflow()\n", + "sdfg.simplify()\n", "sdfg" ] }, @@ -322,7 +322,7 @@ "mult_exit = next(n for n in state.nodes() if isinstance(n, dace.nodes.MapExit) and n.label == '_Mult__map')\n", "# Same goes for the addition entry\n", "add_entry = next(n for n in state.nodes() if isinstance(n, dace.nodes.MapEntry) and n.label == '_Add__map')\n", - "# Since all redundant arrays have been removed by dataflow coarsening, we can get the only transient\n", + "# Since all redundant arrays have been removed by simplification, we can get the only transient\n", "# array that remains in the graph\n", "transient = next(aname for aname, desc in sdfg.arrays.items() if desc.transient)\n", "access_node = next(n for n in state.nodes() if isinstance(n, dace.nodes.AccessNode) and n.data == transient)\n", @@ -376,7 +376,7 @@ "\n", "### Subgraph Transformations\n", "\n", - "The same can be applied with subgraph transformations, but a subgraph is required instead of a pattern. In the following example we reload the SDFG (in the default mode, namely with dataflow coarsening), and then apply `SubgraphFusion` on the entire state (namely all of its nodes, or `state.nodes()`). The result will be similar to fusing the two maps as above, but can generalize to fuse any number of maps, parallel regions, and other cases." + "The same can be applied with subgraph transformations, but a subgraph is required instead of a pattern. In the following example we reload the SDFG (in the default mode, namely with SDFG simplification), and then apply `SubgraphFusion` on the entire state (namely all of its nodes, or `state.nodes()`). The result will be similar to fusing the two maps as above, but can generalize to fuse any number of maps, parallel regions, and other cases." ] }, {