@genai-fi/nanogpt 0.7.3 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generator.d.ts +25 -2
- package/dist/Generator.js +152 -49
- package/dist/{RealDiv-Dy0p8Bvo.js → RealDiv-D_q39E3A.js} +13 -13
- package/dist/{Reshape-DvudQDvJ.js → Reshape-41YpQqEo.js} +1 -1
- package/dist/{Reshape-DH5srBP0.js → Reshape-Bh_jzKzV.js} +5 -5
- package/dist/TeachableLLM.d.ts +6 -6
- package/dist/TeachableLLM.js +33 -31
- package/dist/Trainer.d.ts +13 -2
- package/dist/Trainer.js +21 -12
- package/dist/{axis_util-BzbKo31C.js → axis_util-Did9235A.js} +3 -3
- package/dist/backend.js +2 -2
- package/dist/{backend_util-TE7aTPhZ.js → backend_util-yC3YH1jo.js} +58 -58
- package/dist/{broadcast_to-CdbwV-Dj.js → broadcast_to-CUvOdOT5.js} +2 -2
- package/dist/checks/appendCache.d.ts +1 -0
- package/dist/checks/appendCache.js +22 -0
- package/dist/checks/attentionMask.d.ts +1 -0
- package/dist/checks/attentionMask.js +37 -0
- package/dist/checks/check.d.ts +9 -0
- package/dist/checks/check.js +20 -0
- package/dist/checks/gelu.d.ts +1 -0
- package/dist/checks/gelu.js +18 -0
- package/dist/checks/index.d.ts +19 -0
- package/dist/checks/index.js +21 -0
- package/dist/checks/normRMS.d.ts +1 -0
- package/dist/checks/normRMS.js +16 -0
- package/dist/checks/normRMSGrad.d.ts +1 -0
- package/dist/checks/normRMSGrad.js +12 -0
- package/dist/checks/qkv.d.ts +1 -0
- package/dist/checks/qkv.js +25 -0
- package/dist/checks/rope.d.ts +1 -0
- package/dist/checks/rope.js +21 -0
- package/dist/{concat-CsxrgovM.js → concat-pHiVqR3L.js} +1 -1
- package/dist/{dataset-CtdBYwjo.js → dataset-DPPl-iLT.js} +9 -9
- package/dist/{dropout-DYs5QFGQ.js → dropout-CcKSfOYE.js} +18 -18
- package/dist/exports_initializers-DKk7-bsx.js +16 -0
- package/dist/{gather-CMMy2KEG.js → gather-CPg6ZlQA.js} +1 -1
- package/dist/{gelu-C-dPj6Ku.js → gelu-BkcmEEyD.js} +1 -1
- package/dist/{gpgpu_math-DGNLNL4I.js → gpgpu_math-D_ODOLix.js} +26 -26
- package/dist/{index-BoWRt-10.js → index-DdmHGZjq.js} +659 -650
- package/dist/{index-CLthM0TO.js → index-evZ57wr4.js} +185 -185
- package/dist/{kernel_funcs_utils-BYKWV8Aa.js → kernel_funcs_utils-CDfFpUab.js} +21 -21
- package/dist/layers/BaseLayer.d.ts +8 -13
- package/dist/layers/BaseLayer.js +25 -13
- package/dist/layers/CausalSelfAttention.d.ts +3 -2
- package/dist/layers/CausalSelfAttention.js +28 -28
- package/dist/layers/MLP.d.ts +3 -2
- package/dist/layers/MLP.js +16 -20
- package/dist/layers/PositionEmbedding.d.ts +9 -0
- package/dist/layers/PositionEmbedding.js +45 -0
- package/dist/layers/RMSNorm.d.ts +3 -2
- package/dist/layers/RMSNorm.js +6 -6
- package/dist/layers/RoPECache.d.ts +1 -1
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.d.ts +3 -2
- package/dist/layers/TiedEmbedding.js +29 -7
- package/dist/layers/TransformerBlock.d.ts +3 -2
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/load.d.ts +2 -2
- package/dist/loader/loadHF.d.ts +2 -2
- package/dist/loader/loadTransformers.d.ts +4 -2
- package/dist/loader/loadTransformers.js +10 -9
- package/dist/loader/newZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.d.ts +2 -2
- package/dist/loader/oldZipLoad.js +44 -51
- package/dist/loader/save.d.ts +8 -0
- package/dist/loader/save.js +62 -0
- package/dist/{log_sum_exp-DbjkV734.js → log_sum_exp-C8yFJfZz.js} +45 -24
- package/dist/main.d.ts +6 -4
- package/dist/main.js +24 -18
- package/dist/{mat_mul-8m8pfdcx.js → mat_mul-Dpy2mMRu.js} +1 -1
- package/dist/mod-CbibJi3D.js +27 -0
- package/dist/models/NanoGPTV1.d.ts +15 -0
- package/dist/models/NanoGPTV1.js +71 -0
- package/dist/{config.d.ts → models/config.d.ts} +1 -0
- package/dist/{config.js → models/config.js} +1 -0
- package/dist/models/factory.d.ts +3 -0
- package/dist/models/factory.js +14 -0
- package/dist/models/model.d.ts +26 -0
- package/dist/models/model.js +70 -0
- package/dist/{mulmat_packed_gpu-VSekgsNv.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
- package/dist/{ones-Dj0SDhHf.js → ones-BAqVh-eA.js} +2 -2
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.js +9 -9
- package/dist/ops/cpu/adamMoments.js +2 -2
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +2 -2
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +7 -7
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +2 -2
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +10 -10
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/ops/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +3 -3
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +3 -3
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +5 -5
- package/dist/ops/webgpu/qkv.js +3 -3
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +4 -4
- package/dist/ops-542ai2vG.js +1525 -0
- package/dist/{random_width-sZORGo5k.js → random_width-DKGeiFuR.js} +1471 -1538
- package/dist/{range-CRuAh-gd.js → range-BcUvLuf5.js} +1 -1
- package/dist/{reciprocal-BvGAyKyu.js → reciprocal-DhDWSKiD.js} +1 -1
- package/dist/{register_all_kernels-BwDSRN-f.js → register_all_kernels-Do9VvZmo.js} +2488 -2534
- package/dist/{max-Ddnnb5xe.js → relu-B1AXs7p5.js} +6 -6
- package/dist/{reshape-CdBq1WJ6.js → reshape-WeJkT3ja.js} +1 -1
- package/dist/{scatter_nd_util-DUstGbU1.js → scatter_nd_util-B7yDhiQr.js} +1 -1
- package/dist/{selu_util-BJEXVvjX.js → selu_util-BgUO9gHY.js} +125 -146
- package/dist/{shared-wS99K7_n.js → shared-CZiWmQCI.js} +1 -1
- package/dist/{shared-B8ztnyEk.js → shared-V6D_md-c.js} +72 -72
- package/dist/{sin-BeA3tsEd.js → sin-CPxad7Am.js} +1 -1
- package/dist/{slice-BiOsknYS.js → slice-B7jXtPnp.js} +1 -1
- package/dist/{softmax-Bv_6lyMX.js → softmax-BfsyI4As.js} +1 -1
- package/dist/{split-B-dikLRw.js → split-BPxr8_8m.js} +1 -1
- package/dist/{stack-B17UN2nn.js → stack-BNwLzE43.js} +1 -1
- package/dist/{sum-66ew2byf.js → sum-ByFINZgi.js} +3 -3
- package/dist/{tensor-JwS7ZYY6.js → tensor-DbqgIV9B.js} +1 -1
- package/dist/tensor1d-CtJq5BOv.js +27 -0
- package/dist/{tensor2d-wxPAnDQy.js → tensor2d-CObBWBkW.js} +1 -1
- package/dist/tensor3d-BOukqWwr.js +30 -0
- package/dist/tensor4d-DLtk7Nxh.js +30 -0
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.d.ts +2 -2
- package/dist/training/FullTrainer.d.ts +3 -3
- package/dist/training/FullTrainer.js +61 -69
- package/dist/training/Trainer.d.ts +15 -3
- package/dist/training/Trainer.js +39 -47
- package/dist/training/sparseCrossEntropy.js +12 -13
- package/dist/utilities/arrayClose.d.ts +1 -1
- package/dist/utilities/arrayClose.js +16 -7
- package/dist/utilities/dummy.d.ts +4 -4
- package/dist/utilities/dummy.js +13 -13
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/parameters.d.ts +1 -1
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-BuddVFLa.js → variable-DPFOJyRG.js} +1 -1
- package/dist/{webgpu_program-PFzf1hAQ.js → webgpu_program-Dhk9R5aG.js} +1 -1
- package/dist/{webgpu_util-D____QpY.js → webgpu_util-BqGnZg8t.js} +27 -27
- package/dist/{zeros--BdLQ3oG.js → zeros-Dnwix0p4.js} +1 -1
- package/package.json +2 -3
- package/dist/NanoGPTModel.d.ts +0 -52
- package/dist/NanoGPTModel.js +0 -203
- package/dist/TiedEmbedding-BxOerUmB.js +0 -43
- package/dist/ops-BFGCx8Ri.js +0 -1202
- package/dist/utilities/generate.d.ts +0 -3
- package/dist/utilities/generate.js +0 -22
- package/dist/utilities/save.d.ts +0 -9
- package/dist/utilities/save.js +0 -61
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { defaultConfig as m } from "./config.js";
|
|
2
|
+
import f from "../layers/TransformerBlock.js";
|
|
3
|
+
import u from "../layers/TiedEmbedding.js";
|
|
4
|
+
import g from "../layers/RoPECache.js";
|
|
5
|
+
import b from "../layers/RMSNorm.js";
|
|
6
|
+
import { t as l, k as p } from "../index-DdmHGZjq.js";
|
|
7
|
+
import w from "./model.js";
|
|
8
|
+
import k from "../layers/PositionEmbedding.js";
|
|
9
|
+
class R extends w {
|
|
10
|
+
wte;
|
|
11
|
+
// Token embeddings
|
|
12
|
+
wpe;
|
|
13
|
+
// Position embeddings
|
|
14
|
+
// private drop: layers.Layer; // Dropout
|
|
15
|
+
blocks;
|
|
16
|
+
lnF;
|
|
17
|
+
// Final layer norm
|
|
18
|
+
ropeCache;
|
|
19
|
+
constructor(e = {}) {
|
|
20
|
+
super({ ...m, ...e }), this.wte = new u(this.config, "token_embedding", this), this.config.useRope === !1 ? this.wpe = new k(this.config, "positional_embedding", this) : this.ropeCache = new g(this.config), this.blocks = [];
|
|
21
|
+
for (let i = 0; i < this.config.nLayer; i++)
|
|
22
|
+
this.blocks.push(new f(i, this.config, this));
|
|
23
|
+
this.lnF = new b(this.config, "final_rms_norm", this);
|
|
24
|
+
}
|
|
25
|
+
getClassName() {
|
|
26
|
+
return "GenAI_NanoGPT_v1";
|
|
27
|
+
}
|
|
28
|
+
inputPhase(e, i) {
|
|
29
|
+
return l(() => {
|
|
30
|
+
const s = this.wte.embed(e);
|
|
31
|
+
if (this.config.useRope === !1) {
|
|
32
|
+
const o = this.wpe.call(i, s);
|
|
33
|
+
if (Array.isArray(o))
|
|
34
|
+
throw new Error("PositionEmbedding output should not be an array");
|
|
35
|
+
return o;
|
|
36
|
+
}
|
|
37
|
+
return s;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
forward(e, i, s) {
|
|
41
|
+
return this.validateInput(i), e.ropeCache = this.ropeCache, e.outputEmbeddings && (e.embeddings = []), l(() => {
|
|
42
|
+
this.startMemory();
|
|
43
|
+
let o = this.inputPhase(i, e);
|
|
44
|
+
if (e.cache && e.cache.length !== this.blocks.length)
|
|
45
|
+
throw console.error("Cache", e.cache), new Error(
|
|
46
|
+
`Cache length ${e.cache.length} does not match number of blocks ${this.blocks.length}`
|
|
47
|
+
);
|
|
48
|
+
for (let t = 0; t < this.blocks.length; t++) {
|
|
49
|
+
const c = this.blocks[t], d = Math.random() * 1e9, r = {
|
|
50
|
+
ropeCache: e.ropeCache,
|
|
51
|
+
training: e.training,
|
|
52
|
+
seed: d,
|
|
53
|
+
attentionScores: e.attentionScores,
|
|
54
|
+
pastKV: e.cache ? e.cache[t] : void 0
|
|
55
|
+
}, a = e.checkpointing && e.training ? c.callCheckpoint(r, o) : c.call(r, o);
|
|
56
|
+
e.outputEmbeddings ? (p(o), e.embeddings.push(o)) : o.dispose(), o = a;
|
|
57
|
+
}
|
|
58
|
+
o = this.lnF.call(e, o);
|
|
59
|
+
const n = this.wte.project(o);
|
|
60
|
+
e.outputEmbeddings ? (p(o), e.embeddings.push(o)) : o.dispose();
|
|
61
|
+
let h;
|
|
62
|
+
return s && (h = this.calculateLoss(n, s)), this.endMemory("Forward"), h ? [n, h] : [n];
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
dispose() {
|
|
66
|
+
this.wte.dispose(), this.wpe && this.wpe.dispose(), this.blocks.forEach((e) => e.dispose()), this.lnF.dispose();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
R as default
|
|
71
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import o from "./NanoGPTV1.js";
|
|
2
|
+
function a(e) {
|
|
3
|
+
const n = e.modelType || "GenAI_NanoGPT_v1";
|
|
4
|
+
switch (n) {
|
|
5
|
+
case "GenAI_NanoGPT_1":
|
|
6
|
+
case "GenAI_NanoGPT_v1":
|
|
7
|
+
return new o(e);
|
|
8
|
+
default:
|
|
9
|
+
throw new Error(`Unsupported model type: ${n}`);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
a as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Tensor } from '@tensorflow/tfjs-core';
|
|
2
|
+
import { ForwardAttributes, default as BaseLayer } from '../layers/BaseLayer';
|
|
3
|
+
import { AttentionScores, KVCache } from '../layers/CausalSelfAttention';
|
|
4
|
+
export interface ModelForwardAttributes extends ForwardAttributes {
|
|
5
|
+
cache?: KVCache[];
|
|
6
|
+
attentionScores?: AttentionScores;
|
|
7
|
+
seed?: number;
|
|
8
|
+
outputEmbeddings?: boolean;
|
|
9
|
+
embeddings?: Tensor[];
|
|
10
|
+
}
|
|
11
|
+
interface TrainingState {
|
|
12
|
+
steps: number;
|
|
13
|
+
learningRate: number;
|
|
14
|
+
batchSize: number;
|
|
15
|
+
loss: number;
|
|
16
|
+
}
|
|
17
|
+
export default abstract class Model<T extends ModelForwardAttributes> extends BaseLayer<T> {
|
|
18
|
+
trainingState: TrainingState | null;
|
|
19
|
+
abstract getClassName(): string;
|
|
20
|
+
abstract forward(attrs: T, idx: Tensor, targets?: Tensor): Tensor[];
|
|
21
|
+
abstract dispose(): void;
|
|
22
|
+
getNumParams(): number;
|
|
23
|
+
protected validateInput(idx: Tensor): void;
|
|
24
|
+
protected calculateLoss(logits: Tensor, targets: Tensor): Tensor;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import i from "../layers/BaseLayer.js";
|
|
2
|
+
import "../index-DdmHGZjq.js";
|
|
3
|
+
import "../ops/cpu/attentionMask.js";
|
|
4
|
+
import "../ops/webgl/attentionMask.js";
|
|
5
|
+
import "../ops/grads/attentionMask.js";
|
|
6
|
+
import "../ops/cpu/qkv.js";
|
|
7
|
+
import "../ops/webgl/qkv.js";
|
|
8
|
+
import "../ops/grads/qkv.js";
|
|
9
|
+
import "../random_width-DKGeiFuR.js";
|
|
10
|
+
import "../register_all_kernels-Do9VvZmo.js";
|
|
11
|
+
import "../index-Tf7vU29b.js";
|
|
12
|
+
import "../dataset-DPPl-iLT.js";
|
|
13
|
+
import "../ops/cpu/rope.js";
|
|
14
|
+
import "../ops/webgl/rope.js";
|
|
15
|
+
import "../ops/grads/rope.js";
|
|
16
|
+
import "../ops/cpu/appendCache.js";
|
|
17
|
+
import "../ops/webgl/appendCache.js";
|
|
18
|
+
import "../ops/cpu/fusedSoftmax.js";
|
|
19
|
+
import "../ops/webgl/fusedSoftmax.js";
|
|
20
|
+
import "../ops/grads/fusedSoftmax.js";
|
|
21
|
+
import "../ops/cpu/matMulGelu.js";
|
|
22
|
+
import "../ops/webgl/matMulGelu.js";
|
|
23
|
+
import "../ops/grads/matMulGelu.js";
|
|
24
|
+
import "../ops/cpu/normRMS.js";
|
|
25
|
+
import "../ops/webgl/normRMS.js";
|
|
26
|
+
import "../ops/grads/normRMS.js";
|
|
27
|
+
import "../jszip.min-CjP2V1VV.js";
|
|
28
|
+
import "../index-Dwqa6Zy2.js";
|
|
29
|
+
import "../Generator.js";
|
|
30
|
+
import "../ops/cpu/adamAdjust.js";
|
|
31
|
+
import "../ops/webgl/adamAdjust.js";
|
|
32
|
+
import "../ops/cpu/adamMoments.js";
|
|
33
|
+
import "../ops/webgl/adamMoments.js";
|
|
34
|
+
import "../papaparse.min-C8l2Kvo1.js";
|
|
35
|
+
import { estimateParameterCount as p } from "../utilities/parameters.js";
|
|
36
|
+
import "../ops/cpu/scatterSub.js";
|
|
37
|
+
import "../ops/webgl/scatterSub.js";
|
|
38
|
+
import "../ops/cpu/gatherSub.js";
|
|
39
|
+
import "../ops/webgl/gatherSub.js";
|
|
40
|
+
import "../ops/cpu/gelu.js";
|
|
41
|
+
import "../ops/webgl/gelu.js";
|
|
42
|
+
import "../gelu-BkcmEEyD.js";
|
|
43
|
+
import "../ops/webgl/log.js";
|
|
44
|
+
import "../checks/normRMS.js";
|
|
45
|
+
import "../checks/normRMSGrad.js";
|
|
46
|
+
import { createSoftmaxCrossEntropyWithGrad as m } from "../training/sparseCrossEntropy.js";
|
|
47
|
+
class x extends i {
|
|
48
|
+
trainingState = null;
|
|
49
|
+
getNumParams() {
|
|
50
|
+
return p(this.config);
|
|
51
|
+
}
|
|
52
|
+
validateInput(t) {
|
|
53
|
+
if (t.shape.length !== 2)
|
|
54
|
+
throw new Error(`Invalid input shape: expected [batch_size, sequence_length], got ${t.shape}`);
|
|
55
|
+
if (t.shape[1] > this.config.blockSize)
|
|
56
|
+
throw new Error(`Input sequence length ${t.shape[1]} isn't block size ${this.config.blockSize}`);
|
|
57
|
+
if (t.dtype !== "int32")
|
|
58
|
+
throw new Error(`Input tensor must be of type int32, got ${t.dtype}`);
|
|
59
|
+
}
|
|
60
|
+
calculateLoss(t, o) {
|
|
61
|
+
try {
|
|
62
|
+
return m()(t, o).mean();
|
|
63
|
+
} catch (r) {
|
|
64
|
+
throw console.error("Error computing loss:", r), new Error(`Loss computation failed: ${r}`);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
export {
|
|
69
|
+
x as default
|
|
70
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z as c, c as f } from "./zeros
|
|
1
|
+
import { M as n, N as t, j as m, E as i } from "./index-DdmHGZjq.js";
|
|
2
|
+
import { z as c, c as f } from "./zeros-Dnwix0p4.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
package/dist/ops/adamAdjust.js
CHANGED
package/dist/ops/adamMoments.js
CHANGED
package/dist/ops/appendCache.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { e as a } from "../index-
|
|
1
|
+
import { e as a } from "../index-DdmHGZjq.js";
|
|
2
2
|
import "./cpu/appendCache.js";
|
|
3
3
|
import "./webgl/appendCache.js";
|
|
4
|
-
import { c as s } from "../concat-
|
|
5
|
-
import { z as c } from "../zeros
|
|
4
|
+
import { c as s } from "../concat-pHiVqR3L.js";
|
|
5
|
+
import { z as c } from "../zeros-Dnwix0p4.js";
|
|
6
6
|
function i(r, p, n, o) {
|
|
7
7
|
if (!o) {
|
|
8
8
|
const e = r.shape[2];
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import { f as k,
|
|
2
|
-
function
|
|
3
|
-
const { moments:
|
|
4
|
-
|
|
1
|
+
import { f as k, o as t, q as i, a as q, w } from "../../index-DdmHGZjq.js";
|
|
2
|
+
function z(a) {
|
|
3
|
+
const { moments: s, value: r } = a.inputs, { beta1: l, beta2: u, epsilon: m, learningRate: d } = a.attrs, e = s.shape.length, c = new Array(e).fill(0), n = s.shape.slice();
|
|
4
|
+
n[e - 1] = 1;
|
|
5
5
|
const o = c.slice();
|
|
6
6
|
o[e - 1] = 1;
|
|
7
|
-
const b =
|
|
7
|
+
const b = n.slice(), p = s.slice(c, n).squeeze([e - 1]), M = s.slice(o, b).squeeze([e - 1]), f = t(p, l), g = t(M, u);
|
|
8
8
|
return i(
|
|
9
|
-
q(t(f, i(
|
|
9
|
+
q(t(f, i(w(g), m ?? 1e-8)), -d),
|
|
10
10
|
r
|
|
11
11
|
);
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const A = {
|
|
14
14
|
kernelName: "AdamAdjust",
|
|
15
15
|
backendName: "cpu",
|
|
16
|
-
kernelFunc:
|
|
16
|
+
kernelFunc: z
|
|
17
17
|
};
|
|
18
|
-
k(
|
|
18
|
+
k(A);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as p } from "../../index-
|
|
2
|
-
import { s as f } from "../../stack-
|
|
1
|
+
import { f as p } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { s as f } from "../../stack-BNwLzE43.js";
|
|
3
3
|
function b(t) {
|
|
4
4
|
const { moments: n, gradient: c } = t.inputs, { beta1: o, beta2: m } = t.attrs, e = n.shape.length, a = new Array(e).fill(0), s = n.shape.slice();
|
|
5
5
|
s[e - 1] = 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as d } from "../../index-
|
|
2
|
-
import { c as h } from "../../concat-
|
|
1
|
+
import { f as d } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { c as h } from "../../concat-pHiVqR3L.js";
|
|
3
3
|
function u(p) {
|
|
4
4
|
const { cache: n, item: s } = p.inputs, { maxSize: i, pastLen: c } = p.attrs, t = n.shape[0], o = n.shape[1], a = n.shape[3], e = s.shape[2];
|
|
5
5
|
if (c + e <= i) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as a, h as p, b as u } from "../../index-
|
|
2
|
-
import { l as N, w as b } from "../../ops-
|
|
3
|
-
import { o as A } from "../../ones-
|
|
4
|
-
import { z as I } from "../../zeros
|
|
5
|
-
import { m as g } from "../../mat_mul-
|
|
1
|
+
import { f as a, h as p, b as u } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { l as N, w as b } from "../../ops-542ai2vG.js";
|
|
3
|
+
import { o as A } from "../../ones-BAqVh-eA.js";
|
|
4
|
+
import { z as I } from "../../zeros-Dnwix0p4.js";
|
|
5
|
+
import { m as g } from "../../mat_mul-Dpy2mMRu.js";
|
|
6
6
|
function o(n) {
|
|
7
7
|
const { q: s, k: e } = n.inputs, { divisor: r } = n.attrs, c = s.shape[2], t = e.shape[2], m = N.bandPart(A([t, t]), -1, 0).cast("bool"), l = I([t, t]), i = p([t, t], Number.NEGATIVE_INFINITY), f = b(m, l, i), k = g(s, e, !1, !0).mul(u(r)), d = f.slice([0, 0], [c, t]).expandDims(0).expandDims(0);
|
|
8
8
|
return k.add(d);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as e } from "../../index-
|
|
2
|
-
import { s as f } from "../../softmax-
|
|
1
|
+
import { f as e } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { s as f } from "../../softmax-BfsyI4As.js";
|
|
3
3
|
function n(t) {
|
|
4
4
|
const { inputs: s, attrs: a } = t, { logits: o } = s, { dim: i, dropoutRate: r } = a;
|
|
5
5
|
if (!o)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as f } from "../../range-
|
|
3
|
-
import { s as l } from "../../stack-
|
|
1
|
+
import { C as u, D as c, E as g, a8 as h, f as m, c as p } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { r as f } from "../../range-BcUvLuf5.js";
|
|
3
|
+
import { s as l } from "../../stack-BNwLzE43.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -26,9 +26,9 @@ function d(e) {
|
|
|
26
26
|
const { values: t, labels: n, logits: r } = e.inputs, s = n.shape[0], a = f(0, s, 1, "int32"), i = l([a, n], 1), o = b(r, i);
|
|
27
27
|
return p(t, o);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const D = {
|
|
30
30
|
kernelName: "EfficientGatherSub",
|
|
31
31
|
backendName: "cpu",
|
|
32
32
|
kernelFunc: d
|
|
33
33
|
};
|
|
34
|
-
m(
|
|
34
|
+
m(D);
|
package/dist/ops/cpu/gelu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as e, t as m } from "../../index-
|
|
2
|
-
import { g as d, d as M } from "../../gelu-
|
|
1
|
+
import { f as e, t as m } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { g as d, d as M } from "../../gelu-BkcmEEyD.js";
|
|
3
3
|
function c(t) {
|
|
4
4
|
const { inputs: u } = t, { x: n, kernel: l } = u, a = n, r = l;
|
|
5
5
|
return m(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, t as i } from "../../index-
|
|
1
|
+
import { f as e, t as i } from "../../index-DdmHGZjq.js";
|
|
2
2
|
function n(t) {
|
|
3
3
|
const { inputs: r, attrs: l } = t, { transposeA: o, transposeB: s } = l, { x: u, kernel: a, y: c } = r, m = u, k = a, M = c;
|
|
4
4
|
return i(() => m.matMul(k, o, s).mul(M));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, a as t } from "../../index-
|
|
1
|
+
import { f as e, a as t } from "../../index-DdmHGZjq.js";
|
|
2
2
|
function n(o) {
|
|
3
3
|
const { inputs: r } = o, { a: l, b: u } = r;
|
|
4
4
|
return console.warn("Using fallback mulDrop implementation without dropout."), t(l, u);
|
package/dist/ops/cpu/normRMS.js
CHANGED
package/dist/ops/cpu/qkv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as q } from "../../index-
|
|
2
|
-
import { r as o } from "../../reshape-
|
|
3
|
-
import { s as x } from "../../split-
|
|
1
|
+
import { f as q } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { r as o } from "../../reshape-WeJkT3ja.js";
|
|
3
|
+
import { s as x } from "../../split-BPxr8_8m.js";
|
|
4
4
|
function v(p) {
|
|
5
5
|
const { x: c, kernel: K } = p.inputs, { heads: n } = p.attrs, [s, e, t] = c.shape, a = o(c, [s * e, t]), i = a.dot(K);
|
|
6
6
|
a.dispose();
|
package/dist/ops/cpu/rope.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as S } from "../../index-
|
|
2
|
-
import { r as F } from "../../range-
|
|
3
|
-
import { g as I } from "../../gather-
|
|
4
|
-
import { s as E } from "../../stack-
|
|
5
|
-
import { c as T } from "../../concat-
|
|
1
|
+
import { f as S } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { r as F } from "../../range-BcUvLuf5.js";
|
|
3
|
+
import { g as I } from "../../gather-CPg6ZlQA.js";
|
|
4
|
+
import { s as E } from "../../stack-BNwLzE43.js";
|
|
5
|
+
import { c as T } from "../../concat-pHiVqR3L.js";
|
|
6
6
|
function U(t, c, p, o, r) {
|
|
7
7
|
const n = o.shape[3], s = p;
|
|
8
8
|
if (s > n) return o;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { v as
|
|
3
|
-
import { r as k } from "../../range-
|
|
4
|
-
import { s as v } from "../../stack-
|
|
5
|
-
import { o as E } from "../../ones-
|
|
1
|
+
import { C as f, M as g, D as r, E as l, a7 as N, f as b, c as S, a as D } from "../../index-DdmHGZjq.js";
|
|
2
|
+
import { v as h } from "../../scatter_nd_util-B7yDhiQr.js";
|
|
3
|
+
import { r as k } from "../../range-BcUvLuf5.js";
|
|
4
|
+
import { s as v } from "../../stack-BNwLzE43.js";
|
|
5
|
+
import { o as E } from "../../ones-BAqVh-eA.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -22,14 +22,14 @@ import { o as E } from "../../ones-Dj0SDhHf.js";
|
|
|
22
22
|
function I(a, e, s) {
|
|
23
23
|
g(s);
|
|
24
24
|
const n = r(a, "indices", "scatterND", "int32"), t = r(e, "updates", "scatterND");
|
|
25
|
-
|
|
25
|
+
h(t, n, s);
|
|
26
26
|
const c = { indices: n, updates: t }, o = { shape: s };
|
|
27
27
|
return l.runKernel(N, c, o);
|
|
28
28
|
}
|
|
29
29
|
const C = /* @__PURE__ */ f({ scatterND_: I });
|
|
30
30
|
function K(a) {
|
|
31
31
|
const { logits: e, labels: s, dy: n } = a.inputs, t = s.shape[0], c = e.shape[1], o = k(0, t, 1, "int32"), i = v([o, s], 1), d = E([t]), u = C(i, d, [t, c]), p = S(e, u), m = n.reshape([t, 1]);
|
|
32
|
-
return
|
|
32
|
+
return D(p, m);
|
|
33
33
|
}
|
|
34
34
|
const L = {
|
|
35
35
|
kernelName: "EfficientScatterSub",
|
package/dist/ops/fusedSoftmax.js
CHANGED
package/dist/ops/gatherSub.js
CHANGED
package/dist/ops/gelu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../index-
|
|
1
|
+
import "../index-DdmHGZjq.js";
|
|
2
2
|
import "./cpu/gelu.js";
|
|
3
3
|
import "./webgl/gelu.js";
|
|
4
|
-
import { d as e, g as i } from "../gelu-
|
|
4
|
+
import { d as e, g as i } from "../gelu-BkcmEEyD.js";
|
|
5
5
|
export {
|
|
6
6
|
e as dGelu,
|
|
7
7
|
i as gelu
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as f, a as i, c as l } from "../../index-
|
|
1
|
+
import { i as f, a as i, c as l } from "../../index-DdmHGZjq.js";
|
|
2
2
|
import { mulDrop as g } from "../mulDrop.js";
|
|
3
|
-
import { s as T } from "../../sum-
|
|
3
|
+
import { s as T } from "../../sum-ByFINZgi.js";
|
|
4
4
|
const Y = {
|
|
5
5
|
kernelName: "FusedSoftmax",
|
|
6
6
|
outputsToSave: [!0],
|
package/dist/ops/grads/gelu.js
CHANGED
package/dist/ops/grads/qkv.js
CHANGED
package/dist/ops/grads/rope.js
CHANGED
package/dist/ops/matMulGelu.js
CHANGED
package/dist/ops/matMulMul.js
CHANGED
package/dist/ops/mulDrop.js
CHANGED
package/dist/ops/normRMS.js
CHANGED
package/dist/ops/qkv.js
CHANGED
package/dist/ops/rope.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { e as p } from "../index-
|
|
2
|
-
import "../random_width-
|
|
3
|
-
import "../register_all_kernels-
|
|
1
|
+
import { e as p } from "../index-DdmHGZjq.js";
|
|
2
|
+
import "../random_width-DKGeiFuR.js";
|
|
3
|
+
import "../register_all_kernels-Do9VvZmo.js";
|
|
4
4
|
import "../index-Tf7vU29b.js";
|
|
5
|
-
import "../dataset-
|
|
5
|
+
import "../dataset-DPPl-iLT.js";
|
|
6
6
|
import "./cpu/rope.js";
|
|
7
7
|
import "./webgl/rope.js";
|
|
8
8
|
import "./grads/rope.js";
|
package/dist/ops/scatterSub.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as b, s as I, r as k } from "../../RealDiv-
|
|
2
|
-
import { r as v } from "../../Reshape-
|
|
3
|
-
import { f as w, p as P } from "../../index-
|
|
4
|
-
import { e as S } from "../../axis_util-
|
|
1
|
+
import { m as b, s as I, r as k } from "../../RealDiv-D_q39E3A.js";
|
|
2
|
+
import { r as v } from "../../Reshape-Bh_jzKzV.js";
|
|
3
|
+
import { f as w, p as P } from "../../index-DdmHGZjq.js";
|
|
4
|
+
import { e as S } from "../../axis_util-Did9235A.js";
|
|
5
5
|
class T {
|
|
6
6
|
variableNames = ["logits", "maxLogits"];
|
|
7
7
|
outputShape;
|