aboutsummaryrefslogtreecommitdiff
path: root/chapters/operators.adoc
blob: fa8cd47c4899981618c3f7dffabe18edbb3533bb (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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//
// This confidential and proprietary software may be used only as
// authorised by a licensing agreement from ARM Limited
// (C) COPYRIGHT 2020-2021 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.

== Operators

=== Operator Parameters

An operator processes input operands to produce output operands. An operator can have three types of parameters:

* An input operand. This must be a tensor or a list of tensors and data is read by the operation.
* An output operand. This must be a tensor or a list of tensors and data is written by the operation.
* An attribute. This is a parameter that is constant for a particular instance of the operator. It may have any data type supported by TOSA. It is expected to be set at compile time.

=== Operator Graphs

Some operators, such as control flow operators, take a graph of other operators as an attribute. The type tosa_graph_t will denote a graph of operators and the following functions define the tensor shape list for the graph input and outputs:

....
shape_list_t tosa_input_shape(tosa_graph_t graph);
shape_list_t tosa_output_shape(tosa_graph_t graph);
....

Similarly the type tensor_list_t will be used for a list of tensors and the following function returns the shape of a tensor list:
....
shape_list_t tensor_list_shape(tosa_list_t tensor_list);
....

The following function denotes the execution of a TOSA graph, on an input tensor list to produce an output tensor list.

....
tosa_execute_graph(tosa_graph_t graph, tosa_list_t input_list, tosa_list_t output_list) {
    assert(tensor_list_shape(input_list)==tosa_input_shape(graph));
    assert(tensor_list_shape(output_list)==tosa_output_shape(graph));
    <Execute TOSA graph operators as defined in this specification>
}
....

Note that within the graph, each input operand is instantiated as a PLACEHOLDER operator.

include::tensor_ops.adoc[]

include::activation_funcs.adoc[]

include::ewise_binary.adoc[]

include::ewise_unary.adoc[]

include::ewise_ternary.adoc[]

include::comparison.adoc[]

include::reduction.adoc[]

include::data_layout.adoc[]

include::scatter_gather.adoc[]

include::image.adoc[]

include::type_conversion.adoc[]

include::data_nodes.adoc[]

include::custom.adoc[]

include::control_flow.adoc[]