@genai-fi/nanogpt 0.4.3 → 0.4.4
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 +3 -3
- package/dist/NanoGPTModel.js +7 -7
- package/dist/Reshape-CiAY8ltP.js +212 -0
- package/dist/TeachableLLM.js +7 -1
- package/dist/{TiedEmbedding-CnJ1bx4q.js → TiedEmbedding-DznFwzcB.js} +244 -244
- package/dist/{axis_util-BgTGy5w8.js → axis_util-QP0LdI1v.js} +1 -1
- package/dist/{concat-CuRsVY-K.js → concat-DvWM7HGZ.js} +1 -1
- package/dist/data/parquet.js +9 -6
- package/dist/data/textLoader.js +6 -5
- package/dist/{dropout-DfDdklfL.js → dropout-DFEXTPV0.js} +4 -4
- package/dist/{gather-ZYRWhmXR.js → gather-C5D8PxwA.js} +1 -1
- package/dist/gpgpu_math-CUzjlO9A.js +23 -0
- package/dist/{index-C4JCoBvj.js → index--6vO-cOz.js} +87 -87
- package/dist/{kernel_funcs_utils-CAd1h9X1.js → kernel_funcs_utils-C6YBCuOt.js} +72 -91
- package/dist/layers/CausalSelfAttention.js +8 -8
- package/dist/layers/MLP.js +31 -33
- package/dist/layers/RMSNorm.js +3 -3
- package/dist/layers/RoPECache.js +3 -3
- package/dist/layers/TiedEmbedding.js +5 -5
- package/dist/layers/TransformerBlock.js +1 -1
- package/dist/{log_sum_exp-BswFnwOb.js → log_sum_exp-CiEy1aUe.js} +7 -7
- package/dist/main.js +25 -19
- package/dist/{mat_mul-415y5Qn2.js → mat_mul-BEHRPMh0.js} +1 -1
- package/dist/{max-CP_9O2Yd.js → max-BUShNgfh.js} +1 -1
- package/dist/{moments-CjeIaVdp.js → moments-DYOHXoRV.js} +5 -5
- package/dist/{norm-CZM380I3.js → norm-DSva3hI3.js} +13 -13
- package/dist/{ones-Bf3YR48P.js → ones-D6kB8bdY.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 +2 -2
- package/dist/ops/cpu/fusedSoftmax.js +2 -2
- package/dist/ops/cpu/gatherSub.js +4 -4
- package/dist/ops/cpu/gelu.js +1 -1
- package/dist/ops/cpu/matMulGelu.d.ts +1 -0
- package/dist/ops/cpu/matMulGelu.js +40 -0
- package/dist/ops/cpu/mulDropout.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 +2 -2
- package/dist/ops/grads/attentionMask.js +1 -1
- package/dist/ops/grads/fusedSoftmax.js +2 -2
- package/dist/ops/grads/gelu.js +24 -3
- package/dist/ops/grads/matMulGelu.d.ts +1 -0
- package/dist/ops/grads/matMulGelu.js +17 -0
- package/dist/ops/grads/qkv.js +1 -1
- package/dist/ops/grads/rope.js +1 -1
- package/dist/ops/matMulGelu.d.ts +3 -0
- package/dist/ops/matMulGelu.js +14 -0
- package/dist/ops/mulDrop.js +1 -1
- package/dist/ops/node/sparseCrossEntropy.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 +689 -895
- package/dist/ops/webgl/gatherSub.js +1 -1
- package/dist/ops/webgl/gelu.js +2 -2
- package/dist/ops/webgl/matMulGelu.d.ts +20 -0
- package/dist/ops/webgl/matMulGelu.js +166 -0
- package/dist/ops/webgl/mulDropout.js +1 -1
- 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/{range-9AzeApCc.js → range-C_vpUjBu.js} +1 -1
- package/dist/{reshape-Boe4DuIO.js → reshape-z51Eu-re.js} +1 -1
- package/dist/{sin-KmhiDuMa.js → sin-H567uayl.js} +1 -1
- package/dist/{slice_util-19zDNNSn.js → slice_util-BdhYwFY_.js} +2 -2
- package/dist/{softmax-Cujsg4ay.js → softmax-Dsxflvdl.js} +1 -1
- package/dist/{split-DbcNm1-i.js → split-B_k_jwud.js} +1 -1
- package/dist/{stack-D1YjmgKN.js → stack-CmqSdsfs.js} +1 -1
- package/dist/{sum-R28pucR5.js → sum-DdkDf2MG.js} +1 -1
- package/dist/{tensor-BVeHdl7V.js → tensor-BGYi41cj.js} +1 -1
- package/dist/{tensor2d-DqFGNs_K.js → tensor2d-DUr_htjt.js} +1 -1
- package/dist/{tfjs_backend-Cug-PH75.js → tfjs_backend-DuKis_xG.js} +46 -46
- package/dist/training/AdamExt.js +1 -1
- package/dist/training/DatasetBuilder.js +18 -18
- 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/weights.js +2 -2
- package/dist/{variable-LJT9Ld63.js → variable-BJTZ3jOy.js} +1 -1
- package/dist/{zeros-dnQxFgAD.js → zeros-8xl-W2DC.js} +1 -1
- package/package.json +1 -1
- package/dist/gelu-CnCt17Lk.js +0 -26
package/dist/layers/MLP.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { v as
|
|
5
|
-
import { r as
|
|
6
|
-
import { r as
|
|
7
|
-
import { m as
|
|
8
|
-
class
|
|
1
|
+
import { t as F, c as _, e as h, H as M } from "../index--6vO-cOz.js";
|
|
2
|
+
import v from "./BaseLayer.js";
|
|
3
|
+
import { matMulGelu as x } from "../ops/matMulGelu.js";
|
|
4
|
+
import { v as c } from "../variable-BJTZ3jOy.js";
|
|
5
|
+
import { r as d, d as u } from "../dropout-DFEXTPV0.js";
|
|
6
|
+
import { r as p } from "../reshape-z51Eu-re.js";
|
|
7
|
+
import { m as L } from "../mat_mul-BEHRPMh0.js";
|
|
8
|
+
class G extends v {
|
|
9
9
|
cFc = null;
|
|
10
10
|
cProj = null;
|
|
11
11
|
index;
|
|
@@ -15,12 +15,12 @@ class V extends x {
|
|
|
15
15
|
super(s), this.index = t, this.hiddenUnits = s.gpt.mlpFactor * s.gpt.nEmbed;
|
|
16
16
|
}
|
|
17
17
|
build() {
|
|
18
|
-
this.cFc === null && (this.cFc =
|
|
19
|
-
|
|
18
|
+
this.cFc === null && (this.cFc = c(
|
|
19
|
+
d([this.config.gpt.nEmbed, this.hiddenUnits], 0, 0.02),
|
|
20
20
|
!0
|
|
21
21
|
//`block_${this.index}_attn_cAttn_kernel`
|
|
22
|
-
)), this.cProj === null && (this.cProj =
|
|
23
|
-
|
|
22
|
+
)), this.cProj === null && (this.cProj = c(
|
|
23
|
+
d(
|
|
24
24
|
[this.hiddenUnits, this.config.gpt.nEmbed],
|
|
25
25
|
0,
|
|
26
26
|
0.02 / Math.sqrt(2 * this.config.gpt.nLayer)
|
|
@@ -45,43 +45,41 @@ class V extends x {
|
|
|
45
45
|
const s = t.get(`block_${this.index}_mlpOut`)?.[0], i = t.get(`block_${this.index}_mlpHidden`)?.[0];
|
|
46
46
|
if (!s || !i)
|
|
47
47
|
throw new Error(`Weights for block ${this.index} not found`);
|
|
48
|
-
this.cFc ? this.cFc.assign(i) : this.cFc =
|
|
48
|
+
this.cFc ? this.cFc.assign(i) : this.cFc = c(i, !0), this.cProj ? this.cProj.assign(s) : this.cProj = c(s, !0);
|
|
49
49
|
}
|
|
50
50
|
forward(t) {
|
|
51
|
-
return
|
|
51
|
+
return F(() => {
|
|
52
52
|
this.startMemory();
|
|
53
|
-
const [s, i,
|
|
53
|
+
const [s, i, r] = t.shape, o = p(t, [s * i, r]), e = x(o, this.cFc), n = L(e, this.cProj);
|
|
54
54
|
e.dispose();
|
|
55
|
-
const a =
|
|
56
|
-
|
|
57
|
-
const h = l(a, [s, i, o]);
|
|
58
|
-
return this.endMemory("MLP"), h;
|
|
55
|
+
const a = p(n, [s, i, r]);
|
|
56
|
+
return this.endMemory("MLP"), a;
|
|
59
57
|
});
|
|
60
58
|
}
|
|
61
59
|
call(t, s = !1) {
|
|
62
60
|
if (this.build(), s && this.config.layerConfig.checkpointMLP) {
|
|
63
|
-
const
|
|
61
|
+
const r = _(
|
|
64
62
|
// @ts-expect-error Invalid params
|
|
65
|
-
(
|
|
66
|
-
const
|
|
67
|
-
return a([
|
|
68
|
-
const [
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
return
|
|
63
|
+
(o, e, n, a) => {
|
|
64
|
+
const l = this.forward(o);
|
|
65
|
+
return a([o]), { value: l, gradFunc: (f, g) => {
|
|
66
|
+
const [m] = g, b = h().state.activeTape;
|
|
67
|
+
h().state.activeTape = [];
|
|
68
|
+
const P = M((j, w, T) => this.forward(j))([m, e, n], f);
|
|
69
|
+
return h().state.activeTape = b, P;
|
|
72
70
|
} };
|
|
73
71
|
}
|
|
74
72
|
)(t, this.cFc, this.cProj);
|
|
75
73
|
if (this.config.gpt.dropout > 0) {
|
|
76
|
-
const
|
|
77
|
-
return
|
|
74
|
+
const o = u(r, this.config.gpt.dropout);
|
|
75
|
+
return r.dispose(), o;
|
|
78
76
|
}
|
|
79
|
-
return
|
|
77
|
+
return r;
|
|
80
78
|
} else {
|
|
81
79
|
const i = this.forward(t);
|
|
82
80
|
if (s && this.config.gpt.dropout > 0) {
|
|
83
|
-
const
|
|
84
|
-
return i.dispose(),
|
|
81
|
+
const r = u(i, this.config.gpt.dropout);
|
|
82
|
+
return i.dispose(), r;
|
|
85
83
|
}
|
|
86
84
|
return i;
|
|
87
85
|
}
|
|
@@ -91,5 +89,5 @@ class V extends x {
|
|
|
91
89
|
}
|
|
92
90
|
}
|
|
93
91
|
export {
|
|
94
|
-
|
|
92
|
+
G as default
|
|
95
93
|
};
|
package/dist/layers/RMSNorm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { t as r } from "../index-
|
|
1
|
+
import { t as r } from "../index--6vO-cOz.js";
|
|
2
2
|
import m from "./BaseLayer.js";
|
|
3
|
-
import { v as i } from "../variable-
|
|
4
|
-
import { o } from "../ones-
|
|
3
|
+
import { v as i } from "../variable-BJTZ3jOy.js";
|
|
4
|
+
import { o } from "../ones-D6kB8bdY.js";
|
|
5
5
|
class d extends m {
|
|
6
6
|
gamma;
|
|
7
7
|
epsilon;
|
package/dist/layers/RoPECache.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as h, h as c, E as f,
|
|
2
|
-
import { c as d, s as C } from "../sin-
|
|
3
|
-
import { r as a } from "../range-
|
|
1
|
+
import { o as h, h as c, E as f, T as l, f as n, U as m, t as u, F as p } from "../index--6vO-cOz.js";
|
|
2
|
+
import { c as d, s as C } from "../sin-H567uayl.js";
|
|
3
|
+
import { r as a } from "../range-C_vpUjBu.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { T as a } from "../TiedEmbedding-
|
|
2
|
-
import "../index-
|
|
3
|
-
import "../tfjs_backend-
|
|
4
|
-
import "../variable-
|
|
5
|
-
import "../gather-
|
|
1
|
+
import { T as a } from "../TiedEmbedding-DznFwzcB.js";
|
|
2
|
+
import "../index--6vO-cOz.js";
|
|
3
|
+
import "../tfjs_backend-DuKis_xG.js";
|
|
4
|
+
import "../variable-BJTZ3jOy.js";
|
|
5
|
+
import "../gather-C5D8PxwA.js";
|
|
6
6
|
export {
|
|
7
7
|
a as default
|
|
8
8
|
};
|
|
@@ -2,7 +2,7 @@ import h from "./CausalSelfAttention.js";
|
|
|
2
2
|
import o from "./MLP.js";
|
|
3
3
|
import a from "./RMSNorm.js";
|
|
4
4
|
import p from "./BaseLayer.js";
|
|
5
|
-
import { t as d } from "../index-
|
|
5
|
+
import { t as d } from "../index--6vO-cOz.js";
|
|
6
6
|
class W extends p {
|
|
7
7
|
ln1;
|
|
8
8
|
attn;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as r, h as p, E as u,
|
|
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, h as p, E as u, a6 as h, a7 as E, $, s as S, a8 as d } from "./index--6vO-cOz.js";
|
|
2
|
+
import { e as K } from "./axis_util-QP0LdI1v.js";
|
|
3
|
+
import { m as T } from "./max-BUShNgfh.js";
|
|
4
|
+
import { r as m } from "./reshape-z51Eu-re.js";
|
|
5
|
+
import { s as _ } from "./sum-DdkDf2MG.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -62,12 +62,12 @@ const w = /* @__PURE__ */ r({ log_: v });
|
|
|
62
62
|
* =============================================================================
|
|
63
63
|
*/
|
|
64
64
|
function A(s, n = null, o = !1) {
|
|
65
|
-
const a = p(s, "x", "logSumExp"), t =
|
|
65
|
+
const a = p(s, "x", "logSumExp"), t = $(n, a.shape), x = T(
|
|
66
66
|
a,
|
|
67
67
|
t,
|
|
68
68
|
!0
|
|
69
69
|
/* keepDims */
|
|
70
|
-
), i =
|
|
70
|
+
), i = S(a, x), l = N(i), f = _(l, t), c = w(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);
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { default as
|
|
3
|
-
import { default as
|
|
4
|
-
import { default as
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { estimateMemoryUsage as
|
|
8
|
-
import "./index-
|
|
1
|
+
import { default as w } from "./NanoGPTModel.js";
|
|
2
|
+
import { default as D } from "./TeachableLLM.js";
|
|
3
|
+
import { default as F } from "./tokeniser/CharTokeniser.js";
|
|
4
|
+
import { default as N } from "./tokeniser/bpe.js";
|
|
5
|
+
import { default as j } from "./utilities/waitForModel.js";
|
|
6
|
+
import { default as z } from "./data/textLoader.js";
|
|
7
|
+
import { estimateMemoryUsage as H, estimateParameterCount as I, estimateResources as J, estimateTrainingMemoryUsage as K, validateConfig as O } from "./utilities/parameters.js";
|
|
8
|
+
import "./index--6vO-cOz.js";
|
|
9
9
|
import "./ops/cpu/scatterSub.js";
|
|
10
10
|
import "./ops/webgl/scatterSub.js";
|
|
11
11
|
import "./ops/cpu/gatherSub.js";
|
|
@@ -25,16 +25,22 @@ import "./ops/webgl/appendCache.js";
|
|
|
25
25
|
import "./ops/cpu/fusedSoftmax.js";
|
|
26
26
|
import "./ops/webgl/fusedSoftmax.js";
|
|
27
27
|
import "./ops/grads/fusedSoftmax.js";
|
|
28
|
+
import "./ops/cpu/matMulGelu.js";
|
|
29
|
+
import "./ops/webgl/matMulGelu.js";
|
|
30
|
+
import "./ops/grads/matMulGelu.js";
|
|
31
|
+
import "./ops/cpu/gelu.js";
|
|
32
|
+
import "./ops/webgl/gelu.js";
|
|
33
|
+
import "./ops/grads/gelu.js";
|
|
28
34
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
N as BPETokeniser,
|
|
36
|
+
F as CharTokeniser,
|
|
37
|
+
w as NanoGPT,
|
|
38
|
+
D as TeachableLLM,
|
|
39
|
+
H as estimateMemoryUsage,
|
|
40
|
+
I as estimateParameterCount,
|
|
41
|
+
J as estimateResources,
|
|
42
|
+
K as estimateTrainingMemoryUsage,
|
|
43
|
+
z as loadTextData,
|
|
44
|
+
O as validateConfig,
|
|
45
|
+
j as waitForModel
|
|
40
46
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { o as m, h as c, E as f,
|
|
2
|
-
import { e as v } from "./axis_util-
|
|
3
|
-
import { r as E } from "./reshape-
|
|
1
|
+
import { o as m, h as c, E as f, _ as i, $ as l, a0 as h, s as x, x as d } from "./index--6vO-cOz.js";
|
|
2
|
+
import { e as v } from "./axis_util-QP0LdI1v.js";
|
|
3
|
+
import { r as E } from "./reshape-z51Eu-re.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -46,8 +46,8 @@ function T(a, t = null, e = !1) {
|
|
|
46
46
|
const p = h(x(d(a, "float32"), E(s, o))), u = r(p, n, e);
|
|
47
47
|
return { mean: s, variance: u };
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const K = /* @__PURE__ */ m({ moments_: T });
|
|
50
50
|
export {
|
|
51
|
-
|
|
51
|
+
K as a,
|
|
52
52
|
r as m
|
|
53
53
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { o as l, h as c, E as y,
|
|
2
|
-
import { e as A } 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, h as c, E as y, a1 as E, $ as w, a2 as o, a3 as u, U as v, f as I, a0 as $ } from "./index--6vO-cOz.js";
|
|
2
|
+
import { e as A } from "./axis_util-QP0LdI1v.js";
|
|
3
|
+
import { m as f } from "./max-BUShNgfh.js";
|
|
4
|
+
import { r as h } from "./reshape-z51Eu-re.js";
|
|
5
|
+
import { s as t } from "./sum-DdkDf2MG.js";
|
|
6
6
|
/**
|
|
7
7
|
* @license
|
|
8
8
|
* Copyright 2020 Google Inc. All Rights Reserved.
|
|
@@ -20,8 +20,8 @@ import { s as t } from "./sum-R28pucR5.js";
|
|
|
20
20
|
* =============================================================================
|
|
21
21
|
*/
|
|
22
22
|
function k(n, e = null, r = !1) {
|
|
23
|
-
const
|
|
24
|
-
return y.runKernel(E,
|
|
23
|
+
const a = { x: c(n, "x", "min") }, i = { axis: e, keepDims: r };
|
|
24
|
+
return y.runKernel(E, a, i);
|
|
25
25
|
}
|
|
26
26
|
const s = /* @__PURE__ */ l({ min_: k });
|
|
27
27
|
/**
|
|
@@ -42,13 +42,13 @@ const s = /* @__PURE__ */ l({ min_: k });
|
|
|
42
42
|
*/
|
|
43
43
|
function T(n, e = "euclidean", r = null, m = !1) {
|
|
44
44
|
n = c(n, "x", "norm");
|
|
45
|
-
const
|
|
46
|
-
let
|
|
45
|
+
const a = d(n, e, r);
|
|
46
|
+
let i = a.shape;
|
|
47
47
|
if (m) {
|
|
48
48
|
const p = w(r, n.shape);
|
|
49
|
-
|
|
49
|
+
i = A(a.shape, p);
|
|
50
50
|
}
|
|
51
|
-
return h(
|
|
51
|
+
return h(a, i);
|
|
52
52
|
}
|
|
53
53
|
function d(n, e, r = null) {
|
|
54
54
|
if (n.rank === 0)
|
|
@@ -79,8 +79,8 @@ function d(n, e, r = null) {
|
|
|
79
79
|
}
|
|
80
80
|
throw new Error(`Error in norm: invalid axis: ${r}`);
|
|
81
81
|
}
|
|
82
|
-
const
|
|
82
|
+
const N = /* @__PURE__ */ l({ norm_: T });
|
|
83
83
|
export {
|
|
84
84
|
s as m,
|
|
85
|
-
|
|
85
|
+
N as n
|
|
86
86
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { k as n, l as t, n as m, E as i } from "./index-
|
|
2
|
-
import { z as l, c } from "./zeros-
|
|
1
|
+
import { k as n, l as t, n as m, E as i } from "./index--6vO-cOz.js";
|
|
2
|
+
import { z as l, c } from "./zeros-8xl-W2DC.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--6vO-cOz.js";
|
|
2
2
|
import "./cpu/appendCache.js";
|
|
3
3
|
import "./webgl/appendCache.js";
|
|
4
|
-
import { z as s } from "../zeros-
|
|
5
|
-
import { c } from "../concat-
|
|
4
|
+
import { z as s } from "../zeros-8xl-W2DC.js";
|
|
5
|
+
import { c } from "../concat-DvWM7HGZ.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--6vO-cOz.js";
|
|
2
|
+
import { c as h } from "../../concat-DvWM7HGZ.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,5 +1,5 @@
|
|
|
1
|
-
import { r as o, f as k } from "../../index-
|
|
2
|
-
import { m as d } from "../../mat_mul-
|
|
1
|
+
import { r as o, f as k } from "../../index--6vO-cOz.js";
|
|
2
|
+
import { m as d } from "../../mat_mul-BEHRPMh0.js";
|
|
3
3
|
function r(t) {
|
|
4
4
|
const { q: e, k: n, mask: s } = t.inputs, { divisor: c } = t.attrs, m = e.shape[2], i = n.shape[2], a = d(e, n, !1, !0).mul(k(c));
|
|
5
5
|
if (s) {
|
|
@@ -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--6vO-cOz.js";
|
|
2
|
+
import { s as f } from "../../softmax-Dsxflvdl.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, h as c, E as g,
|
|
2
|
-
import { r as
|
|
3
|
-
import { s as
|
|
1
|
+
import { o as u, h as c, E as g, N as h, r as m, s as p } from "../../index--6vO-cOz.js";
|
|
2
|
+
import { r as N } from "../../range-C_vpUjBu.js";
|
|
3
|
+
import { s as l } from "../../stack-CmqSdsfs.js";
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
6
6
|
* Copyright 2018 Google LLC. All Rights Reserved.
|
|
@@ -23,7 +23,7 @@ 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], o =
|
|
26
|
+
const { values: s, labels: n, logits: r } = e.inputs, t = n.shape[0], o = N(0, t, 1, "int32"), a = l([o, n], 1), i = b(r, a);
|
|
27
27
|
return p(s, i);
|
|
28
28
|
}
|
|
29
29
|
const k = {
|
package/dist/ops/cpu/gelu.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { r as a, t as i } from "../../index--6vO-cOz.js";
|
|
2
|
+
const c = 0.7978845608028654, m = 0.044715;
|
|
3
|
+
function M(o) {
|
|
4
|
+
const { inputs: s } = o, { x: t, kernel: l } = s, e = t, u = l;
|
|
5
|
+
return i(() => {
|
|
6
|
+
const n = e.matMul(u), d = n.mul(n).mul(n), r = n.add(d.mul(m)).mul(c).tanh().add(1).mul(0.5);
|
|
7
|
+
return n.mul(r);
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
const b = {
|
|
11
|
+
kernelName: "MatMulGelu",
|
|
12
|
+
backendName: "cpu",
|
|
13
|
+
kernelFunc: M
|
|
14
|
+
};
|
|
15
|
+
a(b);
|
|
16
|
+
const w = {
|
|
17
|
+
kernelName: "MatMulGelu",
|
|
18
|
+
backendName: "tensorflow",
|
|
19
|
+
kernelFunc: M
|
|
20
|
+
};
|
|
21
|
+
a(w);
|
|
22
|
+
function f(o) {
|
|
23
|
+
const { dy: s, x: t, kernel: l } = o.inputs;
|
|
24
|
+
return i(() => {
|
|
25
|
+
const e = t.matMul(l), u = e.square(), n = u.mul(e), r = e.add(n.mul(m)).mul(c).tanh(), G = r.square().neg().add(1), g = u.mul(3 * m).add(1), p = r.add(1).mul(0.5), N = e.mul(G).mul(c).mul(g).mul(0.5), K = p.add(N), k = s.mul(K), h = k.matMul(l.transpose()), F = t.transpose().matMul(k);
|
|
26
|
+
return [h, F];
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
const x = {
|
|
30
|
+
kernelName: "MatMulGeluGrad",
|
|
31
|
+
backendName: "cpu",
|
|
32
|
+
kernelFunc: f
|
|
33
|
+
};
|
|
34
|
+
a(x);
|
|
35
|
+
const C = {
|
|
36
|
+
kernelName: "MatMulGeluGrad",
|
|
37
|
+
backendName: "tensorflow",
|
|
38
|
+
kernelFunc: f
|
|
39
|
+
};
|
|
40
|
+
a(C);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as e, b as u } from "../../index-
|
|
1
|
+
import { r as e, b as u } from "../../index--6vO-cOz.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/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--6vO-cOz.js";
|
|
2
|
+
import { r as o } from "../../reshape-z51Eu-re.js";
|
|
3
|
+
import { s as x } from "../../split-B_k_jwud.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--6vO-cOz.js";
|
|
2
|
+
import { r as F } from "../../range-C_vpUjBu.js";
|
|
3
|
+
import { g as I } from "../../gather-C5D8PxwA.js";
|
|
4
|
+
import { s as E } from "../../stack-CmqSdsfs.js";
|
|
5
|
+
import { c as T } from "../../concat-DvWM7HGZ.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,7 +1,7 @@
|
|
|
1
|
-
import { o as l, k, h, E as g,
|
|
2
|
-
import { r as b } from "../../range-
|
|
3
|
-
import { s as E } from "../../stack-
|
|
4
|
-
import { o as D } from "../../ones-
|
|
1
|
+
import { o as l, k, h, E as g, a5 as w, r as $, s as d, b as m } from "../../index--6vO-cOz.js";
|
|
2
|
+
import { r as b } from "../../range-C_vpUjBu.js";
|
|
3
|
+
import { s as E } from "../../stack-CmqSdsfs.js";
|
|
4
|
+
import { o as D } from "../../ones-D6kB8bdY.js";
|
|
5
5
|
function N(n, r, t) {
|
|
6
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: ${n}, sliceDim: ${s}, and batchDim: ${e}.`;
|
|
7
7
|
if (t.rank < e)
|
package/dist/ops/fusedSoftmax.js
CHANGED
package/dist/ops/gatherSub.js
CHANGED
package/dist/ops/gelu.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { g as p, b as m, s as d } from "../../index-
|
|
1
|
+
import { g as p, b as m, s as d } from "../../index--6vO-cOz.js";
|
|
2
2
|
import { mulDrop as c } from "../mulDrop.js";
|
|
3
|
-
import { s as f } from "../../sum-
|
|
3
|
+
import { s as f } from "../../sum-DdkDf2MG.js";
|
|
4
4
|
const g = {
|
|
5
5
|
kernelName: "FusedSoftmax",
|
|
6
6
|
outputsToSave: [!0],
|
package/dist/ops/grads/gelu.js
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
|
-
import "../../index-
|
|
2
|
-
import
|
|
1
|
+
import { g as t, e as n } from "../../index--6vO-cOz.js";
|
|
2
|
+
import "../cpu/gelu.js";
|
|
3
|
+
import "../webgl/gelu.js";
|
|
4
|
+
const o = {
|
|
5
|
+
kernelName: "Gelu",
|
|
6
|
+
inputsToSave: ["x"],
|
|
7
|
+
outputsToSave: [],
|
|
8
|
+
gradFunc: (e, r) => {
|
|
9
|
+
const [u] = r;
|
|
10
|
+
return {
|
|
11
|
+
x: () => a(e, u)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
t(o);
|
|
16
|
+
function g(e) {
|
|
17
|
+
return n().runKernel("Gelu", { x: e });
|
|
18
|
+
}
|
|
19
|
+
function a(e, r) {
|
|
20
|
+
return n().runKernel("GeluGrad", { dy: e, x: r });
|
|
21
|
+
}
|
|
3
22
|
export {
|
|
4
|
-
|
|
23
|
+
a as d,
|
|
24
|
+
g,
|
|
25
|
+
o as geluGradConfig
|
|
5
26
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { g as a, e as o } from "../../index--6vO-cOz.js";
|
|
2
|
+
function s(e, n, r) {
|
|
3
|
+
return o().runKernel("MatMulGeluGrad", { dy: e, x: n, kernel: r });
|
|
4
|
+
}
|
|
5
|
+
const d = {
|
|
6
|
+
kernelName: "MatMulGelu",
|
|
7
|
+
inputsToSave: ["x", "kernel"],
|
|
8
|
+
outputsToSave: [],
|
|
9
|
+
gradFunc: (e, n) => {
|
|
10
|
+
const [r, t] = n, [u, l] = s(e, r, t);
|
|
11
|
+
return {
|
|
12
|
+
x: () => u,
|
|
13
|
+
kernel: () => l
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
a(d);
|
package/dist/ops/grads/qkv.js
CHANGED
package/dist/ops/grads/rope.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { e as u } from "../index--6vO-cOz.js";
|
|
2
|
+
import "./cpu/matMulGelu.js";
|
|
3
|
+
import "./webgl/matMulGelu.js";
|
|
4
|
+
import "./grads/matMulGelu.js";
|
|
5
|
+
function M(r, e) {
|
|
6
|
+
return u().runKernel("MatMulGelu", { x: r, kernel: e });
|
|
7
|
+
}
|
|
8
|
+
function a(r, e, t) {
|
|
9
|
+
return u().runKernel("MatMulGeluGrad", { dy: r, x: e, kernel: t });
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
a as dMatMulGelu,
|
|
13
|
+
M as matMulGelu
|
|
14
|
+
};
|