@genai-fi/nanogpt 0.5.4 → 0.5.5
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 +5 -5
- package/dist/NanoGPTModel.d.ts +2 -0
- package/dist/NanoGPTModel.js +8 -8
- package/dist/{Reshape-Bt_t7RNz.js → Reshape-Biok_3X1.js} +6 -6
- package/dist/TeachableLLM.js +1 -1
- package/dist/{TiedEmbedding-DORsPlNL.js → TiedEmbedding-8S8xn8e6.js} +5 -5
- package/dist/Trainer.d.ts +1 -0
- package/dist/Trainer.js +8 -7
- package/dist/{axis_util-CVbf1vmL.js → axis_util-BczFISHz.js} +1 -1
- package/dist/{broadcast_to-BBoMQXbL.js → broadcast_to-B7NGsBSh.js} +2 -2
- package/dist/{concat-BRRtq4S2.js → concat-DdKPyAtw.js} +1 -1
- package/dist/{dataset-ZHEPJmED.js → dataset-iqT4Otvb.js} +7 -7
- package/dist/{dropout-lQm_YyX3.js → dropout-B09InSJS.js} +1 -1
- package/dist/{gather-BWyutxwi.js → gather-D6MsdXqc.js} +1 -1
- package/dist/{gpgpu_math-Df7gzJWH.js → gpgpu_math-BFbOyvk4.js} +1 -1
- package/dist/{index-CnHyhpKc.js → index-Du-bmOP8.js} +98 -98
- package/dist/{kernel_funcs_utils-Dqo82NH4.js → kernel_funcs_utils-DShm7-0k.js} +33 -33
- 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 +3 -3
- package/dist/layers/TiedEmbedding.js +6 -6
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/{log_sum_exp-CRH7Np9v.js → log_sum_exp-CxfBtUaG.js} +5 -5
- package/dist/main.js +1 -1
- package/dist/{mat_mul-DeGU1U_C.js → mat_mul-CbiqIe2d.js} +1 -1
- package/dist/{max-CcnEArWK.js → max-0Xnlpv8k.js} +1 -1
- package/dist/{norm-BpWsOapl.js → norm-01kY9I2B.js} +5 -5
- package/dist/{ones-CDWGzVnm.js → ones-CrutWGas.js} +2 -2
- 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 +3 -3
- 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 +4 -4
- 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 +96 -96
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/matMulGelu.js +4 -4
- 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-DzQTmLIl.js → ops-CJNniCAV.js} +13 -13
- package/dist/{random_width-DI2h9CMs.js → random_width-C-v-35bY.js} +1324 -1279
- package/dist/{range-CkOJ7090.js → range-Bvs1hidm.js} +1 -1
- package/dist/{reshape-CTIbqjwm.js → reshape-BH7eBpwq.js} +1 -1
- package/dist/{sin-HzioENy_.js → sin-CPAZXNjH.js} +1 -1
- package/dist/{slice_util-n4wHKmex.js → slice_util-DskXqRZa.js} +1 -1
- package/dist/{softmax-DX6qXAbm.js → softmax-DhWoBa7r.js} +1 -1
- package/dist/{split-CVwhL8Oe.js → split-BCUhuU7B.js} +1 -1
- package/dist/{stack-S2-D2JAQ.js → stack-BV1v7l3S.js} +1 -1
- package/dist/{sum-UdfvaNhB.js → sum-Cvq06317.js} +1 -1
- package/dist/{tensor-IZex6Bwp.js → tensor-DgTOPY6h.js} +1 -1
- package/dist/{tensor2d-CqtBzOKq.js → tensor2d-CRWjDyUe.js} +1 -1
- package/dist/{tfjs_backend-DX9yVvwk.js → tfjs_backend-D9Ytje0G.js} +39 -39
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +36 -32
- package/dist/training/Trainer.d.ts +7 -4
- package/dist/training/Trainer.js +58 -50
- 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.d.ts +1 -0
- package/dist/utilities/profile.js +6 -3
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-BGvK-VN3.js → variable-DZ3fF0R2.js} +1 -1
- package/dist/{zeros-CYMicyqz.js → zeros-BaHhQTWf.js} +1 -1
- package/package.json +1 -1
- package/dist/moments-DLTE6-1p.js +0 -53
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { f as $t, a as Qt, g as yt, b as Yt, c as Jt } from "../../kernel_funcs_utils-
|
|
3
|
-
import { c as mt, g as Tt, a as Vt, b as Mt, e as wt } from "../../axis_util-
|
|
4
|
-
import { b as te } from "../../broadcast_to-
|
|
5
|
-
import { r as ee } from "../../reshape-
|
|
6
|
-
import { i as ne, c as oe } from "../../slice_util-
|
|
1
|
+
import { a_ as qt, q as y, Q as Ct, ac as J, a$ as nt, b0 as It, b1 as pt, b2 as ft, b3 as kt, Z as ot, ak as B, b4 as q, b5 as Ut, U as Gt, l as jt, t as Zt, b6 as dt, an as ct, b7 as tt, a1 as ut, b8 as Bt, N as Ht, b9 as Kt, r as Xt } from "../../index-Du-bmOP8.js";
|
|
2
|
+
import { f as $t, a as Qt, g as yt, b as Yt, c as Jt } from "../../kernel_funcs_utils-DShm7-0k.js";
|
|
3
|
+
import { c as mt, g as Tt, a as Vt, b as Mt, e as wt } from "../../axis_util-BczFISHz.js";
|
|
4
|
+
import { b as te } from "../../broadcast_to-B7NGsBSh.js";
|
|
5
|
+
import { r as ee } from "../../reshape-BH7eBpwq.js";
|
|
6
|
+
import { i as ne, c as oe } from "../../slice_util-DskXqRZa.js";
|
|
7
7
|
import { g as se } from "../../_commonjsHelpers-ByX85dGu.js";
|
|
8
|
-
import { r as st } from "../../Reshape-
|
|
8
|
+
import { r as st } from "../../Reshape-Biok_3X1.js";
|
|
9
9
|
function re(t, e) {
|
|
10
10
|
for (var n = 0; n < e.length; n++) {
|
|
11
11
|
const o = e[n];
|
|
@@ -341,9 +341,9 @@ function ie() {
|
|
|
341
341
|
if (I >= m)
|
|
342
342
|
return L;
|
|
343
343
|
} else {
|
|
344
|
-
if (I <= -
|
|
344
|
+
if (I <= -v)
|
|
345
345
|
return _;
|
|
346
|
-
if (I + 1 >=
|
|
346
|
+
if (I + 1 >= v)
|
|
347
347
|
return D;
|
|
348
348
|
}
|
|
349
349
|
return I < 0 ? a(-I, l).neg() : i(I % p | 0, I / p | 0, l);
|
|
@@ -381,14 +381,14 @@ function ie() {
|
|
|
381
381
|
return typeof I == "number" ? a(I, l) : typeof I == "string" ? c(I, l) : i(I.low, I.high, typeof l == "boolean" ? l : I.unsigned);
|
|
382
382
|
}
|
|
383
383
|
e.fromValue = h;
|
|
384
|
-
var f = 65536, w = 1 << 24, p = f * f, m = p * p,
|
|
384
|
+
var f = 65536, w = 1 << 24, p = f * f, m = p * p, v = m / 2, d = r(w), g = r(0);
|
|
385
385
|
e.ZERO = g;
|
|
386
386
|
var x = r(0, !0);
|
|
387
387
|
e.UZERO = x;
|
|
388
388
|
var O = r(1);
|
|
389
389
|
e.ONE = O;
|
|
390
|
-
var
|
|
391
|
-
e.UONE =
|
|
390
|
+
var b = r(1, !0);
|
|
391
|
+
e.UONE = b;
|
|
392
392
|
var V = r(-1);
|
|
393
393
|
e.NEG_ONE = V;
|
|
394
394
|
var D = i(-1, 2147483647, !1);
|
|
@@ -532,7 +532,7 @@ function ie() {
|
|
|
532
532
|
if (l.unsigned || (l = l.toUnsigned()), l.gt(this))
|
|
533
533
|
return x;
|
|
534
534
|
if (l.gt(this.shru(1)))
|
|
535
|
-
return
|
|
535
|
+
return b;
|
|
536
536
|
$ = x;
|
|
537
537
|
} else {
|
|
538
538
|
if (this.eq(_)) {
|
|
@@ -869,10 +869,10 @@ function Ee(t, e, n) {
|
|
|
869
869
|
* limitations under the License.
|
|
870
870
|
* =============================================================================
|
|
871
871
|
*/
|
|
872
|
-
function
|
|
872
|
+
function ve(t, e) {
|
|
873
873
|
return `only one output dimension may be -1, not both ${t} and ${e}`;
|
|
874
874
|
}
|
|
875
|
-
function
|
|
875
|
+
function be(t, e) {
|
|
876
876
|
return `size ${t} must be non-negative, not ${e}`;
|
|
877
877
|
}
|
|
878
878
|
function Oe() {
|
|
@@ -955,18 +955,18 @@ function Ve(t) {
|
|
|
955
955
|
*/
|
|
956
956
|
function C(t) {
|
|
957
957
|
return (e, n, o, s, r) => {
|
|
958
|
-
const a = Ct(e, n), i = a.length, u = J(a), c = y(a), h = nt(r, c), f = e.length, w = n.length, p = J(e), m = J(n),
|
|
959
|
-
if (
|
|
958
|
+
const a = Ct(e, n), i = a.length, u = J(a), c = y(a), h = nt(r, c), f = e.length, w = n.length, p = J(e), m = J(n), v = It(e, a), d = It(n, a);
|
|
959
|
+
if (v.length + d.length === 0)
|
|
960
960
|
for (let g = 0; g < h.length; ++g)
|
|
961
961
|
h[g] = t(o[g % o.length], s[g % s.length]);
|
|
962
962
|
else
|
|
963
963
|
for (let g = 0; g < h.length; ++g) {
|
|
964
964
|
const x = pt(g, i, u), O = x.slice(-f);
|
|
965
|
-
|
|
966
|
-
const
|
|
965
|
+
v.forEach((L) => O[L] = 0);
|
|
966
|
+
const b = ft(O, f, p), V = x.slice(-w);
|
|
967
967
|
d.forEach((L) => V[L] = 0);
|
|
968
968
|
const D = ft(V, w, m);
|
|
969
|
-
h[g] = t(o[
|
|
969
|
+
h[g] = t(o[b], s[D]);
|
|
970
970
|
}
|
|
971
971
|
return [h, a];
|
|
972
972
|
};
|
|
@@ -1626,7 +1626,7 @@ function an(t, e, n, o) {
|
|
|
1626
1626
|
for (let w = 0; w < n.length; ++w) {
|
|
1627
1627
|
const p = n[w], m = w + e.length - 1;
|
|
1628
1628
|
if (m >= 0) {
|
|
1629
|
-
const
|
|
1629
|
+
const v = i[m], d = v[v.length - 1] - p[h];
|
|
1630
1630
|
for (let g = h; g < f; ++g)
|
|
1631
1631
|
i[m].push(p[g + 1] + d);
|
|
1632
1632
|
}
|
|
@@ -1644,7 +1644,7 @@ function un(t) {
|
|
|
1644
1644
|
}
|
|
1645
1645
|
return e;
|
|
1646
1646
|
}
|
|
1647
|
-
function
|
|
1647
|
+
function vt(t, e) {
|
|
1648
1648
|
const n = t.slice(0, e);
|
|
1649
1649
|
for (; n.length < e; )
|
|
1650
1650
|
n.push(1);
|
|
@@ -1653,7 +1653,7 @@ function bt(t, e) {
|
|
|
1653
1653
|
return n;
|
|
1654
1654
|
}
|
|
1655
1655
|
function ln(t, e, n, o, s, r) {
|
|
1656
|
-
const a =
|
|
1656
|
+
const a = vt(e, 2)[1], i = vt(r, 2)[1];
|
|
1657
1657
|
let u = 0;
|
|
1658
1658
|
for (const c of n)
|
|
1659
1659
|
for (let h = c[0]; h < c[1]; ++h) {
|
|
@@ -1695,7 +1695,7 @@ function hn(t, e, n, o, s, r, a, i) {
|
|
|
1695
1695
|
* limitations under the License.
|
|
1696
1696
|
* =============================================================================
|
|
1697
1697
|
*/
|
|
1698
|
-
const
|
|
1698
|
+
const bt = 2147483647;
|
|
1699
1699
|
function fn(t, e, n, o, s, r, a) {
|
|
1700
1700
|
if (e.length > 1)
|
|
1701
1701
|
throw new Error("starts must be a scalar or vector");
|
|
@@ -1714,21 +1714,21 @@ function fn(t, e, n, o, s, r, a) {
|
|
|
1714
1714
|
const g = i ? t[0] : t[d], x = u ? o[0] : o[d], O = c ? r[0] : r[d];
|
|
1715
1715
|
if (O === 0)
|
|
1716
1716
|
throw new Error("Requires delta != 0");
|
|
1717
|
-
let
|
|
1717
|
+
let b;
|
|
1718
1718
|
if (O > 0 && x < g || O < 0 && x > g)
|
|
1719
|
-
|
|
1720
|
-
else if (
|
|
1721
|
-
throw new Error(`Requires ((limit - start) / delta) <= ${
|
|
1722
|
-
w[d + 1] = w[d] +
|
|
1719
|
+
b = 0;
|
|
1720
|
+
else if (b = Math.ceil(Math.abs((x - g) / O)), b > bt)
|
|
1721
|
+
throw new Error(`Requires ((limit - start) / delta) <= ${bt}`);
|
|
1722
|
+
w[d + 1] = w[d] + b;
|
|
1723
1723
|
}
|
|
1724
1724
|
const p = w[f], m = q(n, p);
|
|
1725
|
-
let
|
|
1725
|
+
let v = 0;
|
|
1726
1726
|
for (let d = 0; d < f; ++d) {
|
|
1727
1727
|
const g = w[d + 1] - w[d];
|
|
1728
1728
|
let x = i ? t[0] : t[d];
|
|
1729
1729
|
const O = c ? r[0] : r[d];
|
|
1730
|
-
for (let
|
|
1731
|
-
m[
|
|
1730
|
+
for (let b = 0; b < g; ++b)
|
|
1731
|
+
m[v++] = x, x += O;
|
|
1732
1732
|
}
|
|
1733
1733
|
return [w, m];
|
|
1734
1734
|
}
|
|
@@ -1945,14 +1945,14 @@ class at {
|
|
|
1945
1945
|
if (h.length !== u && h.length !== 1) {
|
|
1946
1946
|
const m = this.defaultValueShape;
|
|
1947
1947
|
Zt(() => {
|
|
1948
|
-
const
|
|
1949
|
-
h = te(
|
|
1948
|
+
const v = ee(h, m);
|
|
1949
|
+
h = te(v, i).dataSync();
|
|
1950
1950
|
});
|
|
1951
1951
|
}
|
|
1952
1952
|
let f = 0, w = 0, p = 0;
|
|
1953
1953
|
for (let m = 0; m <= c; ++m) {
|
|
1954
|
-
let
|
|
1955
|
-
if (
|
|
1954
|
+
let v = m < c ? n[m] : -1;
|
|
1955
|
+
if (v === p) {
|
|
1956
1956
|
++p;
|
|
1957
1957
|
continue;
|
|
1958
1958
|
}
|
|
@@ -1962,17 +1962,17 @@ class at {
|
|
|
1962
1962
|
}
|
|
1963
1963
|
if (m >= c) {
|
|
1964
1964
|
const d = o.length;
|
|
1965
|
-
|
|
1965
|
+
v = Math.floor(d / u);
|
|
1966
1966
|
}
|
|
1967
|
-
if (
|
|
1967
|
+
if (v > p)
|
|
1968
1968
|
if (this.defaultValue.length === 1)
|
|
1969
|
-
a.subarray(p * u,
|
|
1969
|
+
a.subarray(p * u, v * u).fill(this.defaultValue[0]), p = v;
|
|
1970
1970
|
else
|
|
1971
|
-
for (;
|
|
1971
|
+
for (; v > p; ) {
|
|
1972
1972
|
const d = a.slice(p * u);
|
|
1973
1973
|
Ot(d, h, u), ++p;
|
|
1974
1974
|
}
|
|
1975
|
-
|
|
1975
|
+
v < 0 ? (f = m + 1, w = p) : (f = m, w = p, p = w + 1);
|
|
1976
1976
|
}
|
|
1977
1977
|
}
|
|
1978
1978
|
}
|
|
@@ -2063,14 +2063,14 @@ function mn(t, e, n, o, s, r, a, i, u, c) {
|
|
|
2063
2063
|
const p = u instanceof dt ? u : B(h, e.dtype);
|
|
2064
2064
|
typeof u == "string" || typeof u == "number" ? p.values.fill(u) : typeof u == "boolean" && p.values.fill(+u);
|
|
2065
2065
|
for (let m = 0; m < r; m++) {
|
|
2066
|
-
const
|
|
2066
|
+
const v = [];
|
|
2067
2067
|
let d = 0;
|
|
2068
2068
|
for (let g = 0; g < a; g++) {
|
|
2069
2069
|
const x = f[m * a + g];
|
|
2070
|
-
|
|
2070
|
+
v.push(x), d += x * i[g];
|
|
2071
2071
|
}
|
|
2072
2072
|
if (d < 0 || d >= o / s)
|
|
2073
|
-
throw new Error(`Invalid indices: ${
|
|
2073
|
+
throw new Error(`Invalid indices: ${v} does not index into ${n}`);
|
|
2074
2074
|
for (let g = 0; g < s; g++)
|
|
2075
2075
|
c ? p.values[d * s + g] += w[m * s + g] : p.values[d * s + g] = e.rank === 0 ? w[0] : w[m * s + g];
|
|
2076
2076
|
}
|
|
@@ -2117,7 +2117,7 @@ function In(t, e, n, o, s) {
|
|
|
2117
2117
|
}
|
|
2118
2118
|
const u = s === "string" ? $t(t) : t, c = B(o, s, u), h = B(n, s);
|
|
2119
2119
|
for (let f = 0; f < h.size; ++f) {
|
|
2120
|
-
const w = h.indexToLoc(f), p = w.map((m,
|
|
2120
|
+
const w = h.indexToLoc(f), p = w.map((m, v) => m + e[v]);
|
|
2121
2121
|
h.set(c.get(...p), ...w);
|
|
2122
2122
|
}
|
|
2123
2123
|
return s === "string" ? Qt(h.values) : h.values;
|
|
@@ -2162,12 +2162,12 @@ function xn(t, e, n, o, s, r, a) {
|
|
|
2162
2162
|
throw new Error(Ee(d, g, u));
|
|
2163
2163
|
++m[g], w = w && g >= p, p = g;
|
|
2164
2164
|
}
|
|
2165
|
-
let
|
|
2165
|
+
let v = !0;
|
|
2166
2166
|
for (let d = 0; d < u; ++d) {
|
|
2167
2167
|
const g = m[d] === 0;
|
|
2168
|
-
c[d] = g,
|
|
2168
|
+
c[d] = g, v = v && !g, m[d] = Math.max(m[d], 1), d > 0 && (m[d] += m[d - 1]);
|
|
2169
2169
|
}
|
|
2170
|
-
if (
|
|
2170
|
+
if (v && w) {
|
|
2171
2171
|
const d = t, g = o;
|
|
2172
2172
|
for (let x = 0; x < i; ++x)
|
|
2173
2173
|
h[x] = x;
|
|
@@ -2180,17 +2180,17 @@ function xn(t, e, n, o, s, r, a) {
|
|
|
2180
2180
|
];
|
|
2181
2181
|
} else {
|
|
2182
2182
|
const d = m[u - 1], g = q(n, d * f), x = q(s, d), O = new Array(u).fill(0);
|
|
2183
|
-
for (let
|
|
2184
|
-
const V = t[
|
|
2183
|
+
for (let b = 0; b < i; ++b) {
|
|
2184
|
+
const V = t[b * f], D = O[V], L = (V === 0 ? 0 : m[V - 1]) + D;
|
|
2185
2185
|
O[V]++;
|
|
2186
2186
|
for (let _ = 0; _ < f; ++_)
|
|
2187
|
-
g[L * f + _] = t[
|
|
2188
|
-
x[L] = o[
|
|
2187
|
+
g[L * f + _] = t[b * f + _];
|
|
2188
|
+
x[L] = o[b], h[b] = L;
|
|
2189
2189
|
}
|
|
2190
|
-
for (let
|
|
2191
|
-
if (O[
|
|
2192
|
-
const D =
|
|
2193
|
-
g[D * f + 0] =
|
|
2190
|
+
for (let b = 0; b < u; ++b)
|
|
2191
|
+
if (O[b] === 0) {
|
|
2192
|
+
const D = b === 0 ? 0 : m[b - 1];
|
|
2193
|
+
g[D * f + 0] = b;
|
|
2194
2194
|
for (let L = 1; L < f; ++L)
|
|
2195
2195
|
g[D * f + L] = 0;
|
|
2196
2196
|
x[D] = a;
|
|
@@ -2227,11 +2227,11 @@ function Sn(t, e, n, o, s) {
|
|
|
2227
2227
|
const g = s[d];
|
|
2228
2228
|
if (g === -1) {
|
|
2229
2229
|
if (h !== -1)
|
|
2230
|
-
throw new Error(
|
|
2230
|
+
throw new Error(ve(h, d));
|
|
2231
2231
|
h = d, u.push(1);
|
|
2232
2232
|
} else {
|
|
2233
2233
|
if (g < 0)
|
|
2234
|
-
throw new Error(
|
|
2234
|
+
throw new Error(be(d, g));
|
|
2235
2235
|
c *= g, u.push(g);
|
|
2236
2236
|
}
|
|
2237
2237
|
}
|
|
@@ -2257,15 +2257,15 @@ function Sn(t, e, n, o, s) {
|
|
|
2257
2257
|
for (let d = i - 2; d >= 0; --d)
|
|
2258
2258
|
m[d] = m[d + 1] * u[d + 1];
|
|
2259
2259
|
}
|
|
2260
|
-
const
|
|
2260
|
+
const v = q(n, a * i);
|
|
2261
2261
|
for (let d = 0; d < a; ++d) {
|
|
2262
2262
|
let g = 0;
|
|
2263
2263
|
for (let x = 0; x < w; ++x)
|
|
2264
2264
|
g += t[d * w + x] * p[x];
|
|
2265
2265
|
for (let x = 0; x < i; ++x)
|
|
2266
|
-
|
|
2266
|
+
v[d * i + x] = Math.trunc(g / m[x]), g %= m[x];
|
|
2267
2267
|
}
|
|
2268
|
-
return [
|
|
2268
|
+
return [v, [a, i], u];
|
|
2269
2269
|
}
|
|
2270
2270
|
/**
|
|
2271
2271
|
* @license
|
|
@@ -2289,12 +2289,12 @@ function En(t, e, n, o, s, r = !1, a = 0) {
|
|
|
2289
2289
|
throw new Error(Et());
|
|
2290
2290
|
const w = e.slice();
|
|
2291
2291
|
w[0] = f;
|
|
2292
|
-
const p = w.reduce((O,
|
|
2292
|
+
const p = w.reduce((O, b) => O * b, 1), m = q(n, p);
|
|
2293
2293
|
if (i === 0)
|
|
2294
2294
|
return f > 0 && m.fill(a), [m, w];
|
|
2295
2295
|
if (f <= 0)
|
|
2296
2296
|
throw new Error(Et());
|
|
2297
|
-
let
|
|
2297
|
+
let v = 0, d = 1, g = 0, x = s[v];
|
|
2298
2298
|
for (; ; ) {
|
|
2299
2299
|
let O = 0;
|
|
2300
2300
|
if (d < i) {
|
|
@@ -2308,17 +2308,17 @@ function En(t, e, n, o, s, r = !1, a = 0) {
|
|
|
2308
2308
|
if (x < 0 || x >= f)
|
|
2309
2309
|
throw new Error(ye(x, f));
|
|
2310
2310
|
x > g && m.fill(a, g * c, x * c);
|
|
2311
|
-
for (let
|
|
2312
|
-
const V = o[
|
|
2311
|
+
for (let b = v; b < d; ++b) {
|
|
2312
|
+
const V = o[b];
|
|
2313
2313
|
if (V < 0 || V >= u[0])
|
|
2314
|
-
throw new Error(Te(
|
|
2314
|
+
throw new Error(Te(b, o[b], u[0]));
|
|
2315
2315
|
for (let D = 0; D < c; D++)
|
|
2316
2316
|
m[x * c + D] += t[V * c + D];
|
|
2317
2317
|
}
|
|
2318
2318
|
if (r)
|
|
2319
|
-
for (let
|
|
2320
|
-
m[x * c +
|
|
2321
|
-
if (
|
|
2319
|
+
for (let b = 0; b < c; b++)
|
|
2320
|
+
m[x * c + b] /= d - v;
|
|
2321
|
+
if (v = d, ++d, g = x + 1, x = O, d > i)
|
|
2322
2322
|
break;
|
|
2323
2323
|
}
|
|
2324
2324
|
return g < f && m.fill(a, g * c, f * c), [m, w];
|
|
@@ -2339,7 +2339,7 @@ function En(t, e, n, o, s, r = !1, a = 0) {
|
|
|
2339
2339
|
* limitations under the License.
|
|
2340
2340
|
* =============================================================================
|
|
2341
2341
|
*/
|
|
2342
|
-
const
|
|
2342
|
+
const vn = K((t) => Math.sqrt(t));
|
|
2343
2343
|
/**
|
|
2344
2344
|
* @license
|
|
2345
2345
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -2356,7 +2356,7 @@ const bn = K((t) => Math.sqrt(t));
|
|
|
2356
2356
|
* limitations under the License.
|
|
2357
2357
|
* =============================================================================
|
|
2358
2358
|
*/
|
|
2359
|
-
const
|
|
2359
|
+
const bn = C((t, e) => {
|
|
2360
2360
|
const n = t - e;
|
|
2361
2361
|
return n * n;
|
|
2362
2362
|
});
|
|
@@ -2443,9 +2443,9 @@ class Rn {
|
|
|
2443
2443
|
p += h * this.rightPad.length;
|
|
2444
2444
|
const m = c + h + f - 1;
|
|
2445
2445
|
p += m * this.separator.length, o[s + i] = new Uint8Array(p);
|
|
2446
|
-
const
|
|
2446
|
+
const v = o[s + i];
|
|
2447
2447
|
let d = 0;
|
|
2448
|
-
const g = (x) => x.forEach((O) =>
|
|
2448
|
+
const g = (x) => x.forEach((O) => v[d++] = O);
|
|
2449
2449
|
for (let x = 0; x < c; ++x)
|
|
2450
2450
|
g(this.leftPad), g(this.separator);
|
|
2451
2451
|
for (let x = 0; x < f - 1; ++x)
|
|
@@ -2685,7 +2685,7 @@ function _n(t, e, n, o, s) {
|
|
|
2685
2685
|
const w = f * i, p = t.subarray(w, w + i);
|
|
2686
2686
|
let m = new Array(p.length);
|
|
2687
2687
|
p.forEach((x, O) => m[O] = { value: x, index: O }), o < m.length && (Dt(m, o), m = m.slice(0, o)), s && m.sort(et);
|
|
2688
|
-
const
|
|
2688
|
+
const v = f * o, d = u.subarray(v, v + o), g = c.subarray(v, v + o);
|
|
2689
2689
|
for (let x = 0; x < o; x++)
|
|
2690
2690
|
d[x] = m[x].value, g[x] = m[x].index;
|
|
2691
2691
|
}
|
|
@@ -2720,31 +2720,31 @@ function Nn(t, e, n, o) {
|
|
|
2720
2720
|
r[2] *= n[m];
|
|
2721
2721
|
const a = /* @__PURE__ */ new Map(), i = new Int32Array(n[s]), u = new dt(r, o, t), c = [], h = r[0] === 1 && r[2] === 1;
|
|
2722
2722
|
for (let m = 0; m < n[s]; m++) {
|
|
2723
|
-
let
|
|
2723
|
+
let v;
|
|
2724
2724
|
if (h)
|
|
2725
|
-
|
|
2725
|
+
v = t[m].toString();
|
|
2726
2726
|
else {
|
|
2727
2727
|
const g = [];
|
|
2728
2728
|
for (let x = 0; x < r[0]; x++)
|
|
2729
2729
|
for (let O = 0; O < r[2]; O++)
|
|
2730
2730
|
g.push(u.get(x, m, O));
|
|
2731
|
-
|
|
2731
|
+
v = g.join(",");
|
|
2732
2732
|
}
|
|
2733
|
-
const d = a.get(
|
|
2733
|
+
const d = a.get(v);
|
|
2734
2734
|
if (d != null)
|
|
2735
2735
|
i[m] = d;
|
|
2736
2736
|
else {
|
|
2737
2737
|
const g = a.size;
|
|
2738
|
-
a.set(
|
|
2738
|
+
a.set(v, g), i[m] = g, c.push(m);
|
|
2739
2739
|
}
|
|
2740
2740
|
}
|
|
2741
2741
|
const f = r.slice();
|
|
2742
2742
|
f[1] = a.size;
|
|
2743
2743
|
const w = new dt(f, o);
|
|
2744
|
-
c.forEach((m,
|
|
2744
|
+
c.forEach((m, v) => {
|
|
2745
2745
|
for (let d = 0; d < r[0]; d++)
|
|
2746
2746
|
for (let g = 0; g < r[2]; g++)
|
|
2747
|
-
w.set(u.get(d, m, g), d,
|
|
2747
|
+
w.set(u.get(d, m, g), d, v, g);
|
|
2748
2748
|
});
|
|
2749
2749
|
const p = n.slice();
|
|
2750
2750
|
return p[s] = f[1], {
|
|
@@ -2810,8 +2810,8 @@ const An = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
2810
2810
|
sparseFillEmptyRowsImpl: xn,
|
|
2811
2811
|
sparseReshapeImpl: Sn,
|
|
2812
2812
|
sparseSegmentReductionImpl: En,
|
|
2813
|
-
sqrtImpl:
|
|
2814
|
-
squaredDifferenceImpl:
|
|
2813
|
+
sqrtImpl: vn,
|
|
2814
|
+
squaredDifferenceImpl: bn,
|
|
2815
2815
|
staticRegexReplaceImpl: On,
|
|
2816
2816
|
stridedSliceImpl: Fn,
|
|
2817
2817
|
stringNGramsImpl: $n,
|
|
@@ -3238,11 +3238,11 @@ function Gn(t) {
|
|
|
3238
3238
|
let p = s;
|
|
3239
3239
|
if (f) {
|
|
3240
3240
|
if (w) {
|
|
3241
|
-
const O = n.texData.get(p.dataId).values,
|
|
3242
|
-
for (let L = 0; L <
|
|
3243
|
-
|
|
3244
|
-
const V = Dn(O, s.shape, s.dtype, h,
|
|
3245
|
-
p = n.makeTensorInfo(
|
|
3241
|
+
const O = n.texData.get(p.dataId).values, b = new Array(i);
|
|
3242
|
+
for (let L = 0; L < b.length; L++)
|
|
3243
|
+
b[L] = s.shape[h[L]];
|
|
3244
|
+
const V = Dn(O, s.shape, s.dtype, h, b);
|
|
3245
|
+
p = n.makeTensorInfo(b, s.dtype);
|
|
3246
3246
|
const D = n.texData.get(p.dataId);
|
|
3247
3247
|
D.values = V;
|
|
3248
3248
|
} else
|
|
@@ -3250,17 +3250,17 @@ function Gn(t) {
|
|
|
3250
3250
|
c = Vt(c.length, i);
|
|
3251
3251
|
}
|
|
3252
3252
|
Mt("max", c, i);
|
|
3253
|
-
const [m,
|
|
3253
|
+
const [m, v] = mt(p.shape, c);
|
|
3254
3254
|
let d = m;
|
|
3255
3255
|
a && (d = wt(m, u));
|
|
3256
3256
|
let g;
|
|
3257
3257
|
if (w) {
|
|
3258
|
-
const O = n.texData.get(p.dataId).values,
|
|
3258
|
+
const O = n.texData.get(p.dataId).values, b = Pn(O, y(v), d, s.dtype);
|
|
3259
3259
|
g = n.makeTensorInfo(d, s.dtype);
|
|
3260
3260
|
const V = n.texData.get(g.dataId);
|
|
3261
|
-
V.values =
|
|
3261
|
+
V.values = b;
|
|
3262
3262
|
} else
|
|
3263
|
-
g = qn(p,
|
|
3263
|
+
g = qn(p, v, d, n);
|
|
3264
3264
|
return f && n.disposeIntermediateTensorInfo(p), g;
|
|
3265
3265
|
}
|
|
3266
3266
|
/**
|
|
@@ -3288,8 +3288,8 @@ function jn(t, e, n, o) {
|
|
|
3288
3288
|
const [f, w] = mt(h.shape, i);
|
|
3289
3289
|
let p = f;
|
|
3290
3290
|
n && (p = wt(f, a));
|
|
3291
|
-
const m = y(w), d = y(t.shape) / m, g = st({ inputs: { x: h }, attrs: { shape: [d, m] }, backend: o }), x = Kt(t.dtype), O = zt(g, x, "sum", o),
|
|
3292
|
-
return o.disposeIntermediateTensorInfo(g), o.disposeIntermediateTensorInfo(O), c && o.disposeIntermediateTensorInfo(h),
|
|
3291
|
+
const m = y(w), d = y(t.shape) / m, g = st({ inputs: { x: h }, attrs: { shape: [d, m] }, backend: o }), x = Kt(t.dtype), O = zt(g, x, "sum", o), b = st({ inputs: { x: O }, attrs: { shape: p }, backend: o });
|
|
3292
|
+
return o.disposeIntermediateTensorInfo(g), o.disposeIntermediateTensorInfo(O), c && o.disposeIntermediateTensorInfo(h), b;
|
|
3293
3293
|
}
|
|
3294
3294
|
/**
|
|
3295
3295
|
* @license
|
|
@@ -3414,8 +3414,8 @@ function Yn(t) {
|
|
|
3414
3414
|
]);
|
|
3415
3415
|
return i.disposeIntermediateTensorInfo(w), i.disposeIntermediateTensorInfo(p), i.disposeIntermediateTensorInfo(m), g;
|
|
3416
3416
|
}
|
|
3417
|
-
const
|
|
3418
|
-
return i.disposeIntermediateTensorInfo(w), i.disposeIntermediateTensorInfo(p), i.disposeIntermediateTensorInfo(m),
|
|
3417
|
+
const v = Kn({ inputs: { a: w, b: m }, backend: i });
|
|
3418
|
+
return i.disposeIntermediateTensorInfo(w), i.disposeIntermediateTensorInfo(p), i.disposeIntermediateTensorInfo(m), v;
|
|
3419
3419
|
}
|
|
3420
3420
|
const Jn = {
|
|
3421
3421
|
kernelName: "FusedSoftmax",
|
package/dist/ops/webgl/gelu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as a } from "../../index-
|
|
2
|
-
import { u as s, C as x } from "../../kernel_funcs_utils-
|
|
1
|
+
import { r as a } from "../../index-Du-bmOP8.js";
|
|
2
|
+
import { u as s, C as x } from "../../kernel_funcs_utils-DShm7-0k.js";
|
|
3
3
|
const t = 0.7978845608028654, r = 0.044715, c = x + `
|
|
4
4
|
float x3 = x * x * x;
|
|
5
5
|
float inner = x + ${r} * x3;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { r as C, t as R, e as I, q as G, Q as L, l as U, U as F } from "../../index-
|
|
2
|
-
import { r as S } from "../../Reshape-
|
|
3
|
-
import { u as H } from "../../gpgpu_math-
|
|
4
|
-
import { m as B } from "../../mat_mul-
|
|
1
|
+
import { r as C, t as R, e as I, q as G, Q as L, l as U, U as F } from "../../index-Du-bmOP8.js";
|
|
2
|
+
import { r as S } from "../../Reshape-Biok_3X1.js";
|
|
3
|
+
import { u as H } from "../../gpgpu_math-BFbOyvk4.js";
|
|
4
|
+
import { m as B } from "../../mat_mul-CbiqIe2d.js";
|
|
5
5
|
/**
|
|
6
6
|
* @license
|
|
7
7
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as p, e as G } from "../../index-
|
|
2
|
-
import { s as x } from "../../sum-
|
|
1
|
+
import { r as p, e as G } from "../../index-Du-bmOP8.js";
|
|
2
|
+
import { s as x } from "../../sum-Cvq06317.js";
|
|
3
3
|
class y {
|
|
4
4
|
variableNames = ["x", "meanSquare", "gamma"];
|
|
5
5
|
outputShape;
|
package/dist/ops/webgl/qkv.js
CHANGED
package/dist/ops/webgl/rope.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { o as h, j as l, E as f,
|
|
2
|
-
import { r as _ } from "./reshape-
|
|
3
|
-
import { s as un } from "./split-
|
|
4
|
-
import { s as q } from "./sum-
|
|
5
|
-
import { b as X } from "./broadcast_to-
|
|
6
|
-
import { r as O } from "./range-
|
|
7
|
-
import { t as Ln } from "./tensor-
|
|
8
|
-
import { s as Y } from "./stack-
|
|
9
|
-
import { c as Xn, z as Qn } from "./zeros-
|
|
10
|
-
import { n as ln } from "./norm-
|
|
11
|
-
import { c as Q } from "./concat-
|
|
12
|
-
import { m as T } from "./mat_mul-
|
|
13
|
-
import { t as H } from "./tensor2d-
|
|
1
|
+
import { o as h, j as l, E as f, az as hn, l as p, aA as fn, Q as w, aB as dn, aC as bn, aD as gn, L as $n, ak as xn, u as j, aE as kn, aF as yn, aG as In, aH as _n, aI as En, aJ as Mn, aK as Nn, D, aL as An, aM as Tn, aN as Sn, aO as wn, I as zn, J as Bn, K as qn, aP as Kn, t as Gn, aQ as J, aR as Rn, aS as Dn, aT as Pn, aU as Vn, aV as vn, aW as jn, f as Fn, aX as Wn, aY as On, b as k, a8 as Z, al as G, g as Yn, s as S, aZ as Cn, y as L, a as Jn } from "./index-Du-bmOP8.js";
|
|
2
|
+
import { r as _ } from "./reshape-BH7eBpwq.js";
|
|
3
|
+
import { s as un } from "./split-BCUhuU7B.js";
|
|
4
|
+
import { s as q } from "./sum-Cvq06317.js";
|
|
5
|
+
import { b as X } from "./broadcast_to-B7NGsBSh.js";
|
|
6
|
+
import { r as O } from "./range-Bvs1hidm.js";
|
|
7
|
+
import { t as Ln } from "./tensor-DgTOPY6h.js";
|
|
8
|
+
import { s as Y } from "./stack-BV1v7l3S.js";
|
|
9
|
+
import { c as Xn, z as Qn } from "./zeros-BaHhQTWf.js";
|
|
10
|
+
import { n as ln } from "./norm-01kY9I2B.js";
|
|
11
|
+
import { c as Q } from "./concat-DdKPyAtw.js";
|
|
12
|
+
import { m as T } from "./mat_mul-CbiqIe2d.js";
|
|
13
|
+
import { t as H } from "./tensor2d-CRWjDyUe.js";
|
|
14
14
|
/**
|
|
15
15
|
* @license
|
|
16
16
|
* Copyright 2018 Google LLC. All Rights Reserved.
|