ModelResource

Trait ModelResource 

Source
pub trait ModelResource<Cx: ?Sized>: Send + Sync {
    // Required methods
    fn label(&self) -> &'static str;
    fn release(&mut self, cx: &Cx) -> Result<()>;
}
Expand description

State that owns device memory and must be released in a defined order.

Drop is the wrong contract for this and the reason is specific: on GB10 unified memory a device free posts in-band TLB invalidations that corrupt neighbouring allocations when interleaved with other allocation traffic. That constrains when frees happen, not whether — teardown, where nothing else is allocating and the streams are synchronised, is the safe case, and the loader’s scratch-buffer workaround exists precisely because loading is not. Drop can express neither that ordering nor a failure.

Cx is whatever releasing needs — for GPU state that is the allocator. Making it a type parameter keeps atlas-core free of a dependency on the backend crate while still letting a resource be handed the thing that owns its memory, rather than making every resource carry its own handle.

Required Methods§

Source

fn label(&self) -> &'static str

Human name, for the teardown report and for attributing a failure.

Source

fn release(&mut self, cx: &Cx) -> Result<()>

Release everything this owns. Must be idempotent: the host calls it, and a Drop backstop may call it again.

Implementors§