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

Commit 911f8f61 authored by David Gross's avatar David Gross Committed by Android (Google) Code Review
Browse files

Merge "Add NNAPI specification and infrastructure for FL7."

parents 7b03aa95 04ed8595
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -429,7 +429,7 @@
    </hal>
    <hal format="aidl" optional="true">
        <name>android.hardware.neuralnetworks</name>
        <version>1-2</version>
        <version>1-3</version>
        <interface>
            <name>IDevice</name>
            <regex-instance>.*</regex-instance>
+2 −0
Original line number Diff line number Diff line
@@ -138,4 +138,6 @@ enum OperationType {
  RANK = 101,
  BATCH_MATMUL = 102,
  PACK = 103,
  MIRROR_PAD = 104,
  REVERSE = 105,
}
+69 −0
Original line number Diff line number Diff line
@@ -4318,6 +4318,8 @@ enum OperationType {
     * Supported tensor {@link OperandType}:
     * * {@link OperandType::TENSOR_FLOAT16}
     * * {@link OperandType::TENSOR_FLOAT32}
     * * {@link OperandType::TENSOR_QUANT8_ASYMM} (since NNAPI feature level 7)
     * * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} (since NNAPI feature level 7)
     *
     * Supported tensor rank: from 1.
     *
@@ -4326,6 +4328,9 @@ enum OperationType {
     *
     * Outputs:
     * * 0: The output tensor of same shape as input0.
     *      For a {@link OperandType::TENSOR_QUANT8_ASYMM} and
     *      {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensor,
     *      the scale and zeroPoint can be different from inputs' scale and zeroPoint.
     */
    RSQRT = 83,

@@ -5322,4 +5327,68 @@ enum OperationType {
     * * 0: The packed tensor.
     */
    PACK = 103,

    /**
     * Pads a tensor with mirrored values.
     *
     * Supported tensor {@link OperandType}:
     * * {@link OperandType::TENSOR_FLOAT16}
     * * {@link OperandType::TENSOR_FLOAT32}
     * * {@link OperandType::TENSOR_QUANT8_ASYMM}
     * * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED}
     * * {@link OperandType::TENSOR_INT32}
     *
     * Supported tensor rank: from 1.
     *
     * Inputs:
     * * 0: An n-D tensor, specifying the tensor to be padded.
     * * 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 elements to be padded in the
     *      front of dimension i.
     *      padding[i, 1] specifies the number of elements to be padded after the
     *      end of dimension i.
     * * 2: An {@link OperandType::INT32} scalar, specifying the mode.
     *      Options are 0:REFLECT and 1:SYMMETRIC.
     *
     * Outputs:
     * * 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]
     *      For a {@link OperandType::TENSOR_QUANT8_ASYMM} and
     *      {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensor,
     *      the scale and zeroPoint must be the same as input0.
     */
    MIRROR_PAD = 104,

    /**
     * Reverses a specified dimension of a tensor.
     *
     * Supported tensor {@link OperandType}:
     * * {@link OperandType::TENSOR_FLOAT16}
     * * {@link OperandType::TENSOR_FLOAT32}
     * * {@link OperandType::TENSOR_QUANT8_ASYMM}
     * * {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED}
     * * {@link OperandType::TENSOR_INT32}
     *
     * Supported tensor rank: up to 8.
     *
     * Inputs:
     * * 0: Input tensor of rank n.
     * * 1: Axis tensor of type {@link OperandType::TENSOR_INT32} and shape [1],
     *      specifying which dimension of the input tensor is to be reversed. The dimension
     *      must be in the range [0, n).
     *
     * Outputs:
     * * 0: The reversed tensor.
     *      For {@link OperandType::TENSOR_QUANT8_ASYMM} and
     *      {@link OperandType::TENSOR_QUANT8_ASYMM_SIGNED} tensors,
     *      the scales and zeroPoint must be the same as input0.
     */
    REVERSE = 105,
}
+10 −2
Original line number Diff line number Diff line
@@ -56,13 +56,21 @@ cc_library_static {
}

cc_library_static {
    name: "neuralnetworks_utils_hal_aidl",
    name: "neuralnetworks_utils_hal_aidl_v2",
    defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
    shared_libs: [
        "android.hardware.neuralnetworks-V2-ndk",
    ],
}

cc_library_static {
    name: "neuralnetworks_utils_hal_aidl",
    defaults: ["neuralnetworks_utils_hal_aidl_defaults"],
    shared_libs: [
        "android.hardware.neuralnetworks-V3-ndk",
    ],
}

// A cc_defaults that includes the latest non-experimental AIDL utilities and other AIDL libraries
// that are commonly used together. Modules that always depend on the latest non-experimental
// AIDL features can include this cc_defaults to avoid managing dependency versions explicitly.
@@ -71,7 +79,7 @@ cc_defaults {
    static_libs: [
        "android.hardware.common-V2-ndk",
        "android.hardware.graphics.common-V3-ndk",
        "android.hardware.neuralnetworks-V2-ndk",
        "android.hardware.neuralnetworks-V3-ndk",
        "neuralnetworks_utils_hal_aidl",
    ],
}
+2 −0
Original line number Diff line number Diff line
@@ -36,6 +36,8 @@ constexpr std::optional<nn::Version> aidlVersionToCanonicalVersion(int aidlVersi
            return nn::kVersionFeatureLevel5;
        case 2:
            return nn::kVersionFeatureLevel6;
        case 3:
            return nn::kVersionFeatureLevel7;
        default:
            return std::nullopt;
    }
Loading