pub trait AllocDispatch: Send + 'static {
// Required methods
fn dtype(&self) -> DType;
fn len(&self) -> usize;
fn run(
self: Box<Self>,
stream: Option<&Arc<CudaStream>>,
state: &Arc<DeviceState>,
mock_mode: bool,
);
}Expand description
Trait object the DeviceActor stashes inside a single
crate::device::DeviceMsg::Alloc variant. The actual T is
erased at the box boundary; the receiving ContextActor calls
AllocDispatch::run which downcasts back into the concrete
AllocReq<T> and performs a typed stream.alloc_zeros::<T>(len).
Required Methods§
Sourcefn run(
self: Box<Self>,
stream: Option<&Arc<CudaStream>>,
state: &Arc<DeviceState>,
mock_mode: bool,
)
fn run( self: Box<Self>, stream: Option<&Arc<CudaStream>>, state: &Arc<DeviceState>, mock_mode: bool, )
Execute the allocation against the given context’s primary
stream and reply on the embedded oneshot channel.
mock_mode == true makes this match the legacy mock-mode
behaviour of super::context_actor::ContextActor::alloc —
it always replies with GpuError::Unrecoverable("alloc not supported in mock mode") so existing tests are unaffected.