@slexisvn/mlfw 0.1.2 → 0.1.4

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.
@@ -0,0 +1,3552 @@
1
+ declare class SymInt {
2
+ static var(name: any): SymInt;
3
+ static const(value: any): any;
4
+ static add(a: any, b: any): any;
5
+ static sub(a: any, b: any): any;
6
+ static neg(a: any): any;
7
+ static mul(a: any, b: any): any;
8
+ static div(a: any, b: any): any;
9
+ static mod(a: any, b: any): number | SymInt;
10
+ static max(a: any, b: any): any;
11
+ static min(a: any, b: any): any;
12
+ static ceilDiv(a: any, b: any): number | SymInt;
13
+ static equals(a: any, b: any): any;
14
+ static substitute(expr: any, varName: any, value: any): any;
15
+ static evaluate(expr: any, env: any): any;
16
+ static freeVars(expr: any, result?: Set<any>): Set<any>;
17
+ static isConst(expr: any): expr is number;
18
+ static toConst(expr: any): number | null;
19
+ constructor(type: any, name?: null, args?: any[]);
20
+ type: any;
21
+ name: any;
22
+ args: any[];
23
+ toString(): any;
24
+ }
25
+
26
+ type SymIntValue = InstanceType<typeof SymInt>;
27
+ type Dim = number | SymIntValue;
28
+ type Shape$1 = readonly Dim[];
29
+ type ScalarDType = `${ScalarType}`;
30
+ declare enum ScalarType {
31
+ F16 = "f16",
32
+ BF16 = "bf16",
33
+ F32 = "f32",
34
+ F64 = "f64",
35
+ I8 = "i8",
36
+ I16 = "i16",
37
+ I32 = "i32",
38
+ I64 = "i64",
39
+ UI8 = "ui8",
40
+ BOOL = "bool",
41
+ INDEX = "index"
42
+ }
43
+ declare class Layout {
44
+ readonly order: readonly number[];
45
+ private _hash;
46
+ constructor(order: readonly number[]);
47
+ static rowMajor(rank: number): Layout;
48
+ static columnMajor(rank: number): Layout;
49
+ get rank(): number;
50
+ isIdentity(): boolean;
51
+ inverse(): Layout;
52
+ compose(other: Layout): Layout;
53
+ computeStrides(shape: Shape$1): number[];
54
+ equals(other: unknown): boolean;
55
+ hash(): number;
56
+ }
57
+ declare class TensorType {
58
+ readonly shape: readonly Dim[];
59
+ readonly dtype: ScalarDType;
60
+ readonly layout: Layout;
61
+ private _hash;
62
+ constructor(shape: Shape$1, dtype: ScalarDType, layout?: Layout | null);
63
+ get rank(): number;
64
+ get isScalar(): boolean;
65
+ get isFullyStatic(): boolean;
66
+ get hasDynamic(): boolean;
67
+ numel(): number;
68
+ symbolicNumel(): number | SymIntValue;
69
+ sizeInBytes(): number;
70
+ strides(): number[];
71
+ withShape(s: Shape$1): TensorType;
72
+ withDtype(d: ScalarDType): TensorType;
73
+ withLayout(l: Layout): TensorType;
74
+ equals(other: unknown): boolean;
75
+ shapeEquals(other: unknown): boolean;
76
+ shapeCompatible(other: TensorType): boolean;
77
+ hash(): number;
78
+ static broadcastShape(...shapes: Shape$1[]): Dim[] | null;
79
+ static broadcastCompatible(...shapes: Shape$1[]): boolean;
80
+ }
81
+
82
+ type DType = ScalarDType;
83
+ type NumericTypedArray = Uint16Array | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | BigInt64Array | Uint8Array;
84
+
85
+ declare enum DeviceType {
86
+ CPU = "cpu",
87
+ GPU = "gpu",
88
+ WASM = "wasm",
89
+ WEBGPU = "webgpu",
90
+ META = "meta",
91
+ LAZY = "lazy"
92
+ }
93
+ type DeviceTypeName = `${DeviceType}`;
94
+ declare class Device {
95
+ readonly type: DeviceTypeName;
96
+ readonly index: number;
97
+ constructor(type: DeviceTypeName, index?: number);
98
+ dispatchKey(): number;
99
+ equals(other: Device): boolean;
100
+ hash(): number;
101
+ toString(): string;
102
+ }
103
+ declare const CPU_DEVICE: Device;
104
+ declare const GPU_DEVICE: Device;
105
+ declare const WASM_DEVICE: Device;
106
+ declare const WEBGPU_DEVICE: Device;
107
+ declare function getDefaultDevice(): Device;
108
+ declare function setDefaultDevice(device: Device): void;
109
+
110
+ declare class CPUAllocator {
111
+ allocate(count: number, dtype: DType): NumericTypedArray;
112
+ free(_data?: NumericTypedArray): void;
113
+ }
114
+ declare class MetaAllocator {
115
+ allocate(): null;
116
+ free(_data?: NumericTypedArray): void;
117
+ }
118
+ type Allocator = CPUAllocator | MetaAllocator;
119
+ declare class StorageImpl {
120
+ #private;
121
+ private _data;
122
+ private _nbytes;
123
+ private readonly _device;
124
+ private readonly _allocator;
125
+ private _refCount;
126
+ static setHostReadHook(fn: ((data: NumericTypedArray) => void) | null): void;
127
+ constructor(data: NumericTypedArray | null, nbytes: number, device: Device, allocator: Allocator);
128
+ static allocate(nbytes: number, dtype: DType, device: Device): StorageImpl;
129
+ static fromData(data: NumericTypedArray | null, device: Device): StorageImpl;
130
+ retain(): StorageImpl;
131
+ release(): void;
132
+ get refCount(): number;
133
+ get data(): NumericTypedArray | null;
134
+ get rawData(): NumericTypedArray | null;
135
+ get nbytes(): number;
136
+ get device(): Device;
137
+ get isValid(): boolean;
138
+ get isMeta(): boolean;
139
+ resize(newNbytes: number, dtype: DType): void;
140
+ clone(): StorageImpl;
141
+ }
142
+
143
+ declare class Storage {
144
+ private readonly _impl;
145
+ constructor(impl: StorageImpl);
146
+ static allocate(nbytes: number, dtype: DType, device: Device): Storage;
147
+ static fromData(data: NumericTypedArray | null, device: Device): Storage;
148
+ get impl(): StorageImpl;
149
+ get data(): NumericTypedArray | null;
150
+ get rawData(): NumericTypedArray | null;
151
+ get nbytes(): number;
152
+ get device(): Device;
153
+ get isValid(): boolean;
154
+ get isMeta(): boolean;
155
+ retain(): Storage;
156
+ release(): void;
157
+ clone(): Storage;
158
+ resize(nbytes: number, dtype: DType): void;
159
+ }
160
+
161
+ declare enum DispatchKey {
162
+ CPU = 0,
163
+ GPU = 1,
164
+ WASM = 2,
165
+ META = 3,
166
+ LAZY = 4,
167
+ CUSTOM_0 = 5,
168
+ CUSTOM_1 = 6,
169
+ CUSTOM_2 = 7,
170
+ CUSTOM_3 = 8,
171
+ BATCHED = 20,
172
+ VMAP = 24,
173
+ FUNCTIONALIZE = 28,
174
+ AUTOCAST = 32,
175
+ AUTOGRAD = 40,
176
+ AUTOGRAD_CPU = 41,
177
+ AUTOGRAD_GPU = 42,
178
+ AUTOGRAD_WASM = 43,
179
+ TRACING = 48,
180
+ NUM_KEYS = 49
181
+ }
182
+ type DispatchKeyValue = DispatchKey;
183
+ declare class DispatchKeySet {
184
+ private readonly _lo;
185
+ private readonly _hi;
186
+ constructor(lo: number, hi: number);
187
+ static fromKey(key: DispatchKeyValue): DispatchKeySet;
188
+ static fromKeys(...keys: DispatchKeyValue[]): DispatchKeySet;
189
+ add(key: DispatchKeyValue): DispatchKeySet;
190
+ remove(key: DispatchKeyValue): DispatchKeySet;
191
+ has(key: DispatchKeyValue): boolean;
192
+ without(key: DispatchKeyValue): DispatchKeySet;
193
+ union(other: DispatchKeySet): DispatchKeySet;
194
+ intersect(other: DispatchKeySet): DispatchKeySet;
195
+ subtract(other: DispatchKeySet): DispatchKeySet;
196
+ isEmpty(): boolean;
197
+ equals(other: DispatchKeySet): boolean;
198
+ highestPriority(): number;
199
+ lowestPriority(): number;
200
+ count(): number;
201
+ [Symbol.iterator](): Generator<DispatchKeyValue>;
202
+ toString(): string;
203
+ }
204
+
205
+ declare enum MemoryFormat {
206
+ CONTIGUOUS = "contiguous",
207
+ CHANNELS_LAST = "channels_last",
208
+ PRESERVE = "preserve"
209
+ }
210
+ type MemoryFormatValue = `${MemoryFormat}`;
211
+
212
+ declare class AutogradMeta {
213
+ private _grad;
214
+ private _gradFn;
215
+ private _outputNr;
216
+ private _requiresGrad;
217
+ private _retainGrad;
218
+ private _gradAccumulator;
219
+ private _versionAtCreation;
220
+ constructor();
221
+ get grad(): Tensor | null;
222
+ set grad(tensor: Tensor | null);
223
+ get gradFn(): unknown | null;
224
+ setGradFn(node: unknown, outputNr?: number): void;
225
+ get outputNr(): number;
226
+ get requiresGrad(): boolean;
227
+ set requiresGrad(flag: boolean);
228
+ get retainGrad(): boolean;
229
+ set retainGrad(flag: boolean);
230
+ get isLeaf(): boolean;
231
+ get versionAtCreation(): number;
232
+ set versionAtCreation(v: number);
233
+ getGradAccumulator(): object | null;
234
+ setGradAccumulator(acc: object): void;
235
+ clearGrad(): void;
236
+ clearGradFn(): void;
237
+ }
238
+
239
+ declare class TensorImpl {
240
+ private _storage;
241
+ private _storageOffset;
242
+ private _sizes;
243
+ private _strides;
244
+ private _dtype;
245
+ private _device;
246
+ private _numel;
247
+ private _keySet;
248
+ private _autogradMeta;
249
+ private _version;
250
+ private _contiguousCache;
251
+ constructor(storage: Storage, storageOffset: number, sizes: readonly number[], strides: readonly number[] | null, dtype: DType, device: Device);
252
+ get storage(): Storage;
253
+ get storageOffset(): number;
254
+ size(dim: number): number;
255
+ stride(dim: number): number;
256
+ sizes(): readonly number[];
257
+ strides(): readonly number[];
258
+ dim(): number;
259
+ numel(): number;
260
+ get dtype(): DType;
261
+ get device(): Device;
262
+ isContiguous(format?: MemoryFormatValue): boolean;
263
+ setSizesAndStrides(sizes: readonly number[], strides?: readonly number[]): void;
264
+ setStorageOffset(offset: number): void;
265
+ bumpVersion(): void;
266
+ get version(): number;
267
+ get autogradMeta(): AutogradMeta | null;
268
+ setAutogradMeta(meta: AutogradMeta | null): void;
269
+ keySet(): DispatchKeySet;
270
+ addKeyToSet(key: DispatchKeyValue): void;
271
+ removeKeyFromSet(key: DispatchKeyValue): void;
272
+ _updateKeySet(): void;
273
+ get isMeta(): boolean;
274
+ shallowCopyFrom(other: TensorImpl): void;
275
+ }
276
+
277
+ declare class Tensor {
278
+ readonly _impl: TensorImpl;
279
+ constructor(impl: TensorImpl);
280
+ get impl(): TensorImpl;
281
+ get shape(): readonly number[];
282
+ get strides(): readonly number[];
283
+ get dtype(): DType;
284
+ get device(): Device;
285
+ get ndim(): number;
286
+ get rank(): number;
287
+ get numel(): number;
288
+ get length(): number;
289
+ get isContiguous(): boolean;
290
+ get dispatchKeySet(): DispatchKeySet;
291
+ get storage(): Storage;
292
+ get storageOffset(): number;
293
+ get data(): NumericTypedArray | null;
294
+ get requiresGrad(): boolean;
295
+ get gradFn(): unknown | null;
296
+ get grad(): Tensor | null;
297
+ set grad(t: Tensor | null);
298
+ get isLeaf(): boolean;
299
+ get version(): number;
300
+ requiresGrad_(flag?: boolean): this;
301
+ retainGrad(): this;
302
+ detach(): Tensor;
303
+ item(): number | bigint;
304
+ toArray(): number | bigint | NestedArray;
305
+ toString(): string;
306
+ [Symbol.iterator](): Generator<Tensor>;
307
+ _select(dim: number, index: number): Tensor;
308
+ _ensureAutogradMeta(): AutogradMeta;
309
+ backward(gradOutput?: Tensor): void;
310
+ }
311
+ type NestedArray = Array<number | bigint | NestedArray>;
312
+
313
+ declare const GradMode: {
314
+ isEnabled(): boolean;
315
+ setEnabled(flag: boolean): void;
316
+ };
317
+ declare function noGrad<T>(fn: () => T): T;
318
+ declare function enableGrad<T>(fn: () => T): T;
319
+
320
+ type SymbolicDim = Dim | string;
321
+ type SymbolicShape = readonly SymbolicDim[];
322
+ type MutableSymbolicShape = SymbolicDim[];
323
+ type TensorInput$2 = Tensor;
324
+ type TensorOutput = Tensor | SymbolicTensor;
325
+ type MaybePromise<T> = T | Promise<T>;
326
+ type AttrValue = unknown;
327
+ type AttrMap = Record<string, AttrValue>;
328
+ type DynamicShapeSpec = true | Set<number> | null | undefined;
329
+ type DynamicShapes = readonly DynamicShapeSpec[] | null | undefined;
330
+ type IRValueLike = {
331
+ id?: number;
332
+ type: TensorType;
333
+ symbolicShape?: SymbolicShape;
334
+ addUse?: (link: unknown) => void;
335
+ removeUse?: (link: unknown) => void;
336
+ replaceAllUsesWith?: (value: IRValueLike) => void;
337
+ };
338
+ type IROperationLike = {
339
+ opName: string;
340
+ operands: IRValueLike[];
341
+ numOperands: number;
342
+ numResults: number;
343
+ getResult(index: number): IRValueLike;
344
+ erase(): void;
345
+ };
346
+ type IRBlockLike = {
347
+ arguments: IRValueLike[];
348
+ firstOp: IROperationLike | null;
349
+ lastOp: IROperationLike | null;
350
+ addArgument(type: TensorType): IRValueLike;
351
+ getArgument(index: number): IRValueLike | undefined;
352
+ insertBefore(op: IROperationLike, before: IROperationLike): void;
353
+ pushOp(op: IROperationLike): void;
354
+ removeArguments(indices: Set<number>): void;
355
+ };
356
+ type GraphFunctionLike$1 = {
357
+ name: string;
358
+ inputTypes: readonly TensorType[];
359
+ outputTypes: readonly TensorType[];
360
+ entryBlock: IRBlockLike;
361
+ args: IRValueLike[];
362
+ getReturnOp(): IROperationLike | null;
363
+ };
364
+ type GraphModuleLike = {
365
+ addFunction(func: GraphFunctionLike$1): void;
366
+ functions(): IterableIterator<GraphFunctionLike$1>;
367
+ };
368
+ type CompilableModel = {
369
+ constructor: {
370
+ name?: string;
371
+ };
372
+ forward(...inputs: TensorOutput[]): MaybePromise<TensorOutput | TensorOutput[]>;
373
+ };
374
+ type CompileOptions = Record<string, unknown> & {
375
+ name?: string;
376
+ target?: unknown;
377
+ backward?: unknown;
378
+ dynamicShapes?: DynamicShapes;
379
+ dynamic_shapes?: DynamicShapes;
380
+ shapeBuckets?: readonly (readonly (readonly number[])[])[];
381
+ foldWeights?: boolean;
382
+ quantization?: {
383
+ foldWeights?: boolean;
384
+ };
385
+ mode?: string;
386
+ rematPolicy?: unknown;
387
+ remat?: Record<string, unknown>;
388
+ };
389
+
390
+ type GuardOp = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le';
391
+ type SymbolInfo = {
392
+ hint: number;
393
+ inputIdx: number;
394
+ dimIdx: number;
395
+ };
396
+ type RelationGuard = {
397
+ lhs: SymbolicDim;
398
+ op: GuardOp;
399
+ rhs: SymbolicDim;
400
+ };
401
+ type DivisibleGuard = {
402
+ type: 'divisible';
403
+ sym: SymbolicDim;
404
+ divisor: number;
405
+ };
406
+ type ShapeGuard = RelationGuard | DivisibleGuard;
407
+ declare class ShapeEnv {
408
+ private _symbols;
409
+ private _guards;
410
+ private _bindings;
411
+ private _nextId;
412
+ constructor();
413
+ allocate(inputIdx: number, dimIdx: number, hint: number): string;
414
+ produceShapeSpec(inputIdx: number, concreteShape: readonly number[], dynamicDims?: Set<number> | null): {
415
+ irShape: number[];
416
+ symShape: MutableSymbolicShape;
417
+ };
418
+ guardRelation(lhs: SymbolicDim, op: GuardOp, rhs: SymbolicDim): void;
419
+ guardDivisible(sym: SymbolicDim, divisor: number): void;
420
+ bindInputShapes(inputs: readonly TensorInput$2[]): void;
421
+ evaluateGuards(): {
422
+ passed: true;
423
+ failedGuard: null;
424
+ } | {
425
+ passed: false;
426
+ failedGuard: ShapeGuard;
427
+ };
428
+ resolveSymbolicShape(symShape: SymbolicShape): number[];
429
+ _resolve(expr: SymbolicDim): number;
430
+ get symbols(): Map<string, SymbolInfo>;
431
+ get guards(): ShapeGuard[];
432
+ get bindings(): Map<string, number>;
433
+ }
434
+
435
+ type Shape = readonly number[];
436
+
437
+ declare class Tracer {
438
+ private _name;
439
+ private _shapeEnv;
440
+ private _inputTypes;
441
+ private _inputSymShapes;
442
+ private _outputTypes;
443
+ private _outputSymShapes;
444
+ private _inputs;
445
+ private _func;
446
+ private _builder;
447
+ private _module;
448
+ private _capturedParams;
449
+ private _capturedParamOrder;
450
+ constructor(name?: string);
451
+ get shapeEnv(): ShapeEnv;
452
+ createInput(shape: Shape, dtype: DType, dynamicDims?: Set<number> | null): {
453
+ shape: number[];
454
+ dtype: DType;
455
+ tensorType: TensorType;
456
+ };
457
+ _initGraph(): SymbolicTensor[];
458
+ recordOp(opName: string, tensorArgs: readonly TensorOutput[], attrs: AttrMap): SymbolicTensor | SymbolicTensor[];
459
+ _propagateSymbolicShape(opName: string, op: IROperationLike, tensorArgs: readonly TensorOutput[], resultType: TensorType, resultIndex?: number): SymbolicShape;
460
+ scan(xsValues: readonly TensorOutput[], carryValues: readonly TensorOutput[], stepFn: (carry: SymbolicTensor[], xs: SymbolicTensor[]) => [SymbolicTensor[], SymbolicTensor[]]): [SymbolicTensor[], SymbolicTensor[]];
461
+ captureConstant(tensor: Tensor): SymbolicTensor;
462
+ get capturedParams(): Tensor[];
463
+ markOutput(symbolicTensor: TensorOutput): void;
464
+ markOutputs(symbolicTensors: readonly SymbolicTensor[]): void;
465
+ get outputSymShapes(): SymbolicShape[];
466
+ getGraphModule(): GraphModuleLike;
467
+ activate(): void;
468
+ deactivate(): void;
469
+ private _requireBuilder;
470
+ private _requireFunc;
471
+ private _requireModule;
472
+ }
473
+
474
+ declare class SymbolicTensor extends Tensor {
475
+ private _irValue;
476
+ private _tracer;
477
+ private _symbolicShape;
478
+ constructor(irValue: IRValueLike, shape: readonly number[], dtype: DType, tracer: Tracer, symbolicShape: SymbolicShape);
479
+ get irValue(): IRValueLike;
480
+ get tracer(): Tracer;
481
+ get symbolicShape(): SymbolicShape;
482
+ get dispatchKeySet(): DispatchKeySet;
483
+ get isSymbolic(): boolean;
484
+ }
485
+
486
+ declare const TraceLevel: Readonly<{
487
+ SILENT: 0;
488
+ INFO: 1;
489
+ VERBOSE: 2;
490
+ DEBUG: 3;
491
+ }>;
492
+
493
+ declare function printModule(module: any): string;
494
+
495
+ declare function preloadCudaRuntime(): Promise<any>;
496
+ declare function preloadWebGPU(): Promise<any>;
497
+
498
+ declare function flushWebGPUEager(): Promise<void>;
499
+
500
+ declare enum IValueTag {
501
+ TENSOR = 0,
502
+ INT = 1,
503
+ FLOAT = 2,
504
+ BOOL = 3,
505
+ INT_LIST = 4,
506
+ TENSOR_LIST = 5,
507
+ STRING = 6,
508
+ NONE = 7,
509
+ DEVICE = 8,
510
+ DTYPE = 9
511
+ }
512
+ type IValueTagValue = IValueTag;
513
+ type BoxedFn = (keySet: unknown, stack: IValue[]) => IValue | IValue[] | unknown;
514
+ type UnboxedFn = (keySet: unknown, ...args: unknown[]) => unknown;
515
+ declare class IValue {
516
+ readonly tag: IValueTagValue;
517
+ readonly value: unknown;
518
+ constructor(tag: IValueTagValue, value: unknown);
519
+ static tensor(t: unknown): IValue;
520
+ static int(n: number): IValue;
521
+ static float(n: number): IValue;
522
+ static bool(b: boolean): IValue;
523
+ static intList(arr: unknown[]): IValue;
524
+ static tensorList(arr: unknown[]): IValue;
525
+ static string(s: string): IValue;
526
+ static none(): IValue;
527
+ static device(d: unknown): IValue;
528
+ static dtype(d: unknown): IValue;
529
+ isTensor(): boolean;
530
+ isInt(): boolean;
531
+ isFloat(): boolean;
532
+ isBool(): boolean;
533
+ isIntList(): boolean;
534
+ isTensorList(): boolean;
535
+ isString(): boolean;
536
+ isNone(): boolean;
537
+ toTensor(): unknown;
538
+ toInt(): unknown;
539
+ toFloat(): unknown;
540
+ toBool(): unknown;
541
+ toIntList(): unknown;
542
+ toTensorList(): unknown;
543
+ toString(): unknown;
544
+ toDevice(): unknown;
545
+ toDtype(): unknown;
546
+ }
547
+
548
+ declare class KernelFunction {
549
+ private readonly _boxed;
550
+ private readonly _unboxed;
551
+ constructor(boxed?: BoxedFn, unboxed?: UnboxedFn);
552
+ static fromBoxed(fn: BoxedFn): KernelFunction;
553
+ static fromUnboxed(fn: UnboxedFn): KernelFunction;
554
+ static fromBoth(boxed: BoxedFn, unboxed: UnboxedFn): KernelFunction;
555
+ get isBoxed(): boolean;
556
+ get isUnboxed(): boolean;
557
+ callUnboxed(keySet: unknown, ...args: unknown[]): unknown;
558
+ callBoxed(keySet: unknown, stack: IValue[]): unknown;
559
+ _callBoxedAsUnboxed(keySet: unknown, args: unknown[]): unknown;
560
+ _callUnboxedAsBoxed(keySet: unknown, stack: IValue[]): IValue[];
561
+ }
562
+
563
+ declare enum ArgKind {
564
+ TENSOR = "Tensor",
565
+ SCALAR = "Scalar",
566
+ INT = "int",
567
+ FLOAT = "float",
568
+ BOOL = "bool",
569
+ INT_LIST = "int[]",
570
+ TENSOR_LIST = "Tensor[]",
571
+ DTYPE = "Dtype",
572
+ DEVICE = "Device",
573
+ STRING = "str",
574
+ MEMORY_FORMAT = "MemoryFormat"
575
+ }
576
+ type ArgKindValue = `${ArgKind}`;
577
+ type ReturnSpec = Readonly<{
578
+ kind: ArgKindValue;
579
+ }>;
580
+ declare class SchemaArg {
581
+ readonly name: string;
582
+ readonly kind: ArgKindValue;
583
+ readonly defaultValue: string | null;
584
+ readonly isOut: boolean;
585
+ constructor(name: string, kind: ArgKindValue, defaultValue?: string, isOut?: boolean);
586
+ get isTensor(): boolean;
587
+ }
588
+ declare class OperatorSchema {
589
+ readonly namespace: string;
590
+ readonly name: string;
591
+ readonly overload: string;
592
+ readonly args: readonly SchemaArg[];
593
+ readonly returns: readonly ReturnSpec[];
594
+ private _key;
595
+ private _tensorArgIndices;
596
+ constructor(namespace: string, name: string, overload: string, args: readonly SchemaArg[], returns: readonly ReturnSpec[]);
597
+ qualifiedName(): string;
598
+ key(): string;
599
+ get tensorArgIndices(): readonly number[];
600
+ get numTensorArgs(): number;
601
+ }
602
+
603
+ type KernelLookup = Readonly<{
604
+ key: DispatchKeyValue | -1;
605
+ kernel: KernelFunction;
606
+ }>;
607
+ declare class OperatorEntry {
608
+ private readonly _schema;
609
+ private readonly _kernels;
610
+ private _catchAll;
611
+ constructor(schema: OperatorSchema);
612
+ get schema(): OperatorSchema;
613
+ registerKernel(key: DispatchKeyValue, kernelFn: KernelFunction): void;
614
+ removeKernel(key: DispatchKeyValue): void;
615
+ lookupKernel(key: DispatchKeyValue): KernelFunction | null;
616
+ hasKernel(key: DispatchKeyValue): boolean;
617
+ get catchAll(): KernelFunction | null;
618
+ setCatchAll(kernelFn: KernelFunction): void;
619
+ bestKernel(keySet: DispatchKeySet): KernelLookup | null;
620
+ registeredKeys(): DispatchKeyValue[];
621
+ }
622
+
623
+ declare class OperatorHandle {
624
+ private readonly _entry;
625
+ private readonly _schema;
626
+ constructor(entry: OperatorEntry, schema: OperatorSchema);
627
+ get entry(): OperatorEntry;
628
+ get schema(): OperatorSchema;
629
+ get name(): string;
630
+ get qualifiedName(): string;
631
+ get key(): string;
632
+ get tensorArgIndices(): readonly number[];
633
+ lookupKernel(dispatchKey: DispatchKeyValue): KernelFunction | null;
634
+ bestKernel(keySet: DispatchKeySet): KernelLookup | null;
635
+ }
636
+
637
+ declare class FallbackTable {
638
+ private readonly _kernels;
639
+ constructor();
640
+ register(key: DispatchKeyValue, kernelFn: KernelFunction): void;
641
+ remove(key: DispatchKeyValue): void;
642
+ lookup(key: DispatchKeyValue): KernelFunction | null;
643
+ has(key: DispatchKeyValue): boolean;
644
+ registeredKeys(): DispatchKeyValue[];
645
+ }
646
+
647
+ type DispatchArg = unknown;
648
+ declare class Dispatcher {
649
+ private readonly _entries;
650
+ private readonly _handles;
651
+ private readonly _fallbacks;
652
+ constructor();
653
+ registerOp(schema: OperatorSchema): OperatorHandle;
654
+ findOp(name: string): OperatorHandle | null;
655
+ findOrRegisterOp(name: string): OperatorHandle;
656
+ registerKernel(name: string, key: DispatchKeyValue, kernelFn: KernelFunction): void;
657
+ registerFallback(key: DispatchKeyValue, kernelFn: KernelFunction): void;
658
+ dispatch(handle: OperatorHandle, keySet: DispatchKeySet, ...args: DispatchArg[]): unknown;
659
+ redispatch(handle: OperatorHandle, keySet: DispatchKeySet, ...args: DispatchArg[]): unknown;
660
+ _dispatchInternal(handle: OperatorHandle, keySet: DispatchKeySet, args: DispatchArg[]): unknown;
661
+ callOp(name: string, ...args: DispatchArg[]): unknown;
662
+ listOps(): string[];
663
+ hasOp(name: string): boolean;
664
+ get fallbacks(): FallbackTable;
665
+ }
666
+ declare const dispatcher: Dispatcher;
667
+
668
+ type TensorOptions = {
669
+ shape?: readonly number[];
670
+ dtype?: DType;
671
+ device?: Device;
672
+ requiresGrad?: boolean;
673
+ offset?: number;
674
+ };
675
+ type TensorDataOptions = Pick<TensorOptions, 'dtype' | 'device'>;
676
+
677
+ declare function empty(shape: readonly number[], opts?: TensorOptions): Tensor;
678
+ declare function zeros(shape: readonly number[], opts?: TensorOptions): Tensor;
679
+ declare function ones(shape: readonly number[], opts?: TensorOptions): Tensor;
680
+ declare function full(shape: readonly number[], value: number | bigint, opts?: TensorOptions): Tensor;
681
+ declare function randn(shape: readonly number[], opts?: TensorOptions): Tensor;
682
+ declare function arange(start: number, end?: number, step?: number, opts?: TensorOptions): Tensor;
683
+ declare function eye(n: number, m?: number, opts?: TensorOptions): Tensor;
684
+ declare function randperm(n: number, opts?: TensorOptions): Tensor;
685
+ declare function linspace(start: number, end: number, steps: number, opts?: TensorOptions): Tensor;
686
+
687
+ declare function emptyLike(tensor: Tensor, opts?: TensorOptions): Tensor;
688
+ declare function zerosLike(tensor: Tensor, opts?: TensorOptions): Tensor;
689
+ declare function onesLike(tensor: Tensor, opts?: TensorOptions): Tensor;
690
+ declare function fullLike(tensor: Tensor, value: number | bigint, opts?: TensorOptions): Tensor;
691
+ declare function randnLike(tensor: Tensor, opts?: TensorOptions): Tensor;
692
+
693
+ type NestedNumberArray = readonly (number | NestedNumberArray)[];
694
+ type TensorInput$1 = number | ArrayLike<number> | NestedNumberArray | NumericTypedArray;
695
+ declare function tensor(data: TensorInput$1, opts?: TensorOptions): Tensor;
696
+ declare function fromBuffer(buffer: NumericTypedArray, shape: readonly number[], dtype: DType, opts?: TensorOptions): Tensor;
697
+ declare function scalar(value: number, opts?: TensorOptions): Tensor;
698
+
699
+ type TensorInput = Tensor | number;
700
+ type PaddingArg = readonly number[] | readonly (readonly number[])[];
701
+ declare function _dispatch(name: string, ...args: unknown[]): unknown;
702
+ declare function add(self: Tensor, other: TensorInput): Tensor;
703
+ declare function sub(self: Tensor, other: TensorInput): Tensor;
704
+ declare function mul(self: Tensor, other: TensorInput): Tensor;
705
+ declare function div(self: Tensor, other: TensorInput): Tensor;
706
+ declare function neg(self: Tensor): Tensor;
707
+ declare function pow(self: Tensor, exponent: TensorInput): Tensor;
708
+ declare function remainder(self: Tensor, other: TensorInput): Tensor;
709
+ declare function maximum(self: Tensor, other: TensorInput): Tensor;
710
+ declare function minimum(self: Tensor, other: TensorInput): Tensor;
711
+ declare function exp(self: Tensor): Tensor;
712
+ declare function log(self: Tensor): Tensor;
713
+ declare function sqrt(self: Tensor): Tensor;
714
+ declare function rsqrt(self: Tensor): Tensor;
715
+ declare function abs(self: Tensor): Tensor;
716
+ declare function sin(self: Tensor): Tensor;
717
+ declare function cos(self: Tensor): Tensor;
718
+ declare function tanh$1(self: Tensor): Tensor;
719
+ declare function erf(self: Tensor): Tensor;
720
+ declare function erfc(self: Tensor): Tensor;
721
+ declare function lgamma(self: Tensor): Tensor;
722
+ declare function gamma(self: Tensor): Tensor;
723
+ declare function sigmoid$1(self: Tensor): Tensor;
724
+ declare function relu$1(self: Tensor): Tensor;
725
+ declare function gelu$1(self: Tensor): Tensor;
726
+ declare function silu$1(self: Tensor): Tensor;
727
+ declare function sign(self: Tensor): Tensor;
728
+ declare function floor(self: Tensor): Tensor;
729
+ declare function ceil(self: Tensor): Tensor;
730
+ declare function eq(self: Tensor, other: TensorInput): Tensor;
731
+ declare function ne(self: Tensor, other: TensorInput): Tensor;
732
+ declare function lt(self: Tensor, other: TensorInput): Tensor;
733
+ declare function le(self: Tensor, other: TensorInput): Tensor;
734
+ declare function gt(self: Tensor, other: TensorInput): Tensor;
735
+ declare function ge(self: Tensor, other: TensorInput): Tensor;
736
+ declare function where(condition: Tensor, self: Tensor, other: Tensor): Tensor;
737
+ declare function clamp(self: Tensor, min: TensorInput, max: TensorInput): Tensor;
738
+ declare function pad(self: Tensor, low: readonly number[], high: readonly number[], value?: TensorInput): Tensor;
739
+ declare function one_hot(indices: Tensor, depth: number): Tensor;
740
+ declare function index_select(self: Tensor, dim: number, index: Tensor): Tensor;
741
+ declare function gather(self: Tensor, dim: number, index: Tensor): Tensor;
742
+ declare function scatter_add(self: Tensor, dim: number, index: Tensor, src: Tensor): Tensor;
743
+ declare function scatter(self: Tensor, dim: number, index: Tensor, src: Tensor): Tensor;
744
+ declare function sum(self: Tensor, dim?: number | readonly number[] | null, keepdim?: boolean): Tensor;
745
+ declare function mean(self: Tensor, dim?: number | readonly number[] | null, keepdim?: boolean): Tensor;
746
+ declare function max(self: Tensor, dim?: number | readonly number[] | null, keepdim?: boolean): Tensor;
747
+ declare function min(self: Tensor, dim?: number | readonly number[] | null, keepdim?: boolean): Tensor;
748
+ declare function argmax(self: Tensor, dim?: number | null, keepdim?: boolean): Tensor;
749
+ declare function argmin(self: Tensor, dim?: number | null, keepdim?: boolean): Tensor;
750
+ declare function prod(self: Tensor, dim?: number | readonly number[] | null, keepdim?: boolean): Tensor;
751
+ declare function matmul(self: Tensor, other: Tensor): Tensor;
752
+ declare function dot(self: Tensor, other: Tensor): Tensor;
753
+ declare function cat(tensors: readonly Tensor[], dim: number): Tensor;
754
+ declare function stack(tensors: readonly Tensor[], dim: number): Tensor;
755
+ declare function clone(self: Tensor): Tensor;
756
+ declare function fill(self: Tensor, value: number | bigint): Tensor;
757
+ declare function reshape(self: Tensor, shape: readonly number[]): Tensor;
758
+ declare function transpose(self: Tensor, dim0: number, dim1: number): Tensor;
759
+ declare function permute(self: Tensor, dims: readonly number[]): Tensor;
760
+ declare function broadcast_in_dim(self: Tensor, resultShape: readonly number[], broadcastDimensions: readonly number[]): Tensor;
761
+ declare function expand(self: Tensor, shape: readonly number[]): Tensor;
762
+ declare function slice(self: Tensor, dim: number, start: number, end?: number | null, step?: number): Tensor;
763
+ declare function unsqueeze(self: Tensor, dim: number): Tensor;
764
+ declare function squeeze(self: Tensor, dim?: number | null): Tensor;
765
+ declare function narrow(self: Tensor, dim: number, start: number, length: number): Tensor;
766
+ declare function select(self: Tensor, dim: number, index: number): Tensor;
767
+ declare function contiguous(self: Tensor): Tensor;
768
+ declare function repeat(self: Tensor, reps: readonly number[]): Tensor;
769
+ declare function tile(self: Tensor, reps: readonly number[]): Tensor;
770
+ declare function split(self: Tensor, sizeOrSizes: number | readonly number[], dim?: number): Tensor[];
771
+ declare function chunk(self: Tensor, chunks: number, dim?: number): Tensor[];
772
+ declare function roll(self: Tensor, shift: number, dim?: number): Tensor;
773
+ declare function flip(self: Tensor, dims: number | readonly number[]): Tensor;
774
+ declare function cumsum(self: Tensor, dim?: number): Tensor;
775
+ declare function sort(self: Tensor, dim?: number, descending?: boolean): Tensor;
776
+ declare function argsort(self: Tensor, dim?: number, descending?: boolean): Tensor;
777
+ declare function topk(self: Tensor, k: number, dim?: number, largest?: boolean): Tensor[];
778
+ declare function softmax$1(self: Tensor, dim: number): Tensor;
779
+ declare function log_softmax$1(self: Tensor, dim: number): Tensor;
780
+ declare function layer_norm(input: Tensor, weight: Tensor, bias: Tensor, axis: number, eps: number): Tensor;
781
+ declare function batch_norm(input: Tensor, weight: Tensor, bias: Tensor, mean: Tensor, variance: Tensor, axis: number, eps: number): Tensor;
782
+ declare function conv2d(input: Tensor, weight: Tensor, strides: readonly number[], padding: PaddingArg, dilation: readonly number[], groups: number): Tensor;
783
+ declare function pool2d(input: Tensor, poolType: string, kernelSize: readonly number[], strides: readonly number[], padding: PaddingArg): Tensor;
784
+ declare function embedding(weight: Tensor, indices: Tensor): Tensor;
785
+
786
+ declare const ops__dispatch: typeof _dispatch;
787
+ declare const ops_abs: typeof abs;
788
+ declare const ops_add: typeof add;
789
+ declare const ops_argmax: typeof argmax;
790
+ declare const ops_argmin: typeof argmin;
791
+ declare const ops_argsort: typeof argsort;
792
+ declare const ops_batch_norm: typeof batch_norm;
793
+ declare const ops_broadcast_in_dim: typeof broadcast_in_dim;
794
+ declare const ops_cat: typeof cat;
795
+ declare const ops_ceil: typeof ceil;
796
+ declare const ops_chunk: typeof chunk;
797
+ declare const ops_clamp: typeof clamp;
798
+ declare const ops_clone: typeof clone;
799
+ declare const ops_contiguous: typeof contiguous;
800
+ declare const ops_conv2d: typeof conv2d;
801
+ declare const ops_cos: typeof cos;
802
+ declare const ops_cumsum: typeof cumsum;
803
+ declare const ops_div: typeof div;
804
+ declare const ops_dot: typeof dot;
805
+ declare const ops_embedding: typeof embedding;
806
+ declare const ops_eq: typeof eq;
807
+ declare const ops_erf: typeof erf;
808
+ declare const ops_erfc: typeof erfc;
809
+ declare const ops_exp: typeof exp;
810
+ declare const ops_expand: typeof expand;
811
+ declare const ops_fill: typeof fill;
812
+ declare const ops_flip: typeof flip;
813
+ declare const ops_floor: typeof floor;
814
+ declare const ops_gamma: typeof gamma;
815
+ declare const ops_gather: typeof gather;
816
+ declare const ops_ge: typeof ge;
817
+ declare const ops_gt: typeof gt;
818
+ declare const ops_index_select: typeof index_select;
819
+ declare const ops_layer_norm: typeof layer_norm;
820
+ declare const ops_le: typeof le;
821
+ declare const ops_lgamma: typeof lgamma;
822
+ declare const ops_log: typeof log;
823
+ declare const ops_lt: typeof lt;
824
+ declare const ops_matmul: typeof matmul;
825
+ declare const ops_max: typeof max;
826
+ declare const ops_maximum: typeof maximum;
827
+ declare const ops_mean: typeof mean;
828
+ declare const ops_min: typeof min;
829
+ declare const ops_minimum: typeof minimum;
830
+ declare const ops_mul: typeof mul;
831
+ declare const ops_narrow: typeof narrow;
832
+ declare const ops_ne: typeof ne;
833
+ declare const ops_neg: typeof neg;
834
+ declare const ops_one_hot: typeof one_hot;
835
+ declare const ops_pad: typeof pad;
836
+ declare const ops_permute: typeof permute;
837
+ declare const ops_pool2d: typeof pool2d;
838
+ declare const ops_pow: typeof pow;
839
+ declare const ops_prod: typeof prod;
840
+ declare const ops_remainder: typeof remainder;
841
+ declare const ops_repeat: typeof repeat;
842
+ declare const ops_reshape: typeof reshape;
843
+ declare const ops_roll: typeof roll;
844
+ declare const ops_rsqrt: typeof rsqrt;
845
+ declare const ops_scatter: typeof scatter;
846
+ declare const ops_scatter_add: typeof scatter_add;
847
+ declare const ops_select: typeof select;
848
+ declare const ops_sign: typeof sign;
849
+ declare const ops_sin: typeof sin;
850
+ declare const ops_slice: typeof slice;
851
+ declare const ops_sort: typeof sort;
852
+ declare const ops_split: typeof split;
853
+ declare const ops_sqrt: typeof sqrt;
854
+ declare const ops_squeeze: typeof squeeze;
855
+ declare const ops_stack: typeof stack;
856
+ declare const ops_sub: typeof sub;
857
+ declare const ops_sum: typeof sum;
858
+ declare const ops_tile: typeof tile;
859
+ declare const ops_topk: typeof topk;
860
+ declare const ops_transpose: typeof transpose;
861
+ declare const ops_unsqueeze: typeof unsqueeze;
862
+ declare const ops_where: typeof where;
863
+ declare namespace ops {
864
+ export { ops__dispatch as _dispatch, ops_abs as abs, ops_add as add, ops_argmax as argmax, ops_argmin as argmin, ops_argsort as argsort, ops_batch_norm as batch_norm, ops_broadcast_in_dim as broadcast_in_dim, ops_cat as cat, ops_ceil as ceil, ops_chunk as chunk, ops_clamp as clamp, ops_clone as clone, ops_contiguous as contiguous, ops_conv2d as conv2d, ops_cos as cos, ops_cumsum as cumsum, ops_div as div, ops_dot as dot, ops_embedding as embedding, ops_eq as eq, ops_erf as erf, ops_erfc as erfc, ops_exp as exp, ops_expand as expand, ops_fill as fill, ops_flip as flip, ops_floor as floor, ops_gamma as gamma, ops_gather as gather, ops_ge as ge, gelu$1 as gelu, ops_gt as gt, ops_index_select as index_select, ops_layer_norm as layer_norm, ops_le as le, ops_lgamma as lgamma, ops_log as log, log_softmax$1 as log_softmax, ops_lt as lt, ops_matmul as matmul, ops_max as max, ops_maximum as maximum, ops_mean as mean, ops_min as min, ops_minimum as minimum, ops_mul as mul, ops_narrow as narrow, ops_ne as ne, ops_neg as neg, ops_one_hot as one_hot, ops_pad as pad, ops_permute as permute, ops_pool2d as pool2d, ops_pow as pow, ops_prod as prod, relu$1 as relu, ops_remainder as remainder, ops_repeat as repeat, ops_reshape as reshape, ops_roll as roll, ops_rsqrt as rsqrt, ops_scatter as scatter, ops_scatter_add as scatter_add, ops_select as select, sigmoid$1 as sigmoid, ops_sign as sign, silu$1 as silu, ops_sin as sin, ops_slice as slice, softmax$1 as softmax, ops_sort as sort, ops_split as split, ops_sqrt as sqrt, ops_squeeze as squeeze, ops_stack as stack, ops_sub as sub, ops_sum as sum, tanh$1 as tanh, ops_tile as tile, ops_topk as topk, ops_transpose as transpose, ops_unsqueeze as unsqueeze, ops_where as where };
865
+ }
866
+
867
+ type NNTensor = Tensor & {
868
+ isSymbolic?: boolean;
869
+ reshape(shape: readonly number[]): NNTensor;
870
+ transpose(dim0: number, dim1: number): NNTensor;
871
+ permute(dims: readonly number[]): NNTensor;
872
+ unsqueeze(dim: number): NNTensor;
873
+ detach(): NNTensor;
874
+ };
875
+ type OptionalTensor = NNTensor | null;
876
+ type TensorPair = [NNTensor, NNTensor];
877
+
878
+ declare class Parameter extends Tensor {
879
+ constructor(data: Tensor | TensorImpl, requiresGrad?: boolean);
880
+ get isParameter(): true;
881
+ }
882
+
883
+ type StateDictValue = Tensor | {
884
+ _impl?: {
885
+ storage: {
886
+ data: NumericTypedArray | null;
887
+ };
888
+ };
889
+ data?: NumericTypedArray | null;
890
+ };
891
+ declare class Module {
892
+ [key: string]: unknown;
893
+ protected _parameters: Map<string, Parameter | null>;
894
+ protected _buffers: Map<string, Tensor | null>;
895
+ protected _modules: Map<string, Module | null>;
896
+ protected _training: boolean;
897
+ private _detected?;
898
+ constructor();
899
+ forward(..._inputs: unknown[]): unknown;
900
+ call(...inputs: unknown[]): unknown;
901
+ registerParameter(name: string, param: Parameter | null): void;
902
+ registerBuffer(name: string, tensor: Tensor | null): void;
903
+ registerModule(name: string, module: Module | null): void;
904
+ parameters(recurse?: boolean): Generator<Parameter>;
905
+ namedParameters(prefix?: string, recurse?: boolean): Generator<[string, Parameter]>;
906
+ buffers(recurse?: boolean): Generator<Tensor>;
907
+ children(): Generator<Module>;
908
+ namedChildren(): Generator<[string, Module]>;
909
+ modules(): Generator<Module>;
910
+ namedModules(prefix?: string): Generator<[string, Module]>;
911
+ stateDict(prefix?: string): Map<string, Tensor>;
912
+ loadStateDict(dict: Map<string, StateDictValue>): void;
913
+ train(mode?: boolean): this;
914
+ eval(): this;
915
+ get training(): boolean;
916
+ to(device: Device | string): this;
917
+ apply(fn: (module: Module) => void): this;
918
+ zeroGrad(): this;
919
+ _autoDetect(): void;
920
+ toString(): string;
921
+ _buildRepr(indent: string): string;
922
+ }
923
+
924
+ type KaimingMode = 'fan_in' | 'fan_out';
925
+ declare function _calculateFanInFanOut(tensor: Tensor): {
926
+ fanIn: number;
927
+ fanOut: number;
928
+ };
929
+ declare function resetLinearParameters(weight: Tensor, bias?: Tensor | null): void;
930
+ declare function uniform_<T extends Tensor>(tensor: T, a?: number, b?: number): T;
931
+ declare function normal_<T extends Tensor>(tensor: T, mean?: number, std?: number): T;
932
+ declare function zeros_<T extends Tensor>(tensor: T): T;
933
+ declare function ones_<T extends Tensor>(tensor: T): T;
934
+ declare function constant_<T extends Tensor>(tensor: T, val: number): T;
935
+ declare function xavier_uniform_<T extends Tensor>(tensor: T, gain?: number): T;
936
+ declare function xavier_normal_<T extends Tensor>(tensor: T, gain?: number): T;
937
+ declare function kaiming_uniform_<T extends Tensor>(tensor: T, a?: number, mode?: KaimingMode, nonlinearity?: string): T;
938
+ declare function kaiming_normal_<T extends Tensor>(tensor: T, a?: number, mode?: KaimingMode, nonlinearity?: string): T;
939
+
940
+ declare const init__calculateFanInFanOut: typeof _calculateFanInFanOut;
941
+ declare const init_constant_: typeof constant_;
942
+ declare const init_kaiming_normal_: typeof kaiming_normal_;
943
+ declare const init_kaiming_uniform_: typeof kaiming_uniform_;
944
+ declare const init_normal_: typeof normal_;
945
+ declare const init_ones_: typeof ones_;
946
+ declare const init_resetLinearParameters: typeof resetLinearParameters;
947
+ declare const init_uniform_: typeof uniform_;
948
+ declare const init_xavier_normal_: typeof xavier_normal_;
949
+ declare const init_xavier_uniform_: typeof xavier_uniform_;
950
+ declare const init_zeros_: typeof zeros_;
951
+ declare namespace init {
952
+ export { init__calculateFanInFanOut as _calculateFanInFanOut, init_constant_ as constant_, init_kaiming_normal_ as kaiming_normal_, init_kaiming_uniform_ as kaiming_uniform_, init_normal_ as normal_, init_ones_ as ones_, init_resetLinearParameters as resetLinearParameters, init_uniform_ as uniform_, init_xavier_normal_ as xavier_normal_, init_xavier_uniform_ as xavier_uniform_, init_zeros_ as zeros_ };
953
+ }
954
+
955
+ declare function relu(input: Tensor): Tensor;
956
+ declare function gelu(input: Tensor): Tensor;
957
+ declare function silu(input: Tensor): Tensor;
958
+ declare function sigmoid(input: Tensor): Tensor;
959
+ declare function tanh(input: Tensor): Tensor;
960
+ declare function softmax(input: Tensor, dim?: number): Tensor;
961
+ declare function log_softmax(input: Tensor, dim?: number): Tensor;
962
+ declare function leaky_relu(input: Tensor, negativeSlope?: number): Tensor;
963
+ declare function elu(input: Tensor, alpha?: number): Tensor;
964
+
965
+ declare const activation_elu: typeof elu;
966
+ declare const activation_gelu: typeof gelu;
967
+ declare const activation_leaky_relu: typeof leaky_relu;
968
+ declare const activation_log_softmax: typeof log_softmax;
969
+ declare const activation_relu: typeof relu;
970
+ declare const activation_sigmoid: typeof sigmoid;
971
+ declare const activation_silu: typeof silu;
972
+ declare const activation_softmax: typeof softmax;
973
+ declare const activation_tanh: typeof tanh;
974
+ declare namespace activation {
975
+ export { activation_elu as elu, activation_gelu as gelu, activation_leaky_relu as leaky_relu, activation_log_softmax as log_softmax, activation_relu as relu, activation_sigmoid as sigmoid, activation_silu as silu, activation_softmax as softmax, activation_tanh as tanh };
976
+ }
977
+
978
+ type Pair2$1 = [number, number];
979
+ type PairPadding2d$1 = [Pair2$1, Pair2$1] | Pair2$1;
980
+ type ConvSize2d = number | Pair2$1;
981
+ type ConvPadding2d = number | PairPadding2d$1;
982
+
983
+ type Pair2 = [number, number];
984
+ type PairPadding2d = [Pair2, Pair2] | Pair2;
985
+ type Pool2dSize = number | Pair2;
986
+ type Pool2dPadding = number | PairPadding2d;
987
+
988
+ type LossReduction = 'mean' | 'sum' | 'none';
989
+
990
+ declare class Linear extends Module {
991
+ inFeatures: number;
992
+ outFeatures: number;
993
+ weight: Parameter;
994
+ bias: Parameter | null;
995
+ constructor(inFeatures: number, outFeatures: number, bias?: boolean);
996
+ _resetParameters(): void;
997
+ forward(input: NNTensor): NNTensor;
998
+ }
999
+
1000
+ type Conv2dOptions = {
1001
+ stride?: ConvSize2d;
1002
+ padding?: ConvPadding2d;
1003
+ dilation?: ConvSize2d;
1004
+ groups?: number;
1005
+ bias?: boolean;
1006
+ };
1007
+ type Conv1dOptions = {
1008
+ stride?: number | readonly number[];
1009
+ padding?: number | Pair2$1;
1010
+ dilation?: number | readonly number[];
1011
+ groups?: number;
1012
+ bias?: boolean;
1013
+ };
1014
+ declare class Conv2d extends Module {
1015
+ inChannels: number;
1016
+ outChannels: number;
1017
+ kernelSize: Pair2$1;
1018
+ stride: Pair2$1;
1019
+ padding: ConvPadding2d;
1020
+ dilation: Pair2$1;
1021
+ groups: number;
1022
+ weight: Parameter;
1023
+ bias: Parameter | null;
1024
+ constructor(inChannels: number, outChannels: number, kernelSize: ConvSize2d, opts?: Conv2dOptions);
1025
+ _resetParameters(): void;
1026
+ forward(input: Tensor): Tensor;
1027
+ }
1028
+ declare class Conv1d extends Module {
1029
+ inChannels: number;
1030
+ outChannels: number;
1031
+ kernelSize: number;
1032
+ stride: number | readonly number[];
1033
+ padding: number | Pair2$1;
1034
+ dilation: number | readonly number[];
1035
+ groups: number;
1036
+ weight: Parameter;
1037
+ bias: Parameter | null;
1038
+ constructor(inChannels: number, outChannels: number, kernelSize: number | readonly number[], opts?: Conv1dOptions);
1039
+ forward(input: Tensor): Tensor;
1040
+ }
1041
+
1042
+ declare class ReLU extends Module {
1043
+ forward(input: Tensor): Tensor;
1044
+ }
1045
+ declare class GELU extends Module {
1046
+ forward(input: Tensor): Tensor;
1047
+ }
1048
+ declare class SiLU extends Module {
1049
+ forward(input: Tensor): Tensor;
1050
+ }
1051
+ declare class Sigmoid extends Module {
1052
+ forward(input: Tensor): Tensor;
1053
+ }
1054
+ declare class Tanh extends Module {
1055
+ forward(input: Tensor): Tensor;
1056
+ }
1057
+ declare class LeakyReLU extends Module {
1058
+ negativeSlope: number;
1059
+ constructor(negativeSlope?: number);
1060
+ forward(input: Tensor): Tensor;
1061
+ }
1062
+ declare class ELU extends Module {
1063
+ alpha: number;
1064
+ constructor(alpha?: number);
1065
+ forward(input: Tensor): Tensor;
1066
+ }
1067
+ declare class Softmax extends Module {
1068
+ dim: number;
1069
+ constructor(dim?: number);
1070
+ forward(input: Tensor): Tensor;
1071
+ }
1072
+ declare class LogSoftmax extends Module {
1073
+ dim: number;
1074
+ constructor(dim?: number);
1075
+ forward(input: Tensor): Tensor;
1076
+ }
1077
+
1078
+ declare class LayerNorm extends Module {
1079
+ normalizedShape: number[];
1080
+ eps: number;
1081
+ weight: Parameter | null;
1082
+ bias: Parameter | null;
1083
+ constructor(normalizedShape: number | readonly number[], eps?: number, elementwiseAffine?: boolean);
1084
+ forward(input: NNTensor): NNTensor;
1085
+ }
1086
+ declare class GroupNorm extends Module {
1087
+ numGroups: number;
1088
+ numChannels: number;
1089
+ eps: number;
1090
+ weight: Parameter | null;
1091
+ bias: Parameter | null;
1092
+ constructor(numGroups: number, numChannels: number, eps?: number, affine?: boolean);
1093
+ forward(input: NNTensor): NNTensor;
1094
+ }
1095
+ declare class BatchNorm1d extends Module {
1096
+ numFeatures: number;
1097
+ eps: number;
1098
+ weight: Parameter | null;
1099
+ bias: Parameter | null;
1100
+ runningMean: NNTensor;
1101
+ runningVar: NNTensor;
1102
+ constructor(numFeatures: number, eps?: number, affine?: boolean);
1103
+ forward(input: NNTensor): NNTensor;
1104
+ }
1105
+ declare class BatchNorm2d extends BatchNorm1d {
1106
+ constructor(numFeatures: number, eps?: number, affine?: boolean);
1107
+ }
1108
+
1109
+ declare class MaxPool2d extends Module {
1110
+ kernelSize: Pair2;
1111
+ stride: Pair2;
1112
+ padding: Pool2dPadding;
1113
+ constructor(kernelSize: Pool2dSize, stride?: Pool2dSize | null, padding?: Pool2dPadding);
1114
+ forward(input: Tensor): Tensor;
1115
+ }
1116
+ declare class AvgPool2d extends Module {
1117
+ kernelSize: Pair2;
1118
+ stride: Pair2;
1119
+ padding: Pool2dPadding;
1120
+ constructor(kernelSize: Pool2dSize, stride?: Pool2dSize | null, padding?: Pool2dPadding);
1121
+ forward(input: Tensor): Tensor;
1122
+ }
1123
+ declare class AdaptiveAvgPool2d extends Module {
1124
+ outputSize: Pair2;
1125
+ constructor(outputSize: Pool2dSize);
1126
+ forward(input: Tensor): Tensor;
1127
+ }
1128
+
1129
+ declare class Dropout extends Module {
1130
+ p: number;
1131
+ constructor(p?: number);
1132
+ forward(input: Tensor): Tensor;
1133
+ }
1134
+
1135
+ declare class MSELoss extends Module {
1136
+ reduction: LossReduction;
1137
+ constructor(reduction?: LossReduction);
1138
+ forward(input: Tensor, target: Tensor): Tensor;
1139
+ }
1140
+ declare class CrossEntropyLoss extends Module {
1141
+ reduction: LossReduction;
1142
+ ignoreIndex: number;
1143
+ constructor(reduction?: LossReduction, ignoreIndex?: number);
1144
+ forward(input: Tensor, target: Tensor): Tensor;
1145
+ }
1146
+ declare class NLLLoss extends Module {
1147
+ reduction: LossReduction;
1148
+ ignoreIndex: number;
1149
+ constructor(reduction?: LossReduction, ignoreIndex?: number);
1150
+ forward(input: Tensor, target: Tensor): Tensor;
1151
+ }
1152
+ declare class BCELoss extends Module {
1153
+ reduction: LossReduction;
1154
+ constructor(reduction?: LossReduction);
1155
+ forward(input: Tensor, target: Tensor): Tensor;
1156
+ }
1157
+
1158
+ declare class Embedding extends Module {
1159
+ numEmbeddings: number;
1160
+ embeddingDim: number;
1161
+ weight: Parameter;
1162
+ constructor(numEmbeddings: number, embeddingDim: number);
1163
+ forward(indices: Tensor): Tensor;
1164
+ }
1165
+
1166
+ declare class GRUCell extends Module {
1167
+ inputSize: number;
1168
+ hiddenSize: number;
1169
+ x2h: Linear;
1170
+ h2h: Linear;
1171
+ constructor(inputSize: number, hiddenSize: number, bias?: boolean);
1172
+ forward(input: NNTensor, hidden?: NNTensor | null): NNTensor;
1173
+ }
1174
+ declare class GRU extends Module {
1175
+ inputSize: number;
1176
+ hiddenSize: number;
1177
+ numLayers: number;
1178
+ batchFirst: boolean;
1179
+ cells: GRUCell[];
1180
+ constructor(inputSize: number, hiddenSize: number, numLayers?: number, batchFirst?: boolean, bias?: boolean);
1181
+ forward(input: NNTensor, h0?: NNTensor | null): [NNTensor, NNTensor];
1182
+ }
1183
+
1184
+ declare class LSTMCell extends Module {
1185
+ inputSize: number;
1186
+ hiddenSize: number;
1187
+ x2h: Linear;
1188
+ h2h: Linear;
1189
+ constructor(inputSize: number, hiddenSize: number, bias?: boolean);
1190
+ forward(input: NNTensor, state?: TensorPair | null): TensorPair;
1191
+ }
1192
+ declare class LSTM extends Module {
1193
+ inputSize: number;
1194
+ hiddenSize: number;
1195
+ numLayers: number;
1196
+ batchFirst: boolean;
1197
+ cells: LSTMCell[];
1198
+ constructor(inputSize: number, hiddenSize: number, numLayers?: number, batchFirst?: boolean, bias?: boolean);
1199
+ forward(input: NNTensor, state?: TensorPair | null): [NNTensor, TensorPair];
1200
+ }
1201
+
1202
+ declare class Sequential extends Module {
1203
+ private _length;
1204
+ constructor(...modules: Module[]);
1205
+ forward(input: unknown): unknown;
1206
+ get length(): number;
1207
+ [Symbol.iterator](): Generator<Module>;
1208
+ push(module: Module): this;
1209
+ }
1210
+ declare class ModuleList extends Module {
1211
+ private _list;
1212
+ constructor(modules?: Module[]);
1213
+ get length(): number;
1214
+ get(i: number): Module | undefined;
1215
+ push(module: Module): this;
1216
+ [Symbol.iterator](): Generator<Module>;
1217
+ forward(): never;
1218
+ }
1219
+ declare class ModuleDict extends Module {
1220
+ private _dict;
1221
+ constructor(modules?: Record<string, Module>);
1222
+ get(key: string): Module | undefined;
1223
+ set(key: string, module: Module): this;
1224
+ has(key: string): boolean;
1225
+ get size(): number;
1226
+ keys(): Generator<string>;
1227
+ values(): Generator<Module>;
1228
+ [Symbol.iterator](): Generator<[string, Module]>;
1229
+ forward(): never;
1230
+ }
1231
+
1232
+ declare class Flatten extends Module {
1233
+ startDim: number;
1234
+ endDim: number;
1235
+ constructor(startDim?: number, endDim?: number);
1236
+ forward(input: Tensor): Tensor;
1237
+ }
1238
+
1239
+ type ActivationName = 'relu' | 'gelu' | string;
1240
+ type ActivationFn = (input: NNTensor) => NNTensor;
1241
+ declare class MultiheadAttention extends Module {
1242
+ embedDim: number;
1243
+ numHeads: number;
1244
+ headDim: number;
1245
+ batchFirst: boolean;
1246
+ dropout: number;
1247
+ qProj: Linear;
1248
+ kProj: Linear;
1249
+ vProj: Linear;
1250
+ outProj: Linear;
1251
+ constructor(embedDim: number, numHeads: number, dropout?: number, bias?: boolean, kdim?: number | null, vdim?: number | null, batchFirst?: boolean);
1252
+ forward(query: NNTensor, key: NNTensor, value: NNTensor, attnMask?: OptionalTensor, keyPaddingMask?: OptionalTensor, isCausal?: boolean): NNTensor;
1253
+ }
1254
+ declare class TransformerEncoderLayer extends Module {
1255
+ selfAttn: MultiheadAttention;
1256
+ linear1: Linear;
1257
+ linear2: Linear;
1258
+ norm1: LayerNorm;
1259
+ norm2: LayerNorm;
1260
+ dropout1: Dropout;
1261
+ dropout2: Dropout;
1262
+ dropoutFFN: Dropout;
1263
+ _activation: ActivationFn;
1264
+ _activationName: ActivationName;
1265
+ normFirst: boolean;
1266
+ _dModel: number;
1267
+ _nhead: number;
1268
+ _dimFeedforward: number;
1269
+ _dropout: number;
1270
+ _layerNormEps: number;
1271
+ _batchFirst: boolean;
1272
+ constructor(dModel: number, nhead: number, dimFeedforward?: number, dropout?: number, activation?: ActivationName, layerNormEps?: number, batchFirst?: boolean, normFirst?: boolean);
1273
+ forward(src: NNTensor, srcMask?: OptionalTensor, srcKeyPaddingMask?: OptionalTensor, isCausal?: boolean): NNTensor;
1274
+ _forwardPostNorm(src: NNTensor, srcMask: OptionalTensor, srcKeyPaddingMask: OptionalTensor, isCausal: boolean): NNTensor;
1275
+ _forwardPreNorm(src: NNTensor, srcMask: OptionalTensor, srcKeyPaddingMask: OptionalTensor, isCausal: boolean): NNTensor;
1276
+ }
1277
+ declare class TransformerDecoderLayer extends Module {
1278
+ selfAttn: MultiheadAttention;
1279
+ crossAttn: MultiheadAttention;
1280
+ linear1: Linear;
1281
+ linear2: Linear;
1282
+ norm1: LayerNorm;
1283
+ norm2: LayerNorm;
1284
+ norm3: LayerNorm;
1285
+ dropout1: Dropout;
1286
+ dropout2: Dropout;
1287
+ dropout3: Dropout;
1288
+ dropoutFFN: Dropout;
1289
+ _activation: ActivationFn;
1290
+ _activationName: ActivationName;
1291
+ normFirst: boolean;
1292
+ _dModel: number;
1293
+ _nhead: number;
1294
+ _dimFeedforward: number;
1295
+ _dropout: number;
1296
+ _layerNormEps: number;
1297
+ _batchFirst: boolean;
1298
+ constructor(dModel: number, nhead: number, dimFeedforward?: number, dropout?: number, activation?: ActivationName, layerNormEps?: number, batchFirst?: boolean, normFirst?: boolean);
1299
+ forward(tgt: NNTensor, memory: NNTensor, tgtMask?: OptionalTensor, memoryMask?: OptionalTensor, tgtKeyPaddingMask?: OptionalTensor, memoryKeyPaddingMask?: OptionalTensor, isCausal?: boolean): NNTensor;
1300
+ _forwardPostNorm(tgt: NNTensor, memory: NNTensor, tgtMask: OptionalTensor, memoryMask: OptionalTensor, tgtKeyPaddingMask: OptionalTensor, memoryKeyPaddingMask: OptionalTensor, isCausal: boolean): NNTensor;
1301
+ _forwardPreNorm(tgt: NNTensor, memory: NNTensor, tgtMask: OptionalTensor, memoryMask: OptionalTensor, tgtKeyPaddingMask: OptionalTensor, memoryKeyPaddingMask: OptionalTensor, isCausal: boolean): NNTensor;
1302
+ }
1303
+ declare class TransformerEncoder extends Module {
1304
+ layers: ModuleList;
1305
+ norm: LayerNorm | null;
1306
+ constructor(encoderLayer: TransformerEncoderLayer, numLayers: number, norm?: LayerNorm | null);
1307
+ forward(src: NNTensor, mask?: OptionalTensor, srcKeyPaddingMask?: OptionalTensor, isCausal?: boolean): NNTensor;
1308
+ }
1309
+ declare class TransformerDecoder extends Module {
1310
+ layers: ModuleList;
1311
+ norm: LayerNorm | null;
1312
+ constructor(decoderLayer: TransformerDecoderLayer, numLayers: number, norm?: LayerNorm | null);
1313
+ forward(tgt: NNTensor, memory: NNTensor, tgtMask?: OptionalTensor, memoryMask?: OptionalTensor, tgtKeyPaddingMask?: OptionalTensor, memoryKeyPaddingMask?: OptionalTensor, isCausal?: boolean): NNTensor;
1314
+ }
1315
+ declare class Transformer extends Module {
1316
+ encoder: TransformerEncoder;
1317
+ decoder: TransformerDecoder;
1318
+ dModel: number;
1319
+ constructor({ dModel, nhead, numEncoderLayers, numDecoderLayers, dimFeedforward, dropout, activation, batchFirst, normFirst, layerNormEps, }?: {
1320
+ dModel?: number;
1321
+ nhead?: number;
1322
+ numEncoderLayers?: number;
1323
+ numDecoderLayers?: number;
1324
+ dimFeedforward?: number;
1325
+ dropout?: number;
1326
+ activation?: ActivationName;
1327
+ batchFirst?: boolean;
1328
+ normFirst?: boolean;
1329
+ layerNormEps?: number;
1330
+ });
1331
+ forward(src: NNTensor, tgt: NNTensor, srcMask?: OptionalTensor, tgtMask?: OptionalTensor, memoryMask?: OptionalTensor, srcKeyPaddingMask?: OptionalTensor, tgtKeyPaddingMask?: OptionalTensor, memoryKeyPaddingMask?: OptionalTensor): NNTensor;
1332
+ static generateSquareSubsequentMask(sz: number): NNTensor;
1333
+ }
1334
+
1335
+ declare class PositionalEncoding extends Module {
1336
+ dropoutLayer: Dropout;
1337
+ pe: Tensor;
1338
+ constructor(dModel: number, maxLen?: number, dropout?: number);
1339
+ forward(x: Tensor): Tensor;
1340
+ }
1341
+
1342
+ declare const F: {
1343
+ scaled_dot_product_attention(query: NNTensor, key: NNTensor, value: NNTensor, attnMask?: OptionalTensor, dropoutP?: number, isCausal?: boolean, training?: boolean): NNTensor;
1344
+ embedding(weight: Tensor, indices: Tensor): Tensor;
1345
+ mse_loss(input: Tensor, target: Tensor, reduction?: LossReduction): Tensor;
1346
+ nll_loss(input: Tensor, target: Tensor, reduction?: LossReduction, ignoreIndex?: number | null): Tensor;
1347
+ cross_entropy(input: Tensor, target: Tensor, reduction?: LossReduction, ignoreIndex?: number | null): Tensor;
1348
+ binary_cross_entropy(input: Tensor, target: Tensor, reduction?: LossReduction): Tensor;
1349
+ dropout(input: Tensor, p?: number, training?: boolean): Tensor;
1350
+ max_pool2d(input: Tensor, kernelSize: Pool2dSize, stride?: Pool2dSize | null, padding?: Pool2dPadding): Tensor;
1351
+ avg_pool2d(input: Tensor, kernelSize: Pool2dSize, stride?: Pool2dSize | null, padding?: Pool2dPadding): Tensor;
1352
+ adaptive_avg_pool2d(input: Tensor, outputSize: Pool2dSize): Tensor;
1353
+ conv2d(input: Tensor, weight: Tensor, bias: Tensor | null, stride?: ConvSize2d, padding?: ConvPadding2d, dilation?: ConvSize2d, groups?: number): Tensor;
1354
+ conv1d(input: Tensor, weight: Tensor, bias: Tensor | null, stride?: number | readonly number[], padding?: number | Pair2$1, dilation?: number | readonly number[], groups?: number): Tensor;
1355
+ linear(input: NNTensor, weight: NNTensor, bias?: OptionalTensor): NNTensor;
1356
+ layer_norm(input: NNTensor, normalizedShape: readonly number[], weight: OptionalTensor, bias: OptionalTensor, eps?: number): NNTensor;
1357
+ group_norm(input: NNTensor, numGroups: number, weight: OptionalTensor, bias: OptionalTensor, eps?: number): NNTensor;
1358
+ batch_norm(input: NNTensor, runningMean: OptionalTensor, runningVar: OptionalTensor, weight: OptionalTensor, bias: OptionalTensor, training?: boolean, eps?: number, momentum?: number): NNTensor;
1359
+ relu(input: Tensor): Tensor;
1360
+ gelu(input: Tensor): Tensor;
1361
+ silu(input: Tensor): Tensor;
1362
+ sigmoid(input: Tensor): Tensor;
1363
+ tanh(input: Tensor): Tensor;
1364
+ softmax(input: Tensor, dim?: number): Tensor;
1365
+ log_softmax(input: Tensor, dim?: number): Tensor;
1366
+ leaky_relu(input: Tensor, negativeSlope?: number): Tensor;
1367
+ elu(input: Tensor, alpha?: number): Tensor;
1368
+ };
1369
+
1370
+ type index$6_AdaptiveAvgPool2d = AdaptiveAvgPool2d;
1371
+ declare const index$6_AdaptiveAvgPool2d: typeof AdaptiveAvgPool2d;
1372
+ type index$6_AvgPool2d = AvgPool2d;
1373
+ declare const index$6_AvgPool2d: typeof AvgPool2d;
1374
+ type index$6_BCELoss = BCELoss;
1375
+ declare const index$6_BCELoss: typeof BCELoss;
1376
+ type index$6_BatchNorm1d = BatchNorm1d;
1377
+ declare const index$6_BatchNorm1d: typeof BatchNorm1d;
1378
+ type index$6_BatchNorm2d = BatchNorm2d;
1379
+ declare const index$6_BatchNorm2d: typeof BatchNorm2d;
1380
+ type index$6_Conv1d = Conv1d;
1381
+ declare const index$6_Conv1d: typeof Conv1d;
1382
+ type index$6_Conv2d = Conv2d;
1383
+ declare const index$6_Conv2d: typeof Conv2d;
1384
+ type index$6_CrossEntropyLoss = CrossEntropyLoss;
1385
+ declare const index$6_CrossEntropyLoss: typeof CrossEntropyLoss;
1386
+ type index$6_Dropout = Dropout;
1387
+ declare const index$6_Dropout: typeof Dropout;
1388
+ type index$6_ELU = ELU;
1389
+ declare const index$6_ELU: typeof ELU;
1390
+ type index$6_Embedding = Embedding;
1391
+ declare const index$6_Embedding: typeof Embedding;
1392
+ declare const index$6_F: typeof F;
1393
+ type index$6_Flatten = Flatten;
1394
+ declare const index$6_Flatten: typeof Flatten;
1395
+ type index$6_GELU = GELU;
1396
+ declare const index$6_GELU: typeof GELU;
1397
+ type index$6_GRU = GRU;
1398
+ declare const index$6_GRU: typeof GRU;
1399
+ type index$6_GRUCell = GRUCell;
1400
+ declare const index$6_GRUCell: typeof GRUCell;
1401
+ type index$6_GroupNorm = GroupNorm;
1402
+ declare const index$6_GroupNorm: typeof GroupNorm;
1403
+ type index$6_LSTM = LSTM;
1404
+ declare const index$6_LSTM: typeof LSTM;
1405
+ type index$6_LSTMCell = LSTMCell;
1406
+ declare const index$6_LSTMCell: typeof LSTMCell;
1407
+ type index$6_LayerNorm = LayerNorm;
1408
+ declare const index$6_LayerNorm: typeof LayerNorm;
1409
+ type index$6_LeakyReLU = LeakyReLU;
1410
+ declare const index$6_LeakyReLU: typeof LeakyReLU;
1411
+ type index$6_Linear = Linear;
1412
+ declare const index$6_Linear: typeof Linear;
1413
+ type index$6_LogSoftmax = LogSoftmax;
1414
+ declare const index$6_LogSoftmax: typeof LogSoftmax;
1415
+ type index$6_MSELoss = MSELoss;
1416
+ declare const index$6_MSELoss: typeof MSELoss;
1417
+ type index$6_MaxPool2d = MaxPool2d;
1418
+ declare const index$6_MaxPool2d: typeof MaxPool2d;
1419
+ type index$6_Module = Module;
1420
+ declare const index$6_Module: typeof Module;
1421
+ type index$6_ModuleDict = ModuleDict;
1422
+ declare const index$6_ModuleDict: typeof ModuleDict;
1423
+ type index$6_ModuleList = ModuleList;
1424
+ declare const index$6_ModuleList: typeof ModuleList;
1425
+ type index$6_MultiheadAttention = MultiheadAttention;
1426
+ declare const index$6_MultiheadAttention: typeof MultiheadAttention;
1427
+ type index$6_NLLLoss = NLLLoss;
1428
+ declare const index$6_NLLLoss: typeof NLLLoss;
1429
+ type index$6_Parameter = Parameter;
1430
+ declare const index$6_Parameter: typeof Parameter;
1431
+ type index$6_PositionalEncoding = PositionalEncoding;
1432
+ declare const index$6_PositionalEncoding: typeof PositionalEncoding;
1433
+ type index$6_ReLU = ReLU;
1434
+ declare const index$6_ReLU: typeof ReLU;
1435
+ type index$6_Sequential = Sequential;
1436
+ declare const index$6_Sequential: typeof Sequential;
1437
+ type index$6_SiLU = SiLU;
1438
+ declare const index$6_SiLU: typeof SiLU;
1439
+ type index$6_Sigmoid = Sigmoid;
1440
+ declare const index$6_Sigmoid: typeof Sigmoid;
1441
+ type index$6_Softmax = Softmax;
1442
+ declare const index$6_Softmax: typeof Softmax;
1443
+ type index$6_Tanh = Tanh;
1444
+ declare const index$6_Tanh: typeof Tanh;
1445
+ type index$6_Transformer = Transformer;
1446
+ declare const index$6_Transformer: typeof Transformer;
1447
+ type index$6_TransformerDecoder = TransformerDecoder;
1448
+ declare const index$6_TransformerDecoder: typeof TransformerDecoder;
1449
+ type index$6_TransformerDecoderLayer = TransformerDecoderLayer;
1450
+ declare const index$6_TransformerDecoderLayer: typeof TransformerDecoderLayer;
1451
+ type index$6_TransformerEncoder = TransformerEncoder;
1452
+ declare const index$6_TransformerEncoder: typeof TransformerEncoder;
1453
+ type index$6_TransformerEncoderLayer = TransformerEncoderLayer;
1454
+ declare const index$6_TransformerEncoderLayer: typeof TransformerEncoderLayer;
1455
+ declare const index$6_init: typeof init;
1456
+ declare namespace index$6 {
1457
+ export { index$6_AdaptiveAvgPool2d as AdaptiveAvgPool2d, index$6_AvgPool2d as AvgPool2d, index$6_BCELoss as BCELoss, index$6_BatchNorm1d as BatchNorm1d, index$6_BatchNorm2d as BatchNorm2d, index$6_Conv1d as Conv1d, index$6_Conv2d as Conv2d, index$6_CrossEntropyLoss as CrossEntropyLoss, index$6_Dropout as Dropout, index$6_ELU as ELU, index$6_Embedding as Embedding, index$6_F as F, index$6_Flatten as Flatten, index$6_GELU as GELU, index$6_GRU as GRU, index$6_GRUCell as GRUCell, index$6_GroupNorm as GroupNorm, index$6_LSTM as LSTM, index$6_LSTMCell as LSTMCell, index$6_LayerNorm as LayerNorm, index$6_LeakyReLU as LeakyReLU, index$6_Linear as Linear, index$6_LogSoftmax as LogSoftmax, index$6_MSELoss as MSELoss, index$6_MaxPool2d as MaxPool2d, index$6_Module as Module, index$6_ModuleDict as ModuleDict, index$6_ModuleList as ModuleList, index$6_MultiheadAttention as MultiheadAttention, index$6_NLLLoss as NLLLoss, index$6_Parameter as Parameter, index$6_PositionalEncoding as PositionalEncoding, index$6_ReLU as ReLU, index$6_Sequential as Sequential, index$6_SiLU as SiLU, index$6_Sigmoid as Sigmoid, index$6_Softmax as Softmax, index$6_Tanh as Tanh, index$6_Transformer as Transformer, index$6_TransformerDecoder as TransformerDecoder, index$6_TransformerDecoderLayer as TransformerDecoderLayer, index$6_TransformerEncoder as TransformerEncoder, index$6_TransformerEncoderLayer as TransformerEncoderLayer, activation as functional, index$6_init as init };
1458
+ }
1459
+
1460
+ declare class Dataset<T = unknown> implements Iterable<T> {
1461
+ get length(): number;
1462
+ get(index: number): T;
1463
+ [Symbol.iterator](): Generator<T>;
1464
+ }
1465
+ declare class TensorDataset extends Dataset<Tensor[]> {
1466
+ private readonly _tensors;
1467
+ private readonly _length;
1468
+ constructor(...tensors: Tensor[]);
1469
+ get length(): number;
1470
+ get(index: number): Tensor[];
1471
+ }
1472
+ declare class MapDataset<TIn, TOut> extends Dataset<TOut> {
1473
+ private readonly _dataset;
1474
+ private readonly _transform;
1475
+ constructor(dataset: Dataset<TIn>, transform: (sample: TIn) => TOut);
1476
+ get length(): number;
1477
+ get(index: number): TOut;
1478
+ }
1479
+
1480
+ type Sized = {
1481
+ length: number;
1482
+ };
1483
+ declare class Sampler implements Iterable<number | number[]> {
1484
+ [Symbol.iterator](): Generator<number | number[]>;
1485
+ }
1486
+ declare class SequentialSampler extends Sampler implements Iterable<number> {
1487
+ private readonly _dataSource;
1488
+ constructor(dataSource: Sized);
1489
+ [Symbol.iterator](): Generator<number>;
1490
+ }
1491
+ declare class RandomSampler extends Sampler implements Iterable<number> {
1492
+ private readonly _dataSource;
1493
+ constructor(dataSource: Sized);
1494
+ [Symbol.iterator](): Generator<number>;
1495
+ }
1496
+ declare class BatchSampler extends Sampler implements Iterable<number[]> {
1497
+ readonly _dropLast: boolean;
1498
+ private readonly _sampler;
1499
+ private readonly _batchSize;
1500
+ constructor(sampler: Iterable<number>, batchSize: number, dropLast?: boolean);
1501
+ [Symbol.iterator](): Generator<number[]>;
1502
+ }
1503
+
1504
+ declare function defaultCollate(batch: readonly unknown[]): unknown;
1505
+
1506
+ type CollateFn<T, TBatch> = (samples: T[]) => TBatch;
1507
+ type DataLoaderOptions<T, TBatch> = {
1508
+ batchSize?: number | null;
1509
+ shuffle?: boolean;
1510
+ sampler?: Iterable<number> | null;
1511
+ batchSampler?: Iterable<number[]> | null;
1512
+ dropLast?: boolean;
1513
+ collate?: CollateFn<T, TBatch>;
1514
+ };
1515
+ declare class DataLoader<T = unknown, TBatch = unknown> implements Iterable<TBatch> {
1516
+ private readonly _dataset;
1517
+ private readonly _collate;
1518
+ private readonly _batchSampler;
1519
+ private readonly _batchSize;
1520
+ private readonly _dropLast;
1521
+ constructor(dataset: Dataset<T>, opts?: DataLoaderOptions<T, TBatch>);
1522
+ get dataset(): Dataset<T>;
1523
+ get length(): number;
1524
+ [Symbol.iterator](): Generator<TBatch>;
1525
+ }
1526
+
1527
+ type index$5_BatchSampler = BatchSampler;
1528
+ declare const index$5_BatchSampler: typeof BatchSampler;
1529
+ type index$5_DataLoader<T = unknown, TBatch = unknown> = DataLoader<T, TBatch>;
1530
+ declare const index$5_DataLoader: typeof DataLoader;
1531
+ type index$5_Dataset<T = unknown> = Dataset<T>;
1532
+ declare const index$5_Dataset: typeof Dataset;
1533
+ type index$5_MapDataset<TIn, TOut> = MapDataset<TIn, TOut>;
1534
+ declare const index$5_MapDataset: typeof MapDataset;
1535
+ type index$5_RandomSampler = RandomSampler;
1536
+ declare const index$5_RandomSampler: typeof RandomSampler;
1537
+ type index$5_Sampler = Sampler;
1538
+ declare const index$5_Sampler: typeof Sampler;
1539
+ type index$5_SequentialSampler = SequentialSampler;
1540
+ declare const index$5_SequentialSampler: typeof SequentialSampler;
1541
+ type index$5_TensorDataset = TensorDataset;
1542
+ declare const index$5_TensorDataset: typeof TensorDataset;
1543
+ declare const index$5_defaultCollate: typeof defaultCollate;
1544
+ declare namespace index$5 {
1545
+ export { index$5_BatchSampler as BatchSampler, index$5_DataLoader as DataLoader, index$5_Dataset as Dataset, index$5_MapDataset as MapDataset, index$5_RandomSampler as RandomSampler, index$5_Sampler as Sampler, index$5_SequentialSampler as SequentialSampler, index$5_TensorDataset as TensorDataset, index$5_defaultCollate as defaultCollate };
1546
+ }
1547
+
1548
+ declare class Vocab {
1549
+ private readonly _tokenToId;
1550
+ private readonly _idToToken;
1551
+ constructor(specials?: readonly string[]);
1552
+ add(token: string): number;
1553
+ getId(token: string, fallback?: number): number;
1554
+ getToken(id: number): string | undefined;
1555
+ has(token: string): boolean;
1556
+ get size(): number;
1557
+ tokens(): string[];
1558
+ static fromTokens(tokens: unknown): Vocab;
1559
+ }
1560
+
1561
+ declare const TOKENIZER_FORMAT = "mlfw-tokenizer";
1562
+ declare const TOKENIZER_VERSION = 1;
1563
+ declare const DEFAULT_SPECIALS: Readonly<{
1564
+ pad: "<pad>";
1565
+ unk: "<unk>";
1566
+ bos: "<bos>";
1567
+ eos: "<eos>";
1568
+ }>;
1569
+ type TokenizerMode = 'word' | 'char' | 'bpe';
1570
+ type SpecialKey = 'pad' | 'unk' | 'bos' | 'eos';
1571
+ type SpecialTokens = Record<SpecialKey, string>;
1572
+ type PartialSpecialTokens = Partial<SpecialTokens> | readonly string[];
1573
+ type StrategyData = {
1574
+ lowercase?: boolean;
1575
+ numMerges?: number;
1576
+ endOfWord?: string;
1577
+ merges?: [string, string][];
1578
+ };
1579
+ type TokenizerOptions = {
1580
+ mode?: TokenizerMode;
1581
+ specialTokens?: PartialSpecialTokens;
1582
+ vocabSize?: number | null;
1583
+ lowercase?: boolean;
1584
+ numMerges?: number;
1585
+ endOfWord?: string;
1586
+ };
1587
+ type EncodeOptions = {
1588
+ addBos?: boolean;
1589
+ addEos?: boolean;
1590
+ };
1591
+ type DecodeOptions = {
1592
+ skipSpecial?: boolean;
1593
+ };
1594
+ type EncodeBatchOptions = EncodeOptions & {
1595
+ maxLen?: number;
1596
+ padId?: number;
1597
+ };
1598
+ type TokenizerJSON = {
1599
+ format: typeof TOKENIZER_FORMAT;
1600
+ version: typeof TOKENIZER_VERSION;
1601
+ mode: TokenizerMode;
1602
+ config: StrategyData & {
1603
+ vocabSize: number | null;
1604
+ };
1605
+ specialTokens: SpecialTokens;
1606
+ vocab: string[];
1607
+ strategy: StrategyData;
1608
+ };
1609
+ declare class Tokenizer {
1610
+ private _mode;
1611
+ private _specials;
1612
+ private _maxVocab;
1613
+ private _strategy;
1614
+ private _vocab;
1615
+ constructor(options?: TokenizerOptions);
1616
+ get mode(): TokenizerMode;
1617
+ get vocabSize(): number;
1618
+ get padId(): number;
1619
+ get unkId(): number;
1620
+ get bosId(): number;
1621
+ get eosId(): number;
1622
+ _ensureFit(): void;
1623
+ _fitVocab(): Vocab;
1624
+ _specialId(name: SpecialKey): number;
1625
+ fit(texts: string | readonly string[]): this;
1626
+ toJSON(): TokenizerJSON;
1627
+ save(path: string): void;
1628
+ static load(path: string): Tokenizer;
1629
+ static fromJSON(data: unknown): Tokenizer;
1630
+ encode(text: string, options?: EncodeOptions): number[];
1631
+ decode(ids: Iterable<number>, options?: DecodeOptions): string;
1632
+ encodeBatch(texts: string | readonly string[], options?: EncodeBatchOptions): Tensor;
1633
+ }
1634
+
1635
+ declare const index$4_DEFAULT_SPECIALS: typeof DEFAULT_SPECIALS;
1636
+ declare const index$4_TOKENIZER_FORMAT: typeof TOKENIZER_FORMAT;
1637
+ declare const index$4_TOKENIZER_VERSION: typeof TOKENIZER_VERSION;
1638
+ type index$4_Tokenizer = Tokenizer;
1639
+ declare const index$4_Tokenizer: typeof Tokenizer;
1640
+ type index$4_Vocab = Vocab;
1641
+ declare const index$4_Vocab: typeof Vocab;
1642
+ declare namespace index$4 {
1643
+ export { index$4_DEFAULT_SPECIALS as DEFAULT_SPECIALS, index$4_TOKENIZER_FORMAT as TOKENIZER_FORMAT, index$4_TOKENIZER_VERSION as TOKENIZER_VERSION, index$4_Tokenizer as Tokenizer, index$4_Vocab as Vocab };
1644
+ }
1645
+
1646
+ type OptimizerParam = Tensor;
1647
+ type OptimizerStateValue = number | boolean | string | readonly number[] | NumericTypedArray | undefined;
1648
+ type OptimizerState = Record<string, OptimizerStateValue>;
1649
+ type OptimizerParamGroup = {
1650
+ params: OptimizerParam[];
1651
+ [key: string]: OptimizerStateValue | OptimizerParam[];
1652
+ };
1653
+ type ParamGroupInput = {
1654
+ params: Iterable<OptimizerParam> | OptimizerParam[];
1655
+ [key: string]: OptimizerStateValue | Iterable<OptimizerParam> | OptimizerParam[];
1656
+ };
1657
+ type OptimizerParams = Iterable<OptimizerParam> | OptimizerParam[] | ParamGroupInput[];
1658
+ type OptimizerStateDict = {
1659
+ state: Map<number, OptimizerState>;
1660
+ paramGroups: Array<Record<string, OptimizerStateValue>>;
1661
+ };
1662
+
1663
+ declare class Optimizer {
1664
+ protected _defaults: Record<string, unknown>;
1665
+ protected _paramGroups: OptimizerParamGroup[];
1666
+ protected _state: Map<number, OptimizerState>;
1667
+ private readonly _paramIndex;
1668
+ private _nextId;
1669
+ constructor(params: OptimizerParams, defaults: Record<string, unknown>);
1670
+ get paramGroups(): OptimizerParamGroup[];
1671
+ get defaults(): Record<string, unknown>;
1672
+ step(): void;
1673
+ zeroGrad(setToNone?: boolean): void;
1674
+ stateDict(): OptimizerStateDict;
1675
+ loadStateDict(dict: OptimizerStateDict): void;
1676
+ _addParamGroup(group: ParamGroupInput): void;
1677
+ _getParamId(param: OptimizerParam): number | undefined;
1678
+ _getState(param: OptimizerParam): OptimizerState;
1679
+ }
1680
+
1681
+ declare class SGD extends Optimizer {
1682
+ constructor(params: ConstructorParameters<typeof Optimizer>[0], { lr, momentum, dampening, weightDecay, nesterov }?: {
1683
+ lr?: number | undefined;
1684
+ momentum?: number | undefined;
1685
+ dampening?: number | undefined;
1686
+ weightDecay?: number | undefined;
1687
+ nesterov?: boolean | undefined;
1688
+ });
1689
+ step(): void;
1690
+ }
1691
+
1692
+ declare class Adam extends Optimizer {
1693
+ constructor(params: ConstructorParameters<typeof Optimizer>[0], { lr, betas, eps, weightDecay, amsgrad }?: {
1694
+ lr?: number | undefined;
1695
+ betas?: number[] | undefined;
1696
+ eps?: number | undefined;
1697
+ weightDecay?: number | undefined;
1698
+ amsgrad?: boolean | undefined;
1699
+ });
1700
+ step(): void;
1701
+ }
1702
+
1703
+ declare class AdamW extends Optimizer {
1704
+ constructor(params: ConstructorParameters<typeof Optimizer>[0], { lr, betas, eps, weightDecay, amsgrad }?: {
1705
+ lr?: number | undefined;
1706
+ betas?: number[] | undefined;
1707
+ eps?: number | undefined;
1708
+ weightDecay?: number | undefined;
1709
+ amsgrad?: boolean | undefined;
1710
+ });
1711
+ step(): void;
1712
+ }
1713
+
1714
+ declare class LRScheduler {
1715
+ protected readonly _optimizer: Optimizer;
1716
+ protected readonly _baseLRs: number[];
1717
+ protected _lastEpoch: number;
1718
+ protected _lastLR: number[] | null;
1719
+ constructor(optimizer: Optimizer, lastEpoch?: number);
1720
+ _init(): void;
1721
+ getLR(): number[];
1722
+ getLastLR(): number[] | null;
1723
+ step(): void;
1724
+ }
1725
+ declare class StepLR extends LRScheduler {
1726
+ private readonly _stepSize;
1727
+ private readonly _gamma;
1728
+ constructor(optimizer: Optimizer, stepSize: number, gamma?: number, lastEpoch?: number);
1729
+ getLR(): number[];
1730
+ }
1731
+ declare class CosineAnnealingLR extends LRScheduler {
1732
+ private readonly _tMax;
1733
+ private readonly _etaMin;
1734
+ constructor(optimizer: Optimizer, tMax: number, etaMin?: number, lastEpoch?: number);
1735
+ getLR(): number[];
1736
+ }
1737
+ declare class ReduceLROnPlateau {
1738
+ private readonly _optimizer;
1739
+ private readonly _mode;
1740
+ private readonly _factor;
1741
+ private readonly _patience;
1742
+ private readonly _threshold;
1743
+ private readonly _thresholdMode;
1744
+ private readonly _cooldown;
1745
+ private readonly _minLR;
1746
+ private readonly _eps;
1747
+ private _best;
1748
+ private _numBadEpochs;
1749
+ private _cooldownCounter;
1750
+ constructor(optimizer: Optimizer, { mode, factor, patience, threshold, thresholdMode, cooldown, minLR, eps, }?: {
1751
+ mode?: string;
1752
+ factor?: number;
1753
+ patience?: number;
1754
+ threshold?: number;
1755
+ thresholdMode?: string;
1756
+ cooldown?: number;
1757
+ minLR?: number;
1758
+ eps?: number;
1759
+ });
1760
+ step(metric?: number): void;
1761
+ _isBetter(current: number): boolean;
1762
+ _reduceAllLRs(): void;
1763
+ }
1764
+
1765
+ declare function clipGradNorm_(parameters: Iterable<Tensor> | Tensor[], maxNorm: number, normType?: number): number;
1766
+ declare function clipGradValue_(parameters: Iterable<Tensor> | Tensor[], clipValue: number): void;
1767
+
1768
+ declare class TargetFeatures {
1769
+ constructor(config: any);
1770
+ kind: any;
1771
+ name: any;
1772
+ vectorWidth: any;
1773
+ numCores: any;
1774
+ maxThreadsPerBlock: any;
1775
+ maxBlockDimX: any;
1776
+ maxBlockDimY: any;
1777
+ maxBlockDimZ: any;
1778
+ maxGridDimX: any;
1779
+ maxGridDimY: any;
1780
+ maxGridDimZ: any;
1781
+ sharedMemoryBytes: any;
1782
+ memoryBudgetBytes: any;
1783
+ registersPerThread: any;
1784
+ warpSize: any;
1785
+ memoryBandwidthGBs: any;
1786
+ computeTFLOPs: any;
1787
+ cacheLineSizeBytes: any;
1788
+ l1CacheBytes: any;
1789
+ l2CacheBytes: any;
1790
+ supportsFloat16: any;
1791
+ supportsTensorCore: any;
1792
+ libraryOps: any;
1793
+ enableEpilogueFusion: any;
1794
+ preferredConvLayout: any;
1795
+ layoutAwareOps: any;
1796
+ preferredBlockFactor: any;
1797
+ supportsBlockedLayout: any;
1798
+ supportsInt8: any;
1799
+ simd: any;
1800
+ host: any;
1801
+ attrs: Map<string, any>;
1802
+ getAttr(key: any, fallback?: null): any;
1803
+ hasAttr(key: any): boolean;
1804
+ withAttr(key: any, value: any): this;
1805
+ isGPU(): boolean;
1806
+ isWebGPU(): boolean;
1807
+ isCPU(): boolean;
1808
+ isWasm(): boolean;
1809
+ supportsThreadBinding(): boolean;
1810
+ supportsVectorization(): boolean;
1811
+ maxParallelism(): any;
1812
+ supportsSimd(): any;
1813
+ hasLibraryOp(opName: any): any;
1814
+ }
1815
+ declare function CPUTarget(overrides?: {}): TargetFeatures;
1816
+ declare function CUDATarget(overrides?: {}): TargetFeatures;
1817
+ declare function WasmTarget(overrides?: {}): TargetFeatures;
1818
+ declare function WebGPUTarget(overrides?: {}): TargetFeatures;
1819
+
1820
+ type CompiledKernel = {
1821
+ run(name: string, ...args: unknown[]): void;
1822
+ };
1823
+ type TargetLike = ReturnType<typeof CPUTarget>;
1824
+ type GraphFunctionLike = unknown;
1825
+ type FusedDefaults = Record<string, unknown>;
1826
+ type FusedSGDOptions = {
1827
+ lr?: number;
1828
+ momentum?: number;
1829
+ dampening?: number;
1830
+ weightDecay?: number;
1831
+ nesterov?: boolean;
1832
+ };
1833
+ type FusedAdamOptions = {
1834
+ lr?: number;
1835
+ betas?: readonly [number, number];
1836
+ eps?: number;
1837
+ weightDecay?: number;
1838
+ amsgrad?: boolean;
1839
+ };
1840
+ declare class FusedOptimizer extends Optimizer {
1841
+ protected _target: TargetLike;
1842
+ private _kernels;
1843
+ constructor(params: OptimizerParams, defaults: FusedDefaults, target?: TargetLike | null);
1844
+ _kernel(numel: number): CompiledKernel;
1845
+ _buildGraph(_numel: number): GraphFunctionLike;
1846
+ }
1847
+ declare class FusedSGD extends FusedOptimizer {
1848
+ constructor(params: OptimizerParams, { lr, momentum, dampening, weightDecay, nesterov }?: FusedSGDOptions, target?: TargetLike | null);
1849
+ _buildGraph(n: number): GraphFunctionLike;
1850
+ step(): void;
1851
+ }
1852
+ declare class FusedAdam extends FusedOptimizer {
1853
+ constructor(params: OptimizerParams, { lr, betas, eps, weightDecay, amsgrad }?: FusedAdamOptions, target?: TargetLike | null);
1854
+ _buildGraph(n: number): GraphFunctionLike;
1855
+ step(): void;
1856
+ }
1857
+
1858
+ declare class GradScaler {
1859
+ enabled: boolean;
1860
+ private _scale;
1861
+ private readonly _growthFactor;
1862
+ private readonly _backoffFactor;
1863
+ private readonly _growthInterval;
1864
+ private _growthTracker;
1865
+ _foundInf: boolean;
1866
+ private _unscaled;
1867
+ constructor(opts?: {
1868
+ enabled?: boolean;
1869
+ initScale?: number;
1870
+ growthFactor?: number;
1871
+ backoffFactor?: number;
1872
+ growthInterval?: number;
1873
+ });
1874
+ getScale(): number;
1875
+ get growthTracker(): number;
1876
+ scale(loss: Tensor): Tensor;
1877
+ unscale_(optimizer: Optimizer): boolean;
1878
+ step(optimizer: Optimizer): boolean;
1879
+ update(newScale?: number): void;
1880
+ }
1881
+
1882
+ type index$3_Adam = Adam;
1883
+ declare const index$3_Adam: typeof Adam;
1884
+ type index$3_AdamW = AdamW;
1885
+ declare const index$3_AdamW: typeof AdamW;
1886
+ type index$3_CosineAnnealingLR = CosineAnnealingLR;
1887
+ declare const index$3_CosineAnnealingLR: typeof CosineAnnealingLR;
1888
+ type index$3_FusedAdam = FusedAdam;
1889
+ declare const index$3_FusedAdam: typeof FusedAdam;
1890
+ type index$3_FusedOptimizer = FusedOptimizer;
1891
+ declare const index$3_FusedOptimizer: typeof FusedOptimizer;
1892
+ type index$3_FusedSGD = FusedSGD;
1893
+ declare const index$3_FusedSGD: typeof FusedSGD;
1894
+ type index$3_GradScaler = GradScaler;
1895
+ declare const index$3_GradScaler: typeof GradScaler;
1896
+ type index$3_LRScheduler = LRScheduler;
1897
+ declare const index$3_LRScheduler: typeof LRScheduler;
1898
+ type index$3_Optimizer = Optimizer;
1899
+ declare const index$3_Optimizer: typeof Optimizer;
1900
+ type index$3_ReduceLROnPlateau = ReduceLROnPlateau;
1901
+ declare const index$3_ReduceLROnPlateau: typeof ReduceLROnPlateau;
1902
+ type index$3_SGD = SGD;
1903
+ declare const index$3_SGD: typeof SGD;
1904
+ type index$3_StepLR = StepLR;
1905
+ declare const index$3_StepLR: typeof StepLR;
1906
+ declare const index$3_clipGradNorm_: typeof clipGradNorm_;
1907
+ declare const index$3_clipGradValue_: typeof clipGradValue_;
1908
+ declare namespace index$3 {
1909
+ export { index$3_Adam as Adam, index$3_AdamW as AdamW, index$3_CosineAnnealingLR as CosineAnnealingLR, index$3_FusedAdam as FusedAdam, index$3_FusedOptimizer as FusedOptimizer, index$3_FusedSGD as FusedSGD, index$3_GradScaler as GradScaler, index$3_LRScheduler as LRScheduler, index$3_Optimizer as Optimizer, index$3_ReduceLROnPlateau as ReduceLROnPlateau, index$3_SGD as SGD, index$3_StepLR as StepLR, index$3_clipGradNorm_ as clipGradNorm_, index$3_clipGradValue_ as clipGradValue_ };
1910
+ }
1911
+
1912
+ type TraceFunction = (...inputs: SymbolicTensor[]) => MaybePromise<TensorOutput | TensorOutput[]>;
1913
+ declare function trace(fn: TraceFunction, exampleInputs: readonly Tensor[], opts?: CompileOptions): MaybePromise<GraphModuleLike>;
1914
+ declare function compile(model: CompilableModel, exampleInputs?: Tensor[], opts?: CompileOptions): unknown;
1915
+
1916
+ type StepValue = TensorOutput | TensorOutput[];
1917
+ type ScanFn = (carry: StepValue, xs: StepValue) => [StepValue, StepValue];
1918
+ declare function scan(fn: ScanFn, initCarry: StepValue, xs: StepValue): [StepValue, StepValue];
1919
+
1920
+ declare function compileWithBackward(model: CompilableModel, exampleInputs?: Tensor[], opts?: CompileOptions): unknown;
1921
+
1922
+ declare class Callback {
1923
+ setup(_trainer: unknown, _model: unknown, _stage: unknown): void;
1924
+ teardown(_trainer: unknown, _model: unknown, _stage: unknown): void;
1925
+ onFitStart(_trainer: unknown, _model: unknown): void;
1926
+ onFitEnd(_trainer: unknown, _model: unknown): void;
1927
+ onTrainStart(_trainer: unknown, _model: unknown): void;
1928
+ onTrainEnd(_trainer: unknown, _model: unknown): void;
1929
+ onTrainEpochStart(_trainer: unknown, _model: unknown): void;
1930
+ onTrainEpochEnd(_trainer: unknown, _model: unknown): void;
1931
+ onTrainBatchStart(_trainer: unknown, _model: unknown, _batch: unknown, _batchIdx: unknown): void;
1932
+ onTrainBatchEnd(_trainer: unknown, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
1933
+ onValidationStart(_trainer: unknown, _model: unknown): void;
1934
+ onValidationEnd(_trainer: unknown, _model: unknown): void;
1935
+ onValidationEpochStart(_trainer: unknown, _model: unknown): void;
1936
+ onValidationEpochEnd(_trainer: unknown, _model: unknown): void;
1937
+ onValidationBatchStart(_trainer: unknown, _model: unknown, _batch: unknown, _batchIdx: unknown): void;
1938
+ onValidationBatchEnd(_trainer: unknown, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
1939
+ onTestStart(_trainer: unknown, _model: unknown): void;
1940
+ onTestEnd(_trainer: unknown, _model: unknown): void;
1941
+ onTestBatchStart(_trainer: unknown, _model: unknown, _batch: unknown, _batchIdx: unknown): void;
1942
+ onTestBatchEnd(_trainer: unknown, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
1943
+ onPredictStart(_trainer: unknown, _model: unknown): void;
1944
+ onPredictEnd(_trainer: unknown, _model: unknown): void;
1945
+ onPredictBatchStart(_trainer: unknown, _model: unknown, _batch: unknown, _batchIdx: unknown): void;
1946
+ onPredictBatchEnd(_trainer: unknown, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
1947
+ onBeforeBackward(_trainer: unknown, _model: unknown, _loss: unknown): void;
1948
+ onAfterBackward(_trainer: unknown, _model: unknown): void;
1949
+ onBeforeOptimizerStep(_trainer: unknown, _model: unknown, _optimizer: unknown): void;
1950
+ onBeforeZeroGrad(_trainer: unknown, _model: unknown, _optimizer: unknown): void;
1951
+ onSaveCheckpoint(_trainer: unknown, _model: unknown, _checkpoint: unknown): void;
1952
+ onLoadCheckpoint(_trainer: unknown, _model: unknown, _checkpoint: unknown): void;
1953
+ }
1954
+
1955
+ declare enum Stage {
1956
+ IDLE = "idle",
1957
+ TRAINING = "training",
1958
+ VALIDATING = "validating",
1959
+ TESTING = "testing",
1960
+ PREDICTING = "predicting"
1961
+ }
1962
+ type ReduceFnName = 'mean' | 'sum' | 'min' | 'max' | 'last';
1963
+ declare class MetricAccumulator {
1964
+ private _accumulators;
1965
+ private _reduceFns;
1966
+ constructor();
1967
+ update(name: string, value: MetricValue, reduceFx?: ReduceFnName): void;
1968
+ compute(name: string): number | undefined;
1969
+ computeAll(): NumericMetricRecord;
1970
+ reset(): void;
1971
+ has(name: string): boolean;
1972
+ get size(): number;
1973
+ }
1974
+ declare class TrainerState {
1975
+ stage: Stage;
1976
+ epoch: number;
1977
+ globalStep: number;
1978
+ maxEpochs: number;
1979
+ maxSteps: number;
1980
+ shouldStop: boolean;
1981
+ stepMetrics: MetricAccumulator;
1982
+ epochMetrics: MetricAccumulator;
1983
+ numTrainingBatches?: number;
1984
+ numValBatches?: number;
1985
+ _progBarMetrics?: Map<string, number>;
1986
+ constructor();
1987
+ resetEpochMetrics(): void;
1988
+ resetStepMetrics(): void;
1989
+ }
1990
+ declare class SingleDeviceStrategy {
1991
+ device: Device | null;
1992
+ constructor();
1993
+ setup(model: unknown, device: Device): void;
1994
+ toDevice(value: unknown): unknown;
1995
+ backward(loss: {
1996
+ backward(): void;
1997
+ }): void;
1998
+ optimizerStep(optimizer: {
1999
+ step(): void;
2000
+ }): void;
2001
+ }
2002
+
2003
+ declare enum HOOKS {
2004
+ ON_FIT_START = "onFitStart",
2005
+ ON_FIT_END = "onFitEnd",
2006
+ ON_TRAIN_START = "onTrainStart",
2007
+ ON_TRAIN_END = "onTrainEnd",
2008
+ ON_TRAIN_EPOCH_START = "onTrainEpochStart",
2009
+ ON_TRAIN_EPOCH_END = "onTrainEpochEnd",
2010
+ ON_TRAIN_BATCH_START = "onTrainBatchStart",
2011
+ ON_TRAIN_BATCH_END = "onTrainBatchEnd",
2012
+ ON_VALIDATION_START = "onValidationStart",
2013
+ ON_VALIDATION_END = "onValidationEnd",
2014
+ ON_VALIDATION_EPOCH_START = "onValidationEpochStart",
2015
+ ON_VALIDATION_EPOCH_END = "onValidationEpochEnd",
2016
+ ON_VALIDATION_BATCH_START = "onValidationBatchStart",
2017
+ ON_VALIDATION_BATCH_END = "onValidationBatchEnd",
2018
+ ON_TEST_START = "onTestStart",
2019
+ ON_TEST_END = "onTestEnd",
2020
+ ON_TEST_BATCH_START = "onTestBatchStart",
2021
+ ON_TEST_BATCH_END = "onTestBatchEnd",
2022
+ ON_PREDICT_START = "onPredictStart",
2023
+ ON_PREDICT_END = "onPredictEnd",
2024
+ ON_PREDICT_BATCH_START = "onPredictBatchStart",
2025
+ ON_PREDICT_BATCH_END = "onPredictBatchEnd",
2026
+ SETUP = "setup",
2027
+ TEARDOWN = "teardown",
2028
+ ON_BEFORE_BACKWARD = "onBeforeBackward",
2029
+ ON_AFTER_BACKWARD = "onAfterBackward",
2030
+ ON_BEFORE_OPTIMIZER_STEP = "onBeforeOptimizerStep",
2031
+ ON_BEFORE_ZERO_GRAD = "onBeforeZeroGrad",
2032
+ ON_SAVE_CHECKPOINT = "onSaveCheckpoint",
2033
+ ON_LOAD_CHECKPOINT = "onLoadCheckpoint"
2034
+ }
2035
+ type HookName = string;
2036
+ type LogModel = LightningModuleLike & {
2037
+ _logBuffer: Map<string, unknown>;
2038
+ };
2039
+ declare class CallbackConnector {
2040
+ private _callbacks;
2041
+ constructor(callbacks?: Callback[]);
2042
+ get callbacks(): Callback[];
2043
+ add(callback: Callback): void;
2044
+ dispatch(hookName: HookName, ...args: unknown[]): void;
2045
+ remove(callback: Callback): void;
2046
+ }
2047
+ declare class LoggerConnector {
2048
+ private _loggers;
2049
+ private _state;
2050
+ constructor(loggers: (Logger | Logger[]) | undefined, state: TrainerState);
2051
+ drain(model: LogModel): void;
2052
+ flushStepMetrics(step: number): NumericMetricRecord;
2053
+ flushEpochMetrics(step: number): NumericMetricRecord;
2054
+ logHyperparams(params: HyperparameterRecord): void;
2055
+ }
2056
+
2057
+ type MetricResult = number | number[] | number[][];
2058
+ type MetricValue = number | {
2059
+ item(): number | bigint;
2060
+ };
2061
+ type UnknownRecord = Record<string, unknown>;
2062
+ type NumericMetricRecord = Record<string, number>;
2063
+ type HyperparameterRecord = UnknownRecord;
2064
+ type LoggerOptions = {
2065
+ name?: string;
2066
+ version?: number | null;
2067
+ };
2068
+ type ClassificationTask = 'binary' | 'multiclass';
2069
+ type AccuracyTask = ClassificationTask | 'multilabel';
2070
+ type AverageMode = 'macro' | 'micro' | 'weighted' | 'none';
2071
+ type TrainerLike = {
2072
+ state: {
2073
+ epoch: number;
2074
+ globalStep: number;
2075
+ maxEpochs?: number;
2076
+ numTrainingBatches?: number;
2077
+ numValBatches?: number;
2078
+ _progBarMetrics?: Map<string, unknown>;
2079
+ epochMetrics?: {
2080
+ computeAll(): Record<string, number | undefined>;
2081
+ };
2082
+ };
2083
+ accumulateGradBatches?: number;
2084
+ limitTrainBatches?: number | null;
2085
+ limitValBatches?: number | null;
2086
+ shouldStop?: boolean;
2087
+ callbackConnector?: {
2088
+ dispatch(hook: string, ...args: unknown[]): void;
2089
+ };
2090
+ };
2091
+ type OptimizerGroupLike = {
2092
+ lr: number;
2093
+ momentum?: number;
2094
+ [key: string]: unknown;
2095
+ };
2096
+ type OptimizerLike = {
2097
+ paramGroups: OptimizerGroupLike[];
2098
+ defaults?: Record<string, unknown>;
2099
+ step(): void;
2100
+ zeroGrad(): void;
2101
+ stateDict?(): unknown;
2102
+ };
2103
+ type LightningModuleLike = {
2104
+ _currentOptimizers?: OptimizerLike[];
2105
+ _logBuffer: Map<string, unknown>;
2106
+ _trainer?: unknown;
2107
+ _device?: Device | null;
2108
+ __compiledTrainStep?: CompiledTrainStep;
2109
+ __eagerGraphRunner?: EagerGraphRunner;
2110
+ automaticOptimization: boolean;
2111
+ log(name: string, value: unknown, options?: UnknownRecord): void;
2112
+ stateDict?(): unknown;
2113
+ loadStateDict?(state: unknown): void;
2114
+ parameters?(): Iterable<unknown>;
2115
+ train(): void;
2116
+ eval(): void;
2117
+ forward(...args: unknown[]): unknown;
2118
+ trainingStep(batch: unknown, batchIdx: number): unknown;
2119
+ validationStep(batch: unknown, batchIdx: number): unknown;
2120
+ testStep(batch: unknown, batchIdx: number): unknown;
2121
+ predictStep(batch: unknown, batchIdx: number): unknown;
2122
+ configureOptimizers(): unknown;
2123
+ onTrainEpochStart(): void;
2124
+ onTrainEpochEnd(): void;
2125
+ onValidationEpochStart(): void;
2126
+ onValidationEpochEnd(): void;
2127
+ onTestEpochStart(): void;
2128
+ onTestEpochEnd(): void;
2129
+ };
2130
+ type DataLoaderLike = Iterable<unknown> & {
2131
+ length: number;
2132
+ };
2133
+ type TrainerCoreLike = {
2134
+ state: TrainerState;
2135
+ strategy: SingleDeviceStrategy;
2136
+ callbackConnector: CallbackConnector;
2137
+ loggerConnector: LoggerConnector;
2138
+ fitLoop: {
2139
+ validationLoop: {
2140
+ run(model: LightningModuleLike, dataLoader: DataLoaderLike, trainer: TrainerCoreLike, schedulerConfigs: Array<SchedulerConfig | null> | null): Promise<NumericMetricRecord>;
2141
+ };
2142
+ };
2143
+ checkValEveryNEpoch: number;
2144
+ accumulateGradBatches: number;
2145
+ limitTrainBatches: number | null;
2146
+ limitValBatches: number | null;
2147
+ limitTestBatches: number | null;
2148
+ logEveryNSteps: number;
2149
+ gradientClipVal: number | null;
2150
+ gradientClipAlgorithm: string;
2151
+ compile: boolean;
2152
+ compileMode: string;
2153
+ cudaGraph: boolean;
2154
+ cudaGraphWarmupSteps: number;
2155
+ _flushEagerInference(): Promise<void>;
2156
+ };
2157
+ type TrainerOptions = {
2158
+ maxEpochs?: number;
2159
+ maxSteps?: number;
2160
+ accelerator?: 'auto' | 'cpu' | 'gpu' | 'wasm' | 'webgpu';
2161
+ precision?: string;
2162
+ callbacks?: Callback[];
2163
+ logger?: boolean | Logger | Logger[] | null;
2164
+ enableCheckpointing?: boolean;
2165
+ enableProgress?: boolean;
2166
+ gradientClipVal?: number | null;
2167
+ gradientClipAlgorithm?: string;
2168
+ accumulateGradBatches?: number;
2169
+ limitTrainBatches?: number | null;
2170
+ limitValBatches?: number | null;
2171
+ limitTestBatches?: number | null;
2172
+ valCheckInterval?: number;
2173
+ checkValEveryNEpoch?: number;
2174
+ logEveryNSteps?: number;
2175
+ deterministic?: boolean;
2176
+ fastDevRun?: boolean | number;
2177
+ defaultRootDir?: string;
2178
+ compile?: boolean;
2179
+ compileMode?: string;
2180
+ cudaGraph?: boolean;
2181
+ cudaGraphWarmupSteps?: number;
2182
+ };
2183
+ type CompiledTrainStep = {
2184
+ (...args: unknown[]): unknown;
2185
+ capturedParams(): Array<{
2186
+ grad: unknown;
2187
+ }>;
2188
+ backward(seed: unknown): unknown;
2189
+ };
2190
+ type EagerGraphRunner = {
2191
+ phase: 'warmup' | 'disabled' | 'replay';
2192
+ seen: number;
2193
+ inputs?: Array<{
2194
+ dptr: unknown;
2195
+ }>;
2196
+ captured?: {
2197
+ exec: unknown;
2198
+ };
2199
+ exec?: unknown;
2200
+ lossDptr?: unknown;
2201
+ lossScratch?: Float32Array;
2202
+ captureError?: unknown;
2203
+ };
2204
+ type TensorLike = {
2205
+ readonly shape: readonly number[];
2206
+ readonly _impl: {
2207
+ readonly storage: {
2208
+ readonly data: NumericTypedArray;
2209
+ };
2210
+ };
2211
+ };
2212
+
2213
+ declare class Logger {
2214
+ protected _name: string;
2215
+ protected _version: number | null;
2216
+ constructor({ name, version }?: LoggerOptions);
2217
+ get name(): string;
2218
+ get version(): number | null;
2219
+ logMetrics(_metrics: NumericMetricRecord, _step: number): void;
2220
+ logHyperparams(_params: HyperparameterRecord): void;
2221
+ finalize(): void;
2222
+ }
2223
+
2224
+ type LogOptions = {
2225
+ onStep?: boolean | null;
2226
+ onEpoch?: boolean | null;
2227
+ reduceFx?: ReduceFnName;
2228
+ progBar?: boolean;
2229
+ };
2230
+ type LogEntry = {
2231
+ value: MetricValue;
2232
+ onStep: boolean;
2233
+ onEpoch: boolean;
2234
+ reduceFx: ReduceFnName;
2235
+ progBar: boolean;
2236
+ };
2237
+ type TrainerRef = {
2238
+ state: {
2239
+ epoch: number;
2240
+ globalStep: number;
2241
+ stage: Stage | string;
2242
+ };
2243
+ logger: Logger | null;
2244
+ loggers: Logger[];
2245
+ strategy?: {
2246
+ backward(loss: {
2247
+ backward(): void;
2248
+ }): void;
2249
+ };
2250
+ };
2251
+ type SchedulerLike = {
2252
+ step(...args: unknown[]): void;
2253
+ };
2254
+ type SchedulerConfig = {
2255
+ scheduler: SchedulerLike;
2256
+ interval: 'step' | 'epoch';
2257
+ frequency: number;
2258
+ monitor: string | null;
2259
+ };
2260
+ declare class LightningModule extends Module {
2261
+ _trainer: TrainerRef | null;
2262
+ _logBuffer: Map<string, LogEntry>;
2263
+ _automaticOptimization: boolean;
2264
+ _currentOptimizers: OptimizerLike[];
2265
+ _device: Device | null;
2266
+ constructor();
2267
+ get trainer(): TrainerRef | null;
2268
+ get currentEpoch(): number;
2269
+ get globalStep(): number;
2270
+ get device(): Device | null;
2271
+ get logger(): Logger | null;
2272
+ get loggers(): Logger[];
2273
+ get automaticOptimization(): boolean;
2274
+ set automaticOptimization(value: boolean);
2275
+ get optimizers(): OptimizerLike[];
2276
+ trainingStep(_batch: unknown, _batchIdx: number): unknown;
2277
+ validationStep(_batch: unknown, _batchIdx: number): unknown;
2278
+ testStep(_batch: unknown, _batchIdx: number): unknown;
2279
+ predictStep(batch: unknown, _batchIdx: number): unknown;
2280
+ configureOptimizers(): unknown;
2281
+ onTrainEpochStart(): void;
2282
+ onTrainEpochEnd(): void;
2283
+ onValidationEpochStart(): void;
2284
+ onValidationEpochEnd(): void;
2285
+ onTestEpochStart(): void;
2286
+ onTestEpochEnd(): void;
2287
+ log(name: string, value: MetricValue, { onStep, onEpoch, reduceFx, progBar, }?: LogOptions): void;
2288
+ logDict(dict: Record<string, MetricValue>, opts?: LogOptions): void;
2289
+ manualBackward(loss: {
2290
+ backward(): void;
2291
+ }): void;
2292
+ }
2293
+
2294
+ type TrainingOutput = unknown;
2295
+ declare class TrainingLoop {
2296
+ run(model: LightningModuleLike, dataLoader: DataLoaderLike, trainer: TrainerCoreLike, optimizers: OptimizerLike[], schedulerConfigs: Array<SchedulerConfig | null>): Promise<NumericMetricRecord>;
2297
+ _automaticStep(model: LightningModuleLike, batch: unknown, batchIdx: number, trainer: TrainerCoreLike, optimizers: OptimizerLike[], schedulerConfigs: Array<SchedulerConfig | null>, strategy: SingleDeviceStrategy, accumGrad: number, callbacks: CallbackConnector): Promise<TrainingOutput>;
2298
+ _compiledStep(model: LightningModuleLike, batch: unknown, batchIdx: number, trainer: TrainerCoreLike, optimizers: OptimizerLike[], schedulerConfigs: Array<SchedulerConfig | null>, accumGrad: number): Promise<unknown>;
2299
+ _eagerTrainStepCore(model: LightningModuleLike, batch: unknown, optimizers: OptimizerLike[], strategy: SingleDeviceStrategy, trainer: TrainerCoreLike | null): Promise<unknown>;
2300
+ _graphedStep(model: LightningModuleLike, batch: unknown, trainer: TrainerCoreLike, optimizers: OptimizerLike[], schedulerConfigs: Array<SchedulerConfig | null>, strategy: SingleDeviceStrategy): Promise<unknown>;
2301
+ _logGraphLoss(trainer: TrainerCoreLike, value: number): void;
2302
+ _clipGradients(model: LightningModuleLike, trainer: TrainerCoreLike): void;
2303
+ _stepStepSchedulers(schedulerConfigs: Array<SchedulerConfig | null> | null, globalStep: number): void;
2304
+ _stepEpochSchedulers(schedulerConfigs: Array<SchedulerConfig | null> | null, epoch: number): void;
2305
+ }
2306
+
2307
+ declare class ValidationLoop {
2308
+ run(model: LightningModuleLike, dataLoader: DataLoaderLike, trainer: TrainerCoreLike, schedulerConfigs: Array<SchedulerConfig | null> | null): Promise<NumericMetricRecord>;
2309
+ private _stepPlateauSchedulers;
2310
+ }
2311
+
2312
+ declare class FitLoop {
2313
+ private _trainingLoop;
2314
+ private _validationLoop;
2315
+ constructor();
2316
+ get trainingLoop(): TrainingLoop;
2317
+ get validationLoop(): ValidationLoop;
2318
+ run(model: LightningModuleLike, trainLoader: DataLoaderLike, valLoader: DataLoaderLike | null, trainer: TrainerCoreLike, optimizers: OptimizerLike[], schedulerConfigs: Array<SchedulerConfig | null>): Promise<void>;
2319
+ _shouldRunValidation(epoch: number, trainer: TrainerCoreLike): boolean;
2320
+ }
2321
+
2322
+ declare class Trainer {
2323
+ private _state;
2324
+ private _compile;
2325
+ private _compileMode;
2326
+ private _cudaGraph;
2327
+ private _cudaGraphWarmupSteps;
2328
+ private _accelerator;
2329
+ private _precision;
2330
+ private _gradientClipVal;
2331
+ private _gradientClipAlgorithm;
2332
+ private _accumulateGradBatches;
2333
+ private _limitTrainBatches;
2334
+ private _limitValBatches;
2335
+ private _limitTestBatches;
2336
+ private _valCheckInterval;
2337
+ private _checkValEveryNEpoch;
2338
+ private _logEveryNSteps;
2339
+ private _deterministic;
2340
+ private _defaultRootDir;
2341
+ private _loggers;
2342
+ private _strategy;
2343
+ private _fitLoop;
2344
+ private _evaluationLoop;
2345
+ private _predictionLoop;
2346
+ private _callbackConnector;
2347
+ private _loggerConnector;
2348
+ private _model;
2349
+ private _webgpuMod;
2350
+ constructor({ maxEpochs, maxSteps, accelerator, precision, callbacks, logger, enableCheckpointing, enableProgress, gradientClipVal, gradientClipAlgorithm, accumulateGradBatches, limitTrainBatches, limitValBatches, limitTestBatches, valCheckInterval, checkValEveryNEpoch, logEveryNSteps, deterministic, fastDevRun, defaultRootDir, compile, compileMode, cudaGraph, cudaGraphWarmupSteps, }?: TrainerOptions);
2351
+ get state(): TrainerState;
2352
+ get strategy(): SingleDeviceStrategy;
2353
+ get callbackConnector(): CallbackConnector;
2354
+ get loggerConnector(): LoggerConnector;
2355
+ get fitLoop(): FitLoop;
2356
+ get gradientClipVal(): number | null;
2357
+ get gradientClipAlgorithm(): string;
2358
+ get compile(): boolean;
2359
+ get compileMode(): string;
2360
+ get cudaGraph(): boolean;
2361
+ get cudaGraphWarmupSteps(): number;
2362
+ get accumulateGradBatches(): number;
2363
+ set accumulateGradBatches(v: number);
2364
+ get limitTrainBatches(): number | null;
2365
+ get limitValBatches(): number | null;
2366
+ get limitTestBatches(): number | null;
2367
+ get checkValEveryNEpoch(): number;
2368
+ get logEveryNSteps(): number;
2369
+ get shouldStop(): boolean;
2370
+ set shouldStop(v: boolean);
2371
+ get currentEpoch(): number;
2372
+ get globalStep(): number;
2373
+ get logger(): Logger | null;
2374
+ get loggers(): Logger[];
2375
+ get callbacks(): Callback[];
2376
+ get model(): LightningModuleLike | null;
2377
+ get defaultRootDir(): string;
2378
+ fit(model: LightningModuleLike, trainLoader: DataLoaderLike, valLoader?: DataLoaderLike | null): Promise<void>;
2379
+ validate(model: LightningModuleLike, dataLoader: DataLoaderLike): Promise<NumericMetricRecord>;
2380
+ test(model: LightningModuleLike, dataLoader: DataLoaderLike): Promise<NumericMetricRecord>;
2381
+ predict(model: LightningModuleLike, dataLoader: DataLoaderLike): Promise<unknown[]>;
2382
+ _resolveDevice(): Device;
2383
+ _guardEagerWebGPU(device: Device, stage: string, hasValidation?: boolean): void;
2384
+ _guardCudaGraph(device: Device, hasValidation?: boolean): void;
2385
+ _prepareDevice(device: Device): Promise<void>;
2386
+ _flushEagerInference(): Promise<void>;
2387
+ _resolveLoggers(loggerConfig: TrainerOptions['logger']): Logger[];
2388
+ _extractHyperparams(model: LightningModuleLike, optimizers: OptimizerLike[]): HyperparameterRecord;
2389
+ }
2390
+
2391
+ declare class EvaluationLoop {
2392
+ run(model: LightningModuleLike, dataLoader: DataLoaderLike, trainer: TrainerCoreLike): Promise<NumericMetricRecord>;
2393
+ }
2394
+
2395
+ declare class PredictionLoop {
2396
+ run(model: LightningModuleLike, dataLoader: DataLoaderLike, trainer: TrainerCoreLike): Promise<unknown[]>;
2397
+ }
2398
+
2399
+ type CheckpointMode = 'min' | 'max';
2400
+ type BestKEntry = {
2401
+ score: number;
2402
+ path: string;
2403
+ };
2404
+ type ModelCheckpointOptions = {
2405
+ dirpath?: string;
2406
+ filename?: string;
2407
+ monitor?: string | null;
2408
+ mode?: CheckpointMode;
2409
+ saveTopK?: number;
2410
+ saveLast?: boolean;
2411
+ everyNEpochs?: number;
2412
+ };
2413
+ type CheckpointModel = Omit<LightningModuleLike, '_currentOptimizers'> & {
2414
+ stateDict(): unknown;
2415
+ _currentOptimizers?: CheckpointOptimizer[];
2416
+ };
2417
+ type CheckpointOptimizer = {
2418
+ stateDict(): unknown;
2419
+ loadStateDict(state: unknown): void;
2420
+ };
2421
+ declare class ModelCheckpoint extends Callback {
2422
+ private _dirpath;
2423
+ private _filename;
2424
+ private _monitor;
2425
+ private _mode;
2426
+ private _saveTopK;
2427
+ private _saveLast;
2428
+ private _everyNEpochs;
2429
+ private _bestK;
2430
+ private _recent;
2431
+ private _compareFn;
2432
+ private _bestModelPath;
2433
+ private _lastModelPath;
2434
+ constructor({ dirpath, filename, monitor, mode, saveTopK, saveLast, everyNEpochs, }?: ModelCheckpointOptions);
2435
+ get bestModelPath(): string | null;
2436
+ get lastModelPath(): string | null;
2437
+ get bestKModels(): BestKEntry[];
2438
+ onTrainEpochEnd(trainer: TrainerLike, model: CheckpointModel): void;
2439
+ private _findInsertIndex;
2440
+ private _updateBest;
2441
+ private _saveCheckpoint;
2442
+ private _fillTemplate;
2443
+ private _ensureDir;
2444
+ private _tryDelete;
2445
+ }
2446
+ declare function loadCheckpoint(path: string): unknown;
2447
+ declare function applyCheckpoint(checkpoint: unknown, model: LightningModuleLike, optimizers?: CheckpointOptimizer[]): unknown;
2448
+
2449
+ declare function serializeCheckpoint(checkpoint: unknown): Uint8Array;
2450
+ declare function deserializeCheckpoint(bytes: Uint8Array | ArrayBufferLike): unknown;
2451
+
2452
+ type EarlyStoppingMode = 'min' | 'max';
2453
+ type EarlyStoppingOptions = {
2454
+ monitor?: string;
2455
+ patience?: number;
2456
+ mode?: EarlyStoppingMode;
2457
+ minDelta?: number;
2458
+ checkOnTrainEpochEnd?: boolean;
2459
+ };
2460
+ declare class EarlyStopping extends Callback {
2461
+ private _monitor;
2462
+ private _patience;
2463
+ private _mode;
2464
+ private _minDelta;
2465
+ private _checkOnTrainEpochEnd;
2466
+ private _waitCount;
2467
+ private _bestScore;
2468
+ private _compareFn;
2469
+ constructor({ monitor, patience, mode, minDelta, checkOnTrainEpochEnd, }?: EarlyStoppingOptions);
2470
+ get monitor(): string;
2471
+ get patience(): number;
2472
+ get bestScore(): number | null;
2473
+ get waitCount(): number;
2474
+ onValidationEnd(trainer: TrainerLike, _model?: unknown): void;
2475
+ onTrainEpochEnd(trainer: TrainerLike, _model?: unknown): void;
2476
+ private _check;
2477
+ reset(): void;
2478
+ }
2479
+
2480
+ type ProgressOptions = {
2481
+ barLength?: number;
2482
+ };
2483
+ declare class ProgressCallback extends Callback {
2484
+ private _barLength;
2485
+ private _trainBatchCount;
2486
+ private _valBatchCount;
2487
+ private _epochStartTime;
2488
+ private _lastLen;
2489
+ private _active;
2490
+ constructor({ barLength }?: ProgressOptions);
2491
+ onTrainEpochStart(trainer: TrainerLike, _model: unknown): void;
2492
+ onTrainBatchEnd(trainer: TrainerLike, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
2493
+ onTrainEpochEnd(trainer: TrainerLike, _model: unknown): void;
2494
+ onTrainEnd(_trainer: unknown, _model: unknown): void;
2495
+ onValidationEpochStart(_trainer: unknown, _model: unknown): void;
2496
+ onValidationBatchEnd(trainer: TrainerLike, _model: unknown, _outputs: unknown, _batch: unknown, _batchIdx: unknown): void;
2497
+ onValidationEnd(trainer: TrainerLike, _model: unknown): void;
2498
+ private _trainTotal;
2499
+ private _valTotal;
2500
+ private _render;
2501
+ private _bar;
2502
+ private _formatProgBarMetrics;
2503
+ }
2504
+
2505
+ type LearningRateMonitorOptions = {
2506
+ logMomentum?: boolean;
2507
+ };
2508
+ type LRHistoryEntry = {
2509
+ step: number;
2510
+ lr: number;
2511
+ };
2512
+ declare class LearningRateMonitor extends Callback {
2513
+ private _logMomentum;
2514
+ private _lrHistory;
2515
+ constructor({ logMomentum }?: LearningRateMonitorOptions);
2516
+ get lrHistory(): Record<string, LRHistoryEntry[]>;
2517
+ onTrainBatchStart(trainer: TrainerLike, model: LightningModuleLike, _batch: unknown, _batchIdx: unknown): void;
2518
+ }
2519
+
2520
+ declare class Timer extends Callback {
2521
+ private _fitStartTime;
2522
+ private _epochStartTime;
2523
+ private _epochDurations;
2524
+ private _validationDurations;
2525
+ private _totalTrainingTime;
2526
+ private _valStartTime;
2527
+ constructor();
2528
+ get epochDurations(): number[];
2529
+ get validationDurations(): number[];
2530
+ get totalTrainingTime(): number;
2531
+ onFitStart(_trainer: unknown, _model: unknown): void;
2532
+ onFitEnd(_trainer: unknown, _model: unknown): void;
2533
+ onTrainEpochStart(_trainer: unknown, _model: unknown): void;
2534
+ onTrainEpochEnd(_trainer: unknown, _model: unknown): void;
2535
+ onValidationStart(_trainer: unknown, _model: unknown): void;
2536
+ onValidationEnd(_trainer: unknown, _model: unknown): void;
2537
+ }
2538
+
2539
+ type GradientAccumulationOptions = {
2540
+ scheduling: Record<string, number>;
2541
+ };
2542
+ declare class GradientAccumulationScheduler extends Callback {
2543
+ private _scheduling;
2544
+ private _sortedEpochs;
2545
+ constructor({ scheduling }: GradientAccumulationOptions);
2546
+ onTrainEpochStart(trainer: TrainerLike, _model?: unknown): void;
2547
+ getCurrentAccumulation(epoch: number): number;
2548
+ }
2549
+
2550
+ type ConsoleLoggerOptions = LoggerOptions & {
2551
+ logFrequency?: number;
2552
+ };
2553
+ declare class ConsoleLogger extends Logger {
2554
+ private _logFrequency;
2555
+ private _callCount;
2556
+ constructor(opts?: ConsoleLoggerOptions);
2557
+ logMetrics(metrics: NumericMetricRecord, step: number): void;
2558
+ logHyperparams(params: HyperparameterRecord): void;
2559
+ }
2560
+
2561
+ type CSVLoggerOptions = LoggerOptions & {
2562
+ saveDir?: string;
2563
+ flushInterval?: number;
2564
+ };
2565
+ declare class CSVLogger extends Logger {
2566
+ private _saveDir;
2567
+ private _flushInterval;
2568
+ private _columns;
2569
+ private _columnSet;
2570
+ private _buffer;
2571
+ private _filePath;
2572
+ private _headerWritten;
2573
+ protected _version: number | null;
2574
+ constructor({ saveDir, name, version, flushInterval, }?: CSVLoggerOptions);
2575
+ get logDir(): string;
2576
+ logMetrics(metrics: NumericMetricRecord, step: number): void;
2577
+ logHyperparams(params: HyperparameterRecord): void;
2578
+ finalize(): void;
2579
+ private _flush;
2580
+ private _getFilePath;
2581
+ private _ensureDir;
2582
+ private _resolveVersion;
2583
+ }
2584
+
2585
+ declare class Metric {
2586
+ protected _computed: MetricResult | null;
2587
+ constructor();
2588
+ update(_preds: unknown, _target: unknown): void;
2589
+ compute(): MetricResult;
2590
+ reset(): void;
2591
+ forward(preds: unknown, target: unknown): MetricResult;
2592
+ get value(): MetricResult | null;
2593
+ }
2594
+
2595
+ declare class MeanMetric extends Metric {
2596
+ private _sum;
2597
+ private _count;
2598
+ constructor();
2599
+ update(value: MetricValue, weight?: number): void;
2600
+ compute(): number;
2601
+ reset(): void;
2602
+ }
2603
+ declare class SumMetric extends Metric {
2604
+ private _sum;
2605
+ constructor();
2606
+ update(value: MetricValue): void;
2607
+ compute(): number;
2608
+ reset(): void;
2609
+ }
2610
+
2611
+ type MetricMap = Record<string, Metric>;
2612
+ declare class MetricCollection {
2613
+ private _metrics;
2614
+ constructor(metrics?: MetricMap);
2615
+ add(name: string, metric: Metric): this;
2616
+ update(preds: TensorLike, target: TensorLike): void;
2617
+ compute(): Record<string, MetricResult>;
2618
+ reset(): void;
2619
+ forward(preds: TensorLike, target: TensorLike): Record<string, MetricResult>;
2620
+ get(name: string): Metric | undefined;
2621
+ has(name: string): boolean;
2622
+ get size(): number;
2623
+ [Symbol.iterator](): MapIterator<[string, Metric]>;
2624
+ }
2625
+
2626
+ type AccuracyOptions = {
2627
+ task?: AccuracyTask;
2628
+ numClasses?: number | null;
2629
+ topK?: number;
2630
+ threshold?: number;
2631
+ };
2632
+ declare class Accuracy extends Metric {
2633
+ private _task;
2634
+ private _numClasses;
2635
+ private _topK;
2636
+ private _threshold;
2637
+ private _correct;
2638
+ private _total;
2639
+ constructor({ task, numClasses, topK, threshold }?: AccuracyOptions);
2640
+ update(preds: TensorLike, target: TensorLike): void;
2641
+ compute(): number;
2642
+ reset(): void;
2643
+ private _updateBinary;
2644
+ private _updateMulticlass;
2645
+ private _updateMultilabel;
2646
+ }
2647
+
2648
+ type ClassificationOptions = {
2649
+ task?: ClassificationTask;
2650
+ numClasses?: number;
2651
+ average?: AverageMode;
2652
+ };
2653
+ declare class Precision extends Metric {
2654
+ private _task;
2655
+ private _numClasses;
2656
+ private _average;
2657
+ private _tp;
2658
+ private _fp;
2659
+ private _support;
2660
+ constructor({ task, numClasses, average }?: ClassificationOptions);
2661
+ update(preds: TensorLike, target: TensorLike): void;
2662
+ compute(): number | number[];
2663
+ reset(): void;
2664
+ }
2665
+ declare class Recall extends Metric {
2666
+ private _task;
2667
+ private _numClasses;
2668
+ private _average;
2669
+ private _tp;
2670
+ private _fn;
2671
+ private _support;
2672
+ constructor({ task, numClasses, average }?: ClassificationOptions);
2673
+ update(preds: TensorLike, target: TensorLike): void;
2674
+ compute(): number | number[];
2675
+ reset(): void;
2676
+ }
2677
+ declare class F1Score extends Metric {
2678
+ private _task;
2679
+ private _numClasses;
2680
+ private _average;
2681
+ private _tp;
2682
+ private _fp;
2683
+ private _fn;
2684
+ private _support;
2685
+ constructor({ task, numClasses, average }?: ClassificationOptions);
2686
+ update(preds: TensorLike, target: TensorLike): void;
2687
+ compute(): number | number[];
2688
+ reset(): void;
2689
+ }
2690
+
2691
+ type ConfusionMatrixOptions = {
2692
+ numClasses: number;
2693
+ };
2694
+ declare class ConfusionMatrix extends Metric {
2695
+ private _numClasses;
2696
+ private _matrix;
2697
+ constructor({ numClasses }: ConfusionMatrixOptions);
2698
+ update(preds: TensorLike, target: TensorLike): void;
2699
+ compute(): number[][];
2700
+ reset(): void;
2701
+ }
2702
+
2703
+ type index$2_Accuracy = Accuracy;
2704
+ declare const index$2_Accuracy: typeof Accuracy;
2705
+ type index$2_CSVLogger = CSVLogger;
2706
+ declare const index$2_CSVLogger: typeof CSVLogger;
2707
+ type index$2_Callback = Callback;
2708
+ declare const index$2_Callback: typeof Callback;
2709
+ type index$2_CallbackConnector = CallbackConnector;
2710
+ declare const index$2_CallbackConnector: typeof CallbackConnector;
2711
+ type index$2_ConfusionMatrix = ConfusionMatrix;
2712
+ declare const index$2_ConfusionMatrix: typeof ConfusionMatrix;
2713
+ type index$2_ConsoleLogger = ConsoleLogger;
2714
+ declare const index$2_ConsoleLogger: typeof ConsoleLogger;
2715
+ type index$2_EarlyStopping = EarlyStopping;
2716
+ declare const index$2_EarlyStopping: typeof EarlyStopping;
2717
+ type index$2_EvaluationLoop = EvaluationLoop;
2718
+ declare const index$2_EvaluationLoop: typeof EvaluationLoop;
2719
+ type index$2_F1Score = F1Score;
2720
+ declare const index$2_F1Score: typeof F1Score;
2721
+ type index$2_FitLoop = FitLoop;
2722
+ declare const index$2_FitLoop: typeof FitLoop;
2723
+ type index$2_GradientAccumulationScheduler = GradientAccumulationScheduler;
2724
+ declare const index$2_GradientAccumulationScheduler: typeof GradientAccumulationScheduler;
2725
+ type index$2_HOOKS = HOOKS;
2726
+ declare const index$2_HOOKS: typeof HOOKS;
2727
+ type index$2_LearningRateMonitor = LearningRateMonitor;
2728
+ declare const index$2_LearningRateMonitor: typeof LearningRateMonitor;
2729
+ type index$2_LightningModule = LightningModule;
2730
+ declare const index$2_LightningModule: typeof LightningModule;
2731
+ type index$2_Logger = Logger;
2732
+ declare const index$2_Logger: typeof Logger;
2733
+ type index$2_LoggerConnector = LoggerConnector;
2734
+ declare const index$2_LoggerConnector: typeof LoggerConnector;
2735
+ type index$2_MeanMetric = MeanMetric;
2736
+ declare const index$2_MeanMetric: typeof MeanMetric;
2737
+ type index$2_Metric = Metric;
2738
+ declare const index$2_Metric: typeof Metric;
2739
+ type index$2_MetricAccumulator = MetricAccumulator;
2740
+ declare const index$2_MetricAccumulator: typeof MetricAccumulator;
2741
+ type index$2_MetricCollection = MetricCollection;
2742
+ declare const index$2_MetricCollection: typeof MetricCollection;
2743
+ type index$2_ModelCheckpoint = ModelCheckpoint;
2744
+ declare const index$2_ModelCheckpoint: typeof ModelCheckpoint;
2745
+ type index$2_Precision = Precision;
2746
+ declare const index$2_Precision: typeof Precision;
2747
+ type index$2_PredictionLoop = PredictionLoop;
2748
+ declare const index$2_PredictionLoop: typeof PredictionLoop;
2749
+ type index$2_ProgressCallback = ProgressCallback;
2750
+ declare const index$2_ProgressCallback: typeof ProgressCallback;
2751
+ type index$2_Recall = Recall;
2752
+ declare const index$2_Recall: typeof Recall;
2753
+ type index$2_SingleDeviceStrategy = SingleDeviceStrategy;
2754
+ declare const index$2_SingleDeviceStrategy: typeof SingleDeviceStrategy;
2755
+ type index$2_Stage = Stage;
2756
+ declare const index$2_Stage: typeof Stage;
2757
+ type index$2_SumMetric = SumMetric;
2758
+ declare const index$2_SumMetric: typeof SumMetric;
2759
+ type index$2_Timer = Timer;
2760
+ declare const index$2_Timer: typeof Timer;
2761
+ type index$2_Trainer = Trainer;
2762
+ declare const index$2_Trainer: typeof Trainer;
2763
+ type index$2_TrainerState = TrainerState;
2764
+ declare const index$2_TrainerState: typeof TrainerState;
2765
+ type index$2_TrainingLoop = TrainingLoop;
2766
+ declare const index$2_TrainingLoop: typeof TrainingLoop;
2767
+ type index$2_ValidationLoop = ValidationLoop;
2768
+ declare const index$2_ValidationLoop: typeof ValidationLoop;
2769
+ declare const index$2_applyCheckpoint: typeof applyCheckpoint;
2770
+ declare const index$2_deserializeCheckpoint: typeof deserializeCheckpoint;
2771
+ declare const index$2_loadCheckpoint: typeof loadCheckpoint;
2772
+ declare const index$2_serializeCheckpoint: typeof serializeCheckpoint;
2773
+ declare namespace index$2 {
2774
+ export { index$2_Accuracy as Accuracy, index$2_CSVLogger as CSVLogger, index$2_Callback as Callback, index$2_CallbackConnector as CallbackConnector, index$2_ConfusionMatrix as ConfusionMatrix, index$2_ConsoleLogger as ConsoleLogger, index$2_EarlyStopping as EarlyStopping, index$2_EvaluationLoop as EvaluationLoop, index$2_F1Score as F1Score, index$2_FitLoop as FitLoop, index$2_GradientAccumulationScheduler as GradientAccumulationScheduler, index$2_HOOKS as HOOKS, index$2_LearningRateMonitor as LearningRateMonitor, index$2_LightningModule as LightningModule, index$2_Logger as Logger, index$2_LoggerConnector as LoggerConnector, index$2_MeanMetric as MeanMetric, index$2_Metric as Metric, index$2_MetricAccumulator as MetricAccumulator, index$2_MetricCollection as MetricCollection, index$2_ModelCheckpoint as ModelCheckpoint, index$2_Precision as Precision, index$2_PredictionLoop as PredictionLoop, index$2_ProgressCallback as ProgressCallback, index$2_Recall as Recall, index$2_SingleDeviceStrategy as SingleDeviceStrategy, index$2_Stage as Stage, index$2_SumMetric as SumMetric, index$2_Timer as Timer, index$2_Trainer as Trainer, index$2_TrainerState as TrainerState, index$2_TrainingLoop as TrainingLoop, index$2_ValidationLoop as ValidationLoop, index$2_applyCheckpoint as applyCheckpoint, index$2_deserializeCheckpoint as deserializeCheckpoint, index$2_loadCheckpoint as loadCheckpoint, index$2_serializeCheckpoint as serializeCheckpoint };
2775
+ }
2776
+
2777
+ declare namespace fs {
2778
+ function readFile(path: any): any;
2779
+ function readBinary(path: any): any;
2780
+ function writeFile(path: any, data: any): void;
2781
+ function writeBinary(path: any, data: any): void;
2782
+ function appendFile(path: any, data: any): void;
2783
+ function exists(path: any): any;
2784
+ function mkdir(path: any): void;
2785
+ function readdir(path: any): any;
2786
+ function remove(path: any): void;
2787
+ function rename(from: any, to: any): void;
2788
+ }
2789
+
2790
+ declare function svd(a: Tensor): {
2791
+ U: Tensor;
2792
+ S: Tensor;
2793
+ V: Tensor;
2794
+ };
2795
+ declare function eigh(a: Tensor): {
2796
+ values: Tensor;
2797
+ vectors: Tensor;
2798
+ };
2799
+ declare function qr(a: Tensor): {
2800
+ Q: Tensor;
2801
+ R: Tensor;
2802
+ };
2803
+ declare const cholesky: (a: Tensor) => Tensor;
2804
+ declare const inv: (a: Tensor) => Tensor;
2805
+ declare const pinv: (a: Tensor) => Tensor;
2806
+ declare const cov: (a: Tensor) => Tensor;
2807
+ declare const solve: (a: Tensor, b: Tensor) => Tensor;
2808
+ declare const lstsq: (a: Tensor, b: Tensor) => Tensor;
2809
+ declare const det: (a: Tensor) => number | bigint;
2810
+
2811
+ declare const linalg_cholesky: typeof cholesky;
2812
+ declare const linalg_cov: typeof cov;
2813
+ declare const linalg_det: typeof det;
2814
+ declare const linalg_eigh: typeof eigh;
2815
+ declare const linalg_inv: typeof inv;
2816
+ declare const linalg_lstsq: typeof lstsq;
2817
+ declare const linalg_pinv: typeof pinv;
2818
+ declare const linalg_qr: typeof qr;
2819
+ declare const linalg_solve: typeof solve;
2820
+ declare const linalg_svd: typeof svd;
2821
+ declare namespace linalg {
2822
+ export { linalg_cholesky as cholesky, linalg_cov as cov, linalg_det as det, linalg_eigh as eigh, linalg_inv as inv, linalg_lstsq as lstsq, linalg_pinv as pinv, linalg_qr as qr, linalg_solve as solve, linalg_svd as svd };
2823
+ }
2824
+
2825
+ type MLTensor = Tensor & {
2826
+ reshape(shape: readonly number[]): MLTensor;
2827
+ transpose(dim0: number, dim1: number): MLTensor;
2828
+ narrow(dim: number, start: number, length: number): MLTensor;
2829
+ toArray(): ArrayLike<number | bigint>;
2830
+ };
2831
+ type FitPredictEstimator = {
2832
+ fit(X: MLTensor, y: MLTensor): FitPredictEstimator;
2833
+ predict(X: MLTensor): MLTensor;
2834
+ score?(X: MLTensor, y: MLTensor): number;
2835
+ };
2836
+
2837
+ declare class StandardScaler {
2838
+ withMean: boolean;
2839
+ withStd: boolean;
2840
+ mean_: Float64Array | null;
2841
+ scale_: Float64Array | null;
2842
+ private _cols?;
2843
+ constructor({ withMean, withStd }?: {
2844
+ withMean?: boolean;
2845
+ withStd?: boolean;
2846
+ });
2847
+ fit(X: MLTensor): this;
2848
+ transform(X: MLTensor): MLTensor;
2849
+ fit_transform(X: MLTensor): MLTensor;
2850
+ inverse_transform(X: MLTensor): MLTensor;
2851
+ }
2852
+ declare class LabelEncoder {
2853
+ classes_: number[] | null;
2854
+ private _lookup;
2855
+ constructor();
2856
+ fit(y: MLTensor): this;
2857
+ transform(y: MLTensor): MLTensor;
2858
+ fit_transform(y: MLTensor): MLTensor;
2859
+ inverse_transform(y: MLTensor): number[];
2860
+ }
2861
+ declare class OneHotEncoder {
2862
+ classes_: number[] | null;
2863
+ constructor();
2864
+ fit(y: MLTensor): this;
2865
+ transform(y: MLTensor): MLTensor;
2866
+ fit_transform(y: MLTensor): MLTensor;
2867
+ }
2868
+ declare class MinMaxScaler {
2869
+ featureRange: readonly [number, number];
2870
+ min_: null;
2871
+ dataMin_: Float64Array | null;
2872
+ dataRange_: Float64Array | null;
2873
+ constructor({ featureRange }?: {
2874
+ featureRange?: readonly [number, number];
2875
+ });
2876
+ fit(X: MLTensor): this;
2877
+ transform(X: MLTensor): MLTensor;
2878
+ fit_transform(X: MLTensor): MLTensor;
2879
+ }
2880
+
2881
+ declare function mean_squared_error(yTrue: MLTensor, yPred: MLTensor): number;
2882
+ declare function mean_absolute_error(yTrue: MLTensor, yPred: MLTensor): number;
2883
+ declare function r2_score(yTrue: MLTensor, yPred: MLTensor): number;
2884
+ declare function accuracy_score(yTrue: MLTensor, yPred: MLTensor): number;
2885
+ declare function confusion_matrix(yTrue: MLTensor, yPred: MLTensor): number[][];
2886
+
2887
+ declare class LinearRegression {
2888
+ fitIntercept: boolean;
2889
+ weight_: MLTensor | null;
2890
+ constructor({ fitIntercept }?: {
2891
+ fitIntercept?: boolean;
2892
+ });
2893
+ fit(X: MLTensor, y: MLTensor): this;
2894
+ predict(X: MLTensor): MLTensor;
2895
+ score(X: MLTensor, y: MLTensor): number;
2896
+ }
2897
+ declare class Ridge {
2898
+ alpha: number;
2899
+ fitIntercept: boolean;
2900
+ coef_: MLTensor | null;
2901
+ intercept_: MLTensor | null;
2902
+ constructor({ alpha, fitIntercept }?: {
2903
+ alpha?: number;
2904
+ fitIntercept?: boolean;
2905
+ });
2906
+ fit(X: MLTensor, y: MLTensor): this;
2907
+ predict(X: MLTensor): MLTensor;
2908
+ score(X: MLTensor, y: MLTensor): number;
2909
+ }
2910
+ declare class ElasticNet {
2911
+ alpha: number;
2912
+ l1Ratio: number;
2913
+ fitIntercept: boolean;
2914
+ maxIter: number;
2915
+ tol: number;
2916
+ coef_: MLTensor | null;
2917
+ intercept_: MLTensor | null;
2918
+ constructor({ alpha, l1Ratio, fitIntercept, maxIter, tol }?: {
2919
+ alpha?: number;
2920
+ l1Ratio?: number;
2921
+ fitIntercept?: boolean;
2922
+ maxIter?: number;
2923
+ tol?: number;
2924
+ });
2925
+ fit(X: MLTensor, y: MLTensor): this;
2926
+ predict(X: MLTensor): MLTensor;
2927
+ score(X: MLTensor, y: MLTensor): number;
2928
+ }
2929
+ declare class Lasso extends ElasticNet {
2930
+ constructor({ alpha, fitIntercept, maxIter, tol }?: {
2931
+ alpha?: number;
2932
+ fitIntercept?: boolean;
2933
+ maxIter?: number;
2934
+ tol?: number;
2935
+ });
2936
+ }
2937
+ declare class LogisticRegression {
2938
+ C: number;
2939
+ lr: number;
2940
+ maxIter: number;
2941
+ W_: MLTensor | null;
2942
+ b_: MLTensor | null;
2943
+ classes_: number[] | null;
2944
+ constructor({ C, lr, maxIter }?: {
2945
+ C?: number;
2946
+ lr?: number;
2947
+ maxIter?: number;
2948
+ });
2949
+ fit(X: MLTensor, y: MLTensor): this;
2950
+ decisionLogits(X: MLTensor): MLTensor;
2951
+ predict(X: MLTensor): MLTensor;
2952
+ score(X: MLTensor, y: MLTensor): number;
2953
+ }
2954
+
2955
+ declare class PCA {
2956
+ nComponents: number | null;
2957
+ components_: MLTensor | null;
2958
+ mean_: MLTensor | null;
2959
+ explainedVariance_: number[] | null;
2960
+ explainedVarianceRatio_: number[] | null;
2961
+ private _nc?;
2962
+ constructor({ nComponents }?: {
2963
+ nComponents?: number | null;
2964
+ });
2965
+ fit(X: MLTensor): this;
2966
+ transform(X: MLTensor): MLTensor;
2967
+ fit_transform(X: MLTensor): MLTensor;
2968
+ inverse_transform(Xr: MLTensor): MLTensor;
2969
+ }
2970
+
2971
+ declare class KMeans {
2972
+ nClusters: number;
2973
+ maxIter: number;
2974
+ nInit: number;
2975
+ randomState: number;
2976
+ clusterCenters_: MLTensor | null;
2977
+ labels_: MLTensor | null;
2978
+ inertia_: number | null;
2979
+ constructor({ nClusters, maxIter, nInit, randomState }?: {
2980
+ nClusters?: number;
2981
+ maxIter?: number;
2982
+ nInit?: number;
2983
+ randomState?: number;
2984
+ });
2985
+ fit(X: MLTensor): this;
2986
+ predict(X: MLTensor): MLTensor;
2987
+ fit_predict(X: MLTensor): MLTensor | null;
2988
+ }
2989
+
2990
+ declare class BaseKNN {
2991
+ nNeighbors: number;
2992
+ protected _classify: boolean;
2993
+ protected _X: MLTensor | null;
2994
+ protected _y: MLTensor | null;
2995
+ constructor(nNeighbors: number, classify: boolean);
2996
+ fit(X: MLTensor, y: MLTensor): this;
2997
+ predict(X: MLTensor): MLTensor;
2998
+ }
2999
+ declare class KNeighborsClassifier extends BaseKNN {
3000
+ constructor({ nNeighbors }?: {
3001
+ nNeighbors?: number | undefined;
3002
+ });
3003
+ score(X: MLTensor, y: MLTensor): number;
3004
+ }
3005
+ declare class KNeighborsRegressor extends BaseKNN {
3006
+ constructor({ nNeighbors }?: {
3007
+ nNeighbors?: number | undefined;
3008
+ });
3009
+ score(X: MLTensor, y: MLTensor): number;
3010
+ }
3011
+
3012
+ declare class GaussianNB {
3013
+ means_: MLTensor | null;
3014
+ variances_: MLTensor | null;
3015
+ priors_: MLTensor | null;
3016
+ classes_: MLTensor | null;
3017
+ constructor();
3018
+ fit(X: MLTensor, y: MLTensor): this;
3019
+ predict(X: MLTensor): MLTensor;
3020
+ score(X: MLTensor, y: MLTensor): number;
3021
+ }
3022
+
3023
+ type TreeParams = {
3024
+ maxDepth?: number;
3025
+ minSamplesSplit?: number;
3026
+ minSamplesLeaf?: number;
3027
+ maxFeatures?: number;
3028
+ randomState?: number;
3029
+ };
3030
+ type ResolvedTreeParams = Required<Pick<TreeParams, 'maxDepth' | 'minSamplesSplit' | 'minSamplesLeaf' | 'maxFeatures'>>;
3031
+ type TreeNodes = [MLTensor, MLTensor, MLTensor, MLTensor, MLTensor];
3032
+ declare class BaseTree {
3033
+ maxDepth: number;
3034
+ minSamplesSplit: number;
3035
+ minSamplesLeaf: number;
3036
+ maxFeatures: number;
3037
+ randomState: number;
3038
+ protected _classify: boolean;
3039
+ protected _nodes: TreeNodes | null;
3040
+ constructor(params: TreeParams, classify: boolean);
3041
+ fit(X: MLTensor, y: MLTensor): this;
3042
+ predict(X: MLTensor): MLTensor;
3043
+ }
3044
+ declare class DecisionTreeRegressor extends BaseTree {
3045
+ constructor(params?: TreeParams);
3046
+ score(X: MLTensor, y: MLTensor): number;
3047
+ }
3048
+ declare class DecisionTreeClassifier extends BaseTree {
3049
+ constructor(params?: TreeParams);
3050
+ score(X: MLTensor, y: MLTensor): number;
3051
+ }
3052
+ declare class BaseForest {
3053
+ nEstimators: number;
3054
+ maxDepth: number;
3055
+ minSamplesSplit: number;
3056
+ minSamplesLeaf: number;
3057
+ maxFeatures: number;
3058
+ randomState: number;
3059
+ protected _classify: boolean;
3060
+ protected _trees: TreeNodes[];
3061
+ constructor(params: TreeParams & {
3062
+ nEstimators?: number;
3063
+ }, classify: boolean);
3064
+ fit(X: MLTensor, y: MLTensor): this;
3065
+ predict(X: MLTensor): MLTensor;
3066
+ }
3067
+ declare class RandomForestRegressor extends BaseForest {
3068
+ constructor(params?: TreeParams & {
3069
+ nEstimators?: number;
3070
+ });
3071
+ score(X: MLTensor, y: MLTensor): number;
3072
+ }
3073
+ declare class RandomForestClassifier extends BaseForest {
3074
+ constructor(params?: TreeParams & {
3075
+ nEstimators?: number;
3076
+ });
3077
+ score(X: MLTensor, y: MLTensor): number;
3078
+ }
3079
+ declare class GradientBoostingRegressor {
3080
+ nEstimators: number;
3081
+ learningRate: number;
3082
+ params: ResolvedTreeParams;
3083
+ randomState: number;
3084
+ init_: number;
3085
+ private _trees;
3086
+ constructor({ nEstimators, learningRate, maxDepth, minSamplesSplit, minSamplesLeaf, randomState }?: TreeParams & {
3087
+ nEstimators?: number;
3088
+ learningRate?: number;
3089
+ });
3090
+ fit(X: MLTensor, y: MLTensor): this;
3091
+ predict(X: MLTensor): MLTensor;
3092
+ score(X: MLTensor, y: MLTensor): number;
3093
+ }
3094
+ declare class GradientBoostingClassifier {
3095
+ nEstimators: number;
3096
+ learningRate: number;
3097
+ params: ResolvedTreeParams;
3098
+ randomState: number;
3099
+ classes_: number[] | null;
3100
+ private _stages;
3101
+ constructor({ nEstimators, learningRate, maxDepth, minSamplesSplit, minSamplesLeaf, randomState }?: TreeParams & {
3102
+ nEstimators?: number;
3103
+ learningRate?: number;
3104
+ });
3105
+ fit(X: MLTensor, y: MLTensor): this;
3106
+ predict(X: MLTensor): MLTensor;
3107
+ score(X: MLTensor, y: MLTensor): number;
3108
+ }
3109
+
3110
+ type SplitOptions = {
3111
+ testSize?: number;
3112
+ shuffle?: boolean;
3113
+ randomState?: number;
3114
+ };
3115
+ type Fold = {
3116
+ train: number[];
3117
+ test: number[];
3118
+ };
3119
+ type ScoringFn = (yTrue: MLTensor, yPred: MLTensor) => number;
3120
+ type EstimatorFactory<T extends FitPredictEstimator = FitPredictEstimator> = (params?: Record<string, unknown> | null) => T;
3121
+ declare function train_test_split(X: MLTensor, y: MLTensor, { testSize, shuffle, randomState }?: SplitOptions): [MLTensor, MLTensor, MLTensor, MLTensor];
3122
+ declare class KFold {
3123
+ nSplits: number;
3124
+ shuffle: boolean;
3125
+ randomState: number;
3126
+ constructor({ nSplits, shuffle, randomState }?: {
3127
+ nSplits?: number;
3128
+ shuffle?: boolean;
3129
+ randomState?: number;
3130
+ });
3131
+ split(n: number): Fold[];
3132
+ }
3133
+ declare class TimeSeriesSplit {
3134
+ nSplits: number;
3135
+ constructor({ nSplits }?: {
3136
+ nSplits?: number;
3137
+ });
3138
+ split(n: number): Fold[];
3139
+ }
3140
+ declare function cross_val_score(makeEstimator: EstimatorFactory, X: MLTensor, y: MLTensor, { cv, scoring, shuffle, randomState }?: {
3141
+ cv?: number;
3142
+ scoring?: ScoringFn | null;
3143
+ shuffle?: boolean;
3144
+ randomState?: number;
3145
+ }): number[];
3146
+ declare class GridSearchCV {
3147
+ makeEstimator: EstimatorFactory;
3148
+ paramGrid: Record<string, readonly unknown[]>;
3149
+ cv: number;
3150
+ scoring: ScoringFn | null;
3151
+ bestParams_: Record<string, unknown> | null;
3152
+ bestScore_: number;
3153
+ bestEstimator_: FitPredictEstimator | null;
3154
+ constructor(makeEstimator: EstimatorFactory, paramGrid: Record<string, readonly unknown[]>, { cv, scoring }?: {
3155
+ cv?: number;
3156
+ scoring?: ScoringFn | null;
3157
+ });
3158
+ fit(X: MLTensor, y: MLTensor): this;
3159
+ predict(X: MLTensor): MLTensor;
3160
+ }
3161
+
3162
+ type index$1_DecisionTreeClassifier = DecisionTreeClassifier;
3163
+ declare const index$1_DecisionTreeClassifier: typeof DecisionTreeClassifier;
3164
+ type index$1_DecisionTreeRegressor = DecisionTreeRegressor;
3165
+ declare const index$1_DecisionTreeRegressor: typeof DecisionTreeRegressor;
3166
+ type index$1_ElasticNet = ElasticNet;
3167
+ declare const index$1_ElasticNet: typeof ElasticNet;
3168
+ type index$1_GaussianNB = GaussianNB;
3169
+ declare const index$1_GaussianNB: typeof GaussianNB;
3170
+ type index$1_GradientBoostingClassifier = GradientBoostingClassifier;
3171
+ declare const index$1_GradientBoostingClassifier: typeof GradientBoostingClassifier;
3172
+ type index$1_GradientBoostingRegressor = GradientBoostingRegressor;
3173
+ declare const index$1_GradientBoostingRegressor: typeof GradientBoostingRegressor;
3174
+ type index$1_GridSearchCV = GridSearchCV;
3175
+ declare const index$1_GridSearchCV: typeof GridSearchCV;
3176
+ type index$1_KFold = KFold;
3177
+ declare const index$1_KFold: typeof KFold;
3178
+ type index$1_KMeans = KMeans;
3179
+ declare const index$1_KMeans: typeof KMeans;
3180
+ type index$1_KNeighborsClassifier = KNeighborsClassifier;
3181
+ declare const index$1_KNeighborsClassifier: typeof KNeighborsClassifier;
3182
+ type index$1_KNeighborsRegressor = KNeighborsRegressor;
3183
+ declare const index$1_KNeighborsRegressor: typeof KNeighborsRegressor;
3184
+ type index$1_LabelEncoder = LabelEncoder;
3185
+ declare const index$1_LabelEncoder: typeof LabelEncoder;
3186
+ type index$1_Lasso = Lasso;
3187
+ declare const index$1_Lasso: typeof Lasso;
3188
+ type index$1_LinearRegression = LinearRegression;
3189
+ declare const index$1_LinearRegression: typeof LinearRegression;
3190
+ type index$1_LogisticRegression = LogisticRegression;
3191
+ declare const index$1_LogisticRegression: typeof LogisticRegression;
3192
+ type index$1_MinMaxScaler = MinMaxScaler;
3193
+ declare const index$1_MinMaxScaler: typeof MinMaxScaler;
3194
+ type index$1_OneHotEncoder = OneHotEncoder;
3195
+ declare const index$1_OneHotEncoder: typeof OneHotEncoder;
3196
+ type index$1_PCA = PCA;
3197
+ declare const index$1_PCA: typeof PCA;
3198
+ type index$1_RandomForestClassifier = RandomForestClassifier;
3199
+ declare const index$1_RandomForestClassifier: typeof RandomForestClassifier;
3200
+ type index$1_RandomForestRegressor = RandomForestRegressor;
3201
+ declare const index$1_RandomForestRegressor: typeof RandomForestRegressor;
3202
+ type index$1_Ridge = Ridge;
3203
+ declare const index$1_Ridge: typeof Ridge;
3204
+ type index$1_StandardScaler = StandardScaler;
3205
+ declare const index$1_StandardScaler: typeof StandardScaler;
3206
+ type index$1_TimeSeriesSplit = TimeSeriesSplit;
3207
+ declare const index$1_TimeSeriesSplit: typeof TimeSeriesSplit;
3208
+ declare const index$1_accuracy_score: typeof accuracy_score;
3209
+ declare const index$1_confusion_matrix: typeof confusion_matrix;
3210
+ declare const index$1_cross_val_score: typeof cross_val_score;
3211
+ declare const index$1_mean_absolute_error: typeof mean_absolute_error;
3212
+ declare const index$1_mean_squared_error: typeof mean_squared_error;
3213
+ declare const index$1_r2_score: typeof r2_score;
3214
+ declare const index$1_train_test_split: typeof train_test_split;
3215
+ declare namespace index$1 {
3216
+ export { index$1_DecisionTreeClassifier as DecisionTreeClassifier, index$1_DecisionTreeRegressor as DecisionTreeRegressor, index$1_ElasticNet as ElasticNet, index$1_GaussianNB as GaussianNB, index$1_GradientBoostingClassifier as GradientBoostingClassifier, index$1_GradientBoostingRegressor as GradientBoostingRegressor, index$1_GridSearchCV as GridSearchCV, index$1_KFold as KFold, index$1_KMeans as KMeans, index$1_KNeighborsClassifier as KNeighborsClassifier, index$1_KNeighborsRegressor as KNeighborsRegressor, index$1_LabelEncoder as LabelEncoder, index$1_Lasso as Lasso, index$1_LinearRegression as LinearRegression, index$1_LogisticRegression as LogisticRegression, index$1_MinMaxScaler as MinMaxScaler, index$1_OneHotEncoder as OneHotEncoder, index$1_PCA as PCA, index$1_RandomForestClassifier as RandomForestClassifier, index$1_RandomForestRegressor as RandomForestRegressor, index$1_Ridge as Ridge, index$1_StandardScaler as StandardScaler, index$1_TimeSeriesSplit as TimeSeriesSplit, index$1_accuracy_score as accuracy_score, index$1_confusion_matrix as confusion_matrix, index$1_cross_val_score as cross_val_score, index$1_mean_absolute_error as mean_absolute_error, index$1_mean_squared_error as mean_squared_error, index$1_r2_score as r2_score, index$1_train_test_split as train_test_split };
3217
+ }
3218
+
3219
+ type NumericVectorInput = Tensor | number | ArrayLike<number>;
3220
+ type NumericMatrixInput = Tensor | ReadonlyArray<ArrayLike<number>>;
3221
+ type NumericElementInput = Tensor | number;
3222
+ type NumericArrayInput = Tensor | ArrayLike<number>;
3223
+ type NumericShape = number | readonly number[];
3224
+ type ScalarFn$1 = (x: number) => number;
3225
+ type VectorFn = (x: number[]) => number;
3226
+ type GradientFn = (x: number[]) => number[];
3227
+ type ResidualFn = (x: number[]) => number[];
3228
+ type JacobianFn = (x: number[], m: number) => number[][];
3229
+ type Bounds = ReadonlyArray<readonly [number, number] | null | undefined>;
3230
+ type TestResult = {
3231
+ statistic: number;
3232
+ pvalue: number;
3233
+ df?: number;
3234
+ };
3235
+
3236
+ type DistOptions = {
3237
+ loc?: number;
3238
+ scale?: number;
3239
+ df?: number;
3240
+ d1?: number;
3241
+ d2?: number;
3242
+ refineSteps?: number;
3243
+ tol?: number;
3244
+ lowerLimit?: number;
3245
+ };
3246
+ declare const normal: {
3247
+ cdf: (x: NumericElementInput, opts?: DistOptions) => number | Tensor;
3248
+ pdf: (x: NumericElementInput, opts?: DistOptions) => number | Tensor;
3249
+ ppf: (p: NumericElementInput, opts?: DistOptions) => number | Tensor;
3250
+ };
3251
+ declare const studentT: {
3252
+ cdf: (x: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3253
+ pdf: (x: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3254
+ ppf: (p: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3255
+ };
3256
+ declare const chi2: {
3257
+ cdf: (x: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3258
+ pdf: (x: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3259
+ ppf: (p: NumericElementInput, df?: number, opts?: DistOptions) => number | Tensor;
3260
+ };
3261
+ declare const fisherF: {
3262
+ cdf: (x: NumericElementInput, d1?: number, d2?: number, opts?: DistOptions) => number | Tensor;
3263
+ pdf: (x: NumericElementInput, d1?: number, d2?: number, opts?: DistOptions) => number | Tensor;
3264
+ ppf: (p: NumericElementInput, d1?: number, d2?: number, opts?: DistOptions) => number | Tensor;
3265
+ };
3266
+
3267
+ declare function erfScalar(x: number): number;
3268
+ declare function erfcScalar(x: number): number;
3269
+ declare function lgammaScalar(x: number): number;
3270
+ declare function gammaScalar(x: number): number;
3271
+ declare function digammaScalar(x: number): number;
3272
+
3273
+ type PpfOptions = {
3274
+ refineSteps?: number;
3275
+ };
3276
+ declare function lowerGammaRegularized(a: number, x: number): number;
3277
+ declare function betaRegularized(a: number, b: number, x: number): number;
3278
+ declare function normalCdfScalar(z: number): number;
3279
+ declare function normalPdfScalar(z: number): number;
3280
+ declare function normalPpfScalar(p: number, opts?: PpfOptions): number;
3281
+
3282
+ type NelderMeadOptions = {
3283
+ maxIter?: number;
3284
+ tol?: number;
3285
+ initialStep?: number;
3286
+ zeroStep?: number;
3287
+ alpha?: number;
3288
+ gamma?: number;
3289
+ rho?: number;
3290
+ sigma?: number;
3291
+ };
3292
+ type MinimizeResult$4 = {
3293
+ point: number[];
3294
+ value: number;
3295
+ iterations: number;
3296
+ converged: boolean;
3297
+ };
3298
+ declare function nelderMead(f: VectorFn, x0: readonly number[], opts?: NelderMeadOptions): MinimizeResult$4;
3299
+
3300
+ type DifferentialEvolutionOptions = {
3301
+ seed?: number;
3302
+ populationSize?: number;
3303
+ mutation?: number;
3304
+ recombination?: number;
3305
+ maxIter?: number;
3306
+ tol?: number;
3307
+ };
3308
+ type MinimizeResult$3 = {
3309
+ point: number[];
3310
+ value: number;
3311
+ iterations: number;
3312
+ converged: boolean;
3313
+ };
3314
+ declare function differentialEvolution(f: VectorFn, bounds: ReadonlyArray<readonly [number, number]>, opts?: DifferentialEvolutionOptions): MinimizeResult$3;
3315
+
3316
+ type LbfgsOptions = {
3317
+ memory?: number;
3318
+ maxIter?: number;
3319
+ gtol?: number;
3320
+ ftol?: number;
3321
+ step?: number;
3322
+ gradient?: GradientFn;
3323
+ };
3324
+ type MinimizeResult$2 = {
3325
+ point: number[];
3326
+ value: number;
3327
+ iterations: number;
3328
+ converged: boolean;
3329
+ };
3330
+ declare function lbfgs(f: VectorFn, x0: readonly number[], opts?: LbfgsOptions): MinimizeResult$2;
3331
+ declare function lbfgsB(f: VectorFn, x0: readonly number[], bounds: Bounds, opts?: LbfgsOptions): MinimizeResult$2;
3332
+
3333
+ type LMOptions = {
3334
+ maxIter?: number;
3335
+ tol?: number;
3336
+ step?: number;
3337
+ jacobian?: JacobianFn;
3338
+ lambda?: number;
3339
+ };
3340
+ type MinimizeResult$1 = {
3341
+ point: number[];
3342
+ value: number;
3343
+ iterations: number;
3344
+ converged: boolean;
3345
+ };
3346
+ declare function levenbergMarquardt(residual: ResidualFn, x0: readonly number[], opts?: LMOptions): MinimizeResult$1;
3347
+
3348
+ type MinimizeResult = {
3349
+ point: number[];
3350
+ value: number;
3351
+ iterations: number;
3352
+ converged: boolean;
3353
+ };
3354
+ type InnerMinimizer = (f: VectorFn, x0: readonly number[], opts?: object) => MinimizeResult;
3355
+ type ConstrainedOptions = {
3356
+ bounds?: Bounds | null;
3357
+ inequalities?: VectorFn[];
3358
+ equalities?: VectorFn[];
3359
+ outerIter?: number;
3360
+ ctol?: number;
3361
+ penaltyGrowth?: number;
3362
+ inner?: InnerMinimizer;
3363
+ innerOpts?: object;
3364
+ penalty?: number;
3365
+ };
3366
+ declare function constrainedMinimize(f: VectorFn, x0: readonly number[], opts?: ConstrainedOptions): MinimizeResult;
3367
+
3368
+ type RootOptions = {
3369
+ tol?: number;
3370
+ maxIter?: number;
3371
+ step?: number;
3372
+ derivative?: (x: number) => number;
3373
+ };
3374
+ type RootResult = {
3375
+ root: number;
3376
+ iterations: number;
3377
+ converged: boolean;
3378
+ };
3379
+ declare function bisect(f: (x: number) => number, a: number, b: number, opts?: RootOptions): RootResult;
3380
+ declare function newton(f: (x: number) => number, x0: number, opts?: RootOptions): RootResult;
3381
+ declare function brentq(f: (x: number) => number, a: number, b: number, opts?: RootOptions): RootResult;
3382
+
3383
+ type IntegrateOptions = {
3384
+ n?: number;
3385
+ tol?: number;
3386
+ maxDepth?: number;
3387
+ };
3388
+ type ScalarFn = (x: number) => number;
3389
+ declare function trapezoid(f: ScalarFn, a: number, b: number, opts?: IntegrateOptions): number;
3390
+ declare function simpson(f: ScalarFn, a: number, b: number, opts?: IntegrateOptions): number;
3391
+ declare function quadrature(f: ScalarFn, a: number, b: number, opts?: IntegrateOptions): number;
3392
+
3393
+ declare function linearInterp(xs: readonly number[], ys: readonly number[], xq: number): number;
3394
+ declare function linearInterp(xs: readonly number[], ys: readonly number[], xq: readonly number[]): number[];
3395
+ type CubicSpline = {
3396
+ xs: readonly number[];
3397
+ ys: readonly number[];
3398
+ coefficients: number[];
3399
+ evaluate: {
3400
+ (xq: number): number;
3401
+ (xq: readonly number[]): number[];
3402
+ };
3403
+ };
3404
+ declare function cubicSpline(xs: readonly number[], ys: readonly number[]): CubicSpline;
3405
+
3406
+ declare const fft: (x: Tensor) => Tensor;
3407
+ declare const ifft: (x: Tensor) => Tensor;
3408
+
3409
+ type MeanOptions = {
3410
+ popmean?: number;
3411
+ };
3412
+ type TTestOptions = MeanOptions & {
3413
+ equalVar?: boolean;
3414
+ };
3415
+ type Chi2Options = {
3416
+ ddof?: number;
3417
+ };
3418
+ type KsOptions = {
3419
+ loc?: number;
3420
+ scale?: number;
3421
+ };
3422
+ declare function tTest1Samp(x: NumericVectorInput, opts?: MeanOptions): TestResult;
3423
+ declare function tTestInd(x: NumericVectorInput, y: NumericVectorInput, opts?: TTestOptions): TestResult;
3424
+ declare function tTestPaired(x: NumericVectorInput, y: NumericVectorInput, opts?: MeanOptions): TestResult;
3425
+ declare function chi2Gof(observed: NumericVectorInput, expected?: NumericVectorInput | null, opts?: Chi2Options): TestResult;
3426
+ declare function chi2Independence(table: NumericMatrixInput): TestResult;
3427
+ declare function ksTest1Samp(x: NumericVectorInput, cdf?: ScalarFn$1, opts?: KsOptions): Omit<TestResult, 'df'>;
3428
+ declare function ksTest2Samp(x: NumericVectorInput, y: NumericVectorInput): Omit<TestResult, 'df'>;
3429
+ declare function jarqueBera(x: NumericVectorInput): TestResult;
3430
+ declare function dagostinoK2(x: NumericVectorInput): TestResult;
3431
+ declare function andersonDarling(x: NumericVectorInput): Omit<TestResult, 'df'>;
3432
+ declare function mannWhitneyU(x: NumericVectorInput, y: NumericVectorInput): Omit<TestResult, 'df'>;
3433
+
3434
+ type AcfOptions = {
3435
+ nlags?: number;
3436
+ };
3437
+ type LjungBoxOptions = {
3438
+ lags?: number;
3439
+ modelDf?: number;
3440
+ };
3441
+ type PeriodogramOptions = {
3442
+ detrend?: boolean;
3443
+ };
3444
+ declare function acf(x: NumericVectorInput, opts?: AcfOptions): Tensor;
3445
+ declare function pacf(x: NumericVectorInput, opts?: AcfOptions): Tensor;
3446
+ declare function ljungBox(x: NumericVectorInput, opts?: LjungBoxOptions): TestResult;
3447
+ declare function durbinWatson(x: NumericVectorInput): number;
3448
+ declare function periodogram(x: NumericVectorInput, opts?: PeriodogramOptions): Tensor;
3449
+
3450
+ type ConvMode = 'full' | 'same' | 'valid';
3451
+ type ModeOptions = {
3452
+ mode?: ConvMode;
3453
+ };
3454
+ type RollingOptions = {
3455
+ ddof?: number;
3456
+ };
3457
+ declare function convolve(a: NumericVectorInput, b: NumericVectorInput, opts?: ModeOptions): Tensor;
3458
+ declare function correlate(a: NumericVectorInput, b: NumericVectorInput, opts?: ModeOptions): Tensor;
3459
+ declare function rollingSum(x: NumericVectorInput, window: number): Tensor;
3460
+ declare function rollingMean(x: NumericVectorInput, window: number): Tensor;
3461
+ declare function rollingStd(x: NumericVectorInput, window: number, opts?: RollingOptions): Tensor;
3462
+ declare function rollingMin(x: NumericVectorInput, window: number): Tensor;
3463
+ declare function rollingMax(x: NumericVectorInput, window: number): Tensor;
3464
+ declare function polyfit(x: NumericVectorInput, y: NumericVectorInput, deg: number): Tensor;
3465
+ declare function polyval(coeffs: NumericVectorInput, x: number): number;
3466
+ declare function polyval(coeffs: NumericVectorInput, x: NumericArrayInput): Tensor;
3467
+ declare function polyroots(coeffs: NumericVectorInput): Tensor;
3468
+
3469
+ type RandomOptions = TensorDataOptions & {
3470
+ low?: number;
3471
+ high?: number;
3472
+ loc?: number;
3473
+ scale?: number;
3474
+ df?: number;
3475
+ };
3476
+ declare class Generator$1 {
3477
+ private readonly _next;
3478
+ constructor(seed?: number);
3479
+ _uniformPositive(): number;
3480
+ _normalDraw(): number;
3481
+ _gammaDraw(a: number): number;
3482
+ _fill(shape: NumericShape, opts: TensorDataOptions, draw: () => number): Tensor;
3483
+ uniform(shape: NumericShape, opts?: RandomOptions): Tensor;
3484
+ normal(shape: NumericShape, opts?: RandomOptions): Tensor;
3485
+ standardT(shape: NumericShape, opts?: RandomOptions): Tensor;
3486
+ chi2(shape: NumericShape, opts?: RandomOptions): Tensor;
3487
+ exponential(shape: NumericShape, opts?: RandomOptions): Tensor;
3488
+ multivariateNormal(mean: NumericVectorInput, cov: NumericMatrixInput, n?: number, opts?: TensorDataOptions): Tensor;
3489
+ }
3490
+
3491
+ declare const index_acf: typeof acf;
3492
+ declare const index_andersonDarling: typeof andersonDarling;
3493
+ declare const index_betaRegularized: typeof betaRegularized;
3494
+ declare const index_bisect: typeof bisect;
3495
+ declare const index_brentq: typeof brentq;
3496
+ declare const index_chi2: typeof chi2;
3497
+ declare const index_chi2Gof: typeof chi2Gof;
3498
+ declare const index_chi2Independence: typeof chi2Independence;
3499
+ declare const index_constrainedMinimize: typeof constrainedMinimize;
3500
+ declare const index_convolve: typeof convolve;
3501
+ declare const index_correlate: typeof correlate;
3502
+ declare const index_cubicSpline: typeof cubicSpline;
3503
+ declare const index_dagostinoK2: typeof dagostinoK2;
3504
+ declare const index_differentialEvolution: typeof differentialEvolution;
3505
+ declare const index_digammaScalar: typeof digammaScalar;
3506
+ declare const index_durbinWatson: typeof durbinWatson;
3507
+ declare const index_erfScalar: typeof erfScalar;
3508
+ declare const index_erfcScalar: typeof erfcScalar;
3509
+ declare const index_fft: typeof fft;
3510
+ declare const index_fisherF: typeof fisherF;
3511
+ declare const index_gammaScalar: typeof gammaScalar;
3512
+ declare const index_ifft: typeof ifft;
3513
+ declare const index_jarqueBera: typeof jarqueBera;
3514
+ declare const index_ksTest1Samp: typeof ksTest1Samp;
3515
+ declare const index_ksTest2Samp: typeof ksTest2Samp;
3516
+ declare const index_lbfgs: typeof lbfgs;
3517
+ declare const index_lbfgsB: typeof lbfgsB;
3518
+ declare const index_levenbergMarquardt: typeof levenbergMarquardt;
3519
+ declare const index_lgammaScalar: typeof lgammaScalar;
3520
+ declare const index_linearInterp: typeof linearInterp;
3521
+ declare const index_ljungBox: typeof ljungBox;
3522
+ declare const index_lowerGammaRegularized: typeof lowerGammaRegularized;
3523
+ declare const index_mannWhitneyU: typeof mannWhitneyU;
3524
+ declare const index_nelderMead: typeof nelderMead;
3525
+ declare const index_newton: typeof newton;
3526
+ declare const index_normal: typeof normal;
3527
+ declare const index_normalCdfScalar: typeof normalCdfScalar;
3528
+ declare const index_normalPdfScalar: typeof normalPdfScalar;
3529
+ declare const index_normalPpfScalar: typeof normalPpfScalar;
3530
+ declare const index_pacf: typeof pacf;
3531
+ declare const index_periodogram: typeof periodogram;
3532
+ declare const index_polyfit: typeof polyfit;
3533
+ declare const index_polyroots: typeof polyroots;
3534
+ declare const index_polyval: typeof polyval;
3535
+ declare const index_qr: typeof qr;
3536
+ declare const index_quadrature: typeof quadrature;
3537
+ declare const index_rollingMax: typeof rollingMax;
3538
+ declare const index_rollingMean: typeof rollingMean;
3539
+ declare const index_rollingMin: typeof rollingMin;
3540
+ declare const index_rollingStd: typeof rollingStd;
3541
+ declare const index_rollingSum: typeof rollingSum;
3542
+ declare const index_simpson: typeof simpson;
3543
+ declare const index_studentT: typeof studentT;
3544
+ declare const index_tTest1Samp: typeof tTest1Samp;
3545
+ declare const index_tTestInd: typeof tTestInd;
3546
+ declare const index_tTestPaired: typeof tTestPaired;
3547
+ declare const index_trapezoid: typeof trapezoid;
3548
+ declare namespace index {
3549
+ export { Generator$1 as Generator, index_acf as acf, index_andersonDarling as andersonDarling, index_betaRegularized as betaRegularized, index_bisect as bisect, index_brentq as brentq, index_chi2 as chi2, index_chi2Gof as chi2Gof, index_chi2Independence as chi2Independence, index_constrainedMinimize as constrainedMinimize, index_convolve as convolve, index_correlate as correlate, index_cubicSpline as cubicSpline, index_dagostinoK2 as dagostinoK2, index_differentialEvolution as differentialEvolution, index_digammaScalar as digammaScalar, index_durbinWatson as durbinWatson, index_erfScalar as erfScalar, index_erfcScalar as erfcScalar, index_fft as fft, index_fisherF as fisherF, index_gammaScalar as gammaScalar, index_ifft as ifft, index_jarqueBera as jarqueBera, index_ksTest1Samp as ksTest1Samp, index_ksTest2Samp as ksTest2Samp, index_lbfgs as lbfgs, index_lbfgsB as lbfgsB, index_levenbergMarquardt as levenbergMarquardt, index_lgammaScalar as lgammaScalar, index_linearInterp as linearInterp, index_ljungBox as ljungBox, index_lowerGammaRegularized as lowerGammaRegularized, index_mannWhitneyU as mannWhitneyU, index_nelderMead as nelderMead, index_newton as newton, index_normal as normal, index_normalCdfScalar as normalCdfScalar, index_normalPdfScalar as normalPdfScalar, index_normalPpfScalar as normalPpfScalar, index_pacf as pacf, index_periodogram as periodogram, index_polyfit as polyfit, index_polyroots as polyroots, index_polyval as polyval, index_qr as qr, index_quadrature as quadrature, index_rollingMax as rollingMax, index_rollingMean as rollingMean, index_rollingMin as rollingMin, index_rollingStd as rollingStd, index_rollingSum as rollingSum, index_simpson as simpson, index_studentT as studentT, index_tTest1Samp as tTest1Samp, index_tTestInd as tTestInd, index_tTestPaired as tTestPaired, index_trapezoid as trapezoid };
3550
+ }
3551
+
3552
+ export { Accuracy, Adam, AdamW, AdaptiveAvgPool2d, AvgPool2d, BCELoss, BatchNorm1d, BatchNorm2d, BatchSampler, CPUTarget, CPU_DEVICE, CSVLogger, CUDATarget, Callback, ConfusionMatrix, ConsoleLogger, Conv1d, Conv2d, CosineAnnealingLR, CrossEntropyLoss, DataLoader, Dataset, Dropout, ELU, EarlyStopping, Embedding, F, F1Score, Flatten, GELU, GPU_DEVICE, GRU, GRUCell, GradMode, GradientAccumulationScheduler, LRScheduler, LSTM, LSTMCell, LayerNorm, LeakyReLU, LearningRateMonitor, LightningModule, Linear, LogSoftmax, Logger, MSELoss, MapDataset, MaxPool2d, MeanMetric, Metric, MetricCollection, ModelCheckpoint, Module, ModuleDict, ModuleList, MultiheadAttention, NLLLoss, Optimizer, Parameter, PositionalEncoding, Precision, ProgressCallback, RandomSampler, ReLU, Recall, ReduceLROnPlateau, SGD, Sampler, Sequential, SequentialSampler, SiLU, Sigmoid, Softmax, StepLR, SumMetric, SymbolicTensor, Tanh, Tensor, TensorDataset, Timer, Tokenizer, TraceLevel, Trainer, Transformer, TransformerDecoder, TransformerDecoderLayer, TransformerEncoder, TransformerEncoderLayer, Vocab, WASM_DEVICE, WEBGPU_DEVICE, WasmTarget, WebGPUTarget, abs, add, applyCheckpoint, arange, argmax, argmin, argsort, broadcast_in_dim, cat, ceil, chunk, clamp, clipGradNorm_, clipGradValue_, clone, compile, compileWithBackward, contiguous, cos, cumsum, index$5 as data, defaultCollate, dispatcher, div, dot, empty, emptyLike, enableGrad, eq, erf, erfc, exp, expand, eye, flip, floor, flushWebGPUEager, fromBuffer, full, fullLike, gamma, gather, ge, gelu$1 as gelu, getDefaultDevice, gt, index_select, init, le, lgamma, index$2 as lightning, linalg, linspace, loadCheckpoint, log, log_softmax$1 as log_softmax, lt, matmul, max, maximum, mean, fs as memfs, min, minimum, index$1 as ml, mul, narrow, ne, neg, index$6 as nn, noGrad, index as numeric, one_hot, ones, onesLike, ops, index$3 as optim, pad, permute, pow, preloadCudaRuntime, preloadWebGPU, printModule, prod, randn, randnLike, randperm, relu$1 as relu, repeat, reshape, roll, rsqrt, scalar, scan, scatter, scatter_add, select, serializeCheckpoint, setDefaultDevice, sigmoid$1 as sigmoid, sign, silu$1 as silu, sin, slice, softmax$1 as softmax, sort, split, sqrt, squeeze, stack, sub, sum, tanh$1 as tanh, tensor, tile, index$4 as tokenizer, topk, trace, transpose, unsqueeze, where, zeros, zerosLike };