psyclone.domain.common.transformations.alg_invoke_2_psy_call_trans

Abstract base class to Transform a PSyclone algorithm-layer-specific invoke call into a call to the corresponding PSy-layer routine.

Classes

class psyclone.domain.common.transformations.alg_invoke_2_psy_call_trans.AlgInvoke2PSyCallTrans

Base class to transform (lower) an AlgorithmInvokeCall into a standard Call to a generated PSy-layer routine. Requires the abstract get_arguments method to be implemented as the logic to create arguments can differ between APIs.

This transformation would normally be written as a lowering method on an AlgorithmInvokeCall. However, we don’t always want to lower the code as we want the flexibility to also be able to output algorithm-layer code containing invoke’s. We therefore need to selectively apply the lowering, which is naturally written as a transformation.

Inheritance

Inheritance diagram of AlgInvoke2PSyCallTrans
apply(node, options=None)

Apply the transformation to the supplied AlgorithmInvokeCall. The supplied node will be replaced with a Call node with appropriate arguments. If there are no more invoke calls in the scope of the symbol table containing the ‘invoke’ symbol then that symbol is removed.

Parameters:
  • node (psyclone.domain.common.psyir.AlgorithmInvokeCall) – a PSyIR algorithm invoke call node.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.

abstract get_arguments(node, options=None)
Parameters:
  • node (psyclone.domain.common.psyir.AlgorithmInvokeCall) – a PSyIR algorithm invoke call node.

  • options (Optional[Dict[str, Any]]) – a dictionary with options for transformations.

static remove_imported_symbols(node)

Removes any imported kernel functor symbols from the supplied AlgorithmInvokeCall if they are not used in another AlgorithmInvokeCall. Also removes the associated container symbol if there are now no symbols imported from it.

Parameters:

node (psyclone.domain.common.algorithm.AlgorithmInvokeCall) – an AlgorithmInvokeCall node.

validate(node, options=None)

Validate the node argument.

Parameters:
Raises:
  • TransformationError – if the supplied call argument is not a PSyIR AlgorithmInvokeCall node.

  • InternalError – if no corresponding ‘invoke’ symbol is present.