Defined in File var_node.h
memory allocation plan held by a variable
A MemAllocPlan is a view (i.e. with offset and layout) for some Chunk; Memory sharing between vars is implemented by sharing a Chunk of their mem plans.
dtype of owner var
tensor format of owner var
get associated chunk
get offset in bytes of this MemAllocPlan in associated chunk
release current chunk and decr its refcnt
Release tensor storage if refcnt drops to zero
reset chunk to a privately owned chunk, and setup offset and layout from owner var, and clear tensor storage
reset to a special marker that indicates this var is not computed in conditional execution
This is used in VarNodeMemManager to detect if the var is invalid without adding a new field.
reset to uninitialized status
This is called before calling OperatorNodeBase::init_output_mem_plan and before memplan optimization.
assign layout, offset and chunk from another mem alloc plan
assign for readonly forward
next readonly-forward reader of this MemAllocPlan
All the readers of a MemAllocPlan form a singly-linked list which is maintained by assign_for_forward().
the var that owns this mem plan
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().
size of this chunk in bytes
update value of m_size, only used in dynamic var allocation
var that first creates this chunk
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()
whether memory is not allocated yet
whether memory comes from owner_var->dev_tensor()
whether memory is statically allocated