@genai-fi/nanogpt 0.8.4 → 0.9.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.d.ts +4 -1
- package/dist/Generator.js +144 -124
- package/dist/{RealDiv-D_q39E3A.js → RealDiv-D4EzDsC0.js} +7 -7
- package/dist/{Reshape-Bh_jzKzV.js → Reshape-Bowtk9BP.js} +2 -2
- package/dist/{Reshape-41YpQqEo.js → Reshape-DUqYftGC.js} +1 -1
- package/dist/TeachableLLM.js +5 -5
- package/dist/Trainer.d.ts +1 -0
- package/dist/Trainer.js +3 -0
- package/dist/{axis_util-Did9235A.js → axis_util-TbGYJ208.js} +1 -1
- package/dist/backend.js +2 -2
- package/dist/{backend_util-yC3YH1jo.js → backend_util-CJIiDoV1.js} +4 -4
- package/dist/{broadcast_to-CUvOdOT5.js → broadcast_to-DzlNweb8.js} +2 -2
- package/dist/checks/appendCache.js +2 -2
- package/dist/checks/attentionMask.js +3 -3
- package/dist/checks/gelu.js +2 -2
- package/dist/checks/matMulGelu.js +5 -5
- package/dist/checks/normRMS.js +4 -4
- package/dist/checks/normRMSGrad.js +3 -3
- package/dist/checks/qkv.js +2 -2
- package/dist/checks/rope.js +2 -2
- package/dist/{concat-pHiVqR3L.js → concat-B912vBbo.js} +1 -1
- package/dist/{dataset-DPPl-iLT.js → dataset-DlZtKmBq.js} +3 -3
- package/dist/{dropout-CcKSfOYE.js → dropout-C-csYCLj.js} +6 -6
- package/dist/{exports_initializers-DKk7-bsx.js → exports_initializers-B8iZMgQ0.js} +1 -1
- package/dist/{gather-CPg6ZlQA.js → gather-Dnpgw-YQ.js} +1 -1
- package/dist/{gelu-BkcmEEyD.js → gelu-Bp_-935b.js} +1 -1
- package/dist/{gpgpu_math-D_ODOLix.js → gpgpu_math-CDaYiyE_.js} +2 -2
- package/dist/{index-DdmHGZjq.js → index-BzFyqcy-.js} +13 -13
- package/dist/{index-evZ57wr4.js → index-C1rx_Ajs.js} +10 -10
- package/dist/{kernel_funcs_utils-CDfFpUab.js → kernel_funcs_utils-DKLK0Mg3.js} +3 -3
- package/dist/layers/BaseLayer.js +2 -2
- package/dist/layers/CausalSelfAttention.js +6 -6
- package/dist/layers/MLP.js +5 -5
- package/dist/layers/PositionEmbedding.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-C8yFJfZz.js → log_sum_exp-DO6z8tSE.js} +9 -9
- package/dist/main.d.ts +1 -0
- package/dist/main.js +18 -16
- package/dist/{mat_mul-Dpy2mMRu.js → mat_mul-DzjTFx-u.js} +1 -1
- package/dist/{mod-CbibJi3D.js → mod-Dobti4j4.js} +1 -1
- package/dist/models/NanoGPTV1.d.ts +1 -0
- package/dist/models/NanoGPTV1.js +12 -9
- package/dist/models/model.d.ts +1 -0
- package/dist/models/model.js +5 -5
- package/dist/{mulmat_packed_gpu-q_Gmwyld.js → mulmat_packed_gpu-BT60jmzP.js} +1 -1
- package/dist/{ones-BAqVh-eA.js → ones-tIJeHlq-.js} +2 -2
- package/dist/ops/adamAdjust.js +1 -1
- package/dist/ops/adamMoments.js +1 -1
- package/dist/ops/appendCache.js +3 -3
- package/dist/ops/attentionMask.js +1 -1
- package/dist/ops/cpu/adamAdjust.js +1 -1
- package/dist/ops/cpu/adamMoments.js +2 -2
- package/dist/ops/cpu/appendCache.js +2 -2
- package/dist/ops/cpu/attentionMask.js +5 -5
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +5 -5
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.js +2 -2
- package/dist/ops/cpu/matMulMul.js +1 -1
- package/dist/ops/cpu/mulDropout.js +1 -1
- package/dist/ops/cpu/normRMS.js +1 -1
- package/dist/ops/cpu/qkv.js +3 -3
- package/dist/ops/cpu/rope.js +5 -5
- package/dist/ops/cpu/scatterSub.js +13 -13
- package/dist/ops/fusedSoftmax.js +1 -1
- package/dist/ops/gatherSub.js +1 -1
- package/dist/ops/gelu.js +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +2 -2
- package/dist/ops/grads/matMulGelu.js +1 -1
- package/dist/ops/grads/normRMS.js +1 -1
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.js +1 -1
- package/dist/ops/matMulMul.js +1 -1
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/normRMS.js +1 -1
- package/dist/ops/qkv.js +1 -1
- package/dist/ops/rope.js +4 -4
- package/dist/ops/scatterSub.js +1 -1
- package/dist/ops/webgl/adamAdjust.js +2 -2
- package/dist/ops/webgl/adamMoments.js +1 -1
- package/dist/ops/webgl/appendCache.js +1 -1
- package/dist/ops/webgl/attentionMask.js +1 -1
- package/dist/ops/webgl/fusedSoftmax.js +4 -4
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +8 -8
- package/dist/ops/webgl/log.js +3 -3
- package/dist/ops/webgl/matMulGelu.js +49 -39
- package/dist/ops/webgl/matMulMul.js +1 -1
- package/dist/ops/webgl/mulDropout.js +1 -1
- package/dist/ops/webgl/normRMS.js +2 -2
- package/dist/ops/webgl/qkv.js +1 -1
- package/dist/ops/webgl/rope.js +1 -1
- package/dist/ops/webgl/scatterSub.js +1 -1
- package/dist/ops/webgpu/adamAdjust.js +3 -3
- package/dist/ops/webgpu/adamMoments.js +3 -3
- package/dist/ops/webgpu/appendCache.js +3 -3
- package/dist/ops/webgpu/attentionMask.js +3 -3
- package/dist/ops/webgpu/gatherSub.js +3 -3
- package/dist/ops/webgpu/gelu.js +42 -34
- package/dist/ops/webgpu/normRMS.js +2 -2
- package/dist/ops/webgpu/normRMSGrad.js +5 -5
- package/dist/ops/webgpu/qkv.js +3 -3
- package/dist/ops/webgpu/rope.js +3 -3
- package/dist/ops/webgpu/scatterSub.js +3 -3
- package/dist/ops/webgpu/utils/reductions.js +4 -4
- package/dist/{ops-542ai2vG.js → ops-LuCMAnmM.js} +65 -65
- package/dist/{random_width-DKGeiFuR.js → random_width-CXVRloNK.js} +23 -23
- package/dist/{range-BcUvLuf5.js → range-CWcz7xFA.js} +3 -3
- package/dist/{reciprocal-DhDWSKiD.js → reciprocal-C4rNcM-S.js} +1 -1
- package/dist/{register_all_kernels-Do9VvZmo.js → register_all_kernels-DIGpEwcf.js} +31 -31
- package/dist/{relu-B1AXs7p5.js → relu-BjCh_SYb.js} +1 -1
- package/dist/{reshape-WeJkT3ja.js → reshape-CnIwVG1c.js} +1 -1
- package/dist/{scatter_nd_util-B7yDhiQr.js → scatter_nd_util-BQdz--Gn.js} +1 -1
- package/dist/{selu_util-BgUO9gHY.js → selu_util-OtRzVwW5.js} +23 -23
- package/dist/{shared-V6D_md-c.js → shared-DmRsFyaJ.js} +6 -6
- package/dist/{shared-CZiWmQCI.js → shared-DuP7ue-R.js} +1 -1
- package/dist/{sin-CPxad7Am.js → sin-gpDNRxE0.js} +1 -1
- package/dist/{slice-B7jXtPnp.js → slice-d0Vo9XTN.js} +1 -1
- package/dist/{softmax-BfsyI4As.js → softmax-D7Jj3p_P.js} +1 -1
- package/dist/{split-BPxr8_8m.js → split-DK2k5eHf.js} +1 -1
- package/dist/{stack-BNwLzE43.js → stack-DFatutCx.js} +1 -1
- package/dist/{sum-ByFINZgi.js → sum-CJ0ULhmt.js} +1 -1
- package/dist/{tensor-DbqgIV9B.js → tensor-CZr4dh61.js} +1 -1
- package/dist/{tensor1d-CtJq5BOv.js → tensor1d-vML0r3q6.js} +1 -1
- package/dist/{tensor2d-CObBWBkW.js → tensor2d-D76QGjF3.js} +1 -1
- package/dist/{tensor4d-DLtk7Nxh.js → tensor4d-Df1WlVDY.js} +1 -1
- package/dist/training/Adam.js +2 -2
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +2 -2
- package/dist/training/FullTrainer.js +1 -1
- package/dist/training/Trainer.js +2 -2
- package/dist/training/sparseCrossEntropy.js +3 -3
- package/dist/utilities/dummy.js +2 -2
- package/dist/utilities/multinomialCPU.js +2 -2
- package/dist/utilities/performance.js +1 -1
- package/dist/utilities/profile.js +1 -1
- package/dist/utilities/safetensors.js +2 -2
- package/dist/utilities/topP.d.ts +1 -0
- package/dist/utilities/topP.js +13 -0
- package/dist/utilities/weights.js +2 -2
- package/dist/{variable-DPFOJyRG.js → variable-Bm2OFwGI.js} +1 -1
- package/dist/{webgpu_program-Dhk9R5aG.js → webgpu_program-DkQJOJSd.js} +1 -1
- package/dist/{webgpu_util-BqGnZg8t.js → webgpu_util-pLEV9tks.js} +1 -1
- package/dist/{zeros-Dnwix0p4.js → zeros-Bj5rMYA7.js} +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as p } from "../../index-
|
|
2
|
-
import { s as f } from "../../stack-
|
|
1
|
+
import { f as p } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { s as f } from "../../stack-DFatutCx.js";
|
|
3
3
|
function b(t) {
|
|
4
4
|
const { moments: n, gradient: c } = t.inputs, { beta1: o, beta2: m } = t.attrs, e = n.shape.length, a = new Array(e).fill(0), s = n.shape.slice();
|
|
5
5
|
s[e - 1] = 1;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as d } from "../../index-
|
|
2
|
-
import { c as h } from "../../concat-
|
|
1
|
+
import { f as d } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { c as h } from "../../concat-B912vBbo.js";
|
|
3
3
|
function u(p) {
|
|
4
4
|
const { cache: n, item: s } = p.inputs, { maxSize: i, pastLen: c } = p.attrs, t = n.shape[0], o = n.shape[1], a = n.shape[3], e = s.shape[2];
|
|
5
5
|
if (c + e <= i) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as a, h as p, b as u } from "../../index-
|
|
2
|
-
import { l as N, w as b } from "../../ops-
|
|
3
|
-
import { o as A } from "../../ones-
|
|
4
|
-
import { z as I } from "../../zeros-
|
|
5
|
-
import { m as g } from "../../mat_mul-
|
|
1
|
+
import { f as a, h as p, b as u } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { l as N, w as b } from "../../ops-LuCMAnmM.js";
|
|
3
|
+
import { o as A } from "../../ones-tIJeHlq-.js";
|
|
4
|
+
import { z as I } from "../../zeros-Bj5rMYA7.js";
|
|
5
|
+
import { m as g } from "../../mat_mul-DzjTFx-u.js";
|
|
6
6
|
function o(n) {
|
|
7
7
|
const { q: s, k: e } = n.inputs, { divisor: r } = n.attrs, c = s.shape[2], t = e.shape[2], m = N.bandPart(A([t, t]), -1, 0).cast("bool"), l = I([t, t]), i = p([t, t], Number.NEGATIVE_INFINITY), f = b(m, l, i), k = g(s, e, !1, !0).mul(u(r)), d = f.slice([0, 0], [c, t]).expandDims(0).expandDims(0);
|
|
8
8
|
return k.add(d);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as e } from "../../index-
|
|
2
|
-
import { s as f } from "../../softmax-
|
|
1
|
+
import { f as e } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { s as f } from "../../softmax-D7Jj3p_P.js";
|
|
3
3
|
function n(t) {
|
|
4
4
|
const { inputs: s, attrs: a } = t, { logits: o } = s, { dim: i, dropoutRate: r } = a;
|
|
5
5
|
if (!o)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { r as f } from "../../range-
|
|
3
|
-
import { s as l } from "../../stack-
|
|
1
|
+
import { E as u, F as c, G as g, a8 as h, f as m, c as p } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { r as f } from "../../range-CWcz7xFA.js";
|
|
3
|
+
import { s as l } from "../../stack-DFatutCx.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -26,9 +26,9 @@ function d(e) {
|
|
|
26
26
|
const { values: t, labels: n, logits: r } = e.inputs, s = n.shape[0], a = f(0, s, 1, "int32"), i = l([a, n], 1), o = b(r, i);
|
|
27
27
|
return p(t, o);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
29
|
+
const k = {
|
|
30
30
|
kernelName: "EfficientGatherSub",
|
|
31
31
|
backendName: "cpu",
|
|
32
32
|
kernelFunc: d
|
|
33
33
|
};
|
|
34
|
-
m(
|
|
34
|
+
m(k);
|
package/dist/ops/cpu/gelu.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as e, t as m } from "../../index-
|
|
2
|
-
import { g as d, d as M } from "../../gelu-
|
|
1
|
+
import { f as e, t as m } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { g as d, d as M } from "../../gelu-Bp_-935b.js";
|
|
3
3
|
function c(t) {
|
|
4
4
|
const { inputs: u } = t, { x: n, kernel: l } = u, a = n, r = l;
|
|
5
5
|
return m(() => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, t as i } from "../../index-
|
|
1
|
+
import { f as e, t as i } from "../../index-BzFyqcy-.js";
|
|
2
2
|
function n(t) {
|
|
3
3
|
const { inputs: r, attrs: l } = t, { transposeA: o, transposeB: s } = l, { x: u, kernel: a, y: c } = r, m = u, k = a, M = c;
|
|
4
4
|
return i(() => m.matMul(k, o, s).mul(M));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as e, a as t } from "../../index-
|
|
1
|
+
import { f as e, a as t } from "../../index-BzFyqcy-.js";
|
|
2
2
|
function n(o) {
|
|
3
3
|
const { inputs: r } = o, { a: l, b: u } = r;
|
|
4
4
|
return console.warn("Using fallback mulDrop implementation without dropout."), t(l, u);
|
package/dist/ops/cpu/normRMS.js
CHANGED
package/dist/ops/cpu/qkv.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as q } from "../../index-
|
|
2
|
-
import { r as o } from "../../reshape-
|
|
3
|
-
import { s as x } from "../../split-
|
|
1
|
+
import { f as q } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { r as o } from "../../reshape-CnIwVG1c.js";
|
|
3
|
+
import { s as x } from "../../split-DK2k5eHf.js";
|
|
4
4
|
function v(p) {
|
|
5
5
|
const { x: c, kernel: K } = p.inputs, { heads: n } = p.attrs, [s, e, t] = c.shape, a = o(c, [s * e, t]), i = a.dot(K);
|
|
6
6
|
a.dispose();
|
package/dist/ops/cpu/rope.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { f as S } from "../../index-
|
|
2
|
-
import { r as F } from "../../range-
|
|
3
|
-
import { g as I } from "../../gather-
|
|
4
|
-
import { s as E } from "../../stack-
|
|
5
|
-
import { c as T } from "../../concat-
|
|
1
|
+
import { f as S } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { r as F } from "../../range-CWcz7xFA.js";
|
|
3
|
+
import { g as I } from "../../gather-Dnpgw-YQ.js";
|
|
4
|
+
import { s as E } from "../../stack-DFatutCx.js";
|
|
5
|
+
import { c as T } from "../../concat-B912vBbo.js";
|
|
6
6
|
function U(t, c, p, o, r) {
|
|
7
7
|
const n = o.shape[3], s = p;
|
|
8
8
|
if (s > n) return o;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { v as
|
|
3
|
-
import { r as k } from "../../range-
|
|
4
|
-
import { s as v } from "../../stack-
|
|
5
|
-
import { o as E } from "../../ones-
|
|
1
|
+
import { E as f, M as g, F as r, G as l, a7 as N, f as b, c as S, a as h } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { v as D } from "../../scatter_nd_util-BQdz--Gn.js";
|
|
3
|
+
import { r as k } from "../../range-CWcz7xFA.js";
|
|
4
|
+
import { s as v } from "../../stack-DFatutCx.js";
|
|
5
|
+
import { o as E } from "../../ones-tIJeHlq-.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -22,18 +22,18 @@ import { o as E } from "../../ones-BAqVh-eA.js";
|
|
|
22
22
|
function I(a, e, s) {
|
|
23
23
|
g(s);
|
|
24
24
|
const n = r(a, "indices", "scatterND", "int32"), t = r(e, "updates", "scatterND");
|
|
25
|
-
|
|
25
|
+
D(t, n, s);
|
|
26
26
|
const c = { indices: n, updates: t }, o = { shape: s };
|
|
27
27
|
return l.runKernel(N, c, o);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
function
|
|
31
|
-
const { logits: e, labels: s, dy: n } = a.inputs, t = s.shape[0], c = e.shape[1], o = k(0, t, 1, "int32"), i = v([o, s], 1), d = E([t]), u =
|
|
32
|
-
return
|
|
29
|
+
const K = /* @__PURE__ */ f({ scatterND_: I });
|
|
30
|
+
function L(a) {
|
|
31
|
+
const { logits: e, labels: s, dy: n } = a.inputs, t = s.shape[0], c = e.shape[1], o = k(0, t, 1, "int32"), i = v([o, s], 1), d = E([t]), u = K(i, d, [t, c]), p = S(e, u), m = n.reshape([t, 1]);
|
|
32
|
+
return h(p, m);
|
|
33
33
|
}
|
|
34
|
-
const
|
|
34
|
+
const T = {
|
|
35
35
|
kernelName: "EfficientScatterSub",
|
|
36
36
|
backendName: "cpu",
|
|
37
|
-
kernelFunc:
|
|
37
|
+
kernelFunc: L
|
|
38
38
|
};
|
|
39
|
-
b(
|
|
39
|
+
b(T);
|
package/dist/ops/fusedSoftmax.js
CHANGED
package/dist/ops/gatherSub.js
CHANGED
package/dist/ops/gelu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../index-
|
|
1
|
+
import "../index-BzFyqcy-.js";
|
|
2
2
|
import "./cpu/gelu.js";
|
|
3
3
|
import "./webgl/gelu.js";
|
|
4
|
-
import { d as e, g as i } from "../gelu-
|
|
4
|
+
import { d as e, g as i } from "../gelu-Bp_-935b.js";
|
|
5
5
|
export {
|
|
6
6
|
e as dGelu,
|
|
7
7
|
i as gelu
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as f, a as i, c as l } from "../../index-
|
|
1
|
+
import { i as f, a as i, c as l } from "../../index-BzFyqcy-.js";
|
|
2
2
|
import { mulDrop as g } from "../mulDrop.js";
|
|
3
|
-
import { s as T } from "../../sum-
|
|
3
|
+
import { s as T } from "../../sum-CJ0ULhmt.js";
|
|
4
4
|
const Y = {
|
|
5
5
|
kernelName: "FusedSoftmax",
|
|
6
6
|
outputsToSave: [!0],
|
package/dist/ops/grads/gelu.js
CHANGED
package/dist/ops/grads/qkv.js
CHANGED
package/dist/ops/grads/rope.js
CHANGED
package/dist/ops/matMulGelu.js
CHANGED
package/dist/ops/matMulMul.js
CHANGED
package/dist/ops/mulDrop.js
CHANGED
package/dist/ops/normRMS.js
CHANGED
package/dist/ops/qkv.js
CHANGED
package/dist/ops/rope.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { e as p } from "../index-
|
|
2
|
-
import "../random_width-
|
|
3
|
-
import "../register_all_kernels-
|
|
1
|
+
import { e as p } from "../index-BzFyqcy-.js";
|
|
2
|
+
import "../random_width-CXVRloNK.js";
|
|
3
|
+
import "../register_all_kernels-DIGpEwcf.js";
|
|
4
4
|
import "../index-Tf7vU29b.js";
|
|
5
|
-
import "../dataset-
|
|
5
|
+
import "../dataset-DlZtKmBq.js";
|
|
6
6
|
import "./cpu/rope.js";
|
|
7
7
|
import "./webgl/rope.js";
|
|
8
8
|
import "./grads/rope.js";
|
package/dist/ops/scatterSub.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { m as b, s as I, r as k } from "../../RealDiv-
|
|
2
|
-
import { r as v } from "../../Reshape-
|
|
3
|
-
import { f as w, p as P } from "../../index-
|
|
4
|
-
import { e as S } from "../../axis_util-
|
|
1
|
+
import { m as b, s as I, r as k } from "../../RealDiv-D4EzDsC0.js";
|
|
2
|
+
import { r as v } from "../../Reshape-Bowtk9BP.js";
|
|
3
|
+
import { f as w, p as P } from "../../index-BzFyqcy-.js";
|
|
4
|
+
import { e as S } from "../../axis_util-TbGYJ208.js";
|
|
5
5
|
class T {
|
|
6
6
|
variableNames = ["logits", "maxLogits"];
|
|
7
7
|
outputShape;
|
package/dist/ops/webgl/gelu.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { f as a } from "../../index-
|
|
2
|
-
import { u as s, C as
|
|
3
|
-
const t = 0.7978845608028654, r = 0.044715,
|
|
1
|
+
import { f as a } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { u as s, C as i } from "../../kernel_funcs_utils-DKLK0Mg3.js";
|
|
3
|
+
const t = 0.7978845608028654, r = 0.044715, c = i + `
|
|
4
4
|
float x3 = x * x * x;
|
|
5
5
|
float inner = x + ${r} * x3;
|
|
6
6
|
inner = ${t} * inner;
|
|
7
|
-
inner = tanh(inner);
|
|
7
|
+
inner = abs(inner) > 15.0 ? sign(inner) : tanh(inner);
|
|
8
8
|
inner = 0.5 * (1.0 + inner);
|
|
9
9
|
inner = x * inner;
|
|
10
10
|
return inner;
|
|
11
|
-
`,
|
|
11
|
+
`, d = s({ opSnippet: c }), x = {
|
|
12
12
|
kernelName: "Gelu",
|
|
13
13
|
backendName: "webgl",
|
|
14
|
-
kernelFunc:
|
|
14
|
+
kernelFunc: d
|
|
15
15
|
};
|
|
16
16
|
a(x);
|
|
17
17
|
class f {
|
|
@@ -27,7 +27,7 @@ class f {
|
|
|
27
27
|
float x2 = x * x;
|
|
28
28
|
float x3 = x2 * x;
|
|
29
29
|
float u = ${t} * (x + ${r} * x3);
|
|
30
|
-
float t
|
|
30
|
+
float t = abs(u) > 15.0 ? sign(u) : tanh(u);
|
|
31
31
|
float sech2 = 1.0 - t * t;
|
|
32
32
|
float du_dx = ${t} * (1.0 + 3.0 * ${r} * x2);
|
|
33
33
|
float dgelu = 0.5 * (1.0 + t) + 0.5 * x * sech2 * du_dx;
|
|
@@ -46,5 +46,5 @@ const p = {
|
|
|
46
46
|
};
|
|
47
47
|
a(p);
|
|
48
48
|
export {
|
|
49
|
-
|
|
49
|
+
d as gelu
|
|
50
50
|
};
|
package/dist/ops/webgl/log.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as e, aj as r } from "../../index-
|
|
2
|
-
import { u as s, l as N } from "../../kernel_funcs_utils-
|
|
3
|
-
import { y as l } from "../../shared-
|
|
1
|
+
import { f as e, aj as r } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { u as s, l as N } from "../../kernel_funcs_utils-DKLK0Mg3.js";
|
|
3
|
+
import { y as l } from "../../shared-DuP7ue-R.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2020 Google LLC. All Rights Reserved.
|
|
@@ -1,63 +1,73 @@
|
|
|
1
|
-
import { f as
|
|
2
|
-
import { r as f } from "../../Reshape-
|
|
3
|
-
import { M as U } from "../../mulmat_packed_gpu-
|
|
4
|
-
import { m as
|
|
5
|
-
const M = 0.7978845608028654,
|
|
1
|
+
import { f as E, t as R, e as C, j as $, l as N, n as H, u as O } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { r as f } from "../../Reshape-Bowtk9BP.js";
|
|
3
|
+
import { M as U } from "../../mulmat_packed_gpu-BT60jmzP.js";
|
|
4
|
+
import { m as A } from "../../mat_mul-DzjTFx-u.js";
|
|
5
|
+
const M = 0.7978845608028654, g = 0.044715, j = `
|
|
6
6
|
vec4 x3 = x * x * x;
|
|
7
|
-
vec4 inner = x + ${
|
|
7
|
+
vec4 inner = x + ${g} * x3;
|
|
8
8
|
inner = ${M} * inner;
|
|
9
|
-
inner =
|
|
9
|
+
inner = vec4(
|
|
10
|
+
abs(inner[0]) > 15.0 ? sign(inner[0]) : tanh(inner[0]),
|
|
11
|
+
abs(inner[1]) > 15.0 ? sign(inner[1]) : tanh(inner[1]),
|
|
12
|
+
abs(inner[2]) > 15.0 ? sign(inner[2]) : tanh(inner[2]),
|
|
13
|
+
abs(inner[3]) > 15.0 ? sign(inner[3]) : tanh(inner[3])
|
|
14
|
+
);
|
|
10
15
|
inner = 0.5 * (1.0 + inner);
|
|
11
16
|
vec4 result = x * inner;
|
|
12
17
|
return result;
|
|
13
18
|
`, q = `
|
|
14
19
|
vec4 a2 = a * a;
|
|
15
20
|
vec4 a3 = a2 * a;
|
|
16
|
-
vec4 u = ${M} * (a + ${
|
|
17
|
-
vec4 t
|
|
21
|
+
vec4 u = ${M} * (a + ${g} * a3);
|
|
22
|
+
vec4 t = vec4(
|
|
23
|
+
abs(u[0]) > 15.0 ? sign(u[0]) : tanh(u[0]),
|
|
24
|
+
abs(u[1]) > 15.0 ? sign(u[1]) : tanh(u[1]),
|
|
25
|
+
abs(u[2]) > 15.0 ? sign(u[2]) : tanh(u[2]),
|
|
26
|
+
abs(u[3]) > 15.0 ? sign(u[3]) : tanh(u[3])
|
|
27
|
+
);
|
|
18
28
|
vec4 sech2 = 1.0 - t * t;
|
|
19
|
-
vec4 du_dx = ${M} * (1.0 + 3.0 * ${
|
|
29
|
+
vec4 du_dx = ${M} * (1.0 + 3.0 * ${g} * a2);
|
|
20
30
|
vec4 dgelu = 0.5 * (1.0 + t) + 0.5 * a * sech2 * du_dx;
|
|
21
31
|
return dgelu * b;
|
|
22
|
-
`,
|
|
23
|
-
function
|
|
32
|
+
`, ne = 1e3;
|
|
33
|
+
function _({
|
|
24
34
|
a: e,
|
|
25
|
-
b:
|
|
35
|
+
b: n,
|
|
26
36
|
transposeA: s,
|
|
27
|
-
transposeB:
|
|
37
|
+
transposeB: t,
|
|
28
38
|
backend: a,
|
|
29
39
|
activationSnippet: c,
|
|
30
40
|
multiplier: o
|
|
31
41
|
}) {
|
|
32
|
-
const r = e.shape.length,
|
|
42
|
+
const r = e.shape.length, i = n.shape.length, u = s ? e.shape[r - 2] : e.shape[r - 1], h = t ? n.shape[i - 1] : n.shape[i - 2], p = s ? e.shape[r - 1] : e.shape[r - 2], l = t ? n.shape[i - 2] : n.shape[i - 1], w = e.shape.slice(0, -2), K = n.shape.slice(0, -2), d = $(w), m = $(K), T = N(e.shape.slice(0, -2), n.shape.slice(0, -2)).concat([p, l]);
|
|
33
43
|
H(
|
|
34
|
-
|
|
35
|
-
() => `Error in matMul: inner shapes (${
|
|
44
|
+
u === h,
|
|
45
|
+
() => `Error in matMul: inner shapes (${u}) and (${h}) of Tensors with shapes ${e.shape} and ${n.shape} and transposeA=${s} and transposeB=${t} must match.`
|
|
36
46
|
);
|
|
37
|
-
const v = s ? [d,
|
|
47
|
+
const v = s ? [d, u, p] : [d, p, u], x = t ? [m, l, h] : [m, h, l], S = f({ inputs: { x: e }, backend: a, attrs: { shape: v } }), b = f({ inputs: { x: n }, backend: a, attrs: { shape: x } }), D = [S, b], y = Math.max(d, m), L = c, B = O(e.dtype, n.dtype), F = new U(
|
|
38
48
|
v,
|
|
39
|
-
|
|
40
|
-
[y,
|
|
49
|
+
x,
|
|
50
|
+
[y, p, l],
|
|
41
51
|
s,
|
|
42
|
-
|
|
52
|
+
t,
|
|
43
53
|
!1,
|
|
44
54
|
L,
|
|
45
55
|
!!o,
|
|
46
56
|
!1
|
|
47
|
-
),
|
|
48
|
-
o &&
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
for (const P of
|
|
57
|
+
), G = [S, b];
|
|
58
|
+
o && G.push(o);
|
|
59
|
+
const k = a.runWebGLProgram(F, G, B), I = f({ inputs: { x: k }, backend: a, attrs: { shape: T } });
|
|
60
|
+
D.push(k);
|
|
61
|
+
for (const P of D)
|
|
52
62
|
a.disposeIntermediateTensorInfo(P);
|
|
53
63
|
return I;
|
|
54
64
|
}
|
|
55
65
|
function z(e) {
|
|
56
|
-
const { inputs:
|
|
57
|
-
if (
|
|
66
|
+
const { inputs: n, backend: s } = e, { x: t, kernel: a } = n;
|
|
67
|
+
if (t === void 0 || a === void 0)
|
|
58
68
|
throw new Error("BatchMatMul requires two input tensors.");
|
|
59
|
-
return
|
|
60
|
-
a:
|
|
69
|
+
return _({
|
|
70
|
+
a: t,
|
|
61
71
|
b: a,
|
|
62
72
|
transposeA: !1,
|
|
63
73
|
transposeB: !1,
|
|
@@ -70,21 +80,21 @@ const W = {
|
|
|
70
80
|
backendName: "webgl",
|
|
71
81
|
kernelFunc: z
|
|
72
82
|
};
|
|
73
|
-
|
|
83
|
+
E(W);
|
|
74
84
|
function J(e) {
|
|
75
|
-
const { dy:
|
|
85
|
+
const { dy: n, x: s, kernel: t } = e.inputs, a = e.backend;
|
|
76
86
|
return R(() => {
|
|
77
87
|
const c = C().makeTensorFromTensorInfo(
|
|
78
|
-
|
|
88
|
+
_({
|
|
79
89
|
a: s,
|
|
80
|
-
b:
|
|
90
|
+
b: t,
|
|
81
91
|
transposeA: !1,
|
|
82
92
|
transposeB: !1,
|
|
83
93
|
backend: a,
|
|
84
94
|
activationSnippet: q,
|
|
85
|
-
multiplier:
|
|
95
|
+
multiplier: n
|
|
86
96
|
})
|
|
87
|
-
), o =
|
|
97
|
+
), o = A(c, t, !1, !0), r = A(s, c, !0, !1);
|
|
88
98
|
return [o, r];
|
|
89
99
|
});
|
|
90
100
|
}
|
|
@@ -93,9 +103,9 @@ const Q = {
|
|
|
93
103
|
backendName: "webgl",
|
|
94
104
|
kernelFunc: J
|
|
95
105
|
};
|
|
96
|
-
|
|
106
|
+
E(Q);
|
|
97
107
|
export {
|
|
98
|
-
|
|
99
|
-
|
|
108
|
+
ne as MATMUL_SHARED_DIM_THRESHOLD,
|
|
109
|
+
_ as batchMatMulGeluImpl,
|
|
100
110
|
z as batchMatMulKernel
|
|
101
111
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { f as p, e as G } from "../../index-
|
|
2
|
-
import { s as x } from "../../sum-
|
|
1
|
+
import { f as p, e as G } from "../../index-BzFyqcy-.js";
|
|
2
|
+
import { s as x } from "../../sum-CJ0ULhmt.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,6 +1,6 @@
|
|
|
1
|
-
import { g as p } from "../../webgpu_program-
|
|
2
|
-
import { f as d, c as l } from "../../webgpu_util-
|
|
3
|
-
import { f, a4 as c } from "../../index-
|
|
1
|
+
import { g as p } from "../../webgpu_program-DkQJOJSd.js";
|
|
2
|
+
import { f as d, c as l } from "../../webgpu_util-pLEV9tks.js";
|
|
3
|
+
import { f, a4 as c } from "../../index-BzFyqcy-.js";
|
|
4
4
|
class h {
|
|
5
5
|
variableNames = ["moments", "value"];
|
|
6
6
|
outputShape;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as m } from "../../webgpu_program-
|
|
2
|
-
import { f as u, c as p } from "../../webgpu_util-
|
|
3
|
-
import { f as d, a4 as c } from "../../index-
|
|
1
|
+
import { g as m } from "../../webgpu_program-DkQJOJSd.js";
|
|
2
|
+
import { f as u, c as p } from "../../webgpu_util-pLEV9tks.js";
|
|
3
|
+
import { f as d, a4 as c } from "../../index-BzFyqcy-.js";
|
|
4
4
|
class h {
|
|
5
5
|
variableNames = ["moments", "gradient"];
|
|
6
6
|
outputShape;
|