summaryrefslogtreecommitdiff
path: root/runtimes/neurun
diff options
context:
space:
mode:
author오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>2018-11-08 15:49:08 +0900
committer이춘석/동작제어Lab(SR)/Staff Engineer/삼성전자 <chunseok.lee@samsung.com>2018-11-08 15:49:08 +0900
commitd01c9dc2320bdc1c218843e38e3e53f72b64142c (patch)
treed739f6f26ae995023d70975df5c124fb071e1c0c /runtimes/neurun
parentbb724e140dea5317def594616a25d534ecf0abb6 (diff)
downloadnnfw-d01c9dc2320bdc1c218843e38e3e53f72b64142c.tar.gz
nnfw-d01c9dc2320bdc1c218843e38e3e53f72b64142c.tar.bz2
nnfw-d01c9dc2320bdc1c218843e38e3e53f72b64142c.zip
Register subtensor info to tensor builder (#3519)
Register subtensor info to tensor builder if - Tensor is subtensor of other tensor - Backend support subtensor allocation Signed-off-by: Hyeongseok Oh <hseok82.oh@samsung.com>
Diffstat (limited to 'runtimes/neurun')
-rw-r--r--runtimes/neurun/src/linear/Linear.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/runtimes/neurun/src/linear/Linear.cc b/runtimes/neurun/src/linear/Linear.cc
index e2c33154e..59a00505d 100644
--- a/runtimes/neurun/src/linear/Linear.cc
+++ b/runtimes/neurun/src/linear/Linear.cc
@@ -21,6 +21,8 @@
#include "graph/operation/LowerInfo.h"
#include "backend/interface/IStageGenerator.h"
#include "internal/Convert.h"
+#include "backend/interface/IConfig.h"
+#include "backend/common/operand/SubTensorInfo.h"
#include "logging.h"
@@ -85,13 +87,34 @@ backend::TensorBuilderSet Linear::planTensors()
uses_map[ind]++;
}
- // Prepare tensor builders to be returned
- const auto info = ::internal::asTensorInfo(obj.shape(), obj.typeInfo());
- iterTensorBuilders(ind, [&tensor_builders, &info](const graph::operand::Index &ind,
- ITensorBuilderPtr tensor_builder) {
- tensor_builder->registerTensorInfo(ind, info);
+ for (auto backend : obj.lower_info()->def_backends())
+ {
+ bool isSubTensor = false;
+ auto tensor_builder = backend->tensor_builder();
+
+ if (backend->config()->SupportSubTensorAlloc())
+ {
+ const auto parentInfo = obj.parent_info();
+ if (parentInfo != nullptr)
+ {
+ isSubTensor = true;
+ }
+ }
+
+ if (isSubTensor)
+ {
+ const backend::operand::SubTensorInfo info(obj);
+ tensor_builder->registerSubTensorInfo(ind, info);
+ }
+ else
+ {
+ const auto info = ::internal::asTensorInfo(obj.shape(), obj.typeInfo());
+ tensor_builder->registerTensorInfo(ind, info);
+ }
+
+ // Prepare tensor builders to be returned
tensor_builders.insert(tensor_builder);
- });
+ }
});
// If a tensor is model output, increase the use of the tensor.
@@ -156,6 +179,8 @@ backend::TensorBuilderSet Linear::planTensors()
assert(uses_map[ind] > 0);
#endif
+ // Set subtensor information
+ // Todo: move this phase outside as optimization phase
return tensor_builders;
}