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

Commit f9700620 authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge changes from topic "aosp-nnapi-cf" am: 8d38d27b am: f02d3808

Change-Id: I0bfdff0ed542b5f2a11c7d18301f6fc367f215b6
parents a481a220 f02d3808
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -629,10 +629,10 @@ bbeee9604128ede83ee755b67e73b5ad29e6e1dbac9ec41fea6ffe2745b0c50a android.hardwar
adb0efdf1462e9b2e742c0dcadd598666aac551f178be06e755bfcdf5797abd0 android.hardware.keymaster@4.1::IOperation
adb0efdf1462e9b2e742c0dcadd598666aac551f178be06e755bfcdf5797abd0 android.hardware.keymaster@4.1::IOperation
ac429fca0da4ce91218768ec31b64ded88251f8a26d8c4f27c06abdc5b1926d9 android.hardware.keymaster@4.1::types
ac429fca0da4ce91218768ec31b64ded88251f8a26d8c4f27c06abdc5b1926d9 android.hardware.keymaster@4.1::types
4b5c8546533db9412fec6d32c0ef42b22e5e68dbf390c775ec3c22bb2d501102 android.hardware.neuralnetworks@1.3::IBuffer
4b5c8546533db9412fec6d32c0ef42b22e5e68dbf390c775ec3c22bb2d501102 android.hardware.neuralnetworks@1.3::IBuffer
234cc547d63d2f24a447aee0a9a76cab68b31c080adadc5a960598b827a69fa2 android.hardware.neuralnetworks@1.3::IDevice
5a6b75f13f0e010a4268defa4f627b862ab2899fb04f9d985194a25bd8f9fe0d android.hardware.neuralnetworks@1.3::IDevice
058b48f0e2e725bb2b3fa2b7917b0f0a696383d03a4c57afe26f0eadb6a7af28 android.hardware.neuralnetworks@1.3::IPreparedModel
058b48f0e2e725bb2b3fa2b7917b0f0a696383d03a4c57afe26f0eadb6a7af28 android.hardware.neuralnetworks@1.3::IPreparedModel
94e803236398bed1febb11cc21051bc42ec003700139b099d6c479e02a7ca3c3 android.hardware.neuralnetworks@1.3::IPreparedModelCallback
94e803236398bed1febb11cc21051bc42ec003700139b099d6c479e02a7ca3c3 android.hardware.neuralnetworks@1.3::IPreparedModelCallback
1435cf1724f9f89ff5f97d4aa6fe2a031b0ef43034cb5801b16229dc2ecfea82 android.hardware.neuralnetworks@1.3::types
12c51f9d04a52324510419aeee3e37bb3607e6900556cdde79774d80ed989855 android.hardware.neuralnetworks@1.3::types
3e01d4446cd69fd1c48f8572efd97487bc179564b32bd795800b97bbe10be37b android.hardware.wifi@1.4::IWifi
3e01d4446cd69fd1c48f8572efd97487bc179564b32bd795800b97bbe10be37b android.hardware.wifi@1.4::IWifi
a64467bae843569f0d465c5be7f0c7a5b987985b55a3ef4794dd5afc68538650 android.hardware.wifi.supplicant@1.3::ISupplicant
a64467bae843569f0d465c5be7f0c7a5b987985b55a3ef4794dd5afc68538650 android.hardware.wifi.supplicant@1.3::ISupplicant
44445b8a03d7b9e68b2fbd954672c18a8fce9e32851b0692f4f4ab3407f86ecb android.hardware.wifi.supplicant@1.3::ISupplicantStaIface
44445b8a03d7b9e68b2fbd954672c18a8fce9e32851b0692f4f4ab3407f86ecb android.hardware.wifi.supplicant@1.3::ISupplicantStaIface
+8 −3
Original line number Original line Diff line number Diff line
@@ -48,9 +48,14 @@ interface IDevice extends @1.2::IDevice {
    /**
    /**
     * Gets the supported operations in a model.
     * Gets the supported operations in a model.
     *
     *
     * getSupportedOperations indicates which operations of a model are fully
     * getSupportedOperations indicates which operations of the top-level
     * supported by the vendor driver. If an operation may not be supported for
     * subgraph are fully supported by the vendor driver. If an operation may
     * any reason, getSupportedOperations must return false for that operation.
     * not be supported for any reason, getSupportedOperations must return
     * false for that operation.
     *
     * The {@link OperationType::IF} and {@link OperationType::WHILE}
     * operations may only be fully supported if the vendor driver fully
     * supports all operations in the referenced subgraphs.
     *
     *
     * @param model A model whose operations--and their corresponding operands--
     * @param model A model whose operations--and their corresponding operands--
     *     are to be verified by the driver.
     *     are to be verified by the driver.
+196 −27
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
package android.hardware.neuralnetworks@1.3;
package android.hardware.neuralnetworks@1.3;


import @1.0::DataLocation;
import @1.0::DataLocation;
import @1.0::OperandLifeTime;
import @1.0::PerformanceInfo;
import @1.0::PerformanceInfo;
import @1.0::RequestArgument;
import @1.0::RequestArgument;
import @1.2::Model.ExtensionNameAndPrefix;
import @1.2::Model.ExtensionNameAndPrefix;
@@ -42,6 +41,13 @@ enum OperandType : @1.2::OperandType {
     */
     */
    TENSOR_QUANT8_ASYMM_SIGNED = 14,
    TENSOR_QUANT8_ASYMM_SIGNED = 14,


    /**
     * A reference to a subgraph.
     *
     * Must have the lifetime {@link OperandLifeTime::SUBGRAPH}.
     */
    SUBGRAPH = 15,

    /*
    /*
     * DEPRECATED. Since HAL version 1.2, extensions are the preferred
     * DEPRECATED. Since HAL version 1.2, extensions are the preferred
     * alternative to OEM operation and data types.
     * alternative to OEM operation and data types.
@@ -70,7 +76,7 @@ enum OperandType : @1.2::OperandType {
enum OperandTypeRange : uint32_t {
enum OperandTypeRange : uint32_t {
    BASE_MIN        = 0,
    BASE_MIN        = 0,
    FUNDAMENTAL_MIN = 0,
    FUNDAMENTAL_MIN = 0,
    FUNDAMENTAL_MAX = 14,
    FUNDAMENTAL_MAX = 15,
    OEM_MIN         = 10000,
    OEM_MIN         = 10000,
    OEM_MAX         = 10001,
    OEM_MAX         = 10001,
    BASE_MAX        = 0xFFFF,
    BASE_MAX        = 0xFFFF,
@@ -4878,6 +4884,92 @@ enum OperationType : int32_t {
     */
     */
    QUANTIZED_LSTM = 95,
    QUANTIZED_LSTM = 95,


    /**
     * Executes one of the two referenced subgraphs as determined by a boolean
     * value.
     *
     * The inputs and outputs of the two referenced subgraphs must agree with the
     * signature of this operation. That is, if the operation has (3 + n) inputs
     * and m outputs, both subgraphs must have n inputs and m outputs with the same
     * types as the corresponding operation inputs and outputs.
     *
     * Inputs:
     * * 0: A value of type {@link OperandType::TENSOR_BOOL8} and shape [1]
     *      that determines which of the two referenced subgraphs to execute.
     * * 1: A {@link OperandType::SUBGRAPH} reference to the subgraph to be
     *      executed if the condition is true.
     * * 2: A {@link OperandType::SUBGRAPH} reference to the subgraph to be
     *      executed if the condition is false.
     * * 3 ~ (n + 2): Inputs to be passed to the subgraph selected for execution.
     *
     * Outputs:
     * * 0 ~ (m - 1): Outputs produced by the selected subgraph.
     */
    IF = 96,

    /**
     * Executes the body subgraph until the condition subgraph outputs false.
     *
     * The inputs to this operation are the condition subgraph, the body subgraph,
     * and operand values for the first iteration of the loop. The values are
     * implicitly split into three groups of input-output, state-only, and
     * input-only values, as described below.
     *
     * The outputs of this operation are the final values of input-output
     * operands.
     *
     * Both the condition and body subgraph receive (m + k + n) inputs.
     * * The first m (m >= 1) inputs are input-output operands. For the first
     *   iteration, these are initialized from the corresponding inputs of the
     *   WHILE operation. In subsequent iterations, their values come from the
     *   corresponding outputs of the body subgraph produced during the previous
     *   iteration.
     * * The next k (k >= 0) inputs are state-only operands. They are similar to
     *   the input-output operands, except that their values are no longer
     *   available after the loop terminates.
     * * The last n (n >= 0) inputs are input-only operands. Their values come
     *   from the corresponding inputs of the WHILE operation.
     *
     * The body subgraph produces (m + k) outputs.
     * * The first m outputs are input-output operands. They become the outputs
     *   of the WHILE operation when a termination condition is reached.
     * * The last k outputs are state-only operands. Their values are no longer
     *   available after the loop terminates.
     *
     * The numbers m, k, and n are inferred by the driver as follows:
     *     m = (WHILE operation output count)
     *     k = (body subgraph output count) - m
     *     n = (body subgraph input count) - m - k
     *
     * The pseudo-code below illustrates the flow of a WHILE operation with
     * inputs condition, body, initial_input_output, initial_state, input_only
     * (m = 1, k = 1, n = 1):
     *
     *     input_output = initial_input_output
     *     state = initial_state
     *     while condition(input_output, state, input_only):
     *         input_output, state = body(input_output, state, input_only)
     *     return input_output
     *
     * Inputs:
     * * 0: A {@link OperandType::SUBGRAPH} reference to the condition
     *      subgraph. The subgraph must have (m + k + n) inputs with
     *      the same types as the corresponding inputs of the WHILE operation
     *      and exactly one output of {@link OperandType::TENSOR_BOOL8}
     *      and shape [1].
     * * 1: A {@link OperandType::SUBGRAPH} reference to the body subgraph.
     *      The subgraph must have (m + k + n) inputs and (m + k) outputs with
     *      the same types as the corresponding inputs and outputs of the WHILE
     *      operation.
     * * (m inputs): Initial values for input-output operands.
     * * (k inputs): Initial values for state-only operands.
     * * (n inputs): Values for input-only operands.
     *
     * Outputs:
     * * 0 ~ (m - 1): Outputs produced by the loop.
     */
    WHILE = 97,

    /**
    /**
     * DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
     * DEPRECATED. Since NNAPI 1.2, extensions are the preferred alternative to
     * OEM operation and data types.
     * OEM operation and data types.
@@ -4900,13 +4992,12 @@ enum OperationType : int32_t {
enum OperationTypeRange : uint32_t {
enum OperationTypeRange : uint32_t {
    BASE_MIN        = 0,
    BASE_MIN        = 0,
    FUNDAMENTAL_MIN = 0,
    FUNDAMENTAL_MIN = 0,
    FUNDAMENTAL_MAX = 95,
    FUNDAMENTAL_MAX = 97,
    OEM_MIN         = 10000,
    OEM_MIN         = 10000,
    OEM_MAX         = 10000,
    OEM_MAX         = 10000,
    BASE_MAX        = 0xFFFF,
    BASE_MAX        = 0xFFFF,
};
};



/**
/**
 * The capabilities of a driver.
 * The capabilities of a driver.
 *
 *
@@ -4967,6 +5058,59 @@ struct Operation {
    vec<uint32_t> outputs;
    vec<uint32_t> outputs;
};
};


/**
 * How an operand is used.
 */
enum OperandLifeTime : int32_t {
    /**
     * The operand is internal to the model. It's created by an operation and
     * consumed by other operations. It must be an output operand of
     * exactly one operation.
     */
    TEMPORARY_VARIABLE,

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

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

    /**
     * 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. It must not be an output operand of any operation.
     */
    CONSTANT_REFERENCE,

    /**
     * The operand does not have a value. This is valid only for optional
     * arguments of operations.
     */
    NO_VALUE,

    /**
     * The operand is a reference to a subgraph. It must be an input to one
     * or more {@link OperationType::IF} or {@link OperationType::WHILE}
     * operations.
     */
    SUBGRAPH,
};

/**
/**
 * Describes one operand of the model's graph.
 * Describes one operand of the model's graph.
 */
 */
@@ -5003,7 +5147,7 @@ struct Operand {
     *     . The operand has lifetime CONSTANT_COPY or
     *     . The operand has lifetime CONSTANT_COPY or
     *       CONSTANT_REFERENCE.
     *       CONSTANT_REFERENCE.
     *
     *
     *     . The operand has lifetime MODEL_INPUT. Fully
     *     . The operand has lifetime SUBGRAPH_INPUT. Fully
     *       specified dimensions must either be present in the
     *       specified dimensions must either be present in the
     *       Operand or they must be provided in the corresponding
     *       Operand or they must be provided in the corresponding
     *       RequestArgument.
     *       RequestArgument.
@@ -5051,8 +5195,8 @@ struct Operand {


    /**
    /**
     * Where to find the data for this operand.
     * Where to find the data for this operand.
     * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
     * If the lifetime is TEMPORARY_VARIABLE, SUBGRAPH_INPUT, SUBGRAPH_OUTPUT,
     * NO_VALUE:
     * or NO_VALUE:
     * - All the fields must be 0.
     * - All the fields must be 0.
     * If the lifetime is CONSTANT_COPY:
     * If the lifetime is CONSTANT_COPY:
     * - location.poolIndex is 0.
     * - location.poolIndex is 0.
@@ -5062,6 +5206,11 @@ struct Operand {
     * - location.poolIndex is set.
     * - location.poolIndex is set.
     * - location.offset is the offset in bytes into the specified pool.
     * - location.offset is the offset in bytes into the specified pool.
     * - location.length is set.
     * - location.length is set.
     * If the lifetime is SUBGRAPH:
     * - location.poolIndex is 0.
     * - location.offset is the index of the referenced subgraph in
     *   {@link Model::referenced}.
     * - location.length is 0.
     */
     */
    DataLocation location;
    DataLocation location;


@@ -5100,32 +5249,19 @@ struct Operand {
 */
 */
struct Model {
struct Model {
    /**
    /**
     * All operands included in the model.
     * The top-level subgraph.
     */
     */
    vec<Operand> operands;
    Subgraph main;


    /**
    /**
     * All operations included in the model.
     * Referenced subgraphs.
     *
     *
     * The operations are sorted into execution order. Every operand
     * Each subgraph is referenced by the main subgraph or at least one other
     * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
     * referenced subgraph.
     * written before it is read.
     */
    vec<Operation> operations;

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

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


    /**
    /**
     * A byte buffer containing operand data that were copied into the model.
     * A byte buffer containing operand data that were copied into the model.
@@ -5177,6 +5313,39 @@ struct Model {
    vec<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix;
    vec<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix;
};
};


/**
 * An excerpt of the execution graph.
 */
struct Subgraph {
    /**
     * All operands included in the subgraph.
     */
    vec<Operand> operands;

    /**
     * All operations included in the subgraph.
     *
     * The operations are sorted into execution order. Every operand
     * with lifetime SUBGRAPH_OUTPUT or TEMPORARY_VARIABLE must be
     * written before it is read.
     */
    vec<Operation> operations;

    /**
     * Input indexes of the subgraph. 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 subgraph. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */
    vec<uint32_t> outputIndexes;
};

/**
/**
 * A buffer descriptor. Describes the properties of a buffer.
 * A buffer descriptor. Describes the properties of a buffer.
 */
 */
+101 −25
Original line number Original line Diff line number Diff line
@@ -19,7 +19,6 @@
package android.hardware.neuralnetworks@1.3;
package android.hardware.neuralnetworks@1.3;


import @1.0::DataLocation;
import @1.0::DataLocation;
import @1.0::OperandLifeTime;
import @1.0::PerformanceInfo;
import @1.0::PerformanceInfo;
import @1.0::RequestArgument;
import @1.0::RequestArgument;
import @1.2::Model.ExtensionNameAndPrefix;
import @1.2::Model.ExtensionNameAndPrefix;
@@ -90,7 +89,6 @@ enum OperationTypeRange : uint32_t {
    BASE_MAX        = 0xFFFF,
    BASE_MAX        = 0xFFFF,
};
};



/**
/**
 * The capabilities of a driver.
 * The capabilities of a driver.
 *
 *
@@ -151,6 +149,59 @@ struct Operation {
    vec<uint32_t> outputs;
    vec<uint32_t> outputs;
};
};


/**
 * How an operand is used.
 */
enum OperandLifeTime : int32_t {
    /**
     * The operand is internal to the model. It's created by an operation and
     * consumed by other operations. It must be an output operand of
     * exactly one operation.
     */
    TEMPORARY_VARIABLE,

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

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

    /**
     * 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. It must not be an output operand of any operation.
     */
    CONSTANT_REFERENCE,

    /**
     * The operand does not have a value. This is valid only for optional
     * arguments of operations.
     */
    NO_VALUE,

    /**
     * The operand is a reference to a subgraph. It must be an input to one
     * or more {@link OperationType::IF} or {@link OperationType::WHILE}
     * operations.
     */
    SUBGRAPH,
};

/**
/**
 * Describes one operand of the model's graph.
 * Describes one operand of the model's graph.
 */
 */
@@ -187,7 +238,7 @@ struct Operand {
     *     . The operand has lifetime CONSTANT_COPY or
     *     . The operand has lifetime CONSTANT_COPY or
     *       CONSTANT_REFERENCE.
     *       CONSTANT_REFERENCE.
     *
     *
     *     . The operand has lifetime MODEL_INPUT. Fully
     *     . The operand has lifetime SUBGRAPH_INPUT. Fully
     *       specified dimensions must either be present in the
     *       specified dimensions must either be present in the
     *       Operand or they must be provided in the corresponding
     *       Operand or they must be provided in the corresponding
     *       RequestArgument.
     *       RequestArgument.
@@ -235,8 +286,8 @@ struct Operand {


    /**
    /**
     * Where to find the data for this operand.
     * Where to find the data for this operand.
     * If the lifetime is TEMPORARY_VARIABLE, MODEL_INPUT, MODEL_OUTPUT, or
     * If the lifetime is TEMPORARY_VARIABLE, SUBGRAPH_INPUT, SUBGRAPH_OUTPUT,
     * NO_VALUE:
     * or NO_VALUE:
     * - All the fields must be 0.
     * - All the fields must be 0.
     * If the lifetime is CONSTANT_COPY:
     * If the lifetime is CONSTANT_COPY:
     * - location.poolIndex is 0.
     * - location.poolIndex is 0.
@@ -246,6 +297,11 @@ struct Operand {
     * - location.poolIndex is set.
     * - location.poolIndex is set.
     * - location.offset is the offset in bytes into the specified pool.
     * - location.offset is the offset in bytes into the specified pool.
     * - location.length is set.
     * - location.length is set.
     * If the lifetime is SUBGRAPH:
     * - location.poolIndex is 0.
     * - location.offset is the index of the referenced subgraph in
     *   {@link Model::referenced}.
     * - location.length is 0.
     */
     */
    DataLocation location;
    DataLocation location;


@@ -284,32 +340,19 @@ struct Operand {
 */
 */
struct Model {
struct Model {
    /**
    /**
     * All operands included in the model.
     * The top-level subgraph.
     */
     */
    vec<Operand> operands;
    Subgraph main;


    /**
    /**
     * All operations included in the model.
     * Referenced subgraphs.
     *
     *
     * The operations are sorted into execution order. Every operand
     * Each subgraph is referenced by the main subgraph or at least one other
     * with lifetime MODEL_OUTPUT or TEMPORARY_VARIABLE must be
     * referenced subgraph.
     * written before it is read.
     */
    vec<Operation> operations;

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

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


    /**
    /**
     * A byte buffer containing operand data that were copied into the model.
     * A byte buffer containing operand data that were copied into the model.
@@ -361,6 +404,39 @@ struct Model {
    vec<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix;
    vec<@1.2::Model.ExtensionNameAndPrefix> extensionNameToPrefix;
};
};


/**
 * An excerpt of the execution graph.
 */
struct Subgraph {
    /**
     * All operands included in the subgraph.
     */
    vec<Operand> operands;

    /**
     * All operations included in the subgraph.
     *
     * The operations are sorted into execution order. Every operand
     * with lifetime SUBGRAPH_OUTPUT or TEMPORARY_VARIABLE must be
     * written before it is read.
     */
    vec<Operation> operations;

    /**
     * Input indexes of the subgraph. 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 subgraph. There must be at least one.
     *
     * Each value corresponds to the index of the operand in "operands".
     */
    vec<uint32_t> outputIndexes;
};

/**
/**
 * A buffer descriptor. Describes the properties of a buffer.
 * A buffer descriptor. Describes the properties of a buffer.
 */
 */
+1 −1
Original line number Original line Diff line number Diff line
@@ -308,7 +308,7 @@ class CompilationCachingTestBase : public testing::Test {
                model,
                model,
                [&fullySupportsModel, &model](ErrorStatus status, const hidl_vec<bool>& supported) {
                [&fullySupportsModel, &model](ErrorStatus status, const hidl_vec<bool>& supported) {
                    ASSERT_EQ(ErrorStatus::NONE, status);
                    ASSERT_EQ(ErrorStatus::NONE, status);
                    ASSERT_EQ(supported.size(), model.operations.size());
                    ASSERT_EQ(supported.size(), model.main.operations.size());
                    fullySupportsModel = std::all_of(supported.begin(), supported.end(),
                    fullySupportsModel = std::all_of(supported.begin(), supported.end(),
                                                     [](bool valid) { return valid; });
                                                     [](bool valid) { return valid; });
                });
                });
Loading