From 26014cf4d0519aef280c8444c60ec34c4e37e3b6 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Mon, 9 Sep 2019 19:00:57 +0100 Subject: COMPMID-2649: Generalize MemoryGroup. Avoids any upcasting. Change-Id: I2181c7c9df59a7fb8a78e11934fbd96058fd39c7 Signed-off-by: Georgios Pinitas Reviewed-on: https://review.mlplatform.org/c/1918 Comments-Addressed: Arm Jenkins Tested-by: Arm Jenkins Reviewed-by: Gian Marco Iodice --- src/runtime/TensorAllocator.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src/runtime/TensorAllocator.cpp') diff --git a/src/runtime/TensorAllocator.cpp b/src/runtime/TensorAllocator.cpp index dfe239c586..7352932ac7 100644 --- a/src/runtime/TensorAllocator.cpp +++ b/src/runtime/TensorAllocator.cpp @@ -66,8 +66,8 @@ bool validate_subtensor_shape(const TensorInfo &parent_info, const TensorInfo &c } } // namespace -TensorAllocator::TensorAllocator(Tensor *owner) - : _associated_memory_group(nullptr), _memory(), _owner(owner) +TensorAllocator::TensorAllocator(IMemoryManageable *owner) + : _owner(owner), _associated_memory_group(nullptr), _memory() { } @@ -78,28 +78,28 @@ TensorAllocator::~TensorAllocator() TensorAllocator::TensorAllocator(TensorAllocator &&o) noexcept : ITensorAllocator(std::move(o)), + _owner(o._owner), _associated_memory_group(o._associated_memory_group), - _memory(std::move(o._memory)), - _owner(o._owner) + _memory(std::move(o._memory)) { + o._owner = nullptr; o._associated_memory_group = nullptr; o._memory = Memory(); - o._owner = nullptr; } TensorAllocator &TensorAllocator::operator=(TensorAllocator &&o) noexcept { if(&o != this) { + _owner = o._owner; + o._owner = nullptr; + _associated_memory_group = o._associated_memory_group; o._associated_memory_group = nullptr; _memory = std::move(o._memory); o._memory = Memory(); - _owner = o._owner; - o._owner = nullptr; - ITensorAllocator::operator=(std::move(o)); } return *this; @@ -161,7 +161,7 @@ Status TensorAllocator::import_memory(void *memory) return Status{}; } -void TensorAllocator::set_associated_memory_group(MemoryGroup *associated_memory_group) +void TensorAllocator::set_associated_memory_group(IMemoryGroup *associated_memory_group) { ARM_COMPUTE_ERROR_ON(associated_memory_group == nullptr); ARM_COMPUTE_ERROR_ON(_associated_memory_group != nullptr && _associated_memory_group != associated_memory_group); -- cgit v1.2.1