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

Method storage_overlap

exir/memory_planning.py:121–139  ·  view source on GitHub ↗
(cls, lhs_spec: TensorSpec, rhs_spec: TensorSpec)

Source from the content-addressed store, hash-verified

119
120 @classmethod
121 def storage_overlap(cls, lhs_spec: TensorSpec, rhs_spec: TensorSpec) -> bool:
122 intervals = []
123 if lhs_spec.mem_id != rhs_spec.mem_id:
124 return False
125 for spec in [lhs_spec, rhs_spec]:
126 internal_assert(
127 spec.allocated_memory >= 0,
128 f"{spec} should have non-zero allocated memory",
129 )
130 internal_assert(
131 isinstance(spec.mem_offset, int) and spec.mem_offset >= 0,
132 f"{spec} should have specified memory offset",
133 )
134 intervals.append(
135 [spec.mem_offset, spec.mem_offset + spec.allocated_memory - 1]
136 )
137 has_overlap = cls.has_overlap(*intervals)
138
139 return has_overlap
140
141 @classmethod
142 def _debug_message_from_specs(

Callers 4

test_mapMethod · 0.95
test_multi_mapMethod · 0.95
verify_storage_reuseMethod · 0.80
get_overlapping_specMethod · 0.80

Calls 3

internal_assertFunction · 0.90
has_overlapMethod · 0.80
appendMethod · 0.45

Tested by 2

test_mapMethod · 0.76
test_multi_mapMethod · 0.76