From 5c34723d3434c316a642e123a2da63df312ca02f Mon Sep 17 00:00:00 2001 From: Jiyoung Giuliana Yun Date: Thu, 5 Sep 2024 10:21:30 +0900 Subject: [PATCH] [onert] Use getUses() copy instead of reference (#13931) This commit fixes the problem that occurs in loop traversal due to change of list by using copy instead of reference. ONE-DCO-1.0-Signed-off-by: Jiyoung Yun --- .../src/compiler/train/pass/TrainableConstantInsertionPass.cc | 2 +- runtime/onert/core/src/ir/train/UseDefGenerator.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/onert/core/src/compiler/train/pass/TrainableConstantInsertionPass.cc b/runtime/onert/core/src/compiler/train/pass/TrainableConstantInsertionPass.cc index 67a50fb328d..64a2d92bd1b 100644 --- a/runtime/onert/core/src/compiler/train/pass/TrainableConstantInsertionPass.cc +++ b/runtime/onert/core/src/compiler/train/pass/TrainableConstantInsertionPass.cc @@ -40,7 +40,7 @@ void TrainableConstantInsertionPass::callback(const ir::OperationIndex &node_ind continue; // Insert new operands for shared constant except for the current node. - const auto &uses = object.getUses(); + const auto uses(object.getUses()); for (const auto &use_index : uses) { if (use_index == node_index) diff --git a/runtime/onert/core/src/ir/train/UseDefGenerator.cc b/runtime/onert/core/src/ir/train/UseDefGenerator.cc index a47bc912b48..23b5bb7bf62 100644 --- a/runtime/onert/core/src/ir/train/UseDefGenerator.cc +++ b/runtime/onert/core/src/ir/train/UseDefGenerator.cc @@ -425,7 +425,7 @@ void UseDefGenerator::initForForwardingNodes() } assert(_training_usedefs.at(forwarding_operand_index).getTrainingUses().size() == 0); - const auto &uses = operand.getUses(); + const auto uses(operand.getUses()); for (const auto &use : uses) insertUse(forwarding_operand_index, TrainingOperationIndex{use, is_forward}); });