[mir_tflite] Do not set names of operations (#6955)
authorСергей Баранников/AI Tools Lab /SRR/Engineer/삼성전자 <s.barannikov@samsung.com>
Wed, 28 Aug 2019 07:55:17 +0000 (16:55 +0900)
committerAlexander Efimov/AI Tools Lab/./Samsung Electronics <a.efimov@samsung.com>
Wed, 28 Aug 2019 07:55:17 +0000 (10:55 +0300)
Remove useless setting of operation names.

Signed-off-by: Sergei Barannikov <s.barannikov@samsung.com>
compiler/mir-tflite-importer/tflite_importer.cpp
compiler/mir-tflite-importer/tflite_importer.h
compiler/mir-tflite-importer/tflite_op_creator.h

index 66a80da..aa8afe4 100644 (file)
@@ -139,7 +139,6 @@ std::unique_ptr<mir::Graph> TfliteImporter::importModel()
 void TfliteImporter::walkGraphAndCreateMIR()
 {
   walkModel(_modelPacked);
-  setIrNodeNames();
   setGraphOutputs();
 }
 
@@ -166,8 +165,7 @@ void TfliteImporter::walkSubGraph(const SubGraph *s)
       input_shape.dim(dim) = t->shape()->Get(dim);
     }
 
-    auto input = _graph->create<mir::ops::InputOp>(t->name()->c_str(), input_shape)->getOutput(0);
-
+    auto input = _graph->create<mir::ops::InputOp>(input_shape)->getOutput(0);
     input->setName(t->name()->c_str());
     assert(_tensorMap.find(i) == _tensorMap.cend());
     _tensorMap[i] = input;
@@ -308,7 +306,7 @@ std::vector<mir::Operation::Output *> TfliteImporter::getMIRInputsForOperator(co
       {
         assert(_tensorMap.find(i) == _tensorMap.end());
         mir::TensorVariant mir_tensor = createTensor(tensor, buffer);
-        inputs.emplace_back(_graph->create<ops::ConstantOp>("", mir_tensor)->getOutput(0));
+        inputs.emplace_back(_graph->create<ops::ConstantOp>(mir_tensor)->getOutput(0));
       }
       else
       {
@@ -362,20 +360,7 @@ void TfliteImporter::setGraphOutputs()
   for (auto output_idx : _graphOutputs)
   {
     auto output = _tensorMap[output_idx];
-    _graph->create<mir::ops::OutputOp>(output->getNode()->getName(), output);
-    output->getNode()->setName("");
-  }
-}
-
-void TfliteImporter::setIrNodeNames()
-{
-  // Setting names of the nodes.
-  // Note: we change the computation graph, (for example, TFLite Conv2D
-  // turns into IR Conv2D->Add->ReLU), so not all of the nodes will have names.
-  for (auto iter : _tensorMap)
-  {
-    const Tensor *tensor = (*_tensors)[iter.first];
-    iter.second->getNode()->setName(tensor->name()->c_str());
+    _graph->create<mir::ops::OutputOp>(output);
   }
 }
 
index e235096..c324d53 100644 (file)
@@ -86,11 +86,6 @@ private:
   void setGraphOutputs();
 
   /**
-   * @brief Set MIR node names
-   */
-  void setIrNodeNames();
-
-  /**
    * @brief Returns MIR operation outputs corresponding to the inputs of the given operator.
    */
   std::vector<mir::Operation::Output *> getMIRInputsForOperator(const ::tflite::Operator *op);
index fb757d9..abe997e 100644 (file)
@@ -163,8 +163,7 @@ private:
 template <typename OpType, typename... Types>
 mir::Operation *TFLiteOpCreator::createOp(Types &&... args)
 {
-  // TODO: how to name operations? in Tensorflow tensors get names, not operations
-  return _graph->create<OpType>("", std::forward<Types>(args)...);
+  return _graph->create<OpType>(std::forward<Types>(args)...);
 }
 
 } // namespace mir_tflite