38 : _mem_planner{createMemoryPlanner(planner_id)}
50MemoryManager::createMemoryPlanner(
const std::string planner_id)
71 const auto &mem_blk =
_mem_planner->memory_plans().at(ind);
78 auto find = _mem_alloc_map.find(tensor);
79 if (find != _mem_alloc_map.end())
80 throw std::runtime_error(
"Cannot allocate memory for a tensor. It was already allocated.");
82 _mem_alloc_map[tensor] = std::make_shared<basic::Allocator>(capacity);
83 return _mem_alloc_map[tensor];
88 auto find = _mem_alloc_map.find(tensor);
89 if (find == _mem_alloc_map.end())
90 throw std::runtime_error(
"Cannot find Allocator for the requested index");
92 find->second->release();
93 _mem_alloc_map.erase(find);
98 for (
auto &&mem_alloc : _mem_alloc_map)
101 mem_alloc.second->release();
104 _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.