/** * WebGPU Tensor Operations * GPU-accelerated tensor operations using compute shaders */ import { Tensor } from '../tensor.js'; export declare const relu: (x: Tensor) => Promise; export declare const silu: (x: Tensor) => Promise; export declare const gelu: (x: Tensor) => Promise; export declare const neg: (x: Tensor) => Promise; export declare const exp: (x: Tensor) => Promise; export declare const sqrt: (x: Tensor) => Promise; export declare const rsqrt: (x: Tensor) => Promise; export declare const tanh: (x: Tensor) => Promise; export declare const add: (a: Tensor, b: Tensor) => Promise; export declare const sub: (a: Tensor, b: Tensor) => Promise; export declare const mul: (a: Tensor, b: Tensor) => Promise; export declare const div: (a: Tensor, b: Tensor) => Promise; export declare const addScalar: (x: Tensor, s: number) => Promise; export declare const mulScalar: (x: Tensor, s: number) => Promise; /** * Broadcast add: input[seqLen, dim] + bias[dim] -> output[seqLen, dim] * Adds bias vector to each row of the input matrix */ export declare function broadcastAdd(input: Tensor, bias: Tensor): Promise; /** * Matrix multiplication: C = A @ B * A: [M, K], B: [K, N] -> C: [M, N] */ export declare function matmul(a: Tensor, b: Tensor): Promise; export declare const sum: (x: Tensor) => Promise; export declare const max: (x: Tensor) => Promise; /** * Compute mean of tensor */ export declare function mean(x: Tensor): Promise; /** * Softmax along the last dimension */ export declare function softmax(x: Tensor): Promise; /** * Reset all cached pipelines (useful after shader updates) */ export declare function resetOpsPipelines(): void; /** * Embedding lookup: maps token indices to embedding vectors * embeddings: [vocabSize, hiddenSize] or [hiddenSize, vocabSize] (GGUF format) * indices: [seqLen] (token IDs) * vocabSize: optional, helps detect transposed format * returns: [seqLen, hiddenSize] */ export declare function embeddingLookup(embeddings: Tensor, indices: number[], vocabSizeHint?: number): Promise; /** * GPU-accelerated causal attention with GQA support * * @param Q - Query tensor [numQPos, numHeads * headDim] * @param K - Key tensor [numKeys, numKVHeads * headDim] * @param V - Value tensor [numKeys, numKVHeads * headDim] * @param numHeads - Number of query heads * @param numKVHeads - Number of KV heads (for GQA) * @param headDim - Dimension per head * @param startPos - Starting position for queries (for incremental inference) * @returns Output tensor [numQPos, numHeads * headDim] */ export declare function causalAttention(Q: Tensor, K: Tensor, V: Tensor, numHeads: number, numKVHeads: number, headDim: number, startPos?: number): Promise; /** * Extract the last row of a 2D tensor on GPU * input: [rows, cols] -> output: [1, cols] * This avoids transferring the entire tensor to CPU just to get the last row */ export declare function sliceLastRow(input: Tensor): Promise; /** * Transpose a 2D tensor * input: [rows, cols] -> output: [cols, rows] */ export declare function transpose(input: Tensor): Promise; //# sourceMappingURL=index.d.ts.map