From e5cabbf7528849aac35b498ce0711a144c1a08d5 Mon Sep 17 00:00:00 2001 From: Jerry Ge Date: Mon, 17 Jul 2023 21:33:17 +0000 Subject: Enable lazy tensor allocation - The previous ref_model was allocating the memory for all tensors in the graph upfront which is unnecessary and wasteful. - This patch changes to only allocate initial input tensors on the entry point using the allocateInputTensor() function. - The output tensors are ensured to have been allocated before executing a node. The output tenosrs are the inputs for the next node. - When a node's evaluation is finished, its input tensors will be freed if they will no longer be used by anyone else. Signed-off-by: Jerry Ge Change-Id: Ibb3e8c9e6344f6cd9eb20532a03b2097b93247f9 --- reference_model/src/model_runner_impl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'reference_model/src/model_runner_impl.cc') diff --git a/reference_model/src/model_runner_impl.cc b/reference_model/src/model_runner_impl.cc index ce548e9..be97644 100644 --- a/reference_model/src/model_runner_impl.cc +++ b/reference_model/src/model_runner_impl.cc @@ -327,9 +327,9 @@ GraphStatus ModelRunnerImpl::initialize(TosaSerializationBasicBlock* bb, return _main_gt->getGraphStatus(); } - if (_main_gt->allocateTensor()) + if (_main_gt->allocateInputTensors()) { - WARNING("Failed to allocate tensor."); + WARNING("Failed to allocate input tensors."); return _main_gt->getGraphStatus(); } -- cgit v1.2.1