1 /*
2 * Copyright (C) 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
17 package android.hardware.neuralnetworks@1.2;
19 import @1.0::Operand;
20 import @1.0::PerformanceInfo;
21 import @1.1::OperationType;
23 /**
24 * Operation types.
25 *
26 * The type of an operation in a model.
27 */
28 enum OperationType : @1.1::OperationType {
29 // TODO(b/116445845): Sync docs when all ops are implemented.
30 ARGMAX = 38,
31 ARGMIN = 39,
32 PAD_V2 = 40,
33 BBOX_TRANSFORM = 41,
34 BIDIRECTIONAL_SEQUENCE_LSTM = 42,
35 BIDIRECTIONAL_SEQUENCE_RNN = 43,
36 BOX_WITH_NMS_LIMIT = 44,
37 CAST = 45,
38 CHANNEL_SHUFFLE = 46,
39 DETECTION_OUTPUT = 47,
40 EMBEDDING_LOOKUP_SPARSE = 48,
41 EXP = 49,
42 EXPAND_DIMS = 50,
43 GATHER = 51,
44 GENERATE_PROPOSALS = 52,
45 GREATER = 53,
46 GREATER_EQUAL = 54,
47 GROUPED_CONV_2D = 55,
48 HEATMAP_MAX_KEYPOINT = 56,
49 LESS = 57,
50 LESS_EQUAL = 58,
51 LOG = 59,
52 LOGICAL_AND = 60,
53 LOGICAL_NOT = 61,
54 LOGICAL_OR = 62,
55 LOG_SOFTMAX = 63,
56 MAXIMUM = 64,
57 MINIMUM = 65,
58 NEG = 66,
59 POW = 67,
60 PRELU = 68,
61 PRIOR_BOX = 69,
62 QUANTIZE = 70,
63 QUANTIZED_16BIT_LSTM = 71,
64 RANDOM_MULTINOMIAL = 72,
65 REDUCE = 73,
66 ROI_ALIGN = 74,
67 RSQRT = 75,
68 SELECT = 76,
69 SIN = 77,
70 SLICE = 78,
71 SPARSE_TO_DENSE = 79,
72 SPLIT = 80,
73 SQRT = 81,
74 TILE = 82,
75 TOPK_V2 = 83,
76 TRANSPOSE_CONV_2D = 84,
77 UNIDIRECTIONAL_SEQUENCE_LSTM = 85,
78 UNIDIRECTIONAL_SEQUENCE_RNN = 86,
79 };
81 /**
82 * Describes one operation of the model's graph.
83 */
84 struct Operation {
85 /**
86 * The operation type.
87 */
88 OperationType type;
90 /**
91 * Describes the table that contains the indexes of the inputs of the
92 * operation. The offset is the index in the operandIndexes table.
93 */
94 vec<uint32_t> inputs;
96 /**
97 * Describes the table that contains the indexes of the outputs of the
98 * operation. The offset is the index in the operandIndexes table.
99 */
100 vec<uint32_t> outputs;
101 };
103 /**
104 * A Neural Network Model.
105 *
106 * This includes not only the execution graph, but also constant data such as
107 * weights or scalars added at construction time. The only information that
108 * may not be known is the shape of the input tensors.
109 */
110 struct Model {
111 /**
112 * All operands included in the model.
113 */
114 vec<Operand> operands;
116 /**
117 * All operations included in the model.
118 *
119 * The operations are sorted into execution order. Every operand
120 * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
121 * written before it is read.
122 */
123 vec<Operation> operations;
125 /**
126 * Input indexes of the model. There must be at least one.
127 *
128 * Each value corresponds to the index of the operand in "operands".
129 */
130 vec<uint32_t> inputIndexes;
132 /**
133 * Output indexes of the model. There must be at least one.
134 *
135 * Each value corresponds to the index of the operand in "operands".
136 */
137 vec<uint32_t> outputIndexes;
139 /**
140 * A byte buffer containing operand data that were copied into the model.
141 *
142 * An operand's value must be located here if and only if Operand::lifetime
143 * equals OperandLifeTime::CONSTANT_COPY.
144 */
145 vec<uint8_t> operandValues;
147 /**
148 * A collection of shared memory pools containing operand values.
149 *
150 * An operand's value must be located here if and only if Operand::lifetime
151 * equals OperandLifeTime::CONSTANT_REFERENCE.
152 */
153 vec<memory> pools;
155 /**
156 * 'true' indicates TENSOR_FLOAT32 may be calculated with range and/or
157 * precision as low as that of the IEEE 754 16-bit floating-point format.
158 * 'false' indicates TENSOR_FLOAT32 must be calculated using at least the
159 * range and precision of the IEEE 754 32-bit floating-point format.
160 */
161 bool relaxComputationFloat32toFloat16;
162 };