/** * Transposes a tensor according to the provided axes. * @param {any} tensor The input tensor to transpose. * @param {Array} axes The axes to transpose the tensor along. * @returns {Tensor} The transposed tensor. */ export function transpose(tensor: any, axes: any[]): Tensor; /** * Concatenates an array of tensors along the 0th dimension. * * @param {any} tensors The array of tensors to concatenate. * @returns {Tensor} The concatenated tensor. */ export function cat(tensors: any): Tensor; /** * Interpolates an Tensor to the given size. * @param {Tensor} input The input tensor to interpolate. Data must be channel-first (i.e., [c, h, w]) * @param {number[]} size The output size of the image * @param {string} mode The interpolation mode * @param {boolean} align_corners Whether to align corners. * @returns {Tensor} The interpolated tensor. */ export function interpolate(input: Tensor, [out_height, out_width]: number[], mode?: string, align_corners?: boolean): Tensor; /** * Perform mean pooling of the last hidden state followed by a normalization step. * @param {Tensor} last_hidden_state Tensor of shape [batchSize, seqLength, embedDim] * @param {Tensor} attention_mask Tensor of shape [batchSize, seqLength] * @returns {Tensor} Returns a new Tensor of shape [batchSize, embedDim]. */ export function mean_pooling(last_hidden_state: Tensor, attention_mask: Tensor): Tensor; declare const Tensor_base: any; export class Tensor extends Tensor_base { [x: string]: any; /** * Create a new Tensor or copy an existing Tensor. * @param {[string, Array|AnyTypedArray, number[]]|[ONNXTensor]} args */ constructor(...args: [string, any[] | AnyTypedArray, number[]] | [any]); /** * Index into a Tensor object. * @param {number} index The index to access. * @returns {Tensor} The data at the specified index. */ _getitem(index: number): Tensor; /** * @param {number|bigint} item The item to search for in the tensor * @returns {number} The index of the first occurrence of item in the tensor data. */ indexOf(item: number | bigint): number; /** * @param {number} index * @param {number} iterSize * @param {any} iterDims * @returns {Tensor} */ _subarray(index: number, iterSize: number, iterDims: any): Tensor; /** * Returns the value of this tensor as a standard JavaScript Number. This only works * for tensors with one element. For other cases, see `Tensor.tolist()`. * @returns {number} The value of this tensor as a standard JavaScript Number. * @throws {Error} If the tensor has more than one element. */ item(): number; /** * Convert tensor data to a n-dimensional JS list * @returns {Array} */ tolist(): any[]; /** * Return a new Tensor with the sigmoid function applied to each element. * @returns {Tensor} The tensor with the sigmoid function applied. */ sigmoid(): Tensor; /** * Applies the sigmoid function to the tensor in place. * @returns {Tensor} Returns `this`. */ sigmoid_(): Tensor; clone(): Tensor; slice(...slices: any[]): Tensor; /** * Return a transposed version of this Tensor, according to the provided dimensions. * @param {...number} dims Dimensions to transpose. * @returns {Tensor} The transposed tensor. */ transpose(...dims: number[]): Tensor; /** * Returns the sum of each row of the input tensor in the given dimension dim. * * @param {number} [dim=null] The dimension or dimensions to reduce. If `null`, all dimensions are reduced. * @param {boolean} keepdim Whether the output tensor has `dim` retained or not. * @returns The summed tensor */ sum(dim?: number, keepdim?: boolean): Tensor; /** * Returns the matrix norm or vector norm of a given tensor. * @param {number|string} [p='fro'] The order of norm * @param {number} [dim=null] Specifies which dimension of the tensor to calculate the norm across. * If dim is None, the norm will be calculated across all dimensions of input. * @param {boolean} [keepdim=false] Whether the output tensors have dim retained or not. * @returns {Tensor} The norm of the tensor. */ norm(p?: number | string, dim?: number, keepdim?: boolean): Tensor; /** * Performs `L_p` normalization of inputs over specified dimension. Operates in place. * @param {number} [p=2] The exponent value in the norm formulation * @param {number} [dim=1] The dimension to reduce * @returns {Tensor} `this` for operation chaining. */ normalize_(p?: number, dim?: number): Tensor; /** * Performs `L_p` normalization of inputs over specified dimension. * @param {number} [p=2] The exponent value in the norm formulation * @param {number} [dim=1] The dimension to reduce * @returns {Tensor} The normalized tensor. */ normalize(p?: number, dim?: number): Tensor; /** * Compute and return the stride of this tensor. * Stride is the jump necessary to go from one element to the next one in the specified dimension dim. * @returns {number[]} The stride of this tensor. */ stride(): number[]; /** * Returns a tensor with all specified dimensions of input of size 1 removed. * * NOTE: The returned tensor shares the storage with the input tensor, so changing the contents of one will change the contents of the other. * If you would like a copy, use `tensor.clone()` before squeezing. * * @param {number} [dim=null] If given, the input will be squeezed only in the specified dimensions. * @returns The squeezed tensor */ squeeze(dim?: number): Tensor; /** * In-place version of @see {@link Tensor.squeeze} */ squeeze_(dim?: any): Tensor; dims: any; /** * Returns a new tensor with a dimension of size one inserted at the specified position. * * NOTE: The returned tensor shares the same underlying data with this tensor. * * @param {number} dim The index at which to insert the singleton dimension * @returns The unsqueezed tensor */ unsqueeze(dim?: number): Tensor; /** * In-place version of @see {@link Tensor.unsqueeze} */ unsqueeze_(dim?: any): Tensor; /** * In-place version of @see {@link Tensor.flatten} */ flatten_(start_dim?: number, end_dim?: number): Tensor; /** * Flattens input by reshaping it into a one-dimensional tensor. * If `start_dim` or `end_dim` are passed, only dimensions starting with `start_dim` * and ending with `end_dim` are flattened. The order of elements in input is unchanged. * @param {number} start_dim the first dim to flatten * @param {number} end_dim the last dim to flatten * @returns The flattened tensor. */ flatten(start_dim?: number, end_dim?: number): Tensor; /** * Returns a new tensor with the same data as the `self` tensor but of a different `shape`. * @param {...number} dims the desired size * @returns {Tensor} The tensor with the same data but different shape */ view(...dims: number[]): Tensor; /** * Returns an iterator object for iterating over the tensor data in row-major order. * If the tensor has more than one dimension, the iterator will yield subarrays. * @returns {Iterator} An iterator object for iterating over the tensor data in row-major order. */ [Symbol.iterator](): Iterator; } /** * This creates a nested array of a given type and depth (see examples). */ export type NestArray = Acc['length'] extends Depth ? T : NestArray; export type AnyTypedArray = import('./maths.js').AnyTypedArray; export {}; //# sourceMappingURL=tensor.d.ts.map