//
// This confidential and proprietary software may be used only as
// authorised by a licensing agreement from ARM Limited
// (C) COPYRIGHT 2020 ARM Limited
// ALL RIGHTS RESERVED
// The entire notice above must be reproduced on all authorised
// copies and copies may only be made to the extent permitted
// by a licensing agreement from ARM Limited.

=== Control Flow Operators

TOSA implements two control flow operators, for conditional branching and loop based transfer of control. Both refer to region labels, which express the address of another operator in the TOSA program, to which control transfers.

==== COND_IF

Evaluates a Boolean condition and then takes one of two distinct execution paths. This implements the semantic If-then-else structure.

*Input Operands:*

* List of Input tensors – up to 4D tensor of any data layout.
* A Boolean condition.

*Output Operands:*

* List of Input tensors – up to 4D tensor of any data layout. These need not have the same shapes as the list of input tensors.

*Region Labels:*

* Then: a reference to an operator that execution control transfers to if the Boolean condition is TRUE.
* Else: a reference to an operator that execution control transfers to if the Boolean condition is FALSE.

==== WHILE_LOOP

Generates and evaluates a Bool condition and either executes a loop body or exits to another control point. This action is performed repeatedly after updating and re-evaluating the Boolean condition every iteration. This implements the semantic foreach or while iterative loop structure.

*Input Operands:*

* List of Input tensors – up to 4D tensor of any data layout. The list comprises both the tensors that are used to compute each iteration of the Bool condition, and the inputs to the body of the loop.

*Output Operands:*

* List of Input tensors – up to 4D tensor of any data layout. These must have the same dynamic shapes as the list of input tensors.

*Region Labels:*

* Cond: a reference to an operator that execution control transfers to in order to evaluate the current iteration of the Bool condition, and to update the condition for the next iteration.
* Body: a reference to an operator that execution control transfers to in order to begin executing the body of the loop.

