{
return ANEURALNETWORKS_BAD_STATE;
}
+
+ if (type->type == ANEURALNETWORKS_TENSOR_QUANT8_ASYMM)
+ {
+ // Quantized:
+ // scale: a 32 bit floating point value greater than zero
+ // zeroPoint: a 32 bit integer, in range [0, 255]
+ if (type->scale <= 0.0f)
+ {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
+
+ if (type->zeroPoint < 0 || type->zeroPoint > 255)
+ {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
+ }
+ // NOTE Validation of scale and zeroPoint would be skipped for a while.
+ // We do not know whether scalar type can have scale and zeroPoint.
+ // To pass ValidationTest and GeneratedTest, this validation code
+ // would not be implemented until we can define this issue clearly.
+ //
+ // scale and zeroPoint should be zero for scalars and non-fixed point tensors
+ // else if ((type->scale != 0.0f) || (type->zeroPoint != 0))
+ // {
+ // return ANEURALNETWORKS_BAD_DATA;
+ // }
+
+ // scalar is ANEURALNETWORKS_FLOAT32, ANEURALNETWORKS_INT32 or ANEURALNETWORKS_UINT32.
+ // ANEURALNETWORKS_TENSOR_FLOAT32, ANEURALNETWORKS_TENSOR_INT32 and
+ // ANEURALNETWORKS_TENSOR_QUANT8_ASYMM are not scalar
+ //
+ // dimensionCount should be zero for scalars
+ if (type->dimensionCount != 0 &&
+ (type->type == ANEURALNETWORKS_FLOAT32 || type->type == ANEURALNETWORKS_INT32 ||
+ type->type == ANEURALNETWORKS_UINT32))
+ {
+ return ANEURALNETWORKS_BAD_DATA;
+ }
+
// ASSUME A tensor operand should consists of fp32 or int32 values.
// NOTE We do not care about scala operands.
assert((type->dimensionCount == 0) || (type->type == ANEURALNETWORKS_TENSOR_FLOAT32 ||