summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLev Proleev2018-10-01 05:18:31 -0500
committerPrzemyslaw Szczepaniak2018-10-19 03:29:09 -0500
commit08662c6f66fa724a46b0ce1ae13a3c9358a658b4 (patch)
tree7488d1670dc8bc7dd6d12c2f24ab3ae42d08b472 /neuralnetworks
parent618028b888dadc61152e0e0afc623a5de268df8a (diff)
downloadplatform-hardware-interfaces-08662c6f66fa724a46b0ce1ae13a3c9358a658b4.tar.gz
platform-hardware-interfaces-08662c6f66fa724a46b0ce1ae13a3c9358a658b4.tar.xz
platform-hardware-interfaces-08662c6f66fa724a46b0ce1ae13a3c9358a658b4.zip
Add new OperandType BOOL.
- Add new enum OperandType::BOOL. - Add v1.2 Operand, OperandType. - Add VTS validation tests for BOOL. Bug: 117423393 Test: NeuralNetworksTest_static Test: VtsHalNeuralnetworksV1_2TargetTest Change-Id: I420e2afeb09b881a499eee6b138c1f26e9874f5a Merged-In: I420e2afeb09b881a499eee6b138c1f26e9874f5a (cherry picked from commit abad9eac448cc61582a9a658a231010358051b97)
Diffstat (limited to 'neuralnetworks')
-rw-r--r--neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h4
-rw-r--r--neuralnetworks/1.2/Android.bp2
-rw-r--r--neuralnetworks/1.2/types.hal109
-rw-r--r--neuralnetworks/1.2/vts/functional/ValidateModel.cpp14
4 files changed, 121 insertions, 8 deletions
diff --git a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
index 0050e52d..a64268f4 100644
--- a/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
+++ b/neuralnetworks/1.1/vts/functional/VtsHalNeuralnetworks.h
@@ -34,9 +34,11 @@ namespace hardware {
34namespace neuralnetworks { 34namespace neuralnetworks {
35namespace V1_1 { 35namespace V1_1 {
36 36
37using V1_0::Request;
38using V1_0::DeviceStatus; 37using V1_0::DeviceStatus;
39using V1_0::ErrorStatus; 38using V1_0::ErrorStatus;
39using V1_0::Operand;
40using V1_0::OperandType;
41using V1_0::Request;
40 42
41namespace vts { 43namespace vts {
42namespace functional { 44namespace functional {
diff --git a/neuralnetworks/1.2/Android.bp b/neuralnetworks/1.2/Android.bp
index d5ef49d4..5a661e06 100644
--- a/neuralnetworks/1.2/Android.bp
+++ b/neuralnetworks/1.2/Android.bp
@@ -17,6 +17,8 @@ hidl_interface {
17 ], 17 ],
18 types: [ 18 types: [
19 "Model", 19 "Model",
20 "Operand",
21 "OperandType",
20 "Operation", 22 "Operation",
21 "OperationType", 23 "OperationType",
22 ], 24 ],
diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal
index bed1d5ca..95e97c4b 100644
--- a/neuralnetworks/1.2/types.hal
+++ b/neuralnetworks/1.2/types.hal
@@ -16,10 +16,22 @@
16 16
17package android.hardware.neuralnetworks@1.2; 17package android.hardware.neuralnetworks@1.2;
18 18
19import @1.0::Operand; 19import @1.0::DataLocation;
20import @1.0::OperandLifeTime;
21import @1.0::OperandType;
20import @1.0::PerformanceInfo; 22import @1.0::PerformanceInfo;
21import @1.1::OperationType; 23import @1.1::OperationType;
22 24
25enum OperandType : @1.0::OperandType {
26 /**
27 * An 8 bit boolean scalar value.
28 *
29 * Values of this operand type are either true or false. A zero value
30 * represents false; any other value represents true.
31 */
32 BOOL = 6,
33};
34
23/** 35/**
24 * Operation types. 36 * Operation types.
25 * 37 *
@@ -102,6 +114,101 @@ struct Operation {
102}; 114};
103 115
104/** 116/**
117 * Describes one operand of the model's graph.
118 */
119struct Operand {
120 /**
121 * Data type of the operand.
122 */
123 OperandType type;
124
125 /**
126 * Dimensions of the operand.
127 *
128 * For a scalar operand, dimensions.size() must be 0.
129 *
130 * For a tensor operand, dimensions.size() must be at least 1;
131 * however, any of the dimensions may be unspecified.
132 *
133 * A tensor operand with all dimensions specified has "fully
134 * specified" dimensions. Whenever possible (i.e., whenever the
135 * dimensions are known at model construction time), a tensor
136 * operand should have (but is not required to have) fully
137 * specified dimensions, in order to enable the best possible
138 * performance.
139 *
140 * If a tensor operand's dimensions are not fully specified, the
141 * dimensions of the operand are deduced from the operand
142 * dimensions and values of the operation for which that operand
143 * is an output.
144 *
145 * In the following situations, a tensor operand's dimensions must
146 * be fully specified:
147 *
148 * . The operand has lifetime CONSTANT_COPY or
149 * CONSTANT_REFERENCE.
150 *
151 * . The operand has lifetime MODEL_INPUT or MODEL_OUTPUT. Fully
152 * specified dimensions must either be present in the
153 * Operand or they must be provided in the corresponding
154 * RequestArgument.
155 * EXCEPTION: If the input or output is optional and omitted
156 * (by setting the hasNoValue field of the corresponding
157 * RequestArgument to true) then it need not have fully
158 * specified dimensions.
159 *
160 * A tensor operand with some number of unspecified dimensions is
161 * represented by setting each unspecified dimension to 0.
162 */
163 vec<uint32_t> dimensions;
164
165 /**
166 * The number of times this operand appears as an operation input.
167 *
168 * (For example, if this operand appears once in one operation's
169 * input list, and three times in another operation's input list,
170 * then numberOfConsumers = 4.)
171 */
172 uint32_t numberOfConsumers;
173
174 /**
175 * Quantized scale of the operand.
176 *
177 * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or
178 * TENSOR_INT32.
179 */
180 float scale;
181
182 /**
183 * Quantized zero-point offset of the operand.
184 *
185 * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM.
186 */
187 int32_t zeroPoint;
188
189 /**
190 * How the operand is used.
191 */
192 OperandLifeTime lifetime;
193
194 /**
195 * Where to find the data for this operand.
196 * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
197 * NO_VALUE:
198 * - All the fields must be 0.
199 * If the lifetime is CONSTANT_COPY:
200 * - location.poolIndex is 0.
201 * - location.offset is the offset in bytes into Model.operandValues.
202 * - location.length is set.
203 * If the lifetime is CONSTANT_REFERENCE:
204 * - location.poolIndex is set.
205 * - location.offset is the offset in bytes into the specified pool.
206 * - location.length is set.
207 */
208 DataLocation location;
209};
210
211/**
105 * A Neural Network Model. 212 * A Neural Network Model.
106 * 213 *
107 * This includes not only the execution graph, but also constant data such as 214 * This includes not only the execution graph, but also constant data such as
diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
index 7ec6ff18..5a8b8c59 100644
--- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
+++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp
@@ -26,9 +26,7 @@ namespace neuralnetworks {
26namespace V1_2 { 26namespace V1_2 {
27 27
28using V1_0::IPreparedModel; 28using V1_0::IPreparedModel;
29using V1_0::Operand;
30using V1_0::OperandLifeTime; 29using V1_0::OperandLifeTime;
31using V1_0::OperandType;
32using V1_1::ExecutionPreference; 30using V1_1::ExecutionPreference;
33 31
34namespace vts { 32namespace vts {
@@ -131,10 +129,10 @@ static uint32_t addOperand(Model* model, OperandLifeTime lifetime) {
131///////////////////////// VALIDATE MODEL OPERAND TYPE ///////////////////////// 129///////////////////////// VALIDATE MODEL OPERAND TYPE /////////////////////////
132 130
133static const int32_t invalidOperandTypes[] = { 131static const int32_t invalidOperandTypes[] = {
134 static_cast<int32_t>(OperandType::FLOAT32) - 1, // lower bound fundamental 132 static_cast<int32_t>(OperandType::FLOAT32) - 1, // lower bound fundamental
135 static_cast<int32_t>(OperandType::TENSOR_QUANT8_ASYMM) + 1, // upper bound fundamental 133 static_cast<int32_t>(OperandType::BOOL) + 1, // upper bound fundamental
136 static_cast<int32_t>(OperandType::OEM) - 1, // lower bound OEM 134 static_cast<int32_t>(OperandType::OEM) - 1, // lower bound OEM
137 static_cast<int32_t>(OperandType::TENSOR_OEM_BYTE) + 1, // upper bound OEM 135 static_cast<int32_t>(OperandType::TENSOR_OEM_BYTE) + 1, // upper bound OEM
138}; 136};
139 137
140static void mutateOperandTypeTest(const sp<IDevice>& device, const Model& model) { 138static void mutateOperandTypeTest(const sp<IDevice>& device, const Model& model) {
@@ -157,6 +155,7 @@ static uint32_t getInvalidRank(OperandType type) {
157 case OperandType::FLOAT32: 155 case OperandType::FLOAT32:
158 case OperandType::INT32: 156 case OperandType::INT32:
159 case OperandType::UINT32: 157 case OperandType::UINT32:
158 case OperandType::BOOL:
160 return 1; 159 return 1;
161 case OperandType::TENSOR_FLOAT32: 160 case OperandType::TENSOR_FLOAT32:
162 case OperandType::TENSOR_INT32: 161 case OperandType::TENSOR_INT32:
@@ -185,6 +184,7 @@ static float getInvalidScale(OperandType type) {
185 case OperandType::FLOAT32: 184 case OperandType::FLOAT32:
186 case OperandType::INT32: 185 case OperandType::INT32:
187 case OperandType::UINT32: 186 case OperandType::UINT32:
187 case OperandType::BOOL:
188 case OperandType::TENSOR_FLOAT32: 188 case OperandType::TENSOR_FLOAT32:
189 return 1.0f; 189 return 1.0f;
190 case OperandType::TENSOR_INT32: 190 case OperandType::TENSOR_INT32:
@@ -214,6 +214,7 @@ static std::vector<int32_t> getInvalidZeroPoints(OperandType type) {
214 case OperandType::FLOAT32: 214 case OperandType::FLOAT32:
215 case OperandType::INT32: 215 case OperandType::INT32:
216 case OperandType::UINT32: 216 case OperandType::UINT32:
217 case OperandType::BOOL:
217 case OperandType::TENSOR_FLOAT32: 218 case OperandType::TENSOR_FLOAT32:
218 case OperandType::TENSOR_INT32: 219 case OperandType::TENSOR_INT32:
219 return {1}; 220 return {1};
@@ -253,6 +254,7 @@ static void mutateOperand(Operand* operand, OperandType type) {
253 case OperandType::FLOAT32: 254 case OperandType::FLOAT32:
254 case OperandType::INT32: 255 case OperandType::INT32:
255 case OperandType::UINT32: 256 case OperandType::UINT32:
257 case OperandType::BOOL:
256 newOperand.dimensions = hidl_vec<uint32_t>(); 258 newOperand.dimensions = hidl_vec<uint32_t>();
257 newOperand.scale = 0.0f; 259 newOperand.scale = 0.0f;
258 newOperand.zeroPoint = 0; 260 newOperand.zeroPoint = 0;