Added TENSOR_QUANT8_SYMM type.

am: 86a9fa0900

Change-Id: I1ad094b24f79440c277f53c2f002ea6dc9a25b10
This commit is contained in:
Herv Guihot
2019-02-11 20:18:21 -08:00
committed by android-build-merger
2 changed files with 17 additions and 2 deletions

View File

@@ -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,

View File

@@ -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<int32_t> 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 =