From 926df1e1823e633090a2248be0f1ac66933750ed Mon Sep 17 00:00:00 2001 From: Michael Butler Date: Tue, 19 Sep 2017 16:26:47 -0700 Subject: [PATCH] Removed WIP tag from Neuralnetworks HAL Additionally cleaned up some comments and formatting. Bug: 63905942 Test: not needed Change-Id: I0306f6d37f3c9ce9b365b5f838c27e81fa001ccd --- neuralnetworks/1.0/IDevice.hal | 32 +++++++++++++++++++++++--------- neuralnetworks/1.0/IEvent.hal | 8 +++++--- neuralnetworks/1.0/IPreparedModel.hal | 11 ++++++++--- neuralnetworks/1.0/types.hal | 14 +++++++++++--- 4 files changed, 47 insertions(+), 18 deletions(-) diff --git a/neuralnetworks/1.0/IDevice.hal b/neuralnetworks/1.0/IDevice.hal index b6f94330..91a9555b 100644 --- a/neuralnetworks/1.0/IDevice.hal +++ b/neuralnetworks/1.0/IDevice.hal @@ -14,8 +14,6 @@ * limitations under the License. */ -/* This HAL is a work in progress */ - package android.hardware.neuralnetworks@1.0; import IEvent; @@ -28,7 +26,10 @@ interface IDevice { /** * Gets the capabilities of a driver. * - * @return status ErrorStatus::NONE if successful. + * @return status Error status of the call, must be: + * - NONE if successful + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if there is an unspecified error * @return capabilities Capabilities of the driver. */ getCapabilities() generates (ErrorStatus status, Capabilities capabilities); @@ -43,7 +44,11 @@ interface IDevice { * * @param model A model whose operations--and their corresponding * operands--are to be verified by the driver. - * @return status ErrorStatus::NONE if successful. + * @return status Error status of the call, must be: + * - NONE if successful + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if there is an unspecified error + * - INVALID_ARGUMENT when provided model is invalid * @return supportedOperations A list of supported operations, where true * indicates the operation is supported and * false indicates the operation is not @@ -52,7 +57,7 @@ interface IDevice { * it is describing. */ getSupportedOperations(Model model) - generates (ErrorStatus status, vec supportedOperations); + generates (ErrorStatus status, vec supportedOperations); /** * Prepares a model for execution. @@ -60,7 +65,7 @@ interface IDevice { * prepareModel is used to make any necessary transformations or alternative * representations to a model for execution, possible including * transformations on the constant data, optimization on the model's graph, - * or compilation into the device's native binary. + * or compilation into the device's native binary format. * * The only information that may be unknown to the model at this stage is * the shape of the tensors, which may only be known at execution time. @@ -68,16 +73,25 @@ interface IDevice { * @param model The model to be prepared for execution. * @param event A synchronization callback that must be signaled once the * execution has finished. - * @return status ErrorStatus::NONE if successful. + * @return status Error status of the call, must be: + * - NONE if preparation task is successfully launched + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if there is an unspecified error + * - INVALID_ARGUMENT when one of the input arguments is + * invalid * @return preparedModel A handle to the resultant prepared model. */ prepareModel(Model model, IEvent event) - generates (ErrorStatus status, IPreparedModel preparedModel); + generates (ErrorStatus status, IPreparedModel preparedModel); /** * Returns the current status of a driver. * - * @return status Status of the driver. + * @return status Status of the driver, one of: + * - DeviceStatus::AVAILABLE + * - DeviceStatus::BUSY + * - DeviceStatus::OFFLINE + * - DeviceStatus::UNKNOWN */ getStatus() generates (DeviceStatus status); }; diff --git a/neuralnetworks/1.0/IEvent.hal b/neuralnetworks/1.0/IEvent.hal index 2ebda589..2fe454c1 100644 --- a/neuralnetworks/1.0/IEvent.hal +++ b/neuralnetworks/1.0/IEvent.hal @@ -14,8 +14,6 @@ * limitations under the License. */ -/* This HAL is a work in progress */ - package android.hardware.neuralnetworks@1.0; /** @@ -37,7 +35,11 @@ interface IEvent { * the work) to mark the event as completed so that any threads requiring * the corresponding output can continue executing. * - * @param status ErrorStatus::NONE if successful. + * @param status Error status returned from the asynchronous task, must be: + * - NONE if asynchronous task was successful + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if the asynchronous task resulted in an + * unspecified error */ oneway notify(ErrorStatus status); }; diff --git a/neuralnetworks/1.0/IPreparedModel.hal b/neuralnetworks/1.0/IPreparedModel.hal index a7c33420..5df883e1 100644 --- a/neuralnetworks/1.0/IPreparedModel.hal +++ b/neuralnetworks/1.0/IPreparedModel.hal @@ -36,11 +36,16 @@ interface IPreparedModel { * * @param request The input and output information on which the prepared * model is to be executed. - * prepared model. * @param event A callback used for synchronization that must be signaled * once the execution has finished. - * @return status ErrorStatus::NONE if the asynchronous task was - * successfully launched. + * @return status Error status of the call, must be: + * - NONE if task is successfully launched + * - DEVICE_UNAVAILABLE if driver is offline or busy + * - GENERAL_FAILURE if there is an unspecified error + * - OUTPUT_INSUFFICIENT_SIZE if provided output buffer is + * not large enough to store the resultant values + * - INVALID_ARGUMENT when one of the input arguments is + * invalid */ execute(Request request, IEvent event) generates (ErrorStatus status); }; diff --git a/neuralnetworks/1.0/types.hal b/neuralnetworks/1.0/types.hal index 39e3d345..537331bb 100644 --- a/neuralnetworks/1.0/types.hal +++ b/neuralnetworks/1.0/types.hal @@ -218,7 +218,7 @@ enum OperationType : int32_t { * * Inputs: * 0: A 4-D tensor, of shape [batches, height, width, depth_in], specifying the input. - * 1: A 4-D tensor, of shape [depth_out, filter_height, filter_width, depth_in], + * 1: A 4-D tensor, of shape [1, filter_height, filter_width, depth_out], * specifying the filter. * 2: A 1-D tensor, of shape [depth_out], specifying the bias. * For input tensor of {@link OperandType::TENSOR_FLOAT32} type, the bias should @@ -1105,14 +1105,16 @@ struct Operand { /** * Quantized scale of the operand. * - * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM. + * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or + * TENSOR_INT32. */ float scale; /** * Quantized zero-point offset of the operand. * - * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM. + * Only applicable if the operand is of type TENSOR_QUANT8_ASYMM or + * TENSOR_INT32. */ int32_t zeroPoint; @@ -1195,12 +1197,18 @@ struct Model { /** * A byte buffer containing operand data that were copied into the model. + * + * An operand's value must be located here if and only if Operand::lifetime + * equals OperandLifeTime::CONSTANT_COPY. */ vec operandValues; /** * A collection of shared memory pools containing operand data that were * registered by the model. + * + * An operand's value must be located here if and only if Operand::lifetime + * equals OperandLifeTime::CONSTANT_REFERENCE. */ vec pools; }; -- 2.11.0