Skip to content

Commit

Permalink
[runtime] DynamicTensor: TensorBuiler checks dynamic tensor (Samsung#731
Browse files Browse the repository at this point in the history
)

Now TensorBuilder checks dynamic tensor or not and performs action accordingly.

Signed-off-by: Hyun Sik Yoon <[email protected]>
  • Loading branch information
hyunsik-yoon authored May 13, 2020
1 parent a68f8ba commit 824f829
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions runtime/onert/backend/cpu/TensorBuilder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,34 @@ void TensorBuilder::registerTensorInfo(const ir::OperandIndex &ind, const ir::Op
if (as_const)
_constants.append(ind);

// TODO consider dynamic tensor
_static_tensor_mgr->buildTensor(ind, info, _constants.contains(ind));
if (info.memAllocType() == ir::MemAllocType::DYNAMIC)
{
_dynamic_tensor_mgr->buildTensor(ind, info);
}
else
{
_static_tensor_mgr->buildTensor(ind, info, _constants.contains(ind));
}
}

void TensorBuilder::notifyFirstUse(const ir::OperandIndex &ind)
{
assert(_tensor_info_map.find(ind) != _tensor_info_map.end());
const auto tensor_info = _tensor_info_map.at(ind);
const auto size = tensor_info.total_size();

// TODO consider dynamic tensor
_static_tensor_mgr->claimPlan(ind, size);
if (!at(ind)->is_dynamic())
{
const auto size = tensor_info.total_size();
_static_tensor_mgr->claimPlan(ind, size);
}
}

void TensorBuilder::notifyLastUse(const ir::OperandIndex &ind)
{
_static_tensor_mgr->releasePlan(ind);
if (!at(ind)->is_dynamic())
{
_static_tensor_mgr->releasePlan(ind);
}
}

bool TensorBuilder::isRegistered(const ir::OperandIndex &ind) const
Expand Down

0 comments on commit 824f829

Please sign in to comment.