diff options
author | Lev Proleev <levp@google.com> | 2019-10-28 11:22:50 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-28 11:22:50 -0700 |
commit | 23cccbde36161a8c784cd5ab95333461ee779420 (patch) | |
tree | caf44bcbb88977e5a61e751318ae34751b7f6cf6 | |
parent | 3dd281fb6f451e37c539837dae646b9c14844a9e (diff) | |
parent | b15a96762973d1a4fcf632ff6f9b9ff5ab38de6b (diff) | |
download | ml-23cccbde36161a8c784cd5ab95333461ee779420.tar.gz |
Merge "Update NNAPI templates and spec with 1.3 operand type" am: 769088e270
am: b15a967629
Change-Id: Ia957e3849a10d00a3c720827fb5496e69654d545
-rw-r--r-- | nn/tools/api/NeuralNetworks.t | 3 | ||||
-rwxr-xr-x | nn/tools/api/generate_api.py | 4 | ||||
-rwxr-xr-x | nn/tools/api/generate_api.sh | 1 | ||||
-rw-r--r-- | nn/tools/api/types.spec | 64 |
4 files changed, 65 insertions, 7 deletions
diff --git a/nn/tools/api/NeuralNetworks.t b/nn/tools/api/NeuralNetworks.t index 0251c9b38..7129c0a9b 100644 --- a/nn/tools/api/NeuralNetworks.t +++ b/nn/tools/api/NeuralNetworks.t @@ -57,6 +57,9 @@ typedef enum { #if __ANDROID_API__ >= __ANDROID_API_Q__ %insert Operand_1.2 #endif // __ANDROID_API__ >= __ANDROID_API_Q__ +#if __ANDROID_API__ >= __ANDROID_API_R__ +%insert Operand_1.3 +#endif // __ANDROID_API__ >= __ANDROID_API_R__ } OperandCode; %insert Operation_1.0_Comment diff --git a/nn/tools/api/generate_api.py b/nn/tools/api/generate_api.py index 742daf583..97326638a 100755 --- a/nn/tools/api/generate_api.py +++ b/nn/tools/api/generate_api.py @@ -205,12 +205,10 @@ class Specification(Reader): return # Check for start of kind - match = re.search("^%kind\s+(\S+)(\s+\S+)*\s*$", self.line) + match = re.search("^%kind\s+((\S+)(\s+\S+)*)\s*$", self.line) if match: assert self.conditional is self.UNCONDITIONAL, "%kind is nested at " + self.context() patterns = match[1] - if not match[2] is None: - patterns = patterns + " " + match[2] if self.match_kind(patterns): self.conditional = self.CONDITIONAL_ON else: diff --git a/nn/tools/api/generate_api.sh b/nn/tools/api/generate_api.sh index a52ad9b75..75aca39c3 100755 --- a/nn/tools/api/generate_api.sh +++ b/nn/tools/api/generate_api.sh @@ -35,6 +35,7 @@ doit ndk $(dirname $0)/NeuralNetworks.t ${ANDROID_BUILD_TOP}/frameworks/ml/nn/ru doit hal_1.0 ${HALDIR}/1.0/types.t ${HALDIR}/1.0/types.hal doit hal_1.1 ${HALDIR}/1.1/types.t ${HALDIR}/1.1/types.hal doit hal_1.2 ${HALDIR}/1.2/types.t ${HALDIR}/1.2/types.hal +doit hal_1.3 ${HALDIR}/1.3/types.t ${HALDIR}/1.3/types.hal if [[ ${RET} -ne 0 ]] ; then echo >&2 "*** FAILED" diff --git a/nn/tools/api/types.spec b/nn/tools/api/types.spec index f55ece5b6..d2b883bed 100644 --- a/nn/tools/api/types.spec +++ b/nn/tools/api/types.spec @@ -1,6 +1,6 @@ %% -*-Fundamental-*- -%kind-validate hal_1.0 hal_1.1 hal_1.2 ndk +%kind-validate hal_1.0 hal_1.1 hal_1.2 hal_1.3 ndk %kind ndk %define ANN ANEURALNETWORKS_ @@ -28,6 +28,10 @@ * * Available since API level 29. %/define-lines +%define-lines AVAIL30 + * + * Available since API level 30. +%/define-lines %define-lines OutputState * * Important: As of API level 29, there is no way to get the output state tensors out and NNAPI @@ -54,6 +58,8 @@ %/define-lines %define-lines AVAIL29 %/define-lines +%define-lines AVAIL30 +%/define-lines %define-lines PaddingCodeValues * following values: {0 (NONE), 1 (SAME), 2 (VALID)}. %/define-lines @@ -75,13 +81,13 @@ %/define-lines %/kind -%kind hal_1.2 +%kind hal_1.2 hal_1.3 %define DeclareOperation %{1} = @1.1::OperationType:%{1} %define BeforeAPILevel29For Before HAL version 1.2, for %define or_1.2 or {@link OperandType::%{1}} %/kind -%kind ndk hal_1.2 +%kind ndk hal_1.2 hal_1.3 %define-lines NHWC_NCHW * Supported tensor rank: 4, with "NHWC" or "NCHW" data layout. * With the default data layout NHWC, the data is stored in the order of: @@ -100,6 +106,31 @@ %/define-lines %/kind +%section OEMDeprecationAndOperandTypeRangeMaxComment + + /* + * DEPRECATED. Since HAL version 1.2, extensions are the preferred + * alternative to OEM operation and data types. + * + * OEM specific scalar value. + * OEM = 10000, + */ + /* + * DEPRECATED. Since HAL version 1.2, extensions are the preferred + * alternative to OEM operation and data types. + * + * A tensor of OEM specific values. + * TENSOR_OEM_BYTE = 10001, + */ + /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF + * OperandTypeRange::FUNDAMENTAL_MAX. + */ + /* ADDING A NEW OEM TYPE REQUIRES UPDATING THE VALUE OF + * OperandTypeRange::OEM_MAX. + */ +%/section + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% HAL OperandType for 1.0 @@ -2545,7 +2576,7 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% HAL OperationType for 1.2 -%% NDK OperationCode for API 20 +%% NDK OperationCode for API 29 %section Operation_1.2 /** @@ -5026,3 +5057,28 @@ %section Operation_1.2_MAX FUNDAMENTAL_MAX = 94, %/section + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% HAL OperandType for 1.3 +%% NDK OperandCode for API 30 + +%section Operand_1.3 + /** + * A tensor of 8 bit signed integers that represent real numbers. + * + * Attached to this tensor are two numbers that can be used to convert the + * 8 bit integer to the real value and vice versa. These two numbers are: + * - scale: a 32 bit floating point value greater than zero. + * - zeroPoint: a 32 bit integer, in range [-128, 127]. + * + * The formula is: + * real_value = (integer_value - zeroPoint) * scale. +%insert-lines AVAIL30 + */ + %{ANN}TENSOR_QUANT8_ASYMM_SIGNED = 14, +%/section + +%section Operand_1.3_MAX + FUNDAMENTAL_MAX = 14, +%/section |