/** * Tensor wrapper for WebGPU buffers */ import type { DType } from './types.ts'; /** * Compute strides from shape (row-major order) */ export declare function computeStrides(shape: number[]): number[]; /** * Compute total number of elements from shape */ export declare function computeSize(shape: number[]): number; /** * Tensor class wrapping a GPUBuffer with shape and dtype information */ export declare class Tensor { readonly buffer: GPUBuffer; readonly shape: readonly number[]; readonly dtype: DType; readonly strides: readonly number[]; readonly size: number; readonly byteSize: number; constructor(buffer: GPUBuffer, shape: number[], dtype: DType, strides?: number[]); /** * Create a Tensor from an existing GPUBuffer (zero-copy). * * This is useful for TVM integration where the buffer is already allocated * by TVM's WebGPU runtime and we want to wrap it without copying data. * * @param buffer - The existing GPUBuffer to wrap * @param shape - The shape of the tensor * @param dtype - The data type of the tensor * @param strides - Optional custom strides (default: row-major) * @returns A new Tensor wrapping the provided buffer */ static fromBuffer(buffer: GPUBuffer, shape: number[], dtype: DType, strides?: number[]): Tensor; /** * Get the number of dimensions */ get ndim(): number; /** * Check if tensor is contiguous (row-major) */ get isContiguous(): boolean; /** * Get a view of the tensor with new shape (must have same size) */ reshape(newShape: number[]): Tensor; /** * Destroy the underlying GPU buffer */ dispose(): void; /** * Get string representation */ toString(): string; }