aboutsummaryrefslogtreecommitdiff
path: root/chapters/control_flow.adoc
blob: 9efa3e7fb88bc9be399fe234964a0ca1b45f2b42 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// 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.