From a503474d8f4af42511cb120b8c92c4e9801d71ea Mon Sep 17 00:00:00 2001 From: Johan Gunnarsson Date: Tue, 22 Apr 2025 10:06:30 +0200 Subject: [PATCH] MLBEDSW-10724: Fix disconnecting activations When we encounter and re-fuse an activation, we should return the original op instead of the activation op. The activation op is disconnected at that point, which means it has no inputs/outputs and will end the graph traversal. Signed-off-by: Johan Gunnarsson Change-Id: I56d7eec2351831b3c087bc5b32f503c14de3ef1e --- ethosu/regor/compiler/tflite_graph_optimiser.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ethosu/regor/compiler/tflite_graph_optimiser.cpp b/ethosu/regor/compiler/tflite_graph_optimiser.cpp index 8629741c..1d71c709 100644 --- a/ethosu/regor/compiler/tflite_graph_optimiser.cpp +++ b/ethosu/regor/compiler/tflite_graph_optimiser.cpp @@ -2745,6 +2745,7 @@ void DisconnectActivation(Operation *const op) Operation *TFLiteGraphOptimiser::SupportedOperatorChecks(Graph *const graph, Operation *const operation) { + Operation *returnOp = operation; if ( !_supportedOps->Check(operation) ) { if ( TfLiteMapping::CanFuseActivationFunction(operation) ) @@ -2761,11 +2762,13 @@ Operation *TFLiteGraphOptimiser::SupportedOperatorChecks(Graph *const graph, Ope // op is an activation function, disconnect op and set pred to passthrough DisconnectActivation(pred.get()); pred->SetPassthroughOp(); + // return pred instead of the disconnected activation + returnOp = pred.get(); } } operation->SetPassthroughOp(); } - return operation; + return returnOp; } Operation *TFLiteGraphOptimiser::ClampActivations(Graph *const graph, Operation *const operation) -- GitLab