Concat elimination in codegen (#3518)
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 8 Nov 2018 02:44:39 +0000 (11:44 +0900)
committerGitHub Enterprise <noreply-CODE@samsung.com>
Thu, 8 Nov 2018 02:44:39 +0000 (11:44 +0900)
Concat elimination in codegen: check output tensor is parent of inputs and do nothing if true

Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
runtimes/neurun/src/backend/acl_cl/StageGenerator.cc

index b8e5181..b173d5a 100644 (file)
@@ -400,6 +400,22 @@ Stage StageGenerator::generate(const graph::operation::ConcatNode &node)
   auto tensors = _tensor_builder;
 
   return [tensors, param](IExecutionBuilder &builder) {
+    // If tensor allocator allocate as subtensor
+    bool canEliminate = true;
+    for (auto ifm_ind : param.input_indexes)
+    {
+      if (!tensors->isSubTensorOf(param.output_index, ifm_ind))
+      {
+        canEliminate = false;
+        break;
+      }
+    }
+    if (canEliminate)
+    {
+      // If concat eliminated, return with nothing to do
+      return;
+    }
+
     auto output_alloc = tensors->at(param.output_index).get();
 
     std::vector<::arm_compute::ICLTensor *> input_allocs;