@genai-fi/nanogpt 0.5.0 → 0.5.2
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 +95 -46
- package/dist/NanoGPTModel.d.ts +3 -2
- package/dist/NanoGPTModel.js +91 -76
- package/dist/{Reshape-BE5rA4rT.js → Reshape-Bt_t7RNz.js} +4 -4
- package/dist/TeachableLLM.js +1 -1
- package/dist/TiedEmbedding-DORsPlNL.js +44 -0
- package/dist/{axis_util-97KkkyRQ.js → axis_util-CVbf1vmL.js} +3 -3
- package/dist/{broadcast_to-CMlkG8NS.js → broadcast_to-BBoMQXbL.js} +4 -4
- package/dist/{concat-Cxbo2sOz.js → concat-BRRtq4S2.js} +1 -1
- package/dist/dataset-ZHEPJmED.js +1226 -0
- package/dist/{dropout-kbDY39Ci.js → dropout-lQm_YyX3.js} +1 -1
- package/dist/{gather-Bxe1Qip8.js → gather-BWyutxwi.js} +3 -3
- package/dist/{gpgpu_math-C0zyxKFi.js → gpgpu_math-Df7gzJWH.js} +1 -1
- package/dist/{index-iNhkcAEQ.js → index-CnHyhpKc.js} +32 -32
- package/dist/{kernel_funcs_utils-C4eIk4fE.js → kernel_funcs_utils-Dqo82NH4.js} +25 -25
- package/dist/layers/BaseLayer.js +114 -3
- package/dist/layers/CausalSelfAttention.d.ts +2 -3
- package/dist/layers/CausalSelfAttention.js +31 -30
- package/dist/layers/MLP.js +10 -9
- package/dist/layers/RMSNorm.js +12 -11
- package/dist/layers/RoPECache.js +3 -3
- package/dist/layers/TiedEmbedding.js +8 -6
- package/dist/layers/TransformerBlock.js +2 -2
- package/dist/{log_sum_exp-CkumwesB.js → log_sum_exp-CRH7Np9v.js} +12 -12
- package/dist/main.js +1 -1
- package/dist/{mat_mul-D0SifYfJ.js → mat_mul-DeGU1U_C.js} +3 -3
- package/dist/{max-CYaAjEEp.js → max-CcnEArWK.js} +3 -3
- package/dist/{moments-B06NlR_V.js → moments-DLTE6-1p.js} +4 -4
- package/dist/{norm-D3676xIo.js → norm-BpWsOapl.js} +5 -5
- package/dist/{ones-BIeFnPHR.js → ones-CDWGzVnm.js} +6 -6
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- 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 +1 -1
- 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 +27 -27
- 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 +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- 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 +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/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 +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +36 -36
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/matMulGelu.js +22 -22
- 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-ObfXLHYQ.js → ops-DzQTmLIl.js} +60 -60
- package/dist/{TiedEmbedding-DsDRvLB0.js → random_width-DI2h9CMs.js} +1215 -1250
- package/dist/{range-BsFU-SNG.js → range-CkOJ7090.js} +1 -1
- package/dist/{reshape-DxTPgnwL.js → reshape-CTIbqjwm.js} +1 -1
- package/dist/{sin-BOX-JVAj.js → sin-HzioENy_.js} +5 -5
- package/dist/{slice_util-D-kaD4ZV.js → slice_util-n4wHKmex.js} +1 -1
- package/dist/{softmax-BjsptB07.js → softmax-DX6qXAbm.js} +2 -2
- package/dist/{split-BCbrzthj.js → split-CVwhL8Oe.js} +3 -3
- package/dist/{stack--cqr9Dgc.js → stack-S2-D2JAQ.js} +1 -1
- package/dist/{sum-B_92TaHD.js → sum-UdfvaNhB.js} +4 -4
- package/dist/{tensor-CfiPXsW4.js → tensor-IZex6Bwp.js} +1 -1
- package/dist/{tensor2d-tSxWdFMH.js → tensor2d-CqtBzOKq.js} +1 -1
- package/dist/{tfjs_backend-NucKez4s.js → tfjs_backend-DX9yVvwk.js} +41 -41
- package/dist/tokeniser/CharTokeniser.js +27 -27
- package/dist/tokeniser/bpe.d.ts +1 -0
- package/dist/tokeniser/bpe.js +38 -35
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +22 -1242
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +5 -5
- package/dist/training/sparseCrossEntropy.js +4 -4
- package/dist/utilities/dummy.js +2 -2
- 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 +5 -5
- package/dist/utilities/weights.js +2 -2
- package/dist/variable-BGvK-VN3.js +23 -0
- package/dist/{zeros-NMYTayy7.js → zeros-CYMicyqz.js} +3 -3
- package/package.json +1 -1
- package/dist/BaseLayer-BhrMN8JO.js +0 -135
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as r,
|
|
2
|
-
import { e as K } from "./axis_util-
|
|
3
|
-
import { m as T } from "./max-
|
|
4
|
-
import { r as m } from "./reshape-
|
|
5
|
-
import { s as _ } from "./sum-
|
|
1
|
+
import { o as r, j as p, E as u, a7 as E, a8 as h, a1 as S, s as $, a9 as d } from "./index-CnHyhpKc.js";
|
|
2
|
+
import { e as K } from "./axis_util-CVbf1vmL.js";
|
|
3
|
+
import { m as T } from "./max-CcnEArWK.js";
|
|
4
|
+
import { r as m } from "./reshape-CTIbqjwm.js";
|
|
5
|
+
import { s as _ } from "./sum-UdfvaNhB.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -40,11 +40,11 @@ const N = /* @__PURE__ */ r({ exp_: b });
|
|
|
40
40
|
* limitations under the License.
|
|
41
41
|
* =============================================================================
|
|
42
42
|
*/
|
|
43
|
-
function
|
|
43
|
+
function j(s) {
|
|
44
44
|
const o = { x: p(s, "x", "log", "float32") };
|
|
45
45
|
return u.runKernel(h, o);
|
|
46
46
|
}
|
|
47
|
-
const
|
|
47
|
+
const v = /* @__PURE__ */ r({ log_: j });
|
|
48
48
|
/**
|
|
49
49
|
* @license
|
|
50
50
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -61,22 +61,22 @@ const w = /* @__PURE__ */ r({ log_: v });
|
|
|
61
61
|
* limitations under the License.
|
|
62
62
|
* =============================================================================
|
|
63
63
|
*/
|
|
64
|
-
function
|
|
64
|
+
function w(s, a = null, o = !1) {
|
|
65
65
|
const n = p(s, "x", "logSumExp"), t = S(a, n.shape), x = T(
|
|
66
66
|
n,
|
|
67
67
|
t,
|
|
68
68
|
!0
|
|
69
69
|
/* keepDims */
|
|
70
|
-
), i = $(n, x), l = N(i), f = _(l, t), c =
|
|
70
|
+
), i = $(n, x), l = N(i), f = _(l, t), c = v(f), e = d(m(x, c.shape), c);
|
|
71
71
|
if (o) {
|
|
72
72
|
const g = K(e.shape, t);
|
|
73
73
|
return m(e, g);
|
|
74
74
|
}
|
|
75
75
|
return e;
|
|
76
76
|
}
|
|
77
|
-
const
|
|
77
|
+
const M = /* @__PURE__ */ r({ logSumExp_: w });
|
|
78
78
|
export {
|
|
79
|
-
|
|
79
|
+
v as a,
|
|
80
80
|
N as e,
|
|
81
|
-
|
|
81
|
+
M as l
|
|
82
82
|
};
|
package/dist/main.js
CHANGED
|
@@ -5,7 +5,7 @@ import { default as q } from "./tokeniser/bpe.js";
|
|
|
5
5
|
import { default as A } from "./utilities/waitForModel.js";
|
|
6
6
|
import { default as I } from "./data/textLoader.js";
|
|
7
7
|
import { estimateMemoryUsage as K, estimateParameterCount as O, estimateResources as Q, estimateTrainingMemoryUsage as S, validateConfig as V } from "./utilities/parameters.js";
|
|
8
|
-
import "./index-
|
|
8
|
+
import "./index-CnHyhpKc.js";
|
|
9
9
|
import "./ops/cpu/scatterSub.js";
|
|
10
10
|
import "./ops/webgl/scatterSub.js";
|
|
11
11
|
import "./ops/cpu/gatherSub.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as m,
|
|
1
|
+
import { o as m, j as s, u as c, E as M, B as p } from "./index-CnHyhpKc.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -21,7 +21,7 @@ function f(e, o, n = !1, l = !1) {
|
|
|
21
21
|
const r = { a, b: t }, u = { transposeA: n, transposeB: l };
|
|
22
22
|
return M.runKernel(p, r, u);
|
|
23
23
|
}
|
|
24
|
-
const
|
|
24
|
+
const i = /* @__PURE__ */ m({ matMul_: f });
|
|
25
25
|
export {
|
|
26
|
-
|
|
26
|
+
i as m
|
|
27
27
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { o as r,
|
|
1
|
+
import { o as r, j as e, E as x, M as c } from "./index-CnHyhpKc.js";
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -15,11 +15,11 @@ import { o as r, i as e, E as x, M as c } from "./index-iNhkcAEQ.js";
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
* =============================================================================
|
|
17
17
|
*/
|
|
18
|
-
function
|
|
18
|
+
function m(n, o = null, s = !1) {
|
|
19
19
|
const t = { x: e(n, "x", "max") }, a = { reductionIndices: o, keepDims: s };
|
|
20
20
|
return x.runKernel(c, t, a);
|
|
21
21
|
}
|
|
22
|
-
const l = /* @__PURE__ */ r({ max_:
|
|
22
|
+
const l = /* @__PURE__ */ r({ max_: m });
|
|
23
23
|
export {
|
|
24
24
|
l as m
|
|
25
25
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as m,
|
|
2
|
-
import { e as v } from "./axis_util-
|
|
3
|
-
import { r as E } from "./reshape-
|
|
1
|
+
import { o as m, j as c, E as f, a0 as i, a1 as l, a2 as h, s as x, D as d } from "./index-CnHyhpKc.js";
|
|
2
|
+
import { e as v } from "./axis_util-CVbf1vmL.js";
|
|
3
|
+
import { r as E } from "./reshape-CTIbqjwm.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -19,7 +19,7 @@ import { r as E } from "./reshape-DxTPgnwL.js";
|
|
|
19
19
|
*/
|
|
20
20
|
function S(a, t = null, e = !1) {
|
|
21
21
|
const s = { x: c(a, "x", "mean") }, o = { axis: t, keepDims: e };
|
|
22
|
-
return
|
|
22
|
+
return f.runKernel(i, s, o);
|
|
23
23
|
}
|
|
24
24
|
const r = /* @__PURE__ */ m({ mean_: S });
|
|
25
25
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as l,
|
|
2
|
-
import { e as $ } from "./axis_util-
|
|
3
|
-
import { m as f } from "./max-
|
|
4
|
-
import { r as h } from "./reshape-
|
|
5
|
-
import { s as t } from "./sum-
|
|
1
|
+
import { o as l, j as c, E as y, a3 as E, a1 as w, a4 as o, a5 as u, W as v, f as I, a2 as A } from "./index-CnHyhpKc.js";
|
|
2
|
+
import { e as $ } from "./axis_util-CVbf1vmL.js";
|
|
3
|
+
import { m as f } from "./max-CcnEArWK.js";
|
|
4
|
+
import { r as h } from "./reshape-CTIbqjwm.js";
|
|
5
|
+
import { s as t } from "./sum-UdfvaNhB.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { z as
|
|
1
|
+
import { n, p as t, q as m, E as i } from "./index-CnHyhpKc.js";
|
|
2
|
+
import { z as c, c as f } from "./zeros-CYMicyqz.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
5
5
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -16,14 +16,14 @@ import { z as l, c } from "./zeros-NMYTayy7.js";
|
|
|
16
16
|
* limitations under the License.
|
|
17
17
|
* =============================================================================
|
|
18
18
|
*/
|
|
19
|
-
function
|
|
19
|
+
function l(o, r = "float32") {
|
|
20
20
|
if (n(o), r === "complex64") {
|
|
21
|
-
const s =
|
|
22
|
-
return
|
|
21
|
+
const s = l(o, "float32"), a = c(o, "float32");
|
|
22
|
+
return f(s, a);
|
|
23
23
|
}
|
|
24
24
|
const e = t(m(o), r);
|
|
25
25
|
return i.makeTensor(e, o, r);
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
28
|
+
l as o
|
|
29
29
|
};
|
package/dist/ops/appendCache.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { e as a } from "../index-
|
|
1
|
+
import { e as a } from "../index-CnHyhpKc.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-BRRtq4S2.js";
|
|
5
|
+
import { z as c } from "../zeros-CYMicyqz.js";
|
|
6
6
|
function i(r, p, n, o) {
|
|
7
7
|
if (!o) {
|
|
8
8
|
const e = r.shape[2];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as d } from "../../index-
|
|
2
|
-
import { c as h } from "../../concat-
|
|
1
|
+
import { r as d } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { c as h } from "../../concat-BRRtq4S2.js";
|
|
3
3
|
function u(p) {
|
|
4
4
|
const { cache: n, item: s } = p.inputs, { maxSize: r, 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 <= r) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as a, g as p, f as u } from "../../index-
|
|
2
|
-
import { l as N, w as b } from "../../ops-
|
|
3
|
-
import { o as g } from "../../ones-
|
|
4
|
-
import { z as A } from "../../zeros-
|
|
5
|
-
import { m as I } from "../../mat_mul-
|
|
1
|
+
import { r as a, g as p, f as u } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { l as N, w as b } from "../../ops-DzQTmLIl.js";
|
|
3
|
+
import { o as g } from "../../ones-CDWGzVnm.js";
|
|
4
|
+
import { z as A } from "../../zeros-CYMicyqz.js";
|
|
5
|
+
import { m as I } from "../../mat_mul-DeGU1U_C.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(g([t, t]), -1, 0).cast("bool"), l = A([t, t]), i = p([t, t], Number.NEGATIVE_INFINITY), f = b(m, l, i), k = I(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 { r as n } from "../../index-
|
|
2
|
-
import { s as f } from "../../softmax-
|
|
1
|
+
import { r as n } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { s as f } from "../../softmax-DX6qXAbm.js";
|
|
3
3
|
function r(t) {
|
|
4
4
|
const { inputs: s, attrs: i } = t, { logits: o } = s, { dim: a, dropoutRate: e } = i;
|
|
5
5
|
if (!o)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as u,
|
|
2
|
-
import { r as l } from "../../range-
|
|
3
|
-
import { s as N } from "../../stack
|
|
1
|
+
import { o as u, j as c, E as g, O as h, r as m, s as p } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { r as l } from "../../range-CkOJ7090.js";
|
|
3
|
+
import { s as N } from "../../stack-S2-D2JAQ.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -23,8 +23,8 @@ function f(e, s) {
|
|
|
23
23
|
}
|
|
24
24
|
const b = /* @__PURE__ */ u({ gatherND_: f });
|
|
25
25
|
function d(e) {
|
|
26
|
-
const { values: s, labels: n, logits: r } = e.inputs, t = n.shape[0],
|
|
27
|
-
return p(s,
|
|
26
|
+
const { values: s, labels: n, logits: r } = e.inputs, t = n.shape[0], o = l(0, t, 1, "int32"), a = N([o, n], 1), i = b(r, a);
|
|
27
|
+
return p(s, i);
|
|
28
28
|
}
|
|
29
29
|
const k = {
|
|
30
30
|
kernelName: "EfficientGatherSub",
|
package/dist/ops/cpu/gelu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as n, t as M } from "../../index-
|
|
1
|
+
import { r as n, t as M } from "../../index-CnHyhpKc.js";
|
|
2
2
|
function e(t) {
|
|
3
3
|
const { inputs: r, attrs: o } = t, { transposeA: s, transposeB: l } = o, { x: c, kernel: u, y: a } = r, m = c, i = u, k = a;
|
|
4
4
|
return M(() => m.matMul(i, s, l).mul(k));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as e, b as u } from "../../index-
|
|
1
|
+
import { r as e, b as u } from "../../index-CnHyhpKc.js";
|
|
2
2
|
function n(o) {
|
|
3
3
|
const { inputs: r } = o, { a: l, b: t } = r;
|
|
4
4
|
return console.warn("Using fallback mulDrop implementation without dropout."), u(l, t);
|
package/dist/ops/cpu/normRMS.js
CHANGED
package/dist/ops/cpu/qkv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as q } from "../../index-
|
|
2
|
-
import { r as o } from "../../reshape-
|
|
3
|
-
import { s as x } from "../../split-
|
|
1
|
+
import { r as q } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { r as o } from "../../reshape-CTIbqjwm.js";
|
|
3
|
+
import { s as x } from "../../split-CVwhL8Oe.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 { r 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 { r as S } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { r as F } from "../../range-CkOJ7090.js";
|
|
3
|
+
import { g as I } from "../../gather-BWyutxwi.js";
|
|
4
|
+
import { s as E } from "../../stack-S2-D2JAQ.js";
|
|
5
|
+
import { c as T } from "../../concat-BRRtq4S2.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,27 +1,27 @@
|
|
|
1
|
-
import { o as l,
|
|
2
|
-
import { r as b } from "../../range-
|
|
3
|
-
import { s as E } from "../../stack
|
|
4
|
-
import { o as D } from "../../ones-
|
|
5
|
-
function N(
|
|
6
|
-
const s = r.rank > 1 ? r.shape[r.rank - 1] : 1, e = r.rank > 1 ? r.rank - 1 : 1, o = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${r.shape}, shape: ${
|
|
1
|
+
import { o as l, n as g, j as h, E as k, a6 as w, r as $, s as d, b as m } from "../../index-CnHyhpKc.js";
|
|
2
|
+
import { r as b } from "../../range-CkOJ7090.js";
|
|
3
|
+
import { s as E } from "../../stack-S2-D2JAQ.js";
|
|
4
|
+
import { o as D } from "../../ones-CDWGzVnm.js";
|
|
5
|
+
function N(a, r, t) {
|
|
6
|
+
const s = r.rank > 1 ? r.shape[r.rank - 1] : 1, e = r.rank > 1 ? r.rank - 1 : 1, o = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${t.shape}, indices.shape: ${r.shape}, shape: ${a}, sliceDim: ${s}, and batchDim: ${e}.`;
|
|
7
7
|
if (t.rank < e)
|
|
8
8
|
throw new Error(o + ` update.rank < ${e}. `);
|
|
9
|
-
if (
|
|
9
|
+
if (a.length < s + (t.rank - e))
|
|
10
10
|
throw new Error(o + ` Output shape length < ${s + (t.rank - e)}`);
|
|
11
|
-
if (t.rank !== e +
|
|
12
|
-
throw new Error(o + ` update.rank != ${e +
|
|
13
|
-
for (let
|
|
14
|
-
if (t.shape[
|
|
15
|
-
throw new Error(o + ` updates.shape[${
|
|
16
|
-
for (let
|
|
17
|
-
if (t.shape[
|
|
18
|
-
throw new Error(o + ` updates.shape[${
|
|
11
|
+
if (t.rank !== e + a.length - s)
|
|
12
|
+
throw new Error(o + ` update.rank != ${e + a.length - s}`);
|
|
13
|
+
for (let n = 0; n < e; ++n)
|
|
14
|
+
if (t.shape[n] !== r.shape[n])
|
|
15
|
+
throw new Error(o + ` updates.shape[${n}] (${t.shape[n]}) != indices.shape[${n}] (${r.shape[n]}).`);
|
|
16
|
+
for (let n = 0; n < t.rank - e; ++n)
|
|
17
|
+
if (t.shape[n + e] !== a[n + s])
|
|
18
|
+
throw new Error(o + ` updates.shape[${n + e}] (${t.shape[n + e]}) != shape[${n + e}] (${a[n + e]})`);
|
|
19
19
|
}
|
|
20
|
-
function S(
|
|
20
|
+
function S(a, r, t) {
|
|
21
21
|
if (r.rank < 1)
|
|
22
22
|
throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${r.rank}.`);
|
|
23
|
-
if (
|
|
24
|
-
throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${
|
|
23
|
+
if (a.rank < 1)
|
|
24
|
+
throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${a.rank}.`);
|
|
25
25
|
if (r.dtype !== "int32")
|
|
26
26
|
throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${r.dtype}`);
|
|
27
27
|
if (t.length < 1)
|
|
@@ -29,10 +29,10 @@ function S(n, r, t) {
|
|
|
29
29
|
if (t.length === 0) {
|
|
30
30
|
if (r.size === 0)
|
|
31
31
|
throw new Error(`Indices specified for empty output. indices shape: ${r.shape}`);
|
|
32
|
-
if (
|
|
33
|
-
throw new Error(`Updates specified for empty output. updates shape: ${
|
|
32
|
+
if (a.size === 0)
|
|
33
|
+
throw new Error(`Updates specified for empty output. updates shape: ${a.shape}`);
|
|
34
34
|
}
|
|
35
|
-
N(t, r,
|
|
35
|
+
N(t, r, a);
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* @license
|
|
@@ -50,16 +50,16 @@ function S(n, r, t) {
|
|
|
50
50
|
* limitations under the License.
|
|
51
51
|
* =============================================================================
|
|
52
52
|
*/
|
|
53
|
-
function y(
|
|
53
|
+
function y(a, r, t) {
|
|
54
54
|
g(t);
|
|
55
|
-
const s =
|
|
55
|
+
const s = h(a, "indices", "scatterND", "int32"), e = h(r, "updates", "scatterND");
|
|
56
56
|
S(e, s, t);
|
|
57
|
-
const o = { indices: s, updates: e },
|
|
58
|
-
return k.runKernel(w, o,
|
|
57
|
+
const o = { indices: s, updates: e }, n = { shape: t };
|
|
58
|
+
return k.runKernel(w, o, n);
|
|
59
59
|
}
|
|
60
60
|
const v = /* @__PURE__ */ l({ scatterND_: y });
|
|
61
|
-
function I(
|
|
62
|
-
const { logits: r, labels: t, dy: s } =
|
|
61
|
+
function I(a) {
|
|
62
|
+
const { logits: r, labels: t, dy: s } = a.inputs, e = t.shape[0], o = r.shape[1], n = b(0, e, 1, "int32"), i = E([n, t], 1), c = D([e]), p = v(i, c, [e, o]), f = d(r, p), u = s.reshape([e, 1]);
|
|
63
63
|
return m(f, u);
|
|
64
64
|
}
|
|
65
65
|
const T = {
|
package/dist/ops/fusedSoftmax.js
CHANGED
package/dist/ops/gatherSub.js
CHANGED
package/dist/ops/gelu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { h as d, b as u, s as f } from "../../index-
|
|
1
|
+
import { h as d, b as u, s as f } from "../../index-CnHyhpKc.js";
|
|
2
2
|
import { mulDrop as l } from "../mulDrop.js";
|
|
3
|
-
import { s as g } from "../../sum-
|
|
3
|
+
import { s as g } from "../../sum-UdfvaNhB.js";
|
|
4
4
|
const T = {
|
|
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/scatterSub.js
CHANGED