aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/CL/functions/CLFullyConnectedLayer.cpp
diff options
context:
space:
mode:
authorGeorgios Pinitas <georgios.pinitas@arm.com>2021-08-13 12:07:59 +0100
committerGiorgio Arena <giorgio.arena@arm.com>2021-08-13 16:15:07 +0000
commit45fbf9fd00cc8fa564229bd6e2c20f84bc7cafd1 (patch)
tree91dec2dc311cb0508abf788a5a8d6be99fb466f2 /src/runtime/CL/functions/CLFullyConnectedLayer.cpp
parent37a4611dcbefc9ad19af803216d9e2cd5ec64697 (diff)
downloadComputeLibrary-45fbf9fd00cc8fa564229bd6e2c20f84bc7cafd1.tar.gz
Avoid releasing weights if they are used by multiple functions
Resolves: COMPMID-4769 Signed-off-by: Georgios Pinitas <georgios.pinitas@arm.com> Change-Id: Iccadcbd68b0fd84ed3bf212e358a4ea944084a40 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/c/VisualCompute/ComputeLibrary/+/349845 Tested-by: bsgcomp <bsgcomp@arm.com> Reviewed-by: Giorgio Arena <giorgio.arena@arm.com> Comments-Addressed: bsgcomp <bsgcomp@arm.com> Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/6107 Reviewed-by: Gian Marco Iodice <gianmarco.iodice@arm.com> Reviewed-by: SiCong Li <sicong.li@arm.com> Comments-Addressed: Arm Jenkins <bsgcomp@arm.com> Tested-by: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/CL/functions/CLFullyConnectedLayer.cpp')
-rw-r--r--src/runtime/CL/functions/CLFullyConnectedLayer.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp
index ae10cd23b1..c719a667a7 100644
--- a/src/runtime/CL/functions/CLFullyConnectedLayer.cpp
+++ b/src/runtime/CL/functions/CLFullyConnectedLayer.cpp
@@ -80,6 +80,11 @@ void CLFullyConnectedLayer::configure(const CLCompileContext &compile_context, c
_impl->op->configure(compile_context, input->info(), weights->info(), (biases != nullptr) ? biases->info() : nullptr, output->info(), fc_info);
+ if(_impl->weights_manager != nullptr)
+ {
+ _impl->weights_manager->manage(weights);
+ }
+
_impl->aux_mem_req = _impl->op->workspace();
_impl->run_pack = { { ACL_SRC_0, input }, { ACL_SRC_1, weights }, { ACL_SRC_2, biases }, { ACL_DST, output } };
_impl->workspace = manage_workspace<CLTensor>(_impl->aux_mem_req, _impl->memory_group, _impl->run_pack, _impl->run_pack);
@@ -108,6 +113,19 @@ void CLFullyConnectedLayer::prepare()
// Release temporary tensors that are only used in prepare stage
release_temporaries<CLTensor>(_impl->aux_mem_req, _impl->workspace);
_impl->is_prepared = true;
+
+ // Handle weights managed infrastructure
+ if(_impl->weights_manager != nullptr && _impl->weights_manager->are_weights_managed(_impl->original_weights))
+ {
+ // If function marks b as unused ensure that all prepare stages are done before releasing
+ const ITensor *original_b = _impl->original_weights;
+ if(!original_b->is_used())
+ {
+ _impl->weights_manager->mark_as_unused(original_b);
+ }
+ _impl->original_weights->mark_as_used();
+ _impl->weights_manager->release(_impl->original_weights);
+ }
}
}
} // namespace arm_compute