From e4e58e15d9916fdcef33f5c43c2f60ef124da6a6 Mon Sep 17 00:00:00 2001 From: Tim Hall Date: Fri, 8 May 2020 09:50:21 +0100 Subject: Add float32 support for unsupported operators - Removed the assert on datatype not being uint8/int8/int16 - Allow unquantised inputs - This will break for float32 versions of supported operators Change-Id: Id579b7adf61645b7578ee59bc2003c49108aedd5 Signed-off-by: Tim Hall --- ethosu/vela/tflite_reader.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ethosu/vela/tflite_reader.py') diff --git a/ethosu/vela/tflite_reader.py b/ethosu/vela/tflite_reader.py index 3632f821..4f9bd7d0 100644 --- a/ethosu/vela/tflite_reader.py +++ b/ethosu/vela/tflite_reader.py @@ -108,10 +108,11 @@ class TFLiteSubgraph: return arr tens.quantization = QuantizationParameters() - tens.quantization.min = len1_array_to_scalar(quant.MinAsNumpy()) - tens.quantization.max = len1_array_to_scalar(quant.MaxAsNumpy()) - tens.quantization.scale_f32 = len1_array_to_scalar(quant.ScaleAsNumpy()) - tens.quantization.zero_point = len1_array_to_scalar(quant.ZeroPointAsNumpy()) + if quant is not None: + tens.quantization.min = len1_array_to_scalar(quant.MinAsNumpy()) + tens.quantization.max = len1_array_to_scalar(quant.MaxAsNumpy()) + tens.quantization.scale_f32 = len1_array_to_scalar(quant.ScaleAsNumpy()) + tens.quantization.zero_point = len1_array_to_scalar(quant.ZeroPointAsNumpy()) if dtype == DataType.uint8: tens.quantization.quant_min = 0 @@ -119,8 +120,6 @@ class TFLiteSubgraph: elif dtype in set((DataType.int8, DataType.int16, DataType.int32, DataType.int64)): tens.quantization.quant_min = -(1 << (dtype.bits - 1)) tens.quantization.quant_max = (1 << (dtype.bits - 1)) - 1 - else: - raise Exception("DataType '" + str(dtype) + "' is not supported for quantization.") if tens.quantization.scale_f32 is None and tens.quantization.zero_point is None: tens.quantization = None -- cgit v1.2.1