Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / runtime / onert / core / src / ir / pass / PermutationInsertionPass.cc
index 7c3da52..3578af8 100644 (file)
@@ -60,36 +60,8 @@ void PermutationInsertionPass::callback(const OperandIndex &index, Operand &obje
     }
 
     auto insert_set = operand_li->use_factors() - operand_li->def_factors();
-    auto def_factor = operand_li->def_factors().getOnlyElement();
-
-    auto compatible_backends = [](auto /* backend1 */, auto /* backend2 */) {
-      // TODO If other issues for Permute elimination are resolved, enable this
-      return false;
-      /*
-      // TODO This is a workaround for not inserting Permute between cpu and controlflow.
-      //      To be general, we need another way of checking they are compatible.
-      const auto cf = backend::controlflow::Config::ID;
-      const auto cpu = "cpu";
-      const auto id1 = backend1->config()->id();
-      const auto id2 = backend2->config()->id();
-      return (id1 == cpu && id2 == cf) // Allows no-Permute for Model inputs
-          || (id1 == cf && id2 == cpu); // Allows no-Permute for Model outputs
-          */
-    };
-
     for (auto factor : insert_set)
     {
-      if (factor.layout() == def_factor.layout() &&
-          compatible_backends(factor.backend(), def_factor.backend()))
-      {
-        // For this factor we can just reuse existing operand - Permute is not added.
-        VERBOSE(PermutationInsertionPass) << "Permutation Insertion is skipped for operand "
-                                          << index << " / as the tensor is compatible with backend "
-                                          << factor.backend()->config()->id() << std::endl;
-        factor_to_index.emplace(factor, index);
-        continue;
-      }
-
       const auto permute_operation_index = insertPermute(index, factor);
       permute_indexes.push_back(permute_operation_index);
       const auto &permute_operation = _graph.operations().at(permute_operation_index);
@@ -235,7 +207,7 @@ OperationIndex PermutationInsertionPass::insertPermute(const OperandIndex &opera
   // Update Use/Def info
   {
     _graph.operands().at(operand_index).insertUse(node_index);
-    _graph.operands().at(out_operand_index).insertDef(node_index);
+    _graph.operands().at(out_operand_index).setDef(node_index);
   }
   return node_index;
 }