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

Function _get_tensor_bytes

devtools/pte_tool/diff_pte.py:230–244  ·  view source on GitHub ↗
(
    tensor: Tensor,
    constant_buffer: list,
    mutable_data: Optional[list],
)

Source from the content-addressed store, hash-verified

228
229
230def _get_tensor_bytes(
231 tensor: Tensor,
232 constant_buffer: list,
233 mutable_data: Optional[list],
234) -> Optional[bytes]:
235 if tensor.data_buffer_idx > 0 and tensor.data_buffer_idx < len(constant_buffer):
236 return constant_buffer[tensor.data_buffer_idx].storage
237 if (
238 tensor.extra_tensor_info
239 and tensor.extra_tensor_info.mutable_data_segments_idx > 0
240 and mutable_data is not None
241 and tensor.extra_tensor_info.mutable_data_segments_idx < len(mutable_data)
242 ):
243 return mutable_data[tensor.extra_tensor_info.mutable_data_segments_idx].storage
244 return None
245
246
247def _unravel_index(flat_idx: int, sizes: List[int]) -> Tuple[int, ...]:

Callers 1

_diff_tensorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected