Class MemAllocPlan::Chunk

Nested Relationships

This class is a nested type of Class MemAllocPlan.

Inheritance Relationships

Base Type

  • public NonCopyableObj

Class Documentation

class mgb::cg::MemAllocPlan::Chunk : public NonCopyableObj

identifier for allocated memory

Each Chunk object corresponds to an allocated memory chunk. Memory forwarding and force updating are implemented by sharing Chunk objects between vars.

If mem_alloc_status is not invalid, the memory region for this chunk is owner_var->dev_tensor().storage().

Public Functions

size_t size() const

size of this chunk in bytes

void update_size_for_dynamic_alloc(size_t size)

update value of m_size, only used in dynamic var allocation

std::string id_str() const
Chunk(VarNode *ov)

Public Members

VarNode *const owner_var

var that first creates this chunk

MemAllocStatus mem_alloc_status
class MemAllocStatus

memory allocation status for this chunk

Allocation status can either be INVALID, FROM_OWNER_VAR, or an offset in a static allocation buffer. This status is compactly represented by an integer value. No error check is performed in the accessors.

Note that for static_offset, it is set in SeqMemOptimizer::plan_chunk_allocation() and accessed in VarNodeMemManager::make_static_var_tensor_from_alloc_plan()

Public Functions

bool is_invalid() const

whether memory is not allocated yet

bool is_from_owner_var() const

whether memory comes from owner_var->dev_tensor()

bool is_static_offset() const

whether memory is statically allocated

size_t static_offset() const
void set_invalid()
void set_from_owner_var()
void set_static_offset(size_t offset)