From 86a9fa0900c8e0d6e1a3b4e96b223f13cd77564a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Guihot?= Date: Wed, 23 Jan 2019 19:18:59 -0800 Subject: [PATCH] Added TENSOR_QUANT8_SYMM type. Test: none Change-Id: I02fc8698b3f80e1ae2a318e5cde593c6d7222bac Merged-In: I02fc8698b3f80e1ae2a318e5cde593c6d7222bac (cherry picked from commit bae91697b5397693a10f225de3d39102152e4f18) --- neuralnetworks/1.2/types.hal | 14 ++++++++++++-- .../1.2/vts/functional/ValidateModel.cpp | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/neuralnetworks/1.2/types.hal b/neuralnetworks/1.2/types.hal index 9e7d8f0d1b..2e48ba016f 100644 --- a/neuralnetworks/1.2/types.hal +++ b/neuralnetworks/1.2/types.hal @@ -47,7 +47,7 @@ enum OperandType : @1.0::OperandType { * used to convert the 16 bit number to a real value in the following way: * realValue = integerValue * scale. * - * scale is a 32 bit floating point with value greater then zero. + * scale is a 32 bit floating point with value greater than zero. */ TENSOR_QUANT16_SYMM = 7, /** A tensor of IEEE 754 16 bit floating point values. */ @@ -97,6 +97,16 @@ enum OperandType : @1.0::OperandType { * real_value = (integer_value - zeroPoint) * scale. */ TENSOR_QUANT16_ASYMM = 12, + /** + * A tensor of 8 bit signed integers that represent real numbers. + * + * Attached to this tensor is a number representing real value scale that is + * used to convert the 8 bit number to a real value in the following way: + * realValue = integerValue * scale. + * + * scale is a 32 bit floating point with value greater than zero. + */ + TENSOR_QUANT8_SYMM = 13, /* ADDING A NEW FUNDAMENTAL TYPE REQUIRES UPDATING THE VALUE OF * OperandTypeRange::FUNDAMENTAL_MAX. */ @@ -111,7 +121,7 @@ enum OperandType : @1.0::OperandType { enum OperandTypeRange : uint32_t { BASE_MIN = 0, FUNDAMENTAL_MIN = 0, - FUNDAMENTAL_MAX = 12, + FUNDAMENTAL_MAX = 13, OEM_MIN = 10000, OEM_MAX = 10001, BASE_MAX = 0xFFFF, diff --git a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp index 1bbb20392a..590116ede2 100644 --- a/neuralnetworks/1.2/vts/functional/ValidateModel.cpp +++ b/neuralnetworks/1.2/vts/functional/ValidateModel.cpp @@ -161,6 +161,7 @@ static uint32_t getInvalidRank(OperandType type) { case OperandType::TENSOR_FLOAT32: case OperandType::TENSOR_INT32: case OperandType::TENSOR_QUANT8_ASYMM: + case OperandType::TENSOR_QUANT8_SYMM: case OperandType::TENSOR_QUANT16_ASYMM: case OperandType::TENSOR_QUANT16_SYMM: case OperandType::TENSOR_QUANT8_SYMM_PER_CHANNEL: @@ -199,6 +200,7 @@ static float getInvalidScale(OperandType type) { return 1.0f; case OperandType::TENSOR_INT32: return -1.0f; + case OperandType::TENSOR_QUANT8_SYMM: case OperandType::TENSOR_QUANT8_ASYMM: case OperandType::TENSOR_QUANT16_ASYMM: case OperandType::TENSOR_QUANT16_SYMM: @@ -235,6 +237,8 @@ static std::vector getInvalidZeroPoints(OperandType type) { return {1}; case OperandType::TENSOR_QUANT8_ASYMM: return {-1, 256}; + case OperandType::TENSOR_QUANT8_SYMM: + return {-129, -1, 1, 128}; case OperandType::TENSOR_QUANT16_ASYMM: return {-1, 65536}; case OperandType::TENSOR_QUANT16_SYMM: @@ -292,6 +296,7 @@ static void mutateOperand(Operand* operand, OperandType type) { newOperand.zeroPoint = 0; break; case OperandType::TENSOR_QUANT8_ASYMM: + case OperandType::TENSOR_QUANT8_SYMM: case OperandType::TENSOR_QUANT16_ASYMM: case OperandType::TENSOR_QUANT16_SYMM: newOperand.dimensions =