psyclone.psyad.utils
Utilities for the PSyclone Adjoint (PSyAD) functionality.
Functions
node_is_active()
: Determines whether this node contains variables that are active.node_is_passive()
: Determines whether this node contains only variables that arenegate_expr()
: Takes a PSyIR expression and negates it by multiplying it by minus
- psyclone.psyad.utils.node_is_active(node, active_variables)
Determines whether this node contains variables that are active.
- Parameters:
node (
psyclone.psyir.nodes.Node
) – the PSyIR node that is being evaluated.active_variables (List[
psyclone.psyir.symbols.DataSymbol
] | List[str]) – a list of active variables either as PSyIR symbols or as strings.
- Returns:
True if active and False otherwise.
- Return type:
bool
- Raises:
TypeError – if the node argument is not a Node.
TypeError – if the active_variables argument is not a list.
ValueError – if the active variables list does not contain datasymbols or if the list does not contain strings.
- psyclone.psyad.utils.node_is_passive(node, active_variables)
Determines whether this node contains only variables that are passive.
- Parameters:
node (
psyclone.psyir.nodes.Node
) – the PSyIR node that is being evaluated.active_variables (List[
psyclone.psyir.symbols.DataSymbol
] or List[str]) – a list of active variables either as PSyIR symbols or as strings.
- Returns:
True if passive and False otherwise.
- Return type:
bool
- psyclone.psyad.utils.negate_expr(orig_expr)
Takes a PSyIR expression and negates it by multiplying it by minus one. it is assumed that the expression returns an integer.
- Parameters:
orig_expr (
psyclone.psyir.nodes.DataNode
) – the PSyIR expression to negate.- Returns:
the expression multiplied by minus one.
- Rytpe: