pub trait DevSliceArg:
Send
+ Sync
+ 'static {
// Required methods
fn validate(&self) -> Result<Box<dyn Any + Send>, GpuError>;
fn push<'a>(&'a self, builder: &mut LaunchArgs<'a>) -> Result<(), GpuError>;
fn dtype(&self) -> Option<DType>;
fn len(&self) -> usize;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
Type-erased typed-device-slice argument for an NVRTC kernel launch.
Boxed as Box<dyn DevSliceArg> inside KernelArg::DevSlice so the
per-launch Vec<KernelArg> does not need one variant per dtype.
The blanket impl impl<T: CudaDtype> DevSliceArg for GpuRef<T>
covers every dtype the runtime understands; raw byte buffers
(GpuRef<u8>) are handled by the same impl because u8 is a
CudaDtype.
§Object safety
Methods take &self and never return Self so the trait is
usable as dyn DevSliceArg.
Required Methods§
Sourcefn validate(&self) -> Result<Box<dyn Any + Send>, GpuError>
fn validate(&self) -> Result<Box<dyn Any + Send>, GpuError>
Validate the underlying GpuRef and return a keep-alive
owner. The caller stores this Box<dyn Any + Send> in a Vec
to keep the device buffer alive until the kernel completes.
Sourcefn push<'a>(&'a self, builder: &mut LaunchArgs<'a>) -> Result<(), GpuError>
fn push<'a>(&'a self, builder: &mut LaunchArgs<'a>) -> Result<(), GpuError>
Push the device-pointer reference onto builder. Implementors
re-access() the GpuRef (cheap — pointer-equality check
against DeviceState.generation) and call
[PushKernelArg::arg] with &CudaSlice<T>.
The 'a lifetime ties &self to the builder so the pushed
device-pointer reference is borrowed from Self for as long as
builder lives.
Returns Err(GpuError::GpuRefStale) if the buffer has gone
stale between validate and push (rare — only happens if a
context rebuild raced inside the actor).