Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5aa15880 authored by David Gross's avatar David Gross
Browse files

Documentation improvements.

Document that every model must have at least one input and one output.

Document graph constraints.

Elaborate a bit on "execution order".

Indicate how operands of different lifetimes are defined (or not).

Fix ANEURALNETWORKS_L2_NORMALIZATION documentation for output shape.

ANEURALNETWORKS_SPACE_TO_DEPTH has inconsistent names for dimensions.

ANEURALNETWORKS_PAD documentation doesn't clearly describe rank or
dimensions of output tensor.

Bug: 66478689
Bug: 67601776
Bug: 69631404
Bug: 79482779
Bug: 79539157
Bug: 79539928

Test: mma at tree root

Change-Id: I6227bea2a486d4b45022d590915e10a124d323d4
(cherry picked from commit aeb1a6cb0160b00ecd5e321f01d8722482c221a7)
parent e3e4a4f9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -383,5 +383,5 @@ cd4330c3196bda1d642a32abfe23a7d64ebfbda721940643af6867af3b3f0aa9 android.hardwar

# ABI preserving changes to HALs during Android Q
574e8f1499436fb4075894dcae0b36682427956ecb114f17f1fe22d116a83c6b android.hardware.neuralnetworks@1.0::IPreparedModel
b07802a3433a9abec67a41525dc04eab9efb62760414e1d37e2f72cc5ae9cb8a android.hardware.neuralnetworks@1.0::types
bf18f51bfee84461f9831f3754f5c68ce2b29e42fe9d59ef8a33163e77f8edbf android.hardware.neuralnetworks@1.1::types
1a5ae9793223658174258b523763c557abad6fb917df0b8e3cc097fc89035811 android.hardware.neuralnetworks@1.0::types
4310eb8272f085914952f3bfb73a8f8bb477a80e8b93596f0ea5acb58546b66d android.hardware.neuralnetworks@1.1::types
+23 −13
Original line number Diff line number Diff line
@@ -596,8 +596,8 @@ enum OperationType : int32_t {
     * * 0: A 4-D tensor, of shape [batches, height, width, depth].
     *
     * Outputs:
     * * 0: The output 4-D tensor, of shape
     *      [batches, out_height, out_width, depth].
     * * 0: The output 4-D tensor, of the same shape as input
     *      [batches, height, width, depth].
     */
    L2_NORMALIZATION = 11,

@@ -1282,8 +1282,8 @@ enum OperationType : int32_t {
     *      input height and width.
     *
     * Outputs:
     * * 0: The output 4-D tensor, of shape [batch, height/block_size,
     *      width/block_size, depth*block_size*block_size].
     * * 0: The output 4-D tensor, of shape [batches, height/block_size,
     *      width/block_size, depth_in*block_size*block_size].
     */
    SPACE_TO_DEPTH = 26,

@@ -1410,28 +1410,36 @@ enum FusedActivationFunc : int32_t {
enum OperandLifeTime : int32_t {
    /**
     * The operand is internal to the model. It's created by an operation and
     * consumed by other operations.
     * consumed by other operations. It must be an output operand of
     * exactly one operation.
     */
    TEMPORARY_VARIABLE,

    /**
     * The operand is an input of the model. An operand can't be both
     * input and output of a model.
     * The operand is an input of the model. It must not be an output
     * operand of any operation.
     *
     * An operand can't be both input and output of a model.
     */
    MODEL_INPUT,

    /**
     * The operand is an output of the model.
     * The operand is an output of the model. It must be an output
     * operand of exactly one operation.
     *
     * An operand can't be both input and output of a model.
     */
    MODEL_OUTPUT,

    /**
     * The operand is a constant found in Model.operandValues.
     * The operand is a constant found in Model.operandValues. It must
     * not be an output operand of any operation.
     */
    CONSTANT_COPY,

    /**
     * The operand is a constant that was specified via a Memory object.
     * The operand is a constant that was specified via a Memory
     * object. It must not be an output operand of any operation.
     */
    CONSTANT_REFERENCE,

@@ -1641,19 +1649,21 @@ struct Model {
    /**
     * All operations included in the model.
     *
     * The operations are sorted into execution order.
     * The operations are sorted into execution order. Every operand
     * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
     * written before it is read.
     */
    vec<Operation> operations;

    /**
     * Input indexes of the model.
     * Input indexes of the model. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */
    vec<uint32_t> inputIndexes;

    /**
     * Output indexes of the model.
     * Output indexes of the model. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */
+14 −6
Original line number Diff line number Diff line
@@ -137,13 +137,19 @@ enum OperationType : @1.0::OperationType {
     * * 1: A 2-D Tensor of {@link OperandType::TENSOR_INT32}, the paddings
     *      for each spatial dimension of the input tensor. The shape of the
     *      tensor must be {rank(input0), 2}.
     *      padding[i, 0] specifies the number of element to be padded in the
     *      padding[i, 0] specifies the number of elements to be padded in the
     *      front of dimension i.
     *      padding[i, 1] specifies the number of element to be padded after the
     *      padding[i, 1] specifies the number of elements to be padded after the
     *      end of dimension i.
     *
     * Outputs:
     * * 0: A tensor of the same {@link OperandType} as input0.
     * * 0: A tensor of the same {@link OperandType} as input0. The
     *      output tensor has the same rank as input0, and each
     *      dimension of the output tensor has the same size as the
     *      corresponding dimension of the input tensor plus the size
     *      of the padding:
     *          output0.dimension[i] =
     *              padding[i, 0] + input0.dimension[i] + padding[i, 1]
     */
    PAD = 32,

@@ -377,19 +383,21 @@ struct Model {
    /**
     * All operations included in the model.
     *
     * The operations are sorted into execution order.
     * The operations are sorted into execution order. Every operand
     * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
     * written before it is read.
     */
    vec<Operation> operations;

    /**
     * Input indexes of the model.
     * Input indexes of the model. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */
    vec<uint32_t> inputIndexes;

    /**
     * Output indexes of the model.
     * Output indexes of the model. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */