torch.TensorData
export type TensorData = WebGPUTensorData | CPUTensorData;Values
WebGPUTensorDataCPUTensorData
Union type for tensor data on any device.
This is the internal representation of tensors. The discriminator field is device,
which indicates whether the tensor is on 'cpu' or 'webgpu' and which fields are available.
Usage: Mainly for internal library code and advanced users implementing custom operations.
Device Discrimination:
const data: TensorData = ...;
if (data.device === 'webgpu') {
// data.buffer is available, is a GPUBuffer
} else {
// data.storage is available, is a TypedArray
}