23.08
|
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>
60 return manage_workspace<TensorType>(mem_reqs, mgroup, run_pack, dummy_pack);
63 template <
typename TensorType>
69 for(
const auto &req : mem_reqs)
79 auto aux_tensor = workspace_memory.back().tensor.get();
81 aux_tensor->allocator()->init(aux_info, req.alignment);
94 for(
auto &mem : workspace_memory)
96 auto tensor = mem.tensor.get();
100 return workspace_memory;
103 template <
typename TensorType>
106 workspace.erase(std::remove_if(workspace.begin(),
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>
125 for(
auto &ws : workspace)
127 const int slot = ws.slot;
128 for(
auto &
m : mem_reqs)
130 if(
m.slot == slot &&
m.lifetime == experimental::MemoryLifetime::Prepare)
132 auto tensor = ws.tensor.get();
133 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-2023 Arm Limited.
std::vector< WorkspaceDataElement< TensorType > > WorkspaceData