From 2094912c78714b046571169691d789084622bf4c Mon Sep 17 00:00:00 2001 From: Elizaveta Lobanova Date: Mon, 24 May 2021 14:42:27 +0300 Subject: [PATCH] [GNA] Fix identity insertion into LSTMCell (#5759) --- .../src/gna_plugin/optimizer/gna_pass_manager.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp index 06e72f8ab87428..3ade076e06f069 100644 --- a/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp +++ b/inference-engine/src/gna_plugin/optimizer/gna_pass_manager.cpp @@ -1680,13 +1680,8 @@ void InsertIdentityToLSTMCellPass::run() { for (auto& input : input_to) { auto& next_layer = input.second; activationInputTo[input.first] = next_layer; - for (int i = next_layer->insData.size() -1; i>= 0; i--) { - auto ins = next_layer->insData[i].lock(); - if (ins == output) { - next_layer->insData.erase(next_layer->insData.begin() + i); - } - } - next_layer->insData.push_back(dataPtr); + std::replace_if(std::begin(next_layer->insData), std::end(next_layer->insData), + [output](DataWeakPtr data) { return data.lock() == output; }, dataPtr); } input_to.clear(); input_to[activationName] = activationLayerWithQuant;