@genai-fi/nanogpt 0.4.5 → 0.5.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/BaseLayer-BhrMN8JO.js +135 -0
- package/dist/Generator.js +44 -41
- package/dist/NanoGPTModel.d.ts +12 -16
- package/dist/NanoGPTModel.js +128 -138
- package/dist/{Reshape-CiAY8ltP.js → Reshape-BE5rA4rT.js} +8 -8
- package/dist/TeachableLLM.js +1 -1
- package/dist/{TiedEmbedding-DznFwzcB.js → TiedEmbedding-DsDRvLB0.js} +751 -768
- package/dist/{axis_util-QP0LdI1v.js → axis_util-97KkkyRQ.js} +1 -1
- package/dist/broadcast_to-CMlkG8NS.js +44 -0
- package/dist/{concat-DvWM7HGZ.js → concat-Cxbo2sOz.js} +3 -3
- package/dist/{dropout-DFEXTPV0.js → dropout-kbDY39Ci.js} +1 -1
- package/dist/{gather-C5D8PxwA.js → gather-Bxe1Qip8.js} +4 -4
- package/dist/{gpgpu_math-CUzjlO9A.js → gpgpu_math-C0zyxKFi.js} +1 -1
- package/dist/{index--6vO-cOz.js → index-iNhkcAEQ.js} +82 -82
- package/dist/{kernel_funcs_utils-C6YBCuOt.js → kernel_funcs_utils-C4eIk4fE.js} +20 -20
- package/dist/layers/BaseLayer.d.ts +28 -4
- package/dist/layers/BaseLayer.js +3 -16
- package/dist/layers/CausalSelfAttention.d.ts +22 -24
- package/dist/layers/CausalSelfAttention.js +73 -128
- package/dist/layers/MLP.d.ts +8 -15
- package/dist/layers/MLP.js +43 -81
- package/dist/layers/RMSNorm.d.ts +5 -10
- package/dist/layers/RMSNorm.js +13 -29
- package/dist/layers/RoPECache.js +14 -12
- package/dist/layers/TiedEmbedding.d.ts +6 -16
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.d.ts +12 -16
- package/dist/layers/TransformerBlock.js +20 -41
- package/dist/{log_sum_exp-CiEy1aUe.js → log_sum_exp-CkumwesB.js} +11 -11
- package/dist/main.js +1 -1
- package/dist/{mat_mul-BEHRPMh0.js → mat_mul-D0SifYfJ.js} +3 -3
- package/dist/{max-BUShNgfh.js → max-CYaAjEEp.js} +3 -3
- package/dist/{moments-DYOHXoRV.js → moments-B06NlR_V.js} +6 -6
- package/dist/{norm-DSva3hI3.js → norm-D3676xIo.js} +7 -7
- package/dist/{ones-D6kB8bdY.js → ones-BIeFnPHR.js} +2 -2
- package/dist/ops/appendCache.js +4 -4
- package/dist/ops/attentionMask.d.ts +1 -1
- package/dist/ops/attentionMask.js +4 -4
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +14 -15
- 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 +1 -1
- package/dist/ops/cpu/matMulMul.d.ts +1 -0
- package/dist/ops/cpu/matMulMul.js +17 -0
- 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 +8 -8
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +1 -1
- package/dist/ops/grads/attentionMask.js +13 -9
- package/dist/ops/grads/fusedSoftmax.js +12 -9
- package/dist/ops/grads/gelu.js +1 -1
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +19 -9
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.d.ts +2 -0
- package/dist/ops/matMulMul.js +9 -0
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +13 -12
- package/dist/ops/webgl/fusedSoftmax.js +43 -40
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/matMulGelu.js +17 -17
- package/dist/ops/webgl/matMulMul.d.ts +14 -0
- package/dist/ops/webgl/matMulMul.js +28 -0
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +29 -21
- 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-ObfXLHYQ.js +1269 -0
- package/dist/{range-C_vpUjBu.js → range-BsFU-SNG.js} +1 -1
- package/dist/{reshape-z51Eu-re.js → reshape-DxTPgnwL.js} +3 -3
- package/dist/{sin-H567uayl.js → sin-BOX-JVAj.js} +5 -5
- package/dist/slice_util-D-kaD4ZV.js +49 -0
- package/dist/{softmax-Dsxflvdl.js → softmax-BjsptB07.js} +2 -2
- package/dist/{split-B_k_jwud.js → split-BCbrzthj.js} +4 -4
- package/dist/{stack-CmqSdsfs.js → stack--cqr9Dgc.js} +2 -2
- package/dist/{sum-DdkDf2MG.js → sum-B_92TaHD.js} +5 -5
- package/dist/{tensor-BGYi41cj.js → tensor-CfiPXsW4.js} +1 -1
- package/dist/{tensor2d-DUr_htjt.js → tensor2d-tSxWdFMH.js} +1 -1
- package/dist/tfjs_backend-NucKez4s.js +1010 -0
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +44 -44
- package/dist/training/Evaluator.js +6 -6
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +7 -7
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.js +10 -10
- package/dist/utilities/generate.js +3 -3
- package/dist/utilities/load.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/save.js +10 -8
- package/dist/utilities/weights.js +2 -2
- package/dist/{zeros-8xl-W2DC.js → zeros-NMYTayy7.js} +3 -3
- package/package.json +1 -1
- package/dist/slice_util-BdhYwFY_.js +0 -90
- package/dist/tfjs_backend-DuKis_xG.js +0 -2271
- package/dist/variable-BJTZ3jOy.js +0 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o,
|
|
1
|
+
import { o, i as t, E as a, u as p } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -19,7 +19,7 @@ function c(r, s) {
|
|
|
19
19
|
const e = { x: t(r, "x", "reshape", "string_or_numeric") }, n = { shape: s };
|
|
20
20
|
return a.runKernel(p, e, n);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const x = /* @__PURE__ */ o({ reshape_: c });
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
x as r
|
|
25
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o,
|
|
1
|
+
import { o, i as t, E as c, _ as i, $ as a } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -15,11 +15,11 @@ import { o, h as t, E as c, V as a, W as e } from "./index--6vO-cOz.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function
|
|
18
|
+
function e(n) {
|
|
19
19
|
const s = { x: t(n, "x", "cos", "float32") };
|
|
20
|
-
return c.runKernel(
|
|
20
|
+
return c.runKernel(i, s);
|
|
21
21
|
}
|
|
22
|
-
const f = /* @__PURE__ */ o({ cos_:
|
|
22
|
+
const f = /* @__PURE__ */ o({ cos_: e });
|
|
23
23
|
/**
|
|
24
24
|
* @license
|
|
25
25
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -38,7 +38,7 @@ const f = /* @__PURE__ */ o({ cos_: i });
|
|
|
38
38
|
*/
|
|
39
39
|
function x(n) {
|
|
40
40
|
const s = { x: t(n, "x", "sin", "float32") };
|
|
41
|
-
return c.runKernel(
|
|
41
|
+
return c.runKernel(a, s);
|
|
42
42
|
}
|
|
43
43
|
const p = /* @__PURE__ */ o({ sin_: x });
|
|
44
44
|
export {
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { k as s } from "./index-iNhkcAEQ.js";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright 2021 Google LLC. All Rights Reserved.
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
* =============================================================================
|
|
17
|
+
*/
|
|
18
|
+
function u(r, n, t) {
|
|
19
|
+
let l = t.length;
|
|
20
|
+
for (let e = 0; e < t.length; e++)
|
|
21
|
+
if (t[e] > 1) {
|
|
22
|
+
l = e;
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
for (let e = l + 1; e < t.length; e++)
|
|
26
|
+
if (n[e] > 0 || t[e] !== r[e])
|
|
27
|
+
return !1;
|
|
28
|
+
return !0;
|
|
29
|
+
}
|
|
30
|
+
function c(r, n) {
|
|
31
|
+
let t = r.length > 0 ? r[r.length - 1] : 1;
|
|
32
|
+
for (let l = 0; l < r.length - 1; l++)
|
|
33
|
+
t += r[l] * n[l];
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
function h(r, n, t) {
|
|
37
|
+
let l;
|
|
38
|
+
const e = r.shape.length;
|
|
39
|
+
typeof n == "number" ? l = [n, ...new Array(e - 1).fill(0)] : n.length < e ? l = n.concat(new Array(e - n.length).fill(0)) : l = n.slice(), l.forEach((a) => {
|
|
40
|
+
s(a !== -1, () => "slice() does not support negative begin indexing.");
|
|
41
|
+
});
|
|
42
|
+
let f;
|
|
43
|
+
return t == null ? f = new Array(e).fill(-1) : typeof t == "number" ? f = [t, ...new Array(e - 1).fill(-1)] : t.length < e ? f = t.concat(new Array(e - t.length).fill(-1)) : f = t, f = f.map((a, o) => a >= 0 ? a : (s(a === -1, () => `Negative size values should be exactly -1 but got ${a} for the slice() size at index ${o}.`), r.shape[o] - l[o])), [l, f];
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
c,
|
|
47
|
+
u as i,
|
|
48
|
+
h as p
|
|
49
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as r,
|
|
1
|
+
import { o as r, i as f, E as i, S as e } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -20,7 +20,7 @@ function l(s, o = -1) {
|
|
|
20
20
|
if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
|
|
21
21
|
throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
|
|
22
22
|
const n = { logits: t }, a = { dim: o };
|
|
23
|
-
return
|
|
23
|
+
return i.runKernel(e, n, a);
|
|
24
24
|
}
|
|
25
25
|
const p = /* @__PURE__ */ r({ softmax_: l });
|
|
26
26
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as
|
|
1
|
+
import { o as i, i as p, E as a, w as c } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -16,10 +16,10 @@ import { o as p, h as i, E as a, u as c } from "./index--6vO-cOz.js";
|
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
18
|
function e(t, s, o = 0) {
|
|
19
|
-
const n = { x:
|
|
19
|
+
const n = { x: p(t, "x", "split") }, r = { numOrSizeSplits: s, axis: o };
|
|
20
20
|
return a.runKernel(c, n, r);
|
|
21
21
|
}
|
|
22
|
-
const
|
|
22
|
+
const u = /* @__PURE__ */ i({ split_: e });
|
|
23
23
|
export {
|
|
24
|
-
|
|
24
|
+
u as s
|
|
25
25
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e,
|
|
1
|
+
import { o as e, j as c, k as n, E as k, P as i } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -19,7 +19,7 @@ function u(r, t = 0) {
|
|
|
19
19
|
const s = c(r, "tensors", "stack", "string_or_numeric");
|
|
20
20
|
n(s.length >= 1, () => "Pass at least one tensor to tf.stack"), s.length > 0 && n(t <= s[0].rank, () => "Axis must be <= rank of the tensor");
|
|
21
21
|
const o = s, a = { axis: t };
|
|
22
|
-
return
|
|
22
|
+
return k.runKernel(i, o, a);
|
|
23
23
|
}
|
|
24
24
|
const l = /* @__PURE__ */ e({ stack_: u });
|
|
25
25
|
export {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as e,
|
|
1
|
+
import { o as e, i as u, y as c, E as i, D as l } from "./index-iNhkcAEQ.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -15,13 +15,13 @@ import { o as e, h as u, x as c, E as l, y as m } from "./index--6vO-cOz.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function
|
|
18
|
+
function m(t, o = null, n = !1) {
|
|
19
19
|
let s = u(t, "x", "sum");
|
|
20
20
|
s.dtype === "bool" && (s = c(s, "int32"));
|
|
21
21
|
const r = { x: s }, a = { axis: o, keepDims: n };
|
|
22
|
-
return
|
|
22
|
+
return i.runKernel(l, r, a);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const f = /* @__PURE__ */ e({ sum_: m });
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
f as s
|
|
27
27
|
};
|