From e131bf4f528f0d461868229972e07f371dcbc881 Mon Sep 17 00:00:00 2001 From: Alexander Bengtsson Date: Mon, 27 Jan 2025 15:20:58 +0100 Subject: [PATCH] MLBEDSW-10319: Add single-consumer check before OFM-fusing - OFM-fusing of Rescales is only valid if the Rescale operation (to be fused) is the single consumer of the preceding operations OFM. Change-Id: Ie341d3e462cf7ce7ec4721f83b459d364542304c Signed-off-by: Alexander Bengtsson --- ethosu/regor/compiler/graphir_optimiser.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ethosu/regor/compiler/graphir_optimiser.cpp b/ethosu/regor/compiler/graphir_optimiser.cpp index 5236b0c3..ddcca184 100644 --- a/ethosu/regor/compiler/graphir_optimiser.cpp +++ b/ethosu/regor/compiler/graphir_optimiser.cpp @@ -1002,7 +1002,8 @@ Operation *GraphIrOptimiser::FuseRescale(Graph *const graph, Operation *const op auto ofmQuant = ofmConn->quantization; ofmQuant.scales = ConvertedScales(ofmConn); - if ( returnOp == operation && producer && producer->Output(TensorUsage::OFM)->quantization.EqualScales(Quantization::Unit()) && + if ( returnOp == operation && producer && ifmConn->tensor->Readers().size() == 1 && + producer->Output(TensorUsage::OFM)->quantization.EqualScales(Quantization::Unit()) && ifmConn->quantization.zeroPoints == Quantization::Unit().zeroPoints && // fused tensor cannot be in graph-outputs !IsTensorInVector(graph->Outputs(), ifmConn->tensor.get()) && -- GitLab