From e6783a07642be2381f600d4dcc9ffd234bcb0c44 Mon Sep 17 00:00:00 2001 From: Jacob Bohlin Date: Tue, 13 May 2025 11:04:48 +0100 Subject: [PATCH] MLBEDSW-10779 Supported ops checks: Reject negative zero points for unsigned Change-Id: I19c16a6a06278d3a0301d763482e0ab9aaee4472 Signed-off-by: Jacob Bohlin --- .../regor/architecture/ethosu55/ethos_u55_constraints.cpp | 6 ++++++ ethosu/regor/compiler/tflite_graph_optimiser.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp index fd657dcd..090530d9 100644 --- a/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp +++ b/ethosu/regor/architecture/ethosu55/ethos_u55_constraints.cpp @@ -281,6 +281,12 @@ bool EthosU55Constraints::SupportedDtypes(OpType opType, DataType ifmType, DataT // Validate that zero-points are supported bool EthosU55Constraints::SupportedZeroPoint(int64_t zp, TensorUsage usage, DataType dType, OpType opType) { + if ( !IsSignedInteger(dType) && zp < 0 ) + { + // must be non-negative for unsigned data types + return false; + } + if ( IsIFM(usage) ) { // must be zero for 32-bit IFM and for CLZ or SHL operations diff --git a/ethosu/regor/compiler/tflite_graph_optimiser.cpp b/ethosu/regor/compiler/tflite_graph_optimiser.cpp index 5e722813..ce1369f4 100644 --- a/ethosu/regor/compiler/tflite_graph_optimiser.cpp +++ b/ethosu/regor/compiler/tflite_graph_optimiser.cpp @@ -2648,8 +2648,14 @@ Operation *TFLiteGraphOptimiser::ConvertZeroPoint(Graph *const graph, Operation // quantization which may require legalization depending on which hardware is targeted. Operation *TFLiteGraphOptimiser::LegalizeAsymmetricQuantization(Graph *const graph, Operation *const operation) { + UNUSED(graph); auto returnOp = operation; OpType opType = operation->Type(); + if ( opType == OpType::Passthrough ) + { + return returnOp; + } + TensorConnection *ifmConn = operation->Input(TensorUsage::IFM); if ( ifmConn->quantization.zeroPoints.size() == 0 ) { -- GitLab