/** * WebInferContext manages WebGPU device and provides core functionality */ import type { DType } from './types.ts'; import { Tensor } from './tensor.ts'; /** * Device vendor detection */ export type Vendor = 'apple' | 'nvidia' | 'amd' | 'intel' | 'unknown'; /** * Device features detected at runtime */ export interface DeviceFeatures { readonly vendor: Vendor; readonly hasSubgroups: boolean; readonly hasF16: boolean; readonly maxWorkgroupSize: number; readonly maxStorageBufferSize: number; readonly maxBufferSize: number; readonly maxWorkgroupsPerDimension: number; } /** * WebInferContext - main context for all WebInfer operations */ export declare class WebInferContext { readonly device: GPUDevice; readonly features: DeviceFeatures; private pipelineCache; private disposed; private constructor(); /** * Create a WebInferContext from an existing GPUDevice. * Use this when integrating with TVM or other WebGPU frameworks * that already have a GPUDevice to enable zero-copy buffer sharing. * * @param device - The existing GPUDevice to use * @param featureOverrides - Optional overrides for detected features * @returns A new WebInferContext using the provided device */ static fromDevice(device: GPUDevice, featureOverrides?: Partial): WebInferContext; /** * Create a new WebInferContext with its own GPUDevice */ static create(): Promise; /** * Create a GPU buffer */ createBuffer(size: number, usage?: GPUBufferUsageFlags): GPUBuffer; /** * Create a tensor with uninitialized data */ createTensor(shape: number[], dtype: DType): Tensor; /** * Create a tensor from TypedArray data */ createTensorFromData(data: Float32Array | Uint16Array, shape: number[], dtype: DType): Tensor; /** * Get or create a cached compute pipeline */ getOrCreatePipeline(key: string, createFn: () => Promise | GPUComputePipeline): Promise; /** * Clear pipeline cache */ clearPipelineCache(): void; /** * Dispose the context and cleanup resources */ dispose(): void; private checkDisposed; }