@genai-fi/nanogpt 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Generator.js +11 -11
- package/dist/NanoGPTModel.d.ts +2 -2
- package/dist/NanoGPTModel.js +104 -136
- package/dist/{RealDiv-BYViZwhN.js → RealDiv-C4hOvYOZ.js} +26 -25
- package/dist/{Reshape-t7Kcikjk.js → Reshape-BLijOA8h.js} +5 -5
- package/dist/TeachableLLM.js +5 -5
- package/dist/{TiedEmbedding-9WeDwvjO.js → TiedEmbedding-BLltddza.js} +4 -4
- package/dist/{axis_util-Bu4h7XWV.js → axis_util-DaAl5MER.js} +3 -3
- package/dist/backend.d.ts +1 -0
- package/dist/backend.js +7 -0
- package/dist/backend_util-DWiwsi2N.js +749 -0
- package/dist/{broadcast_to-DARN-DBD.js → broadcast_to-C4v-j9yA.js} +2 -2
- package/dist/{concat-5aPGqw3Z.js → concat-CsHeR4zV.js} +8 -8
- package/dist/{dataset-pgqp-YfL.js → dataset-JDyjG3QR.js} +3 -3
- package/dist/{dropout-Bciw46HT.js → dropout-hpDwECTe.js} +7 -7
- package/dist/{gather-DjyCjmOD.js → gather-D0_gPiBz.js} +4 -4
- package/dist/gelu-uyHP1x1f.js +26 -0
- package/dist/gpgpu_math-DJm3ZTAf.js +2371 -0
- package/dist/index-BPPzKVdR.js +12099 -0
- package/dist/{index-BAzbokzv.js → index-C0dhsYom.js} +405 -389
- package/dist/{kernel_funcs_utils-CUxJCg0g.js → kernel_funcs_utils-CwRTFqrc.js} +31 -30
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +4 -4
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/loader/loadTransformers.js +1 -1
- package/dist/loader/oldZipLoad.js +5 -5
- package/dist/{log_sum_exp-YEo2h3gb.js → log_sum_exp-D086OgZJ.js} +15 -15
- package/dist/main.d.ts +2 -0
- package/dist/main.js +9 -5
- package/dist/{mat_mul-7121rsJk.js → mat_mul-1nwdPkQ_.js} +4 -4
- package/dist/{max-DtlIuVeW.js → max-BQc2Aj-I.js} +4 -4
- package/dist/{mulmat_packed_gpu-D4nKF7Je.js → mulmat_packed_gpu-Gzf3I9UV.js} +1 -1
- package/dist/non_max_suppression_impl-CsEgBuMA.js +134 -0
- package/dist/{ones-BBlSRqn1.js → ones-D63HpSF_.js} +2 -2
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/appendCache.js +8 -8
- package/dist/ops/cpu/attentionMask.js +9 -9
- package/dist/ops/cpu/fusedSoftmax.js +17 -11
- package/dist/ops/cpu/gatherSub.js +7 -7
- package/dist/ops/cpu/gelu.js +13 -13
- package/dist/ops/cpu/matMulGelu.js +36 -24
- package/dist/ops/cpu/matMulMul.js +14 -8
- package/dist/ops/cpu/mulDropout.js +9 -3
- package/dist/ops/cpu/normRMS.js +5 -5
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +11 -11
- 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 +3 -24
- package/dist/ops/grads/matMulGelu.js +5 -5
- package/dist/ops/grads/normRMS.js +6 -6
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +3 -3
- 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/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 +5 -5
- package/dist/ops/webgl/matMulGelu.js +17 -17
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +4 -4
- 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/appendCache.d.ts +1 -0
- package/dist/ops/webgpu/appendCache.js +56 -0
- package/dist/ops/webgpu/attentionMask.d.ts +1 -0
- package/dist/ops/webgpu/attentionMask.js +64 -0
- package/dist/ops/webgpu/gatherSub.d.ts +1 -0
- package/dist/ops/webgpu/gatherSub.js +37 -0
- package/dist/ops/webgpu/gelu.d.ts +14 -0
- package/dist/ops/webgpu/gelu.js +86 -0
- package/dist/ops/webgpu/index.d.ts +0 -0
- package/dist/ops/webgpu/index.js +8 -0
- package/dist/ops/webgpu/normRMS.d.ts +1 -0
- package/dist/ops/webgpu/normRMS.js +115 -0
- package/dist/ops/webgpu/qkv.d.ts +1 -0
- package/dist/ops/webgpu/qkv.js +56 -0
- package/dist/ops/webgpu/rope.d.ts +1 -0
- package/dist/ops/webgpu/rope.js +68 -0
- package/dist/ops/webgpu/scatterSub.d.ts +1 -0
- package/dist/ops/webgpu/scatterSub.js +37 -0
- package/dist/{ops-C0sQEcPw.js → ops-CIQLNshk.js} +452 -503
- package/dist/{random_width-DWzaOgrn.js → random_width-DkYP8W8N.js} +143 -144
- package/dist/{range-DYsrnfiy.js → range-CYzpQY53.js} +1 -1
- package/dist/{reciprocal-CJQeasVa.js → reciprocal-_A9yv27J.js} +1 -1
- package/dist/{register_all_kernels-BfFCQAqs.js → register_all_kernels-guvSxp7M.js} +202 -200
- package/dist/{reshape-krWGKraP.js → reshape-BMUzc1UY.js} +3 -3
- package/dist/{scatter_nd_util-93ln7Hut.js → scatter_nd_util-IRBqKz_b.js} +3 -3
- package/dist/{selu_util-sntGesxr.js → selu_util-Dt_iuXaq.js} +6 -6
- package/dist/shared-BNa2q6jD.js +69 -0
- package/dist/{shared-Ca6iDobD.js → shared-CDu9S76h.js} +541 -606
- package/dist/{sin-D_h-qCSx.js → sin-Cocju-BY.js} +6 -6
- package/dist/{softmax-fsdtf6JC.js → softmax-GPNK3o-U.js} +3 -3
- package/dist/{split-eiktj-6L.js → split-CHzJjxDv.js} +4 -4
- package/dist/{stack-dfEEz2OY.js → stack-Dpgg_1W1.js} +2 -2
- package/dist/{sum-BE_Irnim.js → sum-B8wEpKsg.js} +5 -5
- package/dist/{tensor-Xyi595sG.js → tensor-RvZVNmg0.js} +1 -1
- package/dist/{tensor2d-CPEkynbH.js → tensor2d-B_kyod7_.js} +1 -1
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/Evaluator.js +1 -1
- package/dist/training/FullTrainer.js +20 -20
- package/dist/training/Trainer.d.ts +5 -6
- package/dist/training/Trainer.js +59 -60
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.js +19 -19
- package/dist/utilities/generate.js +15 -16
- package/dist/utilities/multinomialCPU.d.ts +2 -0
- package/dist/utilities/multinomialCPU.js +13 -0
- package/dist/utilities/performance.d.ts +2 -0
- package/dist/utilities/performance.js +16 -0
- package/dist/utilities/profile.d.ts +1 -0
- package/dist/utilities/profile.js +9 -6
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-wSS22xj5.js → variable-DXEUOwew.js} +1 -1
- package/dist/webgpu_util-g13LvDIv.js +625 -0
- package/dist/{zeros-YJDE7oRb.js → zeros-DCPCdFGq.js} +8 -8
- package/package.json +2 -1
- package/dist/gpgpu_math-CNslybmD.js +0 -3115
- package/dist/norm-CzltS9Fz.js +0 -86
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { u as O, f as Y
|
|
1
|
+
import { k as B, j as G, ak as K, a1 as W, al as z, am as V, ac as N, an as F, u as S } from "./index-C0dhsYom.js";
|
|
2
|
+
import { u as O, f as Y } from "./gpgpu_math-DJm3ZTAf.js";
|
|
3
|
+
import { f as v } from "./backend_util-DWiwsi2N.js";
|
|
3
4
|
/**
|
|
4
5
|
* @license
|
|
5
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -22,7 +23,7 @@ function H(t, e) {
|
|
|
22
23
|
function Z(t, e) {
|
|
23
24
|
return e === 1 ? [t] : H(t, e);
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function pe(t, e) {
|
|
26
27
|
if (t === 1)
|
|
27
28
|
return "rc";
|
|
28
29
|
let s = "";
|
|
@@ -62,11 +63,11 @@ class q {
|
|
|
62
63
|
`;
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
const T = "if (isnan(x)) return x;",
|
|
66
|
+
const T = "if (isnan(x)) return x;", j = "return x;", de = "return abs(x);", M = "return (x >= 0.0) ? x : (exp(x) - 1.0);", J = T + `
|
|
66
67
|
return (x < 0.0) ? 0.0 : x;
|
|
67
68
|
`, Q = T + `
|
|
68
69
|
return (x < 0.0) ? 0.0 : min(6.0, x);
|
|
69
|
-
`,
|
|
70
|
+
`, he = "return x;", X = "return 1.0 / (1.0 + exp(-1.0 * x));";
|
|
70
71
|
/**
|
|
71
72
|
* @license
|
|
72
73
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -145,7 +146,7 @@ class ne {
|
|
|
145
146
|
* limitations under the License.
|
|
146
147
|
* =============================================================================
|
|
147
148
|
*/
|
|
148
|
-
const
|
|
149
|
+
const fe = `
|
|
149
150
|
if (isnan(a)) return a;
|
|
150
151
|
if (isnan(b)) return b;
|
|
151
152
|
`;
|
|
@@ -180,7 +181,7 @@ class b {
|
|
|
180
181
|
* limitations under the License.
|
|
181
182
|
* =============================================================================
|
|
182
183
|
*/
|
|
183
|
-
const
|
|
184
|
+
const xe = `
|
|
184
185
|
result.r = isNaN.r ? NAN : result.r;
|
|
185
186
|
result.g = isNaN.g ? NAN : result.g;
|
|
186
187
|
result.b = isNaN.b ? NAN : result.b;
|
|
@@ -268,7 +269,7 @@ function P(t) {
|
|
|
268
269
|
const { inputs: e, backend: s } = t, { x: r } = e;
|
|
269
270
|
return s.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype };
|
|
270
271
|
}
|
|
271
|
-
const
|
|
272
|
+
const ge = {
|
|
272
273
|
kernelName: K,
|
|
273
274
|
backendName: "webgl",
|
|
274
275
|
kernelFunc: P
|
|
@@ -293,7 +294,7 @@ function L(t) {
|
|
|
293
294
|
const { inputs: e, backend: s } = t, { real: r, imag: u } = e, n = s.makeTensorInfo(r.shape, "complex64"), o = s.texData.get(n.dataId), i = P({ inputs: { x: r }, backend: s }), a = P({ inputs: { x: u }, backend: s });
|
|
294
295
|
return o.complexTensorInfos = { real: i, imag: a }, n;
|
|
295
296
|
}
|
|
296
|
-
const
|
|
297
|
+
const me = {
|
|
297
298
|
kernelName: W,
|
|
298
299
|
backendName: "webgl",
|
|
299
300
|
kernelFunc: L
|
|
@@ -322,7 +323,7 @@ function oe(t) {
|
|
|
322
323
|
const { inputs: e, backend: s, attrs: r } = t, { x: u } = e, { alpha: n } = r, o = s.makeTensorInfo([], "float32", V(n, "float32")), i = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E(k, u.shape, o.shape) : new b(w, u.shape, o.shape), a = s.runWebGLProgram(i, [u, o], "float32");
|
|
323
324
|
return s.disposeIntermediateTensorInfo(o), a;
|
|
324
325
|
}
|
|
325
|
-
const
|
|
326
|
+
const be = {
|
|
326
327
|
kernelName: z,
|
|
327
328
|
backendName: "webgl",
|
|
328
329
|
kernelFunc: oe
|
|
@@ -351,7 +352,7 @@ function ue(t) {
|
|
|
351
352
|
const { inputs: e, backend: s } = t, { x: r, alpha: u } = e, n = N().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new E(U, r.shape, u.shape) : new b(R, r.shape, u.shape);
|
|
352
353
|
return s.runWebGLProgram(n, [r, u], "float32");
|
|
353
354
|
}
|
|
354
|
-
const
|
|
355
|
+
const Ne = {
|
|
355
356
|
kernelName: F,
|
|
356
357
|
backendName: "webgl",
|
|
357
358
|
kernelFunc: ue
|
|
@@ -372,8 +373,8 @@ const be = {
|
|
|
372
373
|
* limitations under the License.
|
|
373
374
|
* =============================================================================
|
|
374
375
|
*/
|
|
375
|
-
const
|
|
376
|
-
function
|
|
376
|
+
const Oe = "if (isnan(x)) return x;";
|
|
377
|
+
function ye({ opSnippet: t, packedOpSnippet: e, cpuKernelImpl: s, dtype: r }) {
|
|
377
378
|
return ({ inputs: u, backend: n }) => {
|
|
378
379
|
const { x: o } = u, i = n, a = r || o.dtype;
|
|
379
380
|
if (i.shouldExecuteOnCPU([o]) && s != null) {
|
|
@@ -385,7 +386,7 @@ function Oe({ opSnippet: t, packedOpSnippet: e, cpuKernelImpl: s, dtype: r }) {
|
|
|
385
386
|
return c ? l = new ne(o.shape, e) : l = new q(o.shape, t), i.runWebGLProgram(l, [o], a);
|
|
386
387
|
};
|
|
387
388
|
}
|
|
388
|
-
function
|
|
389
|
+
function Ie({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, supportsComplex: r = !1, cpuKernelImpl: u, dtype: n }) {
|
|
389
390
|
return ({ inputs: o, backend: i }) => {
|
|
390
391
|
const { a, b: c } = o, l = i;
|
|
391
392
|
if (r && a.dtype === "complex64") {
|
|
@@ -422,13 +423,13 @@ function ye({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: s = !1, suppor
|
|
|
422
423
|
return y ? I = new E(e, a.shape, c.shape, s) : I = new b(t, a.shape, c.shape), l.runWebGLProgram(I, [a, c], d);
|
|
423
424
|
};
|
|
424
425
|
}
|
|
425
|
-
function
|
|
426
|
+
function Ae(t, e = !1) {
|
|
426
427
|
if (t === "linear")
|
|
427
|
-
return e ? ee :
|
|
428
|
+
return e ? ee : j;
|
|
428
429
|
if (t === "relu")
|
|
429
430
|
return e ? se : J;
|
|
430
431
|
if (t === "elu")
|
|
431
|
-
return e ? te :
|
|
432
|
+
return e ? te : M;
|
|
432
433
|
if (t === "relu6")
|
|
433
434
|
return e ? ae : Q;
|
|
434
435
|
if (t === "prelu")
|
|
@@ -440,26 +441,26 @@ function Ie(t, e = !1) {
|
|
|
440
441
|
throw new Error(`Activation ${t} has not been implemented for the WebGL backend.`);
|
|
441
442
|
}
|
|
442
443
|
export {
|
|
443
|
-
|
|
444
|
+
de as A,
|
|
444
445
|
E as B,
|
|
445
446
|
T as C,
|
|
446
447
|
ne as U,
|
|
447
448
|
Z as a,
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
449
|
+
Ie as b,
|
|
450
|
+
pe as c,
|
|
451
|
+
he as d,
|
|
451
452
|
q as e,
|
|
452
453
|
L as f,
|
|
453
454
|
H as g,
|
|
454
455
|
b as h,
|
|
455
456
|
P as i,
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
457
|
+
fe as j,
|
|
458
|
+
xe as k,
|
|
459
|
+
Oe as l,
|
|
460
|
+
Ae as m,
|
|
461
|
+
me as n,
|
|
462
|
+
ge as o,
|
|
463
|
+
be as p,
|
|
464
|
+
Ne as q,
|
|
465
|
+
ye as u
|
|
465
466
|
};
|
package/dist/layers/BaseLayer.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as g,
|
|
2
|
-
import { v as _ } from "../variable-
|
|
1
|
+
import { T as g, q as p, e as o, w as v } from "../index-C0dhsYom.js";
|
|
2
|
+
import { v as _ } from "../variable-DXEUOwew.js";
|
|
3
3
|
class M {
|
|
4
4
|
parent;
|
|
5
5
|
config;
|
|
@@ -3,13 +3,13 @@ import O from "./BaseLayer.js";
|
|
|
3
3
|
import { qkv as P } from "../ops/qkv.js";
|
|
4
4
|
import { rope as v } from "../ops/rope.js";
|
|
5
5
|
import { appendCache as V } from "../ops/appendCache.js";
|
|
6
|
-
import {
|
|
6
|
+
import { o as c, t as C } from "../index-C0dhsYom.js";
|
|
7
7
|
import { fusedSoftmax as T } from "../ops/fusedSoftmax.js";
|
|
8
|
-
import { d as y } from "../random_width-
|
|
9
|
-
import { v as b } from "../variable-
|
|
10
|
-
import { r as k, d as L } from "../dropout-
|
|
11
|
-
import { r as N } from "../reshape-
|
|
12
|
-
import { m as R } from "../mat_mul-
|
|
8
|
+
import { d as y } from "../random_width-DkYP8W8N.js";
|
|
9
|
+
import { v as b } from "../variable-DXEUOwew.js";
|
|
10
|
+
import { r as k, d as L } from "../dropout-hpDwECTe.js";
|
|
11
|
+
import { r as N } from "../reshape-BMUzc1UY.js";
|
|
12
|
+
import { m as R } from "../mat_mul-1nwdPkQ_.js";
|
|
13
13
|
class $ extends O {
|
|
14
14
|
divisor;
|
|
15
15
|
index;
|
package/dist/layers/MLP.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { t as l } from "../index-
|
|
1
|
+
import { t as l } from "../index-C0dhsYom.js";
|
|
2
2
|
import u from "./BaseLayer.js";
|
|
3
3
|
import { matMulGelu as M } from "../ops/matMulGelu.js";
|
|
4
|
-
import { v as o } from "../variable-
|
|
5
|
-
import { r as h, d as f } from "../dropout-
|
|
6
|
-
import { r as d } from "../reshape-
|
|
7
|
-
import { m as c } from "../mat_mul-
|
|
4
|
+
import { v as o } from "../variable-DXEUOwew.js";
|
|
5
|
+
import { r as h, d as f } from "../dropout-hpDwECTe.js";
|
|
6
|
+
import { r as d } from "../reshape-BMUzc1UY.js";
|
|
7
|
+
import { m as c } from "../mat_mul-1nwdPkQ_.js";
|
|
8
8
|
class V extends u {
|
|
9
9
|
index;
|
|
10
10
|
hiddenUnits;
|
package/dist/layers/RMSNorm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as s } from "../index-
|
|
1
|
+
import { t as s } from "../index-C0dhsYom.js";
|
|
2
2
|
import e from "./BaseLayer.js";
|
|
3
3
|
import { normRMS as a } from "../ops/normRMS.js";
|
|
4
|
-
import { v as i } from "../variable-
|
|
5
|
-
import { o as m } from "../ones-
|
|
4
|
+
import { v as i } from "../variable-DXEUOwew.js";
|
|
5
|
+
import { o as m } from "../ones-D63HpSF_.js";
|
|
6
6
|
class f extends e {
|
|
7
7
|
GAMMA;
|
|
8
8
|
constructor(r, t = "", o) {
|
package/dist/layers/RoPECache.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as c } from "../reciprocal-
|
|
3
|
-
import { c as f, s as m } from "../sin-
|
|
4
|
-
import { r as a } from "../range-
|
|
1
|
+
import { b as t, n as h, t as n, o as p } from "../index-C0dhsYom.js";
|
|
2
|
+
import { r as c } from "../reciprocal-_A9yv27J.js";
|
|
3
|
+
import { c as f, s as m } from "../sin-Cocju-BY.js";
|
|
4
|
+
import { r as a } from "../range-CYzpQY53.js";
|
|
5
5
|
class D {
|
|
6
6
|
constructor(o) {
|
|
7
7
|
this.config = o;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import "../random_width-
|
|
2
|
-
import "../index-
|
|
3
|
-
import { T as e } from "../TiedEmbedding-
|
|
1
|
+
import "../random_width-DkYP8W8N.js";
|
|
2
|
+
import "../index-C0dhsYom.js";
|
|
3
|
+
import { T as e } from "../TiedEmbedding-BLltddza.js";
|
|
4
4
|
import "./BaseLayer.js";
|
|
5
|
-
import "../variable-
|
|
6
|
-
import "../gather-
|
|
5
|
+
import "../variable-DXEUOwew.js";
|
|
6
|
+
import "../gather-D0_gPiBz.js";
|
|
7
7
|
export {
|
|
8
8
|
e as default
|
|
9
9
|
};
|
|
@@ -2,7 +2,7 @@ import l from "./CausalSelfAttention.js";
|
|
|
2
2
|
import r from "./MLP.js";
|
|
3
3
|
import o from "./RMSNorm.js";
|
|
4
4
|
import d from "./BaseLayer.js";
|
|
5
|
-
import { t as p } from "../index-
|
|
5
|
+
import { t as p } from "../index-C0dhsYom.js";
|
|
6
6
|
class k extends d {
|
|
7
7
|
ln1;
|
|
8
8
|
attn;
|
|
@@ -2,7 +2,7 @@ import b from "../NanoGPTModel.js";
|
|
|
2
2
|
import c from "../tokeniser/CharTokeniser.js";
|
|
3
3
|
import l from "../tokeniser/bpe.js";
|
|
4
4
|
import { load_safetensors as u } from "../utilities/safetensors.js";
|
|
5
|
-
import {
|
|
5
|
+
import { Y as y } from "../index-C0dhsYom.js";
|
|
6
6
|
import { dummyPassAsync as h } from "../utilities/dummy.js";
|
|
7
7
|
async function L(e, a, r, t) {
|
|
8
8
|
const n = {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import d from "../NanoGPTModel.js";
|
|
2
2
|
import "../jszip.min-CjP2V1VV.js";
|
|
3
3
|
import h from "../tokeniser/CharTokeniser.js";
|
|
4
|
-
import {
|
|
4
|
+
import { Y as k } from "../index-C0dhsYom.js";
|
|
5
5
|
import b from "../tokeniser/bpe.js";
|
|
6
6
|
import { dummyPassAsync as u } from "../utilities/dummy.js";
|
|
7
7
|
import "../Generator.js";
|
|
8
8
|
import "../index-Dwqa6Zy2.js";
|
|
9
|
-
import "../dataset-
|
|
9
|
+
import "../dataset-JDyjG3QR.js";
|
|
10
10
|
import "../index-Tf7vU29b.js";
|
|
11
11
|
import "../papaparse.min-C8l2Kvo1.js";
|
|
12
12
|
import "../ops/cpu/scatterSub.js";
|
|
@@ -19,8 +19,8 @@ import "../ops/grads/attentionMask.js";
|
|
|
19
19
|
import "../ops/cpu/qkv.js";
|
|
20
20
|
import "../ops/webgl/qkv.js";
|
|
21
21
|
import "../ops/grads/qkv.js";
|
|
22
|
-
import "../random_width-
|
|
23
|
-
import "../register_all_kernels-
|
|
22
|
+
import "../random_width-DkYP8W8N.js";
|
|
23
|
+
import "../register_all_kernels-guvSxp7M.js";
|
|
24
24
|
import "../ops/cpu/rope.js";
|
|
25
25
|
import "../ops/webgl/rope.js";
|
|
26
26
|
import "../ops/grads/rope.js";
|
|
@@ -34,7 +34,7 @@ import "../ops/webgl/matMulGelu.js";
|
|
|
34
34
|
import "../ops/grads/matMulGelu.js";
|
|
35
35
|
import "../ops/cpu/gelu.js";
|
|
36
36
|
import "../ops/webgl/gelu.js";
|
|
37
|
-
import "../
|
|
37
|
+
import "../gelu-uyHP1x1f.js";
|
|
38
38
|
import "../ops/cpu/normRMS.js";
|
|
39
39
|
import "../ops/webgl/normRMS.js";
|
|
40
40
|
import "../ops/grads/normRMS.js";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as
|
|
3
|
-
import { m as
|
|
4
|
-
import { r as m } from "./reshape-
|
|
5
|
-
import { s as
|
|
1
|
+
import { x as r, y as p, E as u, a7 as E, a8 as h, p as S, c as $, a6 as d } from "./index-C0dhsYom.js";
|
|
2
|
+
import { e as K } from "./axis_util-DaAl5MER.js";
|
|
3
|
+
import { m as T } from "./max-BQc2Aj-I.js";
|
|
4
|
+
import { r as m } from "./reshape-BMUzc1UY.js";
|
|
5
|
+
import { s as _ } from "./sum-B8wEpKsg.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -19,11 +19,11 @@ import { s as T } from "./sum-BE_Irnim.js";
|
|
|
19
19
|
* limitations under the License.
|
|
20
20
|
* =============================================================================
|
|
21
21
|
*/
|
|
22
|
-
function
|
|
22
|
+
function b(s) {
|
|
23
23
|
const o = { x: p(s, "x", "exp") };
|
|
24
24
|
return u.runKernel(E, o);
|
|
25
25
|
}
|
|
26
|
-
const N = /* @__PURE__ */ r({ exp_:
|
|
26
|
+
const N = /* @__PURE__ */ r({ exp_: b });
|
|
27
27
|
/**
|
|
28
28
|
* @license
|
|
29
29
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -40,11 +40,11 @@ const N = /* @__PURE__ */ r({ exp_: _ });
|
|
|
40
40
|
* limitations under the License.
|
|
41
41
|
* =============================================================================
|
|
42
42
|
*/
|
|
43
|
-
function
|
|
43
|
+
function v(s) {
|
|
44
44
|
const o = { x: p(s, "x", "log", "float32") };
|
|
45
45
|
return u.runKernel(h, o);
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const w = /* @__PURE__ */ r({ log_: v });
|
|
48
48
|
/**
|
|
49
49
|
* @license
|
|
50
50
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -61,22 +61,22 @@ const v = /* @__PURE__ */ r({ log_: q });
|
|
|
61
61
|
* limitations under the License.
|
|
62
62
|
* =============================================================================
|
|
63
63
|
*/
|
|
64
|
-
function
|
|
65
|
-
const a = p(s, "x", "logSumExp"), t = S(n, a.shape), x =
|
|
64
|
+
function y(s, n = null, o = !1) {
|
|
65
|
+
const a = p(s, "x", "logSumExp"), t = S(n, a.shape), x = T(
|
|
66
66
|
a,
|
|
67
67
|
t,
|
|
68
68
|
!0
|
|
69
69
|
/* keepDims */
|
|
70
|
-
), i = $(a, x), l = N(i), f =
|
|
70
|
+
), i = $(a, x), l = N(i), f = _(l, t), c = w(f), e = d(m(x, c.shape), c);
|
|
71
71
|
if (o) {
|
|
72
|
-
const g =
|
|
72
|
+
const g = K(e.shape, t);
|
|
73
73
|
return m(e, g);
|
|
74
74
|
}
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
|
-
const M = /* @__PURE__ */ r({ logSumExp_:
|
|
77
|
+
const M = /* @__PURE__ */ r({ logSumExp_: y });
|
|
78
78
|
export {
|
|
79
|
-
|
|
79
|
+
w as a,
|
|
80
80
|
N as e,
|
|
81
81
|
M as l
|
|
82
82
|
};
|
package/dist/main.d.ts
CHANGED
|
@@ -11,3 +11,5 @@ export type { ITokeniser } from './tokeniser/type';
|
|
|
11
11
|
export type { TrainingProgress } from './training/Trainer';
|
|
12
12
|
export type { GPTConfig } from './config';
|
|
13
13
|
export { estimateParameterCount, estimateMemoryUsage, estimateTrainingMemoryUsage, estimateResources, validateConfig, } from './utilities/parameters';
|
|
14
|
+
export { selectBackend } from './backend';
|
|
15
|
+
export { default as performanceTest } from './utilities/performance';
|
package/dist/main.js
CHANGED
|
@@ -5,7 +5,7 @@ import { default as I } from "./tokeniser/bpe.js";
|
|
|
5
5
|
import { default as K } from "./utilities/waitForModel.js";
|
|
6
6
|
import { default as Q } from "./data/textLoader.js";
|
|
7
7
|
import { estimateMemoryUsage as V, estimateParameterCount as W, estimateResources as X, estimateTrainingMemoryUsage as Y, validateConfig as Z } from "./utilities/parameters.js";
|
|
8
|
-
import "./index-
|
|
8
|
+
import "./index-C0dhsYom.js";
|
|
9
9
|
import "./ops/cpu/scatterSub.js";
|
|
10
10
|
import "./ops/webgl/scatterSub.js";
|
|
11
11
|
import "./ops/cpu/gatherSub.js";
|
|
@@ -16,10 +16,10 @@ import "./ops/grads/attentionMask.js";
|
|
|
16
16
|
import "./ops/cpu/qkv.js";
|
|
17
17
|
import "./ops/webgl/qkv.js";
|
|
18
18
|
import "./ops/grads/qkv.js";
|
|
19
|
-
import "./random_width-
|
|
20
|
-
import "./register_all_kernels-
|
|
19
|
+
import "./random_width-DkYP8W8N.js";
|
|
20
|
+
import "./register_all_kernels-guvSxp7M.js";
|
|
21
21
|
import "./index-Tf7vU29b.js";
|
|
22
|
-
import "./dataset-
|
|
22
|
+
import "./dataset-JDyjG3QR.js";
|
|
23
23
|
import "./ops/cpu/rope.js";
|
|
24
24
|
import "./ops/webgl/rope.js";
|
|
25
25
|
import "./ops/grads/rope.js";
|
|
@@ -33,11 +33,13 @@ import "./ops/webgl/matMulGelu.js";
|
|
|
33
33
|
import "./ops/grads/matMulGelu.js";
|
|
34
34
|
import "./ops/cpu/gelu.js";
|
|
35
35
|
import "./ops/webgl/gelu.js";
|
|
36
|
-
import "./
|
|
36
|
+
import "./gelu-uyHP1x1f.js";
|
|
37
37
|
import "./ops/cpu/normRMS.js";
|
|
38
38
|
import "./ops/webgl/normRMS.js";
|
|
39
39
|
import "./ops/grads/normRMS.js";
|
|
40
40
|
import "./ops/webgl/log.js";
|
|
41
|
+
import { selectBackend as $ } from "./backend.js";
|
|
42
|
+
import { default as ot } from "./utilities/performance.js";
|
|
41
43
|
export {
|
|
42
44
|
I as BPETokeniser,
|
|
43
45
|
A as CharTokeniser,
|
|
@@ -48,6 +50,8 @@ export {
|
|
|
48
50
|
X as estimateResources,
|
|
49
51
|
Y as estimateTrainingMemoryUsage,
|
|
50
52
|
Q as loadTextData,
|
|
53
|
+
ot as performanceTest,
|
|
54
|
+
$ as selectBackend,
|
|
51
55
|
Z as validateConfig,
|
|
52
56
|
K as waitForModel
|
|
53
57
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as m, y as s, F as c, E as M, H as p } from "./index-C0dhsYom.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,10 +15,10 @@ import { o as m, q as s, B as c, E as M, C as p } from "./index-BAzbokzv.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function f(e,
|
|
19
|
-
let a = s(e, "a", "matMul"), t = s(
|
|
18
|
+
function f(e, n, o = !1, l = !1) {
|
|
19
|
+
let a = s(e, "a", "matMul"), t = s(n, "b", "matMul");
|
|
20
20
|
[a, t] = c(a, t);
|
|
21
|
-
const r = { a, b: t }, u = { transposeA:
|
|
21
|
+
const r = { a, b: t }, u = { transposeA: o, transposeB: l };
|
|
22
22
|
return M.runKernel(p, r, u);
|
|
23
23
|
}
|
|
24
24
|
const i = /* @__PURE__ */ m({ matMul_: f });
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { x as r, y as x, E as e, N as c } from "./index-C0dhsYom.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,9 +15,9 @@ import { o as r, q as e, E as x, M as c } from "./index-BAzbokzv.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function m(n,
|
|
19
|
-
const t = { x:
|
|
20
|
-
return
|
|
18
|
+
function m(n, s = null, o = !1) {
|
|
19
|
+
const t = { x: x(n, "x", "max") }, a = { reductionIndices: s, keepDims: o };
|
|
20
|
+
return e.runKernel(c, t, a);
|
|
21
21
|
}
|
|
22
22
|
const l = /* @__PURE__ */ r({ max_: m });
|
|
23
23
|
export {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC. All Rights Reserved.
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
* =============================================================================
|
|
16
|
+
*/
|
|
17
|
+
function J(e, t, o) {
|
|
18
|
+
const n = k(e, t, o), s = n < 0 ? -(n + 1) : n;
|
|
19
|
+
e.splice(s, 0, t);
|
|
20
|
+
}
|
|
21
|
+
function k(e, t, o) {
|
|
22
|
+
return A(e, t, o || v);
|
|
23
|
+
}
|
|
24
|
+
function v(e, t) {
|
|
25
|
+
return e > t ? 1 : e < t ? -1 : 0;
|
|
26
|
+
}
|
|
27
|
+
function A(e, t, o) {
|
|
28
|
+
let n = 0, s = e.length, r = 0, u = !1;
|
|
29
|
+
for (; n < s; ) {
|
|
30
|
+
r = n + (s - n >>> 1);
|
|
31
|
+
const l = o(t, e[r]);
|
|
32
|
+
l > 0 ? n = r + 1 : (s = r, u = !l);
|
|
33
|
+
}
|
|
34
|
+
return u ? n : -n - 1;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* @license
|
|
38
|
+
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
39
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
40
|
+
* you may not use this file except in compliance with the License.
|
|
41
|
+
* You may obtain a copy of the License at
|
|
42
|
+
*
|
|
43
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
44
|
+
*
|
|
45
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
46
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
47
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
48
|
+
* See the License for the specific language governing permissions and
|
|
49
|
+
* limitations under the License.
|
|
50
|
+
* =============================================================================
|
|
51
|
+
*/
|
|
52
|
+
function O(e, t, o, n, s) {
|
|
53
|
+
return y(
|
|
54
|
+
e,
|
|
55
|
+
t,
|
|
56
|
+
o,
|
|
57
|
+
n,
|
|
58
|
+
s,
|
|
59
|
+
0
|
|
60
|
+
/* softNmsSigma */
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
function P(e, t, o, n, s, r) {
|
|
64
|
+
return y(
|
|
65
|
+
e,
|
|
66
|
+
t,
|
|
67
|
+
o,
|
|
68
|
+
n,
|
|
69
|
+
s,
|
|
70
|
+
0,
|
|
71
|
+
!1,
|
|
72
|
+
r,
|
|
73
|
+
!0
|
|
74
|
+
/* returnValidOutputs */
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
function X(e, t, o, n, s, r) {
|
|
78
|
+
return y(
|
|
79
|
+
e,
|
|
80
|
+
t,
|
|
81
|
+
o,
|
|
82
|
+
n,
|
|
83
|
+
s,
|
|
84
|
+
r,
|
|
85
|
+
!0
|
|
86
|
+
/* returnScoresTensor */
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
function y(e, t, o, n, s, r, u = !1, l = !1, h = !1) {
|
|
90
|
+
const c = [];
|
|
91
|
+
for (let i = 0; i < t.length; i++)
|
|
92
|
+
t[i] > s && c.push({ score: t[i], boxIndex: i, suppressBeginIndex: 0 });
|
|
93
|
+
c.sort(C);
|
|
94
|
+
const d = r > 0 ? -0.5 / r : 0, a = [], f = [];
|
|
95
|
+
for (; a.length < o && c.length > 0; ) {
|
|
96
|
+
const i = c.pop(), { score: M, boxIndex: I, suppressBeginIndex: g } = i;
|
|
97
|
+
if (M < s)
|
|
98
|
+
break;
|
|
99
|
+
let S = !1;
|
|
100
|
+
for (let b = a.length - 1; b >= g; --b) {
|
|
101
|
+
const w = B(e, I, a[b]);
|
|
102
|
+
if (w >= n) {
|
|
103
|
+
S = !0;
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
if (i.score = i.score * V(n, d, w), i.score <= s)
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
i.suppressBeginIndex = a.length, S || (i.score === M ? (a.push(I), f.push(i.score)) : i.score > s && J(c, i, C));
|
|
110
|
+
}
|
|
111
|
+
const x = a.length, p = o - x;
|
|
112
|
+
l && p > 0 && (a.push(...new Array(p).fill(0)), f.push(...new Array(p).fill(0)));
|
|
113
|
+
const m = { selectedIndices: a };
|
|
114
|
+
return u && (m.selectedScores = f), h && (m.validOutputs = x), m;
|
|
115
|
+
}
|
|
116
|
+
function B(e, t, o) {
|
|
117
|
+
const n = e.subarray(t * 4, t * 4 + 4), s = e.subarray(o * 4, o * 4 + 4), r = Math.min(n[0], n[2]), u = Math.min(n[1], n[3]), l = Math.max(n[0], n[2]), h = Math.max(n[1], n[3]), c = Math.min(s[0], s[2]), d = Math.min(s[1], s[3]), a = Math.max(s[0], s[2]), f = Math.max(s[1], s[3]), x = (l - r) * (h - u), p = (a - c) * (f - d);
|
|
118
|
+
if (x <= 0 || p <= 0)
|
|
119
|
+
return 0;
|
|
120
|
+
const m = Math.max(r, c), i = Math.max(u, d), M = Math.min(l, a), I = Math.min(h, f), g = Math.max(M - m, 0) * Math.max(I - i, 0);
|
|
121
|
+
return g / (x + p - g);
|
|
122
|
+
}
|
|
123
|
+
function V(e, t, o) {
|
|
124
|
+
const n = Math.exp(t * o * o);
|
|
125
|
+
return o <= e ? n : 0;
|
|
126
|
+
}
|
|
127
|
+
function C(e, t) {
|
|
128
|
+
return e.score - t.score || e.score === t.score && t.boxIndex - e.boxIndex;
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
X as a,
|
|
132
|
+
P as b,
|
|
133
|
+
O as n
|
|
134
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z as c, c as f } from "./zeros-
|
|
1
|
+
import { C as n, D as t, j as m, E as i } from "./index-C0dhsYom.js";
|
|
2
|
+
import { z as c, c as f } from "./zeros-DCPCdFGq.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
package/dist/ops/appendCache.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { e as a } from "../index-
|
|
1
|
+
import { e as a } from "../index-C0dhsYom.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-CsHeR4zV.js";
|
|
5
|
+
import { z as c } from "../zeros-DCPCdFGq.js";
|
|
6
6
|
function i(r, p, n, o) {
|
|
7
7
|
if (!o) {
|
|
8
8
|
const e = r.shape[2];
|