Backend

Trait Backend 

Source
pub trait Backend: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn is_available(&self) -> bool;
    fn capabilities(&self) -> DeviceCapabilities;
    fn allocate(&self, size: usize) -> *mut u8;
    fn deallocate(&self, ptr: *mut u8, size: usize);
    fn copy_to_device(&self, dst: *mut u8, src: *const u8, size: usize);
    fn copy_to_host(&self, dst: *mut u8, src: *const u8, size: usize);
    fn copy_device_to_device(&self, dst: *mut u8, src: *const u8, size: usize);
    fn synchronize(&self);
}
Expand description

Common trait for all compute backends.

This trait defines the interface that all backends must implement, enabling device-agnostic tensor operations.

Required Methods§

Source

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

Returns the name of this backend.

Source

fn is_available(&self) -> bool

Returns whether this backend is available on the current system.

Source

fn capabilities(&self) -> DeviceCapabilities

Returns the device capabilities.

Source

fn allocate(&self, size: usize) -> *mut u8

Allocates memory on this backend.

Source

fn deallocate(&self, ptr: *mut u8, size: usize)

Deallocates memory on this backend.

Source

fn copy_to_device(&self, dst: *mut u8, src: *const u8, size: usize)

Copies data from host to device.

Source

fn copy_to_host(&self, dst: *mut u8, src: *const u8, size: usize)

Copies data from device to host.

Source

fn copy_device_to_device(&self, dst: *mut u8, src: *const u8, size: usize)

Copies data within the device.

Source

fn synchronize(&self)

Synchronizes the device (waits for all operations to complete).

Implementors§