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_into<F>(
client: &Self::Client,
inputs: &[&crate::tensor::Tensor<Self>],
outputs: &[&crate::tensor::Tensor<Self>],
f: F,
) -> crate::error::Result<crate::runtime::CapturedGraph<Self>>
where
F: FnOnce(&Self::Client) -> crate::error::Result<()>,
Self: Sized,
{
let _ = (client, inputs, outputs, f);
Err(crate::error::Error::BackendLimitation {
backend: Self::name(),
operation: "capture_graph_into",
reason: "this backend does not support CUDA-style graph capture".into(),
})
}
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;
}