pub struct Allocator(/* private fields */);Expand description
A thread-affine allocator arena retained by all of its resident tensors.
Implementations§
Source§impl Allocator
impl Allocator
Sourcepub fn tensor_bytes(&self) -> (usize, usize)
pub fn tensor_bytes(&self) -> (usize, usize)
Reports live tensor storage and its high-water mark, excluding allocator pools, staging, workspace, and driver allocations. Imported storage is included without implying ownership.
Sourcepub fn upload(&self, mat: &Mat) -> Result<Tensor>
pub fn upload(&self, mat: &Mat) -> Result<Tensor>
Uploads and waits before returning resident FP32 storage.
A device that refuses the storage reports the refusal as a native failure during
Vulkan upload; the allocator, the tensors it already returned and later requests stay
usable.
Sourcepub fn command<'a>(&self, net: &'a Net) -> Result<Command<'a>>
pub fn command<'a>(&self, net: &'a Net) -> Result<Command<'a>>
Records resident inference. Submission occurs only in Command::wait.
Sourcepub unsafe fn import_buffer(
&self,
buffer: u64,
offset: usize,
capacity: usize,
elements: usize,
access: u32,
stage: u32,
) -> Result<Tensor>
pub unsafe fn import_buffer( &self, buffer: u64, offset: usize, capacity: usize, elements: usize, access: u32, stage: u32, ) -> Result<Tensor>
Borrows a caller-owned same-device Vulkan storage buffer as unpacked FP32.
§Safety
The buffer must belong to Device::raw_device_handle, support storage and
transfer usage, and remain allocated and exclusively available until every
tensor and command using it is dropped. Offset must satisfy native Vulkan
storage-buffer alignment. Access/stage masks must describe its last use.
External queues must be synchronized before and after Rust use. Neither
the buffer nor its memory is freed by this API. Device adoption is absent.