@min-pack/tfjs-node 2.17.2 → 3.8.1-patch.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/addon-node_modules/onnxruntime-node/bin/{napi-v3/linux/x64/libonnxruntime.so.1.14.0 → napi-v6/linux/arm64/libonnxruntime.so.1} +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v6/linux/x64/onnxruntime_binding.node +0 -0
- package/index.d.ts +2 -0
- package/index.js +7102 -3371
- package/package.json +1 -10
- package/tfjs-types/backends/onnx.d.ts +37 -0
- package/tfjs-types/base/feature_extraction_utils.d.ts +41 -0
- package/tfjs-types/base/image_processors_utils.d.ts +332 -0
- package/tfjs-types/base/processing_utils.d.ts +89 -0
- package/tfjs-types/configs.d.ts +93 -0
- package/tfjs-types/env.d.ts +112 -0
- package/tfjs-types/generation/configuration_utils.d.ts +326 -0
- package/tfjs-types/generation/logits_process.d.ts +364 -0
- package/tfjs-types/generation/logits_sampler.d.ts +51 -0
- package/tfjs-types/generation/parameters.d.ts +47 -0
- package/tfjs-types/generation/stopping_criteria.d.ts +81 -0
- package/tfjs-types/generation/streamers.d.ts +88 -0
- package/tfjs-types/models/audio_spectrogram_transformer/feature_extraction_audio_spectrogram_transformer.d.ts +25 -0
- package/tfjs-types/models/auto/feature_extraction_auto.d.ts +5 -0
- package/tfjs-types/models/auto/image_processing_auto.d.ts +5 -0
- package/tfjs-types/models/auto/processing_auto.d.ts +39 -0
- package/tfjs-types/models/beit/image_processing_beit.d.ts +4 -0
- package/tfjs-types/models/bit/image_processing_bit.d.ts +4 -0
- package/tfjs-types/models/chinese_clip/image_processing_chinese_clip.d.ts +4 -0
- package/tfjs-types/models/clap/feature_extraction_clap.d.ts +57 -0
- package/tfjs-types/models/clip/image_processing_clip.d.ts +6 -0
- package/tfjs-types/models/convnext/image_processing_convnext.d.ts +12 -0
- package/tfjs-types/models/dac/feature_extraction_dac.d.ts +4 -0
- package/tfjs-types/models/deit/image_processing_deit.d.ts +6 -0
- package/tfjs-types/models/detr/image_processing_detr.d.ts +42 -0
- package/tfjs-types/models/dinov3_vit/image_processing_dinov3_vit.d.ts +4 -0
- package/tfjs-types/models/donut/image_processing_donut.d.ts +7 -0
- package/tfjs-types/models/dpt/image_processing_dpt.d.ts +6 -0
- package/tfjs-types/models/efficientnet/image_processing_efficientnet.d.ts +6 -0
- package/tfjs-types/models/encodec/feature_extraction_encodec.d.ts +13 -0
- package/tfjs-types/models/feature_extractors.d.ts +16 -0
- package/tfjs-types/models/florence2/processing_florence2.d.ts +39 -0
- package/tfjs-types/models/gemma3n/feature_extraction_gemma3n.d.ts +35 -0
- package/tfjs-types/models/gemma3n/processing_gemma3n.d.ts +31 -0
- package/tfjs-types/models/glpn/image_processing_glpn.d.ts +4 -0
- package/tfjs-types/models/grounding_dino/image_processing_grounding_dino.d.ts +20 -0
- package/tfjs-types/models/grounding_dino/processing_grounding_dino.d.ts +27 -0
- package/tfjs-types/models/idefics3/image_processing_idefics3.d.ts +40 -0
- package/tfjs-types/models/idefics3/processing_idefics3.d.ts +19 -0
- package/tfjs-types/models/image_processors.d.ts +44 -0
- package/tfjs-types/models/janus/image_processing_janus.d.ts +7 -0
- package/tfjs-types/models/janus/processing_janus.d.ts +77 -0
- package/tfjs-types/models/jina_clip/image_processing_jina_clip.d.ts +5 -0
- package/tfjs-types/models/jina_clip/processing_jina_clip.d.ts +9 -0
- package/tfjs-types/models/llava/processing_llava.d.ts +12 -0
- package/tfjs-types/models/llava_onevision/image_processing_llava_onevision.d.ts +4 -0
- package/tfjs-types/models/mask2former/image_processing_mask2former.d.ts +4 -0
- package/tfjs-types/models/maskformer/image_processing_maskformer.d.ts +22 -0
- package/tfjs-types/models/mgp_str/processing_mgp_str.d.ts +64 -0
- package/tfjs-types/models/mobilenet_v1/image_processing_mobilenet_v1.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v2/image_processing_mobilenet_v2.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v3/image_processing_mobilenet_v3.d.ts +6 -0
- package/tfjs-types/models/mobilenet_v4/image_processing_mobilenet_v4.d.ts +6 -0
- package/tfjs-types/models/mobilevit/image_processing_mobilevit.d.ts +6 -0
- package/tfjs-types/models/moonshine/feature_extraction_moonshine.d.ts +13 -0
- package/tfjs-types/models/moonshine/processing_moonshine.d.ts +17 -0
- package/tfjs-types/models/nougat/image_processing_nougat.d.ts +4 -0
- package/tfjs-types/models/owlv2/image_processing_owlv2.d.ts +4 -0
- package/tfjs-types/models/owlvit/image_processing_owlvit.d.ts +10 -0
- package/tfjs-types/models/owlvit/processing_owlvit.d.ts +8 -0
- package/tfjs-types/models/paligemma/processing_paligemma.d.ts +12 -0
- package/tfjs-types/models/parakeet/feature_extraction_parakeet.d.ts +22 -0
- package/tfjs-types/models/phi3_v/image_processing_phi3_v.d.ts +17 -0
- package/tfjs-types/models/phi3_v/processing_phi3_v.d.ts +21 -0
- package/tfjs-types/models/pixtral/image_processing_pixtral.d.ts +4 -0
- package/tfjs-types/models/pixtral/processing_pixtral.d.ts +12 -0
- package/tfjs-types/models/processors.d.ts +25 -0
- package/tfjs-types/models/pvt/image_processing_pvt.d.ts +4 -0
- package/tfjs-types/models/pyannote/feature_extraction_pyannote.d.ts +31 -0
- package/tfjs-types/models/pyannote/processing_pyannote.d.ts +19 -0
- package/tfjs-types/models/qwen2_vl/image_processing_qwen2_vl.d.ts +11 -0
- package/tfjs-types/models/qwen2_vl/processing_qwen2_vl.d.ts +17 -0
- package/tfjs-types/models/rt_detr/image_processing_rt_detr.d.ts +8 -0
- package/tfjs-types/models/sam/image_processing_sam.d.ts +103 -0
- package/tfjs-types/models/sam/processing_sam.d.ts +9 -0
- package/tfjs-types/models/sam2/image_processing_sam2.d.ts +2 -0
- package/tfjs-types/models/sam2/processing_sam2.d.ts +6 -0
- package/tfjs-types/models/sam3/image_processing_sam3.d.ts +2 -0
- package/tfjs-types/models/sapiens/image_processing_sapiens.d.ts +10 -0
- package/tfjs-types/models/seamless_m4t/feature_extraction_seamless_m4t.d.ts +34 -0
- package/tfjs-types/models/segformer/image_processing_segformer.d.ts +10 -0
- package/tfjs-types/models/siglip/image_processing_siglip.d.ts +4 -0
- package/tfjs-types/models/smolvlm/image_processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/smolvlm/processing_smolvlm.d.ts +2 -0
- package/tfjs-types/models/snac/feature_extraction_snac.d.ts +4 -0
- package/tfjs-types/models/speecht5/feature_extraction_speecht5.d.ts +4 -0
- package/tfjs-types/models/speecht5/processing_speecht5.d.ts +14 -0
- package/tfjs-types/models/swin2sr/image_processing_swin2sr.d.ts +5 -0
- package/tfjs-types/models/ultravox/processing_ultravox.d.ts +16 -0
- package/tfjs-types/models/vit/image_processing_vit.d.ts +6 -0
- package/tfjs-types/models/vitmatte/image_processing_vitmatte.d.ts +12 -0
- package/tfjs-types/models/vitpose/image_processing_vitpose.d.ts +26 -0
- package/tfjs-types/models/voxtral/processing_voxtral.d.ts +16 -0
- package/tfjs-types/models/wav2vec2/feature_extraction_wav2vec2.d.ts +19 -0
- package/tfjs-types/models/wav2vec2/processing_wav2vec2.d.ts +14 -0
- package/tfjs-types/models/wav2vec2_with_lm/processing_wav2vec2_with_lm.d.ts +14 -0
- package/tfjs-types/models/wespeaker/feature_extraction_wespeaker.d.ts +23 -0
- package/tfjs-types/models/whisper/common_whisper.d.ts +8 -0
- package/tfjs-types/models/whisper/feature_extraction_whisper.d.ts +23 -0
- package/tfjs-types/models/whisper/generation_whisper.d.ts +76 -0
- package/tfjs-types/models/whisper/processing_whisper.d.ts +17 -0
- package/tfjs-types/models/yolos/image_processing_yolos.d.ts +10 -0
- package/tfjs-types/models.d.ts +4396 -0
- package/tfjs-types/ops/registry.d.ts +13 -0
- package/tfjs-types/pipelines.d.ts +2433 -0
- package/tfjs-types/tokenizers.d.ts +1002 -0
- package/tfjs-types/transformers.d.ts +27 -0
- package/tfjs-types/utils/audio.d.ts +160 -0
- package/tfjs-types/utils/constants.d.ts +8 -0
- package/tfjs-types/utils/core.d.ts +231 -0
- package/tfjs-types/utils/data-structures.d.ts +294 -0
- package/tfjs-types/utils/devices.d.ts +18 -0
- package/tfjs-types/utils/dtypes.d.ts +20 -0
- package/tfjs-types/utils/generic.d.ts +11 -0
- package/tfjs-types/utils/hub.d.ts +175 -0
- package/tfjs-types/utils/image.d.ts +141 -0
- package/tfjs-types/utils/maths.d.ts +282 -0
- package/tfjs-types/utils/tensor.d.ts +490 -0
- package/tfjs-types/utils/video.d.ts +37 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/libonnxruntime.so.1.14.0 +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/onnxruntime_binding.node +0 -0
- package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/x64/onnxruntime_binding.node +0 -0
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permutes a tensor according to the provided axes.
|
|
3
|
+
* @param {any} tensor The input tensor to permute.
|
|
4
|
+
* @param {Array} axes The axes to permute the tensor along.
|
|
5
|
+
* @returns {Tensor} The permuted tensor.
|
|
6
|
+
*/
|
|
7
|
+
export function permute(tensor: any, axes: any[]): Tensor;
|
|
8
|
+
/**
|
|
9
|
+
* Interpolates an Tensor to the given size.
|
|
10
|
+
* @param {Tensor} input The input tensor to interpolate. Data must be channel-first (i.e., [c, h, w])
|
|
11
|
+
* @param {number[]} size The output size of the image
|
|
12
|
+
* @param {string} mode The interpolation mode
|
|
13
|
+
* @param {boolean} align_corners Whether to align corners.
|
|
14
|
+
* @returns {Tensor} The interpolated tensor.
|
|
15
|
+
*/
|
|
16
|
+
export function interpolate(input: Tensor, [out_height, out_width]: number[], mode?: string, align_corners?: boolean): Tensor;
|
|
17
|
+
/**
|
|
18
|
+
* Down/up samples the input.
|
|
19
|
+
* Inspired by https://pytorch.org/docs/stable/generated/torch.nn.functional.interpolate.html.
|
|
20
|
+
* @param {Tensor} input the input tensor
|
|
21
|
+
* @param {Object} options the options for the interpolation
|
|
22
|
+
* @param {[number, number]|[number, number, number]|[number, number, number, number]} [options.size=null] output spatial size.
|
|
23
|
+
* @param {"nearest"|"bilinear"|"bicubic"} [options.mode='bilinear'] algorithm used for upsampling
|
|
24
|
+
* @returns {Promise<Tensor>} The interpolated tensor.
|
|
25
|
+
*/
|
|
26
|
+
export function interpolate_4d(input: Tensor, { size, mode, }?: {
|
|
27
|
+
size?: [number, number] | [number, number, number] | [number, number, number, number];
|
|
28
|
+
mode?: "nearest" | "bilinear" | "bicubic";
|
|
29
|
+
}): Promise<Tensor>;
|
|
30
|
+
/**
|
|
31
|
+
* Matrix product of two tensors.
|
|
32
|
+
* Inspired by https://pytorch.org/docs/stable/generated/torch.matmul.html
|
|
33
|
+
* @param {Tensor} a the first tensor to be multiplied
|
|
34
|
+
* @param {Tensor} b the second tensor to be multiplied
|
|
35
|
+
* @returns {Promise<Tensor>} The matrix product of the two tensors.
|
|
36
|
+
*/
|
|
37
|
+
export function matmul(a: Tensor, b: Tensor): Promise<Tensor>;
|
|
38
|
+
/**
|
|
39
|
+
* Computes the one dimensional Fourier transform of real-valued input.
|
|
40
|
+
* Inspired by https://pytorch.org/docs/stable/generated/torch.fft.rfft.html
|
|
41
|
+
* @param {Tensor} x the real input tensor
|
|
42
|
+
* @param {Tensor} a The dimension along which to take the one dimensional real FFT.
|
|
43
|
+
* @returns {Promise<Tensor>} the output tensor.
|
|
44
|
+
*/
|
|
45
|
+
export function rfft(x: Tensor, a: Tensor): Promise<Tensor>;
|
|
46
|
+
/**
|
|
47
|
+
* Returns the k largest elements of the given input tensor.
|
|
48
|
+
* Inspired by https://pytorch.org/docs/stable/generated/torch.topk.html
|
|
49
|
+
* @param {Tensor} x the input tensor
|
|
50
|
+
* @param {number} [k] the k in "top-k"
|
|
51
|
+
* @returns {Promise<[Tensor, Tensor]>} the output tuple of (Tensor, LongTensor) of top-k elements and their indices.
|
|
52
|
+
*/
|
|
53
|
+
export function topk(x: Tensor, k?: number): Promise<[Tensor, Tensor]>;
|
|
54
|
+
/**
|
|
55
|
+
* Slice a multidimensional float32 tensor.
|
|
56
|
+
* @param {Tensor} data: Tensor of data to extract slices from
|
|
57
|
+
* @param {number[]} starts: 1-D array of starting indices of corresponding axis in axes
|
|
58
|
+
* @param {number[]} ends: 1-D array of ending indices (exclusive) of corresponding axis in axes
|
|
59
|
+
* @param {number[]} axes: 1-D array of axes that starts and ends apply to
|
|
60
|
+
* @param {number[]} [steps]: 1-D array of slice step of corresponding axis in axes.
|
|
61
|
+
* @returns {Promise<Tensor>} Sliced data tensor.
|
|
62
|
+
*/
|
|
63
|
+
export function slice(data: Tensor, starts: number[], ends: number[], axes: number[], steps?: number[]): Promise<Tensor>;
|
|
64
|
+
/**
|
|
65
|
+
* Perform mean pooling of the last hidden state followed by a normalization step.
|
|
66
|
+
* @param {Tensor} last_hidden_state Tensor of shape [batchSize, seqLength, embedDim]
|
|
67
|
+
* @param {Tensor} attention_mask Tensor of shape [batchSize, seqLength]
|
|
68
|
+
* @returns {Tensor} Returns a new Tensor of shape [batchSize, embedDim].
|
|
69
|
+
*/
|
|
70
|
+
export function mean_pooling(last_hidden_state: Tensor, attention_mask: Tensor): Tensor;
|
|
71
|
+
/**
|
|
72
|
+
* Apply Layer Normalization for last certain number of dimensions.
|
|
73
|
+
* @param {Tensor} input The input tensor
|
|
74
|
+
* @param {number[]} normalized_shape input shape from an expected input of size
|
|
75
|
+
* @param {Object} options The options for the layer normalization
|
|
76
|
+
* @param {number} [options.eps=1e-5] A value added to the denominator for numerical stability.
|
|
77
|
+
* @returns {Tensor} The normalized tensor.
|
|
78
|
+
*/
|
|
79
|
+
export function layer_norm(input: Tensor, normalized_shape: number[], { eps, }?: {
|
|
80
|
+
eps?: number;
|
|
81
|
+
}): Tensor;
|
|
82
|
+
/**
|
|
83
|
+
* Concatenates an array of tensors along a specified dimension.
|
|
84
|
+
* @param {Tensor[]} tensors The array of tensors to concatenate.
|
|
85
|
+
* @param {number} dim The dimension to concatenate along.
|
|
86
|
+
* @returns {Tensor} The concatenated tensor.
|
|
87
|
+
*/
|
|
88
|
+
export function cat(tensors: Tensor[], dim?: number): Tensor;
|
|
89
|
+
/**
|
|
90
|
+
* Stack an array of tensors along a specified dimension.
|
|
91
|
+
* @param {Tensor[]} tensors The array of tensors to stack.
|
|
92
|
+
* @param {number} dim The dimension to stack along.
|
|
93
|
+
* @returns {Tensor} The stacked tensor.
|
|
94
|
+
*/
|
|
95
|
+
export function stack(tensors: Tensor[], dim?: number): Tensor;
|
|
96
|
+
/**
|
|
97
|
+
* Calculates the standard deviation and mean over the dimensions specified by dim. dim can be a single dimension or `null` to reduce over all dimensions.
|
|
98
|
+
* @param {Tensor} input the input tenso
|
|
99
|
+
* @param {number|null} dim the dimension to reduce. If None, all dimensions are reduced.
|
|
100
|
+
* @param {number} correction difference between the sample size and sample degrees of freedom. Defaults to Bessel's correction, correction=1.
|
|
101
|
+
* @param {boolean} keepdim whether the output tensor has dim retained or not.
|
|
102
|
+
* @returns {Tensor[]} A tuple of (std, mean) tensors.
|
|
103
|
+
*/
|
|
104
|
+
export function std_mean(input: Tensor, dim?: number | null, correction?: number, keepdim?: boolean): Tensor[];
|
|
105
|
+
/**
|
|
106
|
+
* Returns the mean value of each row of the input tensor in the given dimension dim.
|
|
107
|
+
* @param {Tensor} input the input tensor.
|
|
108
|
+
* @param {number|null} dim the dimension to reduce.
|
|
109
|
+
* @param {boolean} keepdim whether the output tensor has dim retained or not.
|
|
110
|
+
* @returns {Tensor} A new tensor with means taken along the specified dimension.
|
|
111
|
+
*/
|
|
112
|
+
export function mean(input: Tensor, dim?: number | null, keepdim?: boolean): Tensor;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a tensor of size size filled with fill_value. The tensor's dtype is inferred from fill_value.
|
|
115
|
+
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
116
|
+
* @param {number|bigint|boolean} fill_value The value to fill the output tensor with.
|
|
117
|
+
* @returns {Tensor} The filled tensor.
|
|
118
|
+
*/
|
|
119
|
+
export function full(size: number[], fill_value: number | bigint | boolean): Tensor;
|
|
120
|
+
export function full_like(tensor: any, fill_value: any): Tensor;
|
|
121
|
+
/**
|
|
122
|
+
* Returns a tensor filled with the scalar value 1, with the shape defined by the variable argument size.
|
|
123
|
+
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
124
|
+
* @returns {Tensor} The ones tensor.
|
|
125
|
+
*/
|
|
126
|
+
export function ones(size: number[]): Tensor;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a tensor filled with the scalar value 1, with the same size as input.
|
|
129
|
+
* @param {Tensor} tensor The size of input will determine size of the output tensor.
|
|
130
|
+
* @returns {Tensor} The ones tensor.
|
|
131
|
+
*/
|
|
132
|
+
export function ones_like(tensor: Tensor): Tensor;
|
|
133
|
+
/**
|
|
134
|
+
* Returns a tensor filled with the scalar value 0, with the shape defined by the variable argument size.
|
|
135
|
+
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
136
|
+
* @returns {Tensor} The zeros tensor.
|
|
137
|
+
*/
|
|
138
|
+
export function zeros(size: number[]): Tensor;
|
|
139
|
+
/**
|
|
140
|
+
* Returns a tensor filled with the scalar value 0, with the same size as input.
|
|
141
|
+
* @param {Tensor} tensor The size of input will determine size of the output tensor.
|
|
142
|
+
* @returns {Tensor} The zeros tensor.
|
|
143
|
+
*/
|
|
144
|
+
export function zeros_like(tensor: Tensor): Tensor;
|
|
145
|
+
/**
|
|
146
|
+
* Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1)
|
|
147
|
+
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
148
|
+
* @returns {Tensor} The random tensor.
|
|
149
|
+
*/
|
|
150
|
+
export function rand(size: number[]): Tensor;
|
|
151
|
+
/**
|
|
152
|
+
* Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).
|
|
153
|
+
* @param {number[]} size A sequence of integers defining the shape of the output tensor.
|
|
154
|
+
* @returns {Tensor} The random tensor.
|
|
155
|
+
*/
|
|
156
|
+
export function randn(size: number[]): Tensor;
|
|
157
|
+
/**
|
|
158
|
+
* Quantizes the embeddings tensor to binary or unsigned binary precision.
|
|
159
|
+
* @param {Tensor} tensor The tensor to quantize.
|
|
160
|
+
* @param {'binary'|'ubinary'} precision The precision to use for quantization.
|
|
161
|
+
* @returns {Tensor} The quantized tensor.
|
|
162
|
+
*/
|
|
163
|
+
export function quantize_embeddings(tensor: Tensor, precision: "binary" | "ubinary"): Tensor;
|
|
164
|
+
export const DataTypeMap: Readonly<{
|
|
165
|
+
float32: Float32ArrayConstructor;
|
|
166
|
+
float16: Uint16ArrayConstructor | Float16ArrayConstructor;
|
|
167
|
+
float64: Float64ArrayConstructor;
|
|
168
|
+
string: ArrayConstructor;
|
|
169
|
+
int8: Int8ArrayConstructor;
|
|
170
|
+
uint8: Uint8ArrayConstructor;
|
|
171
|
+
int16: Int16ArrayConstructor;
|
|
172
|
+
uint16: Uint16ArrayConstructor;
|
|
173
|
+
int32: Int32ArrayConstructor;
|
|
174
|
+
uint32: Uint32ArrayConstructor;
|
|
175
|
+
int64: BigInt64ArrayConstructor;
|
|
176
|
+
uint64: BigUint64ArrayConstructor;
|
|
177
|
+
bool: Uint8ArrayConstructor;
|
|
178
|
+
uint4: Uint8ArrayConstructor;
|
|
179
|
+
int4: Int8ArrayConstructor;
|
|
180
|
+
}>;
|
|
181
|
+
/**
|
|
182
|
+
* @typedef {keyof typeof DataTypeMap} DataType
|
|
183
|
+
* @typedef {import('./maths.js').AnyTypedArray | any[]} DataArray
|
|
184
|
+
*/
|
|
185
|
+
export class Tensor {
|
|
186
|
+
/**
|
|
187
|
+
* Create a new Tensor or copy an existing Tensor.
|
|
188
|
+
* @param {[DataType, DataArray, number[]]|[ONNXTensor]} args
|
|
189
|
+
*/
|
|
190
|
+
constructor(...args: [DataType, DataArray, number[]] | [ONNXTensor]);
|
|
191
|
+
set dims(value: number[]);
|
|
192
|
+
/** @type {number[]} Dimensions of the tensor. */
|
|
193
|
+
get dims(): number[];
|
|
194
|
+
/** @type {DataType} Type of the tensor. */
|
|
195
|
+
get type(): DataType;
|
|
196
|
+
/** @type {DataArray} The data stored in the tensor. */
|
|
197
|
+
get data(): DataArray;
|
|
198
|
+
/** @type {number} The number of elements in the tensor. */
|
|
199
|
+
get size(): number;
|
|
200
|
+
/** @type {string} The location of the tensor data. */
|
|
201
|
+
get location(): string;
|
|
202
|
+
ort_tensor: ONNXTensor;
|
|
203
|
+
dispose(): void;
|
|
204
|
+
/**
|
|
205
|
+
* Index into a Tensor object.
|
|
206
|
+
* @param {number} index The index to access.
|
|
207
|
+
* @returns {Tensor} The data at the specified index.
|
|
208
|
+
*/
|
|
209
|
+
_getitem(index: number): Tensor;
|
|
210
|
+
/**
|
|
211
|
+
* @param {number|bigint} item The item to search for in the tensor
|
|
212
|
+
* @returns {number} The index of the first occurrence of item in the tensor data.
|
|
213
|
+
*/
|
|
214
|
+
indexOf(item: number | bigint): number;
|
|
215
|
+
/**
|
|
216
|
+
* @param {number} index
|
|
217
|
+
* @param {number} iterSize
|
|
218
|
+
* @param {any} iterDims
|
|
219
|
+
* @returns {Tensor}
|
|
220
|
+
*/
|
|
221
|
+
_subarray(index: number, iterSize: number, iterDims: any): Tensor;
|
|
222
|
+
/**
|
|
223
|
+
* Returns the value of this tensor as a standard JavaScript Number. This only works
|
|
224
|
+
* for tensors with one element. For other cases, see `Tensor.tolist()`.
|
|
225
|
+
* @returns {number|bigint} The value of this tensor as a standard JavaScript Number.
|
|
226
|
+
* @throws {Error} If the tensor has more than one element.
|
|
227
|
+
*/
|
|
228
|
+
item(): number | bigint;
|
|
229
|
+
/**
|
|
230
|
+
* Convert tensor data to a n-dimensional JS list
|
|
231
|
+
* @returns {Array}
|
|
232
|
+
*/
|
|
233
|
+
tolist(): any[];
|
|
234
|
+
/**
|
|
235
|
+
* Return a new Tensor with the sigmoid function applied to each element.
|
|
236
|
+
* @returns {Tensor} The tensor with the sigmoid function applied.
|
|
237
|
+
*/
|
|
238
|
+
sigmoid(): Tensor;
|
|
239
|
+
/**
|
|
240
|
+
* Applies the sigmoid function to the tensor in place.
|
|
241
|
+
* @returns {Tensor} Returns `this`.
|
|
242
|
+
*/
|
|
243
|
+
sigmoid_(): Tensor;
|
|
244
|
+
/**
|
|
245
|
+
* Return a new Tensor with a callback function applied to each element.
|
|
246
|
+
* @param {Function} callback - The function to apply to each element. It should take three arguments:
|
|
247
|
+
* the current element, its index, and the tensor's data array.
|
|
248
|
+
* @returns {Tensor} A new Tensor with the callback function applied to each element.
|
|
249
|
+
*/
|
|
250
|
+
map(callback: Function): Tensor;
|
|
251
|
+
/**
|
|
252
|
+
* Apply a callback function to each element of the tensor in place.
|
|
253
|
+
* @param {Function} callback - The function to apply to each element. It should take three arguments:
|
|
254
|
+
* the current element, its index, and the tensor's data array.
|
|
255
|
+
* @returns {Tensor} Returns `this`.
|
|
256
|
+
*/
|
|
257
|
+
map_(callback: Function): Tensor;
|
|
258
|
+
/**
|
|
259
|
+
* Return a new Tensor with every element multiplied by a constant.
|
|
260
|
+
* @param {number} val The value to multiply by.
|
|
261
|
+
* @returns {Tensor} The new tensor.
|
|
262
|
+
*/
|
|
263
|
+
mul(val: number): Tensor;
|
|
264
|
+
/**
|
|
265
|
+
* Multiply the tensor by a constant in place.
|
|
266
|
+
* @param {number} val The value to multiply by.
|
|
267
|
+
* @returns {Tensor} Returns `this`.
|
|
268
|
+
*/
|
|
269
|
+
mul_(val: number): Tensor;
|
|
270
|
+
/**
|
|
271
|
+
* Return a new Tensor with every element divided by a constant.
|
|
272
|
+
* @param {number} val The value to divide by.
|
|
273
|
+
* @returns {Tensor} The new tensor.
|
|
274
|
+
*/
|
|
275
|
+
div(val: number): Tensor;
|
|
276
|
+
/**
|
|
277
|
+
* Divide the tensor by a constant in place.
|
|
278
|
+
* @param {number} val The value to divide by.
|
|
279
|
+
* @returns {Tensor} Returns `this`.
|
|
280
|
+
*/
|
|
281
|
+
div_(val: number): Tensor;
|
|
282
|
+
/**
|
|
283
|
+
* Return a new Tensor with every element added by a constant.
|
|
284
|
+
* @param {number} val The value to add by.
|
|
285
|
+
* @returns {Tensor} The new tensor.
|
|
286
|
+
*/
|
|
287
|
+
add(val: number): Tensor;
|
|
288
|
+
/**
|
|
289
|
+
* Add the tensor by a constant in place.
|
|
290
|
+
* @param {number} val The value to add by.
|
|
291
|
+
* @returns {Tensor} Returns `this`.
|
|
292
|
+
*/
|
|
293
|
+
add_(val: number): Tensor;
|
|
294
|
+
/**
|
|
295
|
+
* Return a new Tensor with every element subtracted by a constant.
|
|
296
|
+
* @param {number} val The value to subtract by.
|
|
297
|
+
* @returns {Tensor} The new tensor.
|
|
298
|
+
*/
|
|
299
|
+
sub(val: number): Tensor;
|
|
300
|
+
/**
|
|
301
|
+
* Subtract the tensor by a constant in place.
|
|
302
|
+
* @param {number} val The value to subtract by.
|
|
303
|
+
* @returns {Tensor} Returns `this`.
|
|
304
|
+
*/
|
|
305
|
+
sub_(val: number): Tensor;
|
|
306
|
+
/**
|
|
307
|
+
* Creates a deep copy of the current Tensor.
|
|
308
|
+
* @returns {Tensor} A new Tensor with the same type, data, and dimensions as the original.
|
|
309
|
+
*/
|
|
310
|
+
clone(): Tensor;
|
|
311
|
+
/**
|
|
312
|
+
* Performs a slice operation on the Tensor along specified dimensions.
|
|
313
|
+
*
|
|
314
|
+
* Consider a Tensor that has a dimension of [4, 7]:
|
|
315
|
+
* ```
|
|
316
|
+
* [ 1, 2, 3, 4, 5, 6, 7]
|
|
317
|
+
* [ 8, 9, 10, 11, 12, 13, 14]
|
|
318
|
+
* [15, 16, 17, 18, 19, 20, 21]
|
|
319
|
+
* [22, 23, 24, 25, 26, 27, 28]
|
|
320
|
+
* ```
|
|
321
|
+
* We can slice against the two dims of row and column, for instance in this
|
|
322
|
+
* case we can start at the second element, and return to the second last,
|
|
323
|
+
* like this:
|
|
324
|
+
* ```
|
|
325
|
+
* tensor.slice([1, -1], [1, -1]);
|
|
326
|
+
* ```
|
|
327
|
+
* which would return:
|
|
328
|
+
* ```
|
|
329
|
+
* [ 9, 10, 11, 12, 13 ]
|
|
330
|
+
* [ 16, 17, 18, 19, 20 ]
|
|
331
|
+
* ```
|
|
332
|
+
*
|
|
333
|
+
* @param {...(number|number[]|null)} slices The slice specifications for each dimension.
|
|
334
|
+
* - If a number is given, then a single element is selected.
|
|
335
|
+
* - If an array of two numbers is given, then a range of elements [start, end (exclusive)] is selected.
|
|
336
|
+
* - If null is given, then the entire dimension is selected.
|
|
337
|
+
* @returns {Tensor} A new Tensor containing the selected elements.
|
|
338
|
+
* @throws {Error} If the slice input is invalid.
|
|
339
|
+
*/
|
|
340
|
+
slice(...slices: (number | number[] | null)[]): Tensor;
|
|
341
|
+
/**
|
|
342
|
+
* Return a permuted version of this Tensor, according to the provided dimensions.
|
|
343
|
+
* @param {...number} dims Dimensions to permute.
|
|
344
|
+
* @returns {Tensor} The permuted tensor.
|
|
345
|
+
*/
|
|
346
|
+
permute(...dims: number[]): Tensor;
|
|
347
|
+
transpose(...dims: any[]): Tensor;
|
|
348
|
+
/**
|
|
349
|
+
* Returns the sum of each row of the input tensor in the given dimension dim.
|
|
350
|
+
*
|
|
351
|
+
* @param {number} [dim=null] The dimension or dimensions to reduce. If `null`, all dimensions are reduced.
|
|
352
|
+
* @param {boolean} keepdim Whether the output tensor has `dim` retained or not.
|
|
353
|
+
* @returns The summed tensor
|
|
354
|
+
*/
|
|
355
|
+
sum(dim?: number, keepdim?: boolean): Tensor;
|
|
356
|
+
/**
|
|
357
|
+
* Returns the matrix norm or vector norm of a given tensor.
|
|
358
|
+
* @param {number|string} [p='fro'] The order of norm
|
|
359
|
+
* @param {number} [dim=null] Specifies which dimension of the tensor to calculate the norm across.
|
|
360
|
+
* If dim is None, the norm will be calculated across all dimensions of input.
|
|
361
|
+
* @param {boolean} [keepdim=false] Whether the output tensors have dim retained or not.
|
|
362
|
+
* @returns {Tensor} The norm of the tensor.
|
|
363
|
+
*/
|
|
364
|
+
norm(p?: number | string, dim?: number, keepdim?: boolean): Tensor;
|
|
365
|
+
/**
|
|
366
|
+
* Performs `L_p` normalization of inputs over specified dimension. Operates in place.
|
|
367
|
+
* @param {number} [p=2] The exponent value in the norm formulation
|
|
368
|
+
* @param {number} [dim=1] The dimension to reduce
|
|
369
|
+
* @returns {Tensor} `this` for operation chaining.
|
|
370
|
+
*/
|
|
371
|
+
normalize_(p?: number, dim?: number): Tensor;
|
|
372
|
+
/**
|
|
373
|
+
* Performs `L_p` normalization of inputs over specified dimension.
|
|
374
|
+
* @param {number} [p=2] The exponent value in the norm formulation
|
|
375
|
+
* @param {number} [dim=1] The dimension to reduce
|
|
376
|
+
* @returns {Tensor} The normalized tensor.
|
|
377
|
+
*/
|
|
378
|
+
normalize(p?: number, dim?: number): Tensor;
|
|
379
|
+
/**
|
|
380
|
+
* Compute and return the stride of this tensor.
|
|
381
|
+
* Stride is the jump necessary to go from one element to the next one in the specified dimension dim.
|
|
382
|
+
* @returns {number[]} The stride of this tensor.
|
|
383
|
+
*/
|
|
384
|
+
stride(): number[];
|
|
385
|
+
/**
|
|
386
|
+
* Returns a tensor with all specified dimensions of input of size 1 removed.
|
|
387
|
+
*
|
|
388
|
+
* NOTE: The returned tensor shares the storage with the input tensor, so changing the contents of one will change the contents of the other.
|
|
389
|
+
* If you would like a copy, use `tensor.clone()` before squeezing.
|
|
390
|
+
*
|
|
391
|
+
* @param {number|number[]} [dim=null] If given, the input will be squeezed only in the specified dimensions.
|
|
392
|
+
* @returns {Tensor} The squeezed tensor
|
|
393
|
+
*/
|
|
394
|
+
squeeze(dim?: number | number[]): Tensor;
|
|
395
|
+
/**
|
|
396
|
+
* In-place version of @see {@link Tensor.squeeze}
|
|
397
|
+
*/
|
|
398
|
+
squeeze_(dim?: any): this;
|
|
399
|
+
/**
|
|
400
|
+
* Returns a new tensor with a dimension of size one inserted at the specified position.
|
|
401
|
+
*
|
|
402
|
+
* NOTE: The returned tensor shares the same underlying data with this tensor.
|
|
403
|
+
*
|
|
404
|
+
* @param {number} dim The index at which to insert the singleton dimension
|
|
405
|
+
* @returns {Tensor} The unsqueezed tensor
|
|
406
|
+
*/
|
|
407
|
+
unsqueeze(dim?: number): Tensor;
|
|
408
|
+
/**
|
|
409
|
+
* In-place version of @see {@link Tensor.unsqueeze}
|
|
410
|
+
*/
|
|
411
|
+
unsqueeze_(dim?: any): this;
|
|
412
|
+
/**
|
|
413
|
+
* In-place version of @see {@link Tensor.flatten}
|
|
414
|
+
*/
|
|
415
|
+
flatten_(start_dim?: number, end_dim?: number): this;
|
|
416
|
+
/**
|
|
417
|
+
* Flattens input by reshaping it into a one-dimensional tensor.
|
|
418
|
+
* If `start_dim` or `end_dim` are passed, only dimensions starting with `start_dim`
|
|
419
|
+
* and ending with `end_dim` are flattened. The order of elements in input is unchanged.
|
|
420
|
+
* @param {number} start_dim the first dim to flatten
|
|
421
|
+
* @param {number} end_dim the last dim to flatten
|
|
422
|
+
* @returns {Tensor} The flattened tensor.
|
|
423
|
+
*/
|
|
424
|
+
flatten(start_dim?: number, end_dim?: number): Tensor;
|
|
425
|
+
/**
|
|
426
|
+
* Returns a new tensor with the same data as the `self` tensor but of a different `shape`.
|
|
427
|
+
* @param {...number} dims the desired size
|
|
428
|
+
* @returns {Tensor} The tensor with the same data but different shape
|
|
429
|
+
*/
|
|
430
|
+
view(...dims: number[]): Tensor;
|
|
431
|
+
neg_(): this;
|
|
432
|
+
neg(): Tensor;
|
|
433
|
+
/**
|
|
434
|
+
* Computes input > val element-wise.
|
|
435
|
+
* @param {number} val The value to compare with.
|
|
436
|
+
* @returns {Tensor} A boolean tensor that is `true` where input is greater than other and `false` elsewhere.
|
|
437
|
+
*/
|
|
438
|
+
gt(val: number): Tensor;
|
|
439
|
+
/**
|
|
440
|
+
* Computes input < val element-wise.
|
|
441
|
+
* @param {number} val The value to compare with.
|
|
442
|
+
* @returns {Tensor} A boolean tensor that is `true` where input is less than other and `false` elsewhere.
|
|
443
|
+
*/
|
|
444
|
+
lt(val: number): Tensor;
|
|
445
|
+
/**
|
|
446
|
+
* In-place version of @see {@link Tensor.clamp}
|
|
447
|
+
*/
|
|
448
|
+
clamp_(min: any, max: any): this;
|
|
449
|
+
/**
|
|
450
|
+
* Clamps all elements in input into the range [ min, max ]
|
|
451
|
+
* @param {number} min lower-bound of the range to be clamped to
|
|
452
|
+
* @param {number} max upper-bound of the range to be clamped to
|
|
453
|
+
* @returns {Tensor} the output tensor.
|
|
454
|
+
*/
|
|
455
|
+
clamp(min: number, max: number): Tensor;
|
|
456
|
+
/**
|
|
457
|
+
* In-place version of @see {@link Tensor.round}
|
|
458
|
+
*/
|
|
459
|
+
round_(): this;
|
|
460
|
+
/**
|
|
461
|
+
* Rounds elements of input to the nearest integer.
|
|
462
|
+
* @returns {Tensor} the output tensor.
|
|
463
|
+
*/
|
|
464
|
+
round(): Tensor;
|
|
465
|
+
mean(dim?: any, keepdim?: boolean): Tensor;
|
|
466
|
+
min(dim?: any, keepdim?: boolean): Tensor;
|
|
467
|
+
max(dim?: any, keepdim?: boolean): Tensor;
|
|
468
|
+
argmin(dim?: any, keepdim?: boolean): Tensor;
|
|
469
|
+
argmax(dim?: any, keepdim?: boolean): Tensor;
|
|
470
|
+
/**
|
|
471
|
+
* Performs Tensor dtype conversion.
|
|
472
|
+
* @param {DataType} type The desired data type.
|
|
473
|
+
* @returns {Tensor} The converted tensor.
|
|
474
|
+
*/
|
|
475
|
+
to(type: DataType): Tensor;
|
|
476
|
+
/**
|
|
477
|
+
* Returns an iterator object for iterating over the tensor data in row-major order.
|
|
478
|
+
* If the tensor has more than one dimension, the iterator will yield subarrays.
|
|
479
|
+
* @returns {Iterator} An iterator object for iterating over the tensor data in row-major order.
|
|
480
|
+
*/
|
|
481
|
+
[Symbol.iterator](): Iterator<any, any, any>;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* This creates a nested array of a given type and depth (see examples).
|
|
485
|
+
*/
|
|
486
|
+
export type NestArray<T, Depth extends number, Acc extends never[] = []> = Acc["length"] extends Depth ? T : NestArray<T[], Depth, [...Acc, never]>;
|
|
487
|
+
export type DataType = keyof typeof DataTypeMap;
|
|
488
|
+
export type DataArray = import("./maths.js").AnyTypedArray | any[];
|
|
489
|
+
import { Tensor as ONNXTensor } from '../backends/onnx.js';
|
|
490
|
+
//# sourceMappingURL=tensor.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Loads a video.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|Blob|HTMLVideoElement} src The video to process.
|
|
5
|
+
* @param {Object} [options] Optional parameters.
|
|
6
|
+
* @param {number} [options.num_frames=null] The number of frames to sample uniformly.
|
|
7
|
+
* @param {number} [options.fps=null] The number of frames to sample per second.
|
|
8
|
+
*
|
|
9
|
+
* @returns {Promise<RawVideo>} The loaded video.
|
|
10
|
+
*/
|
|
11
|
+
export function load_video(src: string | Blob | HTMLVideoElement, { num_frames, fps }?: {
|
|
12
|
+
num_frames?: number;
|
|
13
|
+
fps?: number;
|
|
14
|
+
}): Promise<RawVideo>;
|
|
15
|
+
export class RawVideoFrame {
|
|
16
|
+
/**
|
|
17
|
+
* @param {RawImage} image
|
|
18
|
+
* @param {number} timestamp
|
|
19
|
+
*/
|
|
20
|
+
constructor(image: RawImage, timestamp: number);
|
|
21
|
+
image: RawImage;
|
|
22
|
+
timestamp: number;
|
|
23
|
+
}
|
|
24
|
+
export class RawVideo {
|
|
25
|
+
/**
|
|
26
|
+
* @param {RawVideoFrame[]|RawImage[]} frames
|
|
27
|
+
* @param {number} duration
|
|
28
|
+
*/
|
|
29
|
+
constructor(frames: RawVideoFrame[] | RawImage[], duration: number);
|
|
30
|
+
frames: RawVideoFrame[];
|
|
31
|
+
duration: number;
|
|
32
|
+
get width(): number;
|
|
33
|
+
get height(): number;
|
|
34
|
+
get fps(): number;
|
|
35
|
+
}
|
|
36
|
+
import { RawImage } from "./image.js";
|
|
37
|
+
//# sourceMappingURL=video.d.ts.map
|
package/addon-node_modules/onnxruntime-node/bin/napi-v3/linux/arm64/libonnxruntime.so.1.14.0
DELETED
|
Binary file
|