pub enum Device {
Cpu,
Wgpu(Arc<WgpuContext>),
}Expand description
Where a tensor lives and where its ops execute.
Variants§
Cpu
Reference implementation used for testing and verification.
Wgpu(Arc<WgpuContext>)
Production backend: WebGPU via wgpu (Vulkan/Metal/D3D12/Browser).
Implementations§
Source§impl Device
impl Device
Sourcepub fn wgpu() -> Result<Device>
Available on non-WebAssembly only.
pub fn wgpu() -> Result<Device>
Create the default WebGPU device (highest-performance adapter).
Sync facade — native only; on wasm use Device::wgpu_async.
Sourcepub async fn wgpu_async() -> Result<Device>
pub async fn wgpu_async() -> Result<Device>
Async device creation — the primary form (roadmap v4, pitfall 14); works on native and wasm32/browser.
Sourcepub fn dispatch_scope(&self) -> Option<DispatchScope>
pub fn dispatch_scope(&self) -> Option<DispatchScope>
Batch every dispatch made while the returned guard is alive into one
command buffer and one submit. None on the CPU backend, which has no
queue to batch.
Hold it for the span of a logical step — a decode step issues ~100 kernels, and a submit each leaves the GPU waiting on the CPU between every one of them. Readbacks flush automatically, so a scope can wrap code that reads results without special care.
Sourcepub fn max_binding_bytes(&self) -> usize
pub fn max_binding_bytes(&self) -> usize
Largest single buffer binding this device supports, in bytes. Large weights (GPT-2’s wte) are row-chunked to stay under this.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Device
impl !UnwindSafe for Device
impl Freeze for Device
impl Send for Device
impl Sync for Device
impl Unpin for Device
impl UnsafeUnpin for Device
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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