pub trait Runtime: Clone + Send + Sync + 'static {
type Device: super::Device;
type Client: super::RuntimeClient<Self>;
type Allocator: crate::runtime::Allocator;
type Graph: crate::runtime::Graph;
type RawHandle: Send + Sync;
type DType: crate::dtype::DataType;
fn name() -> &'static str;
fn supports_graph_capture() -> bool {
false
}
fn capture_graph<F, T>(client: &Self::Client, f: F) -> crate::error::Result<(Self::Graph, T)>
where
F: FnOnce(&Self::Client) -> crate::error::Result<T>;
fn allocate(size_bytes: usize, device: &Self::Device) -> crate::error::Result<u64>;
fn deallocate(ptr: u64, size_bytes: usize, device: &Self::Device);
fn copy_to_device(src: &[u8], dst: u64, device: &Self::Device) -> crate::error::Result<()>;
fn copy_from_device(
src: u64,
dst: &mut [u8],
device: &Self::Device,
) -> crate::error::Result<()>;
fn copy_within_device(
src: u64,
dst: u64,
size_bytes: usize,
device: &Self::Device,
) -> crate::error::Result<()>;
fn copy_strided(
src_handle: u64,
src_byte_offset: usize,
dst_handle: u64,
shape: &[usize],
strides: &[isize],
elem_size: usize,
device: &Self::Device,
) -> crate::error::Result<()>;
fn record_compute_event(_device: &Self::Device) -> crate::error::Result<u64> {
Ok(0)
}
fn copy_from_device_pipelined(
src: u64,
dst: &mut [u8],
device: &Self::Device,
event: u64,
) -> crate::error::Result<()> {
let _ = event;
Self::copy_from_device(src, dst, device)
}
fn default_device() -> Self::Device;
fn default_client(device: &Self::Device) -> Self::Client;
fn raw_handle(client: &Self::Client) -> &Self::RawHandle;
}