BufferHandle
Ownership / residency mode of a tensor's backing memory.
Every TensorStorage holds a BufferHandle that describes how the runtime acquired the bytes and therefore what operations are legal:
| Mode | Mutable? | Runtime owns memory? | Can outlive source? |
|---|---|---|---|
| Owned | yes | yes | yes |
| Borrowed | no* | no | no |
| Aliased | no | no (shared) | tied to parent |
| FileBacked | no | no (OS-managed) | tied to mapping |
| DeviceResident | varies | backend-managed | tied to device ctx |
*Borrowed buffers expose the original array but callers must not mutate it unless they know the source permits mutation.
Inheritors
Types
A slice/view into another BufferHandle. Shares the parent's backing memory. Mutations (if the parent is mutable) are visible to both.
A reference to externally-owned memory (e.g. a caller-supplied array). The runtime must not free or resize it. Mutation is possible only if the source explicitly permits it.
Buffer managed by a compute backend (GPU, NPU, DSP, …). Access semantics depend on the backend.
Memory-mapped file region. Immutable from the runtime's perspective (the OS manages paging and eviction).