24.02.1
|
Go to the documentation of this file.
24 #ifndef SRC_COMMON_MEMORY_HELPERS_H
25 #define SRC_COMMON_MEMORY_HELPERS_H
43 template <
typename TensorType>
48 std::unique_ptr<TensorType>
tensor{
nullptr};
51 template <
typename TensorType>
54 template <
typename TensorType>
59 return manage_workspace<TensorType>(mem_reqs, mgroup, run_pack, dummy_pack);
62 template <
typename TensorType>
69 for (
const auto &req : mem_reqs)
77 workspace_memory.emplace_back(
80 auto aux_tensor = workspace_memory.back().tensor.get();
82 aux_tensor->allocator()->init(aux_info, req.alignment);
95 for (
auto &mem : workspace_memory)
97 auto tensor = mem.tensor.get();
101 return workspace_memory;
104 template <
typename TensorType>
107 workspace.erase(std::remove_if(workspace.begin(), workspace.end(),
108 [&prep_pack](
auto &wk)
110 const bool to_erase = wk.lifetime == experimental::MemoryLifetime::Prepare;
113 prep_pack.remove_tensor(wk.slot);
121 template <
typename TensorType>
124 for (
auto &ws : workspace)
126 const int slot = ws.slot;
127 for (
auto &m : mem_reqs)
129 if (m.slot == slot && m.lifetime == experimental::MemoryLifetime::Prepare)
131 auto tensor = ws.tensor.get();
132 tensor->allocator()->free();
std::vector< MemoryInfo > MemoryRequirements
void manage(IMemoryManageable *obj) override
Sets a object to be managed by the given memory group.
experimental::MemoryLifetime lifetime
void add_tensor(int id, ITensor *tensor)
Add tensor to the pack.
void release_prepare_tensors(WorkspaceData< TensorType > &workspace, ITensorPack &prep_pack)
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
WorkspaceData< TensorType > manage_workspace(const experimental::MemoryRequirements &mem_reqs, MemoryGroup &mgroup, ITensorPack &run_pack)
void release_temporaries(const experimental::MemoryRequirements &mem_reqs, WorkspaceData< TensorType > &workspace)
Utility function to release tensors with lifetime marked as Prepare.
@ U8
unsigned 8-bit number
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
void allocate() override
Allocate size specified by TensorInfo of OpenCL memory.
CLTensor * tensor
Pointer to the auxiliary tensor.
CLTensorAllocator * allocator()
Return a pointer to the tensor's allocator.
std::unique_ptr< TensorType > tensor
Store the tensor's metadata.
int offset_int_vec(int offset)
Copyright (c) 2017-2024 Arm Limited.
std::vector< WorkspaceDataElement< TensorType > > WorkspaceData