34 : _mem_planner{createMemoryPlanner(planner_id)}
46MemoryManager::createMemoryPlanner(
const std::string planner_id)
67 const auto &mem_blk =
_mem_planner->memory_plans().at(ind);
74 auto find = _mem_alloc_map.find(tensor);
75 if (find != _mem_alloc_map.end())
76 throw std::runtime_error(
"Cannot allocate memory for a tensor. It was already allocated.");
78 _mem_alloc_map[tensor] = std::make_shared<basic::Allocator>(capacity);
79 return _mem_alloc_map[tensor];
84 auto find = _mem_alloc_map.find(tensor);
85 if (find == _mem_alloc_map.end())
86 throw std::runtime_error(
"Cannot find Allocator for the requested index");
88 find->second->release();
89 _mem_alloc_map.erase(find);
94 for (
auto &&mem_alloc : _mem_alloc_map)
97 mem_alloc.second->release();
100 _mem_alloc_map.clear();
std::shared_ptr< Allocator > allocate(const ITensor *tensor, uint32_t capacity)
std::shared_ptr< Allocator > _mem_alloc
void claimPlan(const ir::OperandIndex &ind, uint32_t size)
std::shared_ptr< IMemoryPlanner< ir::OperandIndex > > _mem_planner
void releasePlan(const ir::OperandIndex &ind)
uint8_t * getBuffer(const ir::OperandIndex &ind) const
IMemoryPlanner< ir::OperandIndex > * create(const std::string &key)
static MemoryPlannerFactory & get()
std::string getConfigString(const std::string &key)
Interface to plan memory.
virtual void claim(const Index &, size_t)=0
Claim memory for tensor.