2 * Copyright (C) 2017 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 /* This HAL is a work in progress */
19 package android.hardware.neuralnetworks@1.0;
21 // The types an operand can have.
22 // These values are the same as found in the NeuralNetworks.h file.
23 // When modifying, be sure to update HAL_NUM_OPERAND_TYPES in HalIntefaces.h.
24 enum OperandType : uint32_t {
36 TENSOR_QUANT8_ASYMM = 11,
39 // The type of operations. Unlike the operation types found in
40 // NeuralNetworks.h file, these specify the data type they operate on.
41 // This is done to simplify the work of drivers.
42 // TODO: Currently they are the same. Add a conversion when finalizing the model.
43 // When modifying, be sure to update HAL_NUM_OPERATION_TYPES in HalIntefaces.h.
44 enum OperationType : uint32_t {
50 DEPTHWISE_CONV_2D = 5,
57 HASHTABLE_LOOKUP = 12,
58 L2_NORMALIZATION = 13,
60 LOCAL_RESPONSE_NORMALIZATION = 15,
78 // Fused activation functions
79 enum FusedActivationFunc : int32_t {
86 // Two special values that can be used instead of a regular poolIndex.
87 enum LocationValues : uint32_t {
88 // The location will be specified at runtime. It's either a temporary
89 // variable, an input, or an output.
90 LOCATION_AT_RUN_TIME = 0xFFFFFFFF,
91 // The operand's value is stored in the
93 LOCATION_SAME_BLOCK = 0xFFFFFFFE
96 // Status of a device.
97 enum DeviceStatus : uint32_t {
101 UNKNOWN // Do we need this?
104 // For the reference workload
105 // Used by a driver to report its performance characteristics.
106 // TODO revisit the data types and scales.
107 struct PerformanceInfo {
108 float execTime; // in nanoseconds
109 float powerUsage; // in picoJoules
112 struct OperationTuple {
113 // The type of operation.
114 OperationType operationType;
115 // The input data type of operation.
116 OperandType operandType;
119 // The capabilities of a driver.
120 struct Capabilities {
121 vec<OperationTuple> supportedOperationTuples;
122 // TODO Do the same for baseline model IDs
123 bool cachesCompilation;
124 // TODO revisit the data types and scales.
125 float bootupTime; // in nanoseconds
126 PerformanceInfo float16Performance;
127 PerformanceInfo float32Performance;
128 PerformanceInfo quantized8Performance;
131 // Describes the location of a data object.
132 struct DataLocation {
133 // The index of the memory pool where this location is found.
134 // Two special values can also be used. See the LOCATION_* constants above.
136 // Offset in bytes from the start of the pool.
138 // The length of the data, in bytes.
144 vec<uint32_t> dimensions;
146 // The number of operations that uses this operand as input.
147 // TODO It would be nice to track the actual consumers, e.g. vec<uint32_t> consumers;
148 uint32_t numberOfConsumers;
153 // Where to find the data for this operand.
154 DataLocation location;
157 // Describes one operation of the graph.
159 // The tuple describing the operation type and input type.
160 OperationTuple opTuple;
161 // Describes the table that contains the indexes of the inputs of the
162 // operation. The offset is the index in the operandIndexes table.
163 vec<uint32_t> inputs;
164 // Describes the table that contains the indexes of the outputs of the
165 // operation. The offset is the index in the operandIndexes table.
166 vec<uint32_t> outputs;
169 struct InputOutputInfo {
170 DataLocation location;
171 // If dimensions.size() > 0, we have updated dimensions.
172 vec<uint32_t> dimensions;
176 vec<Operand> operands;
177 vec<Operation> operations;
178 vec<uint32_t> inputIndexes;
179 vec<uint32_t> outputIndexes;
180 vec<uint8_t> operandValues;
185 vec<InputOutputInfo> inputs;
186 vec<InputOutputInfo> outputs;
190 enum Status : uint32_t {