# loki.transformations.dependency

Classes

`DuplicateKernel`([duplicate_kernels, ...]) | Duplicate subroutines which includes the creation of new :any:`Item`s as well as the addition of the corresponding new dependencies.
`RemoveKernel`([remove_kernels]) | Remove subroutines which includes the removal of the relevant :any:`Item`s as well as the removal of the corresponding dependencies.

class DuplicateKernel(duplicate_kernels=None, duplicate_suffix='duplicated', duplicate_module_suffix=None, duplicate_subgraph=False)

  Bases: `Transformation`

  Duplicate subroutines which includes the creation of new :any:`Item`s as well as the addition of the corresponding new dependencies.

  Therefore, this transformation creates a new item and also implements the relevant routines for dry-run pipeline planning runs.

  Parameters:

    - duplicate_kernels (str|tuple|list, optional) – Kernel name(s) to be duplicated.

    - duplicate_suffix (str, optional) – Suffix to be used to append the original kernel name(s).

    - duplicate_module_suffix (str, optional) – Suffix to be used to append the original module name(s), if defined, otherwise duplicate_suffix

    - duplicate_subgraph (bool, optional) – Whether or not duplicate the subgraph beneath the kernel(s) that are duplicated.

  creates_items = True
  reverse_traversal = True
  transform_subroutine(routine, **kwargs)

    Defines the transformation to apply to `Subroutine` items.

    For transformations that modify `Subroutine` objects, this method should be implemented. It gets called via the dispatch method `apply()`.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.

  plan_subroutine(routine, **kwargs)

    Define the planning steps to apply for `Subroutine` items.

    For transformations that modify the dependencies of `routine` (e.g., adding new procedure calls, inlining calls, renaming the interface) this should be implemented. It gets called via the dispatch method `apply()` if the optional `plan_mode` argument is set to True.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.

class RemoveKernel(remove_kernels=None)

  Bases: `Transformation`

  Remove subroutines which includes the removal of the relevant :any:`Item`s as well as the removal of the corresponding dependencies.

  Therefore, this transformation creates a new item and also implements the relevant routines for dry-run pipeline planning runs.

  Parameters:

    remove_kernels (str|tuple|list, optional) – Kernel name(s) to be removed.

  creates_items = True
  transform_subroutine(routine, **kwargs)

    Defines the transformation to apply to `Subroutine` items.

    For transformations that modify `Subroutine` objects, this method should be implemented. It gets called via the dispatch method `apply()`.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.

  plan_subroutine(routine, **kwargs)

    Define the planning steps to apply for `Subroutine` items.

    For transformations that modify the dependencies of `routine` (e.g., adding new procedure calls, inlining calls, renaming the interface) this should be implemented. It gets called via the dispatch method `apply()` if the optional `plan_mode` argument is set to True.

    Parameters:

      - routine (`Subroutine`) – The subroutine to be transformed.

      - **kwargs (optional) – Keyword arguments for the transformation.