24.02.1
|
Go to the documentation of this file.
46 if (child_dims <= parent_dims)
48 for (
size_t num_dimensions = child_dims; num_dimensions > 0; --num_dimensions)
50 const size_t child_dim_size = coords[num_dimensions - 1] + child_shape[num_dimensions - 1];
52 if ((coords[num_dimensions - 1] < 0) || (child_dim_size > parent_shape[num_dimensions - 1]))
80 _associated_memory_group(o._associated_memory_group),
81 _memory(std::move(o._memory))
84 o._associated_memory_group =
nullptr;
95 _associated_memory_group = o._associated_memory_group;
96 o._associated_memory_group =
nullptr;
98 _memory = std::move(o._memory);
130 return (_memory.
region() ==
nullptr) ? nullptr :
reinterpret_cast<uint8_t *
>(_memory.
region()->
buffer());
137 if (_associated_memory_group ==
nullptr)
139 _memory.
set_owned_region(std::make_unique<MemoryRegion>(
info().total_size(), alignment_to_use));
169 ARM_COMPUTE_ERROR_ON(_associated_memory_group !=
nullptr && _associated_memory_group != associated_memory_group);
172 _associated_memory_group = associated_memory_group;
175 uint8_t *TensorAllocator::lock()
178 return reinterpret_cast<uint8_t *
>(_memory.
region()->
buffer());
181 void TensorAllocator::unlock()
void init(const TensorAllocator &allocator, const Coordinates &coords, TensorInfo &sub_info)
Shares the same backing memory with another tensor allocator, while the tensor info might be differen...
~TensorAllocator()
Default destructor.
Interface of an object than can be memory managed.
const Strides & strides_in_bytes() const override
The strides in bytes for accessing each dimension of the tensor.
void set_owned_region(std::unique_ptr< IMemoryRegion > region) final
Sets a memory region.
IMemoryRegion * region() final
Region accessor.
size_t alignment() const
Return underlying's tensor buffer alignment.
CPU implementation of memory object.
TensorAllocator(IMemoryManageable *owner)
Default constructor.
size_t num_dimensions() const override
The number of dimensions of the tensor (rank)
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
TensorInfo & info()
Return a reference to the tensor's metadata.
Format format() const override
Colour format of the image.
bool check_aligned(void *ptr, const size_t alignment)
Checks if a pointer complies with a given alignment.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
size_t total_size() const override
Returns the total size of the tensor in bytes.
ITensorAllocator & operator=(const ITensorAllocator &)=default
Allow instances of this class to be copied.
uint8_t * data() const
Returns the pointer to the allocated data.
virtual void finalize_memory(IMemoryManageable *obj, IMemory &obj_memory, size_t size, size_t alignment)=0
Finalizes memory for a given object.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
void init(Format format)
Initialize the tensor info with just a format.
ITensorInfo & set_is_resizable(bool is_resizable) override
Set the flag whether the tensor size can be changed.
void set_associated_memory_group(IMemoryGroup *associated_memory_group)
Associates the tensor with a memory group.
Basic implementation of a CPU memory tensor allocator.
Store the tensor's metadata.
void set_region(IMemoryRegion *region) final
Sets a memory region.
void allocate() override
Allocate size specified by TensorInfo of CPU memory.
int32_t offset_element_in_bytes(const Coordinates &pos) const override
The offset in bytes from the beginning of the memory allocation to access the element at position (x,...
Copyright (c) 2017-2024 Arm Limited.
virtual void * buffer()=0
Returns the pointer to the allocated data.
void free() override
Free allocated CPU memory.
size_t offset_first_element_in_bytes() const override
The offset from the beginning of the memory allocation to the first element of the tensor.
Status import_memory(void *memory)
Import an existing memory as a tensor's backing memory.
Interface to allocate tensors.
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
TensorAllocator & operator=(const TensorAllocator &)=delete
Prevent instances of this class from being copy assigned (As this class contains pointers)
input allocator() -> allocate()