diff options
author | Sang-Hoon Park <sang-hoon.park@arm.com> | 2021-05-25 13:12:47 +0100 |
---|---|---|
committer | Sang-Hoon Park <sang-hoon.park@arm.com> | 2021-05-25 15:26:33 +0000 |
commit | 8b83d4684249bb96e27f95e11cf8f38a1c33b82b (patch) | |
tree | a150f1266e6cb17540251233b02465a76426d329 /src/runtime/gpu/cl/utils/ClAuxTensorHandler.h | |
parent | bf1dbd85cfccc9ad4a351ae403218b83e3dc87a6 (diff) | |
download | ComputeLibrary-8b83d4684249bb96e27f95e11cf8f38a1c33b82b.tar.gz |
Remove used auxilary tensors from ClGemm's tensor pack
When the used auxilary tensors are kept in the tensor pack,
the pointers in the tensor pack can point memory space
that has been already freed. In some cases, this leads
crashes or unpredictable behaviour.
Resolves: COMPMID-4536
Change-Id: I4cc83310dfe084d477a5f9bece216228c3edb172
Signed-off-by: Sang-Hoon Park <sang-hoon.park@arm.com>
Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5710
Tested-by: Arm Jenkins <bsgcomp@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
Comments-Addressed: Arm Jenkins <bsgcomp@arm.com>
Diffstat (limited to 'src/runtime/gpu/cl/utils/ClAuxTensorHandler.h')
-rw-r--r-- | src/runtime/gpu/cl/utils/ClAuxTensorHandler.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/runtime/gpu/cl/utils/ClAuxTensorHandler.h b/src/runtime/gpu/cl/utils/ClAuxTensorHandler.h index ad893acea5..152e3c6c04 100644 --- a/src/runtime/gpu/cl/utils/ClAuxTensorHandler.h +++ b/src/runtime/gpu/cl/utils/ClAuxTensorHandler.h @@ -50,6 +50,8 @@ public: if(pack_inject) { pack.add_tensor(slot_id, &_tensor); + _injected_tensor_pack = &pack; + _injected_slot_id = slot_id; } } else @@ -68,6 +70,17 @@ public: } } + CLAuxTensorHandler(const CLAuxTensorHandler &) = delete; + CLAuxTensorHandler &operator=(const CLAuxTensorHandler) = delete; + + ~CLAuxTensorHandler() + { + if(_injected_tensor_pack) + { + _injected_tensor_pack->remove_tensor(_injected_slot_id); + } + } + ICLTensor *get() { return &_tensor; @@ -79,7 +92,9 @@ public: } private: - CLTensor _tensor{}; + CLTensor _tensor{}; + ITensorPack *_injected_tensor_pack{ nullptr }; + int _injected_slot_id{ TensorType::ACL_UNKNOWN }; }; } // namespace opencl } // namespace arm_compute |