MCPcopy Create free account
hub / github.com/pytorch/executorch / SharedObject

Class SharedObject

exir/memory_planning.py:703–726  ·  view source on GitHub ↗

r""" We define the concept of shared object, which represents a segment in the memory buffer that can be shared by multiple tensors. In order to check if a shared object is available for a tensor, we maintain the last_used_index attribute. The shared object will be available for node

Source from the content-addressed store, hash-verified

701
702@dataclass
703class SharedObject:
704 r"""
705 We define the concept of shared object, which represents a segment
706 in the memory buffer that can be shared by multiple tensors. In order to
707 check if a shared object is available for a tensor, we maintain the
708 last_used_index attribute. The shared object will be available for nodes
709 with index greater than last_used_index.
710 """
711
712 # index of the shared object in the list of shared objects, used as a unique id
713 idx: int
714 # offset in the memory buffer
715 offset: int
716 # size of this shared object in bytes
717 size: int
718 # When the object is first created
719 first_used_index: int
720 # the object will be available for index (last_used_index + 1)
721 last_used_index: int
722 # list of allocations belong to this shared object
723 allocations: List[AllocationSpec] = field(default_factory=list)
724
725 def __repr__(self) -> str:
726 return f"SharedObject(idx={self.idx}, offset={self.offset}, size={self.size}, lifetime=[{self.first_used_index, self.last_used_index}])"
727
728
729@dataclass

Callers 1

pick_shared_objFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected