COMPMID-1016: Optimize kernel reconfiguration
Optimizes kernel reconfiguration when memory manager is used.
Note that this works only if every sub-sequent reconfigurations leads to
sizes less than the first one.
Change-Id: I08898e99929c3756147a02979b726c2380b6e11d
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/125114
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Tested-by: Jenkins <bsgcomp@arm.com>
diff --git a/arm_compute/runtime/MemoryGroupBase.h b/arm_compute/runtime/MemoryGroupBase.h
index dc640f1..06e4321 100644
--- a/arm_compute/runtime/MemoryGroupBase.h
+++ b/arm_compute/runtime/MemoryGroupBase.h
@@ -96,7 +96,7 @@
template <typename TensorType>
inline void MemoryGroupBase<TensorType>::manage(TensorType *obj)
{
- if(_memory_manager)
+ if(_memory_manager && _mappings.empty())
{
ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
@@ -114,7 +114,11 @@
template <typename TensorType>
inline void MemoryGroupBase<TensorType>::finalize_memory(TensorType *obj, void **handle, size_t size)
{
- if(_memory_manager)
+ // TODO (geopin01) : Check size (track size in MemoryMappings)
+ // Check if existing mapping is valid
+ ARM_COMPUTE_ERROR_ON(!_mappings.empty() && (_mappings.find(handle) == std::end(_mappings)));
+
+ if(_memory_manager && _mappings.empty())
{
ARM_COMPUTE_ERROR_ON(!_memory_manager->lifetime_manager());
_memory_manager->lifetime_manager()->end_lifetime(obj, handle, size);