Struct burn_compute::Compute

source ·
pub struct Compute<Device, Server: ComputeServer, Channel> { /* private fields */ }
Expand description

The compute type has the responsibility to retrieve the correct compute client based on the given device.

Implementations§

source§

impl<Device, Server, Channel> Compute<Device, Server, Channel>where Device: Hash + PartialEq + Eq + Clone + Debug, Server: ComputeServer, Channel: ComputeChannel<Server>,

source

pub const fn new() -> Self

Create a new compute.

source

pub fn client<Init>( &self, device: &Device, init: Init ) -> ComputeClient<Server, Channel>where Init: Fn() -> ComputeClient<Server, Channel>,

Get the compute client for the given device.

Provide the init function to create a new client if it isn’t already initialized.

source

pub fn register(&self, device: &Device, client: ComputeClient<Server, Channel>)

Register the compute client for the given device.

Note

This function is mostly useful when the creation of the compute client can’t be done synchronously and require special context.

Panics

If a client is already registered for the given device.

Auto Trait Implementations§

§

impl<Device, Server, Channel> !RefUnwindSafe for Compute<Device, Server, Channel>

§

impl<Device, Server, Channel> Send for Compute<Device, Server, Channel>where Channel: Send, Device: Send, <Server as ComputeServer>::AutotuneKey: Send,

§

impl<Device, Server, Channel> Sync for Compute<Device, Server, Channel>where Channel: Send, Device: Send, <Server as ComputeServer>::AutotuneKey: Send,

§

impl<Device, Server, Channel> Unpin for Compute<Device, Server, Channel>where Channel: Unpin, Device: Unpin, Server: Unpin,

§

impl<Device, Server, Channel> !UnwindSafe for Compute<Device, Server, Channel>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V