Replace TENSOR_QUANT16_ASYMM with TENSOR_QUANT16_SYMM

* Update doc string
* Update zero point mutation to check for symmetric quantization

Fix: 118671831
Test: VtsHalNeuralnetworksV1_2TargetTest
Change-Id: Id1999c793c839b892cfe45cbb245611b12db2a72
Merged-In: Id1999c793c839b892cfe45cbb245611b12db2a72
(cherry picked from commit 48c8820bac)
This commit is contained in:
Lev Proleev
2018-11-13 15:42:36 +00:00
parent 1a2492f311
commit 217c4071cc
2 changed files with 10 additions and 12 deletions

View File

@@ -33,15 +33,13 @@ enum OperandType : @1.0::OperandType {
/**
* A tensor of 16 bit signed integers that represent real numbers.
*
* Attached to this tensor are two numbers that are used to convert the 16
* 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 [-32768, 32767].
* Attached to this tensor is a number representing real value scale that is
* used to convert the 16 bit number to a real value in the following way:
* realValue = integerValue * scale.
*
* The formula is:
* realValue = (integerValue - zeroPoint) * scale.
* scale is a 32 bit floating point with value greater then zero.
*/
TENSOR_QUANT16_ASYMM = 7,
TENSOR_QUANT16_SYMM = 7,
/** A tensor of 16 bit floating point values. */
TENSOR_FLOAT16 = 8,
};

View File

@@ -161,7 +161,7 @@ static uint32_t getInvalidRank(OperandType type) {
case OperandType::TENSOR_FLOAT32:
case OperandType::TENSOR_INT32:
case OperandType::TENSOR_QUANT8_ASYMM:
case OperandType::TENSOR_QUANT16_ASYMM:
case OperandType::TENSOR_QUANT16_SYMM:
return 0;
default:
return 0;
@@ -193,7 +193,7 @@ static float getInvalidScale(OperandType type) {
case OperandType::TENSOR_INT32:
return -1.0f;
case OperandType::TENSOR_QUANT8_ASYMM:
case OperandType::TENSOR_QUANT16_ASYMM:
case OperandType::TENSOR_QUANT16_SYMM:
return 0.0f;
default:
return 0.0f;
@@ -225,8 +225,8 @@ static std::vector<int32_t> getInvalidZeroPoints(OperandType type) {
return {1};
case OperandType::TENSOR_QUANT8_ASYMM:
return {-1, 256};
case OperandType::TENSOR_QUANT16_ASYMM:
return {-32769, 32768};
case OperandType::TENSOR_QUANT16_SYMM:
return {-32769, -1, 1, 32768};
default:
return {};
}
@@ -279,7 +279,7 @@ static void mutateOperand(Operand* operand, OperandType type) {
newOperand.zeroPoint = 0;
break;
case OperandType::TENSOR_QUANT8_ASYMM:
case OperandType::TENSOR_QUANT16_ASYMM:
case OperandType::TENSOR_QUANT16_SYMM:
newOperand.dimensions =
operand->dimensions.size() > 0 ? operand->dimensions : hidl_vec<uint32_t>({1});
newOperand.scale = operand->scale != 0.0f ? operand->scale : 1.0f;