diff options
author | Jerry Ge <jerry.ge@arm.com> | 2023-07-17 21:33:17 +0000 |
---|---|---|
committer | Jerry Ge <jerry.ge@arm.com> | 2023-07-27 17:24:26 +0000 |
commit | e5cabbf7528849aac35b498ce0711a144c1a08d5 (patch) | |
tree | c4d4756a5961cd095a4f0faa677dbe6b47522f82 /reference_model/src/ops/control_flow.cc | |
parent | 97b0027ca018ad9b5f91f41b413e843afb15c6d7 (diff) | |
download | reference_model-e5cabbf7528849aac35b498ce0711a144c1a08d5.tar.gz |
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 <jerry.ge@arm.com>
Change-Id: Ibb3e8c9e6344f6cd9eb20532a03b2097b93247f9
Diffstat (limited to 'reference_model/src/ops/control_flow.cc')
-rw-r--r-- | reference_model/src/ops/control_flow.cc | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/reference_model/src/ops/control_flow.cc b/reference_model/src/ops/control_flow.cc index 0afb7e2..6bbc587 100644 --- a/reference_model/src/ops/control_flow.cc +++ b/reference_model/src/ops/control_flow.cc @@ -43,7 +43,8 @@ int OpControlFlow::evalBlock(TosaSerializationBasicBlock* block, ERROR_IF(block_sgt.linkTensorsAndNodes(), "evalBlock(): Failed to link tensors and nodes for %s", block_name.c_str()); ERROR_IF(block_sgt.validateGraph(), "evalBlock(): Failed to validate subgraph for %s", block_name.c_str()); - ERROR_IF(block_sgt.allocateTensor(), "evalBlock(): Failed to allocate tensor for %s", block_name.c_str()); + ERROR_IF(block_sgt.allocateInputTensors(), "evalBlock(): Failed to allocate input tensors for %s", + block_name.c_str()); int num_input_tensors = block_sgt.getNumInputTensors(); int num_output_tensors = block_sgt.getNumOutputTensors(); |