Trait RunnerChannel

Source
pub trait RunnerChannel:
    Clone
    + Send
    + Sync
    + 'static
    + Sized {
    type Device: DeviceOps;
    type Bridge: MultiBackendBridge<Device = Self::Device>;
    type Client: RunnerClient<Device = Self::Device>;
    type FloatElem: Element;
    type IntElem: Element;
    type BoolElem: Element;

    // Required methods
    fn name(device: &Self::Device) -> String;
    fn init_client(device: &Self::Device) -> Self::Client;
    fn get_tensor_handle(
        tensor: &TensorIr,
        client: &Self::Client,
    ) -> TensorHandle<Self::Bridge>;
    fn register_tensor(
        client: &Self::Client,
        handle: TensorHandle<Self::Bridge>,
        shape: Vec<usize>,
        dtype: DType,
    ) -> RouterTensor<Self::Client>;

    // Provided method
    fn change_client_backend(
        tensor: RouterTensor<Self::Client>,
        device: &Self::Device,
    ) -> RouterTensor<Self::Client> { ... }
}
Expand description

Defines the connection channel and operations for a setup with multiple backend runner clients.

Required Associated Types§

Source

type Device: DeviceOps

Device type.

Source

type Bridge: MultiBackendBridge<Device = Self::Device>

A bridge that can transfer tensors between multiple backends.

Source

type Client: RunnerClient<Device = Self::Device>

Client type.

Source

type FloatElem: Element

Float element type.

Source

type IntElem: Element

Int element type.

Source

type BoolElem: Element

Bool element type.

Required Methods§

Source

fn name(device: &Self::Device) -> String

Name of the channel.

Source

fn init_client(device: &Self::Device) -> Self::Client

Initialize a new client for the given device.

Source

fn get_tensor_handle( tensor: &TensorIr, client: &Self::Client, ) -> TensorHandle<Self::Bridge>

Get the tensor handle corresponding to the tensor representation.

Source

fn register_tensor( client: &Self::Client, handle: TensorHandle<Self::Bridge>, shape: Vec<usize>, dtype: DType, ) -> RouterTensor<Self::Client>

Create a tensor with the given handle and shape.

Provided Methods§

Source

fn change_client_backend( tensor: RouterTensor<Self::Client>, device: &Self::Device, ) -> RouterTensor<Self::Client>

Change the tensor to a different client backend.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<B1: BackendIr, B2: BackendIr, B3: BackendIr, B4: BackendIr, Br> RunnerChannel for DirectChannel<(B1, B2, B3, B4), Br>
where Br: MultiBackendBridge<TensorHandle = Handle<B1, B2, B3, B4>, Device = MultiDevice<B1, B2, B3, B4>>,

Source§

impl<B1: BackendIr, B2: BackendIr, B3: BackendIr, Br> RunnerChannel for DirectChannel<(B1, B2, B3), Br>
where Br: MultiBackendBridge<TensorHandle = Handle<B1, B2, B3>, Device = MultiDevice<B1, B2, B3>>,

Source§

impl<B1: BackendIr, B2: BackendIr, Br> RunnerChannel for DirectChannel<(B1, B2), Br>
where Br: MultiBackendBridge<TensorHandle = Handle<B1, B2>, Device = MultiDevice<B1, B2>>,