Readonly
idUnique identifier for this device instance
Readonly
typeDevice type identifier (e.g., 'cpu', 'webgpu', 'cuda')
Allocate data on this device
Number of bytes to allocate
Newly allocated data handle
Execute a tensor operation
Takes a StorageTransformation describing the operation and input data, executes the computation, and returns the result data.
Operation metadata from storage layer
Input tensor data (must be on this device)
Optional
output: DeviceDataOptional pre-allocated output buffer
Promise resolving to result data
Read data from device to host memory
Device data to read
Promise resolving to data as ArrayBuffer
Check if this device supports non-contiguous tensors for a specific operation
The operation type to check
True if the operation can handle non-contiguous inputs, false otherwise
// CPU device might not support non-contiguous for most ops
cpuDevice.supportsNonContiguous('matmul'); // false
cpuDevice.supportsNonContiguous('neg'); // false
// GPU device might support non-contiguous for all ops
gpuDevice.supportsNonContiguous('matmul'); // true
gpuDevice.supportsNonContiguous('neg'); // true
Write data from host to device memory
Device data handle to write to
Source data as ArrayBuffer
Promise resolving when write is complete
Device interface for tensor computation
Represents a compute device (CPU, GPU, etc.) that can execute tensor operations. Devices are responsible for:
Example