pub trait ComputeBackend: Send + Sync {
Show 13 methods
// Required methods
fn name(&self) -> &str;
fn capabilities(&self) -> BackendCapabilities;
fn tensor_ops(&self) -> &dyn TensorOps;
fn tensor_factory(&self) -> &dyn TensorFactory;
fn memory_manager(&self) -> &dyn DeviceMemoryManager;
fn kernel_executor(&self) -> Option<&dyn KernelExecutor>;
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn supports_device(&self, device: &Device) -> bool;
fn version(&self) -> String;
fn synchronize<'life0, 'life1, 'async_trait>(
&'life0 self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn status(&self) -> BackendStatus;
fn shutdown<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided method
fn kernel_ops(&self) -> Option<&dyn KernelOps> { ... }
}Expand description
Compute backend for tensor operations and kernel execution
Required Methods§
Sourcefn capabilities(&self) -> BackendCapabilities
fn capabilities(&self) -> BackendCapabilities
Get backend capabilities
Sourcefn tensor_ops(&self) -> &dyn TensorOps
fn tensor_ops(&self) -> &dyn TensorOps
Get tensor operations interface
Sourcefn tensor_factory(&self) -> &dyn TensorFactory
fn tensor_factory(&self) -> &dyn TensorFactory
Get tensor factory for creating tensors
Sourcefn memory_manager(&self) -> &dyn DeviceMemoryManager
fn memory_manager(&self) -> &dyn DeviceMemoryManager
Get memory manager for this backend
Sourcefn kernel_executor(&self) -> Option<&dyn KernelExecutor>
fn kernel_executor(&self) -> Option<&dyn KernelExecutor>
Get kernel executor (if backend supports custom kernels)
Sourcefn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 mut self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize backend with device
Sourcefn supports_device(&self, device: &Device) -> bool
fn supports_device(&self, device: &Device) -> bool
Check if backend supports specific device
Sourcefn synchronize<'life0, 'life1, 'async_trait>(
&'life0 self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn synchronize<'life0, 'life1, 'async_trait>(
&'life0 self,
device: &'life1 Device,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Synchronize all pending operations
Sourcefn status(&self) -> BackendStatus
fn status(&self) -> BackendStatus
Get backend status
Provided Methods§
Sourcefn kernel_ops(&self) -> Option<&dyn KernelOps>
fn kernel_ops(&self) -> Option<&dyn KernelOps>
Get LLM-specific kernel operations (if backend provides optimized impls).
Returns None by default — existing backends compile unchanged.
Backends that implement KernelOps sub-traits (NormOps, PositionOps, etc.)
return Some here to enable accelerated paths.