diff options
author | SiCongLi <sicong.li@arm.com> | 2021-05-25 14:29:21 +0100 |
---|---|---|
committer | Georgios Pinitas <georgios.pinitas@arm.com> | 2021-05-26 15:40:07 +0000 |
commit | bc91297c865808ed2c321febc405179f63195ff8 (patch) | |
tree | e7503b8ba251341b2cd9d666077a05019fd2b878 /src/graph/mutators | |
parent | f733e0375f62bbecbbf87045e4e40afad858b318 (diff) | |
download | ComputeLibrary-bc91297c865808ed2c321febc405179f63195ff8.tar.gz |
Fix node fusion mutator
Node fusion mutator adds new nodes to the node list, invalidating the
list iterator during iteration. The fix uses index instead.
Resolves COMPMID-4543
Change-Id: Ibb38e2394c616ac6e458568e73f09fb5243e94fe
Signed-off-by: SiCongLi <sicong.li@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5717
Reviewed-by: Michele Di Giorgio <michele.digiorgio@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/graph/mutators')
-rw-r--r-- | src/graph/mutators/NodeFusionMutator.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/graph/mutators/NodeFusionMutator.cpp b/src/graph/mutators/NodeFusionMutator.cpp index 1d47668cf2..5a696f8386 100644 --- a/src/graph/mutators/NodeFusionMutator.cpp +++ b/src/graph/mutators/NodeFusionMutator.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020 Arm Limited. + * Copyright (c) 2018-2021 Arm Limited. * * SPDX-License-Identifier: MIT * @@ -268,9 +268,12 @@ void fuse_node_with_activation(Graph &g, const Edge *output_edge, const std::set template <typename N1, typename N2, typename F, typename... Args> void fuse_layer(Graph &g, std::function<bool(INode &)> const &prec, const F fuse_fcn, Args &&... optional_arguments) { - // Not interested in the order of nodes - for(auto &node : g.nodes()) + // Note that fused nodes may be added to the end of the node list. + // Instead of only looping over the original list of nodes, we loop over the current node list which could be growing. + // This is intentional as it probes the newly added fused nodes for further fusing opportunities. + for(unsigned int i = 0; i < g.nodes().size(); ++i) { + auto node = g.node(i); // Check if the node is of type N and not a branching node if(node && node->type() == N1::node_type && node->output_edges().size() == 1) { |