Skip to main content

WebGpuBackend

Struct WebGpuBackend 

Source
pub struct WebGpuBackend { /* private fields */ }
Expand description

CubeCL WebGPU tensor backend.

§Examples

use tenferro_gpu::webgpu::WebGpuBackend;

let _ctor: fn(usize) -> tenferro_tensor::Result<WebGpuBackend> = WebGpuBackend::new;

The backend is not an operation route: the operations live on [WebGpuExecSession], so the owner does not implement the operation traits.

ⓘ
fn requires_elementwise<B: tenferro_tensor::TensorElementwise>() {}
requires_elementwise::<tenferro_gpu::webgpu::WebGpuBackend>();

Implementations§

Source§

impl WebGpuBackend

Source

pub fn new(device_ordinal: usize) -> Result<Self>

Initialize a WebGPU backend for a discrete GPU ordinal.

§Examples
use tenferro_gpu::webgpu::WebGpuBackend;

let _ctor: fn(usize) -> tenferro_tensor::Result<WebGpuBackend> = WebGpuBackend::new;
§Errors

Returns crate::Error::RuntimeState when no adapter/device is available, or crate::Error::BackendSource when CubeCL initialization fails.

Source

pub fn new_default() -> Result<Self>

Initialize a WebGPU backend using CubeCL’s default adapter selection.

§Examples
use tenferro_gpu::webgpu::WebGpuBackend;

let _ctor: fn() -> tenferro_tensor::Result<WebGpuBackend> = WebGpuBackend::new_default;
§Errors

Returns crate::Error::RuntimeState when default adapter selection is unavailable, or crate::Error::BackendSource when initialization fails.

Source

pub fn from_runtime(runtime: WebGpuRuntime) -> Self

Build a WebGPU backend from an initialized runtime.

§Examples
use tenferro_gpu::{webgpu::WebGpuBackend, webgpu::WebGpuRuntime};

let _from_runtime: fn(WebGpuRuntime) -> WebGpuBackend = WebGpuBackend::from_runtime;
Source

pub fn runtime(&self) -> &WebGpuRuntime

Return this backend’s WebGPU runtime.

§Examples
use tenferro_gpu::{webgpu::WebGpuBackend, webgpu::WebGpuRuntime};

let _runtime: fn(&WebGpuBackend) -> &WebGpuRuntime = WebGpuBackend::runtime;
Source

pub fn runtime_identity(&self) -> WebGpuRuntimeIdentity

Return the opaque identity of this exact executable backend instance.

Clones of a backend return the same identity. Independently initialized backends return different identities even when they target the same WebGPU device ordinal. This also covers Apple-backed WebGPU runtimes.

§Examples
use tenferro_gpu::webgpu::WebGpuBackend;

let _identity = WebGpuBackend::runtime_identity;
Source

pub fn synchronize(&self) -> Result<()>

Block until queued WebGPU work completes.

§Examples
use tenferro_gpu::webgpu::WebGpuBackend;

let _sync: fn(&WebGpuBackend) -> tenferro_tensor::Result<()> = WebGpuBackend::synchronize;
§Errors

Returns crate::Error::BackendSource when queue flush or synchronization fails, or crate::Error::RuntimeState when the runtime has lost its device state.

Trait Implementations§

Source§

impl BackendRuntimeCache for WebGpuBackend

Source§

impl BackendSessionHost for WebGpuBackend

Source§

fn with_backend_session<R: Send>( &mut self, f: impl FnOnce(&mut dyn BackendSession) -> R + Send, ) -> Result<R, SessionEntryError>

Open one backend session and run f inside it. Read more
Source§

impl Clone for WebGpuBackend

Source§

fn clone(&self) -> WebGpuBackend

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WebGpuBackend

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl DotGeneralPreparation for WebGpuBackend

Source§

fn prepare( &self, request: DotGeneralPrepareRequest<'_>, ) -> Result<PrepareCapability, PrepareError>

Prepare one dot-general operation. Read more
Source§

impl TensorBackend for WebGpuBackend

Source§

impl TensorDeviceTransfer for WebGpuBackend

Source§

fn download_to_host(&mut self, tensor: TensorRead<'_>) -> Result<Tensor>

Explicitly copy a provider-owned read target into host storage. Read more
Source§

fn upload_host_tensor(&mut self, tensor: TensorRead<'_>) -> Result<Tensor>

Explicitly copy a host read target into provider storage. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
§

impl<T> ByRef<T> for T

§

fn by_ref(&self) -> &T

§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<C> CloneExpand for C
where C: Clone,

§

fn __expand_clone_method(&self, _scope: &mut Scope) -> C

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where 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.

§

impl<T> IntoComptime for T

§

fn comptime(self) -> Self

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> MaybeSend for T
where T: Send,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

§

impl<T> MaybeSync for T
where T: Sync,

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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<T> TuneInputs for T
where T: Clone + Send + Sync + 'static,

§

type At<'a> = T

The concrete input type at lifetime 'a.
§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

§

impl<T> WasmNotSend for T
where T: Send,

§

impl<T> WasmNotSendSync for T
where T: WasmNotSend + WasmNotSync,

§

impl<T> WasmNotSync for T
where T: Sync,