webgpu

package
v0.7.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Rendered for windows/amd64

Overview

Package webgpu provides the WebGPU backend for GPU-accelerated tensor operations.

WebGPU is a cross-platform graphics and compute API that works on:

  • Windows (via Dawn/D3D12)
  • macOS (via Dawn/Metal)
  • Linux (via Dawn/Vulkan)
  • Web browsers (via wasm)

Example:

import (
    "github.com/born-ml/born/autodiff"
    "github.com/born-ml/born/backend/webgpu"
    "github.com/born-ml/born/tensor"
)

func main() {
    gpu, err := webgpu.New()
    if err != nil {
        log.Fatal(err)
    }
    defer gpu.Release()

    backend := autodiff.New(gpu)
    x := tensor.Randn[float32](tensor.Shape{1024, 1024}, backend)
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsAvailable

func IsAvailable() bool

IsAvailable checks if WebGPU is available on the current system.

This function attempts to initialize a WebGPU adapter to verify that a compatible GPU and drivers are present. It's useful for graceful fallback to CPU backend when GPU is not available.

Example:

if webgpu.IsAvailable() {
    gpu, _ := webgpu.New()
    backend = autodiff.New(gpu)
} else {
    backend = autodiff.New(cpu.New())
}

Types

type Backend

type Backend = internalwebgpu.Backend

Backend represents the WebGPU backend implementation for GPU-accelerated tensor operations.

func New

func New() (*Backend, error)

New creates a new WebGPU backend.

This function initializes the WebGPU device and returns a backend ready for tensor operations. Call Release() when done to free GPU resources.

Returns an error if WebGPU initialization fails (e.g., no compatible GPU).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL