// DO NOTHING
}
-void TensorBuilder::notifyFirstUse(const graph::operand::Index &ind,
- const ::arm_compute::TensorInfo &info)
+void TensorBuilder::registerTensorInfo(const ::neurun::graph::operand::Index &ind,
+ const ::arm_compute::TensorInfo &info)
{
assert(_tensors.size() == 0);
_tensor_info_map.insert({ind, info});
}
+void TensorBuilder::notifyFirstUse(const graph::operand::Index &)
+{
+ // DO NOTHING
+}
+
void TensorBuilder::notifyLastUse(const graph::operand::Index &)
{
// DO NOTHING
public:
TensorBuilder();
- virtual void notifyFirstUse(const graph::operand::Index &,
- const ::arm_compute::TensorInfo &) override;
+ /**
+ * @brief Register tensor information to allocate on ACL-CL backend
+ * @param[in] ind Operand index
+ * @param[in] info Tensor information
+ */
+ virtual void registerTensorInfo(const graph::operand::Index &ind,
+ const ::arm_compute::TensorInfo &info) override;
+ virtual void notifyFirstUse(const graph::operand::Index &) override;
virtual void notifyLastUse(const graph::operand::Index &) override;
virtual void prepare(void) override;
// DO NOTHING
}
-void TensorBuilder::notifyFirstUse(const graph::operand::Index &ind,
- const ::arm_compute::TensorInfo &info)
+void TensorBuilder::registerTensorInfo(const graph::operand::Index &ind,
+ const ::arm_compute::TensorInfo &info)
{
assert(_mem_alloc);
_tensor_info_map.insert({ind, info});
+}
+
+void TensorBuilder::notifyFirstUse(const graph::operand::Index &ind)
+{
+ assert(_tensor_info_map.find(ind) != _tensor_info_map.end());
+ const auto &info = _tensor_info_map.at(ind);
const auto size = info.total_size();
auto mem_blk = _mem_alloc->allocate(ind, size);
public:
TensorBuilder();
- virtual void notifyFirstUse(const graph::operand::Index &,
- const ::arm_compute::TensorInfo &) override;
+ /**
+ * @brief Register tensor information to allocate on CPU backend
+ * @param[in] ind Operand index
+ * @param[in] info Tensor information
+ */
+ virtual void registerTensorInfo(const graph::operand::Index &ind,
+ const ::arm_compute::TensorInfo &info) override;
+ virtual void notifyFirstUse(const graph::operand::Index &) override;
virtual void notifyLastUse(const graph::operand::Index &) override;
-
virtual void prepare(void) override;
virtual void allocate(void) override;
virtual ~ITensorBuilder(void) = default;
- virtual void notifyFirstUse(const graph::operand::Index &, const ::arm_compute::TensorInfo &) = 0;
+ // TODO Merge registerTensorInfo and registerSubTensorInfo using abstraction by internal class
+ /**
+ * @brief Register tensor information to allocate on backend
+ */
+ virtual void registerTensorInfo(const graph::operand::Index &,
+ const ::arm_compute::TensorInfo &) = 0;
+ virtual void notifyFirstUse(const graph::operand::Index &) = 0;
virtual void notifyLastUse(const graph::operand::Index &) = 0;
// TODO Add an interface for adding subsumption info
}
// Prepare tensor builders to be returned
- iterTensorBuilders(ind, [&tensor_builders](const graph::operand::Index &,
- ITensorBuilderPtr tensor_builder) {
+ 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);
tensor_builders.insert(tensor_builder);
});
});
VERBOSE(LINEAR) << "TENSORS as CONSTANT" << std::endl;
for (const auto &ind : constants)
{
- const auto &obj = operands.at(ind);
- const auto info = ::internal::asTensorInfo(obj.shape(), obj.typeInfo());
- iterTensorBuilders(ind,
- [&info](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
- tensor_builder->notifyFirstUse(ind, info);
- });
+ iterTensorBuilders(ind, [](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
+ tensor_builder->notifyFirstUse(ind);
+ });
}
// Allocate Model's inputs
VERBOSE(LINEAR) << "TENSORS as MODEL INPUT" << std::endl;
for (const auto &ind : _graph.getInputs())
{
- const auto &obj = operands.at(ind);
- const auto info = ::internal::asTensorInfo(obj.shape(), obj.typeInfo());
- iterTensorBuilders(ind,
- [&info](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
- tensor_builder->notifyFirstUse(ind, info);
- });
+ iterTensorBuilders(ind, [](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
+ tensor_builder->notifyFirstUse(ind);
+ });
}
// At each operation,
const auto &obj = operands.at(ind);
if (obj.getDef().size())
{
- const auto info = ::internal::asTensorInfo(obj.shape(), obj.typeInfo());
- iterTensorBuilders(
- ind, [&info](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
- tensor_builder->notifyFirstUse(ind, info);
- });
+ iterTensorBuilders(ind,
+ [](const graph::operand::Index &ind, ITensorBuilderPtr tensor_builder) {
+ tensor_builder->notifyFirstUse(ind);
+ });
}
}