@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.
Files changed (92) hide show
  1. package/dist/Generator.js +3 -3
  2. package/dist/NanoGPTModel.js +7 -7
  3. package/dist/Reshape-CiAY8ltP.js +212 -0
  4. package/dist/TeachableLLM.js +7 -1
  5. package/dist/{TiedEmbedding-CnJ1bx4q.js → TiedEmbedding-DznFwzcB.js} +244 -244
  6. package/dist/{axis_util-BgTGy5w8.js → axis_util-QP0LdI1v.js} +1 -1
  7. package/dist/{concat-CuRsVY-K.js → concat-DvWM7HGZ.js} +1 -1
  8. package/dist/data/parquet.js +9 -6
  9. package/dist/data/textLoader.js +6 -5
  10. package/dist/{dropout-DfDdklfL.js → dropout-DFEXTPV0.js} +4 -4
  11. package/dist/{gather-ZYRWhmXR.js → gather-C5D8PxwA.js} +1 -1
  12. package/dist/gpgpu_math-CUzjlO9A.js +23 -0
  13. package/dist/{index-C4JCoBvj.js → index--6vO-cOz.js} +87 -87
  14. package/dist/{kernel_funcs_utils-CAd1h9X1.js → kernel_funcs_utils-C6YBCuOt.js} +72 -91
  15. package/dist/layers/CausalSelfAttention.js +8 -8
  16. package/dist/layers/MLP.js +31 -33
  17. package/dist/layers/RMSNorm.js +3 -3
  18. package/dist/layers/RoPECache.js +3 -3
  19. package/dist/layers/TiedEmbedding.js +5 -5
  20. package/dist/layers/TransformerBlock.js +1 -1
  21. package/dist/{log_sum_exp-BswFnwOb.js → log_sum_exp-CiEy1aUe.js} +7 -7
  22. package/dist/main.js +25 -19
  23. package/dist/{mat_mul-415y5Qn2.js → mat_mul-BEHRPMh0.js} +1 -1
  24. package/dist/{max-CP_9O2Yd.js → max-BUShNgfh.js} +1 -1
  25. package/dist/{moments-CjeIaVdp.js → moments-DYOHXoRV.js} +5 -5
  26. package/dist/{norm-CZM380I3.js → norm-DSva3hI3.js} +13 -13
  27. package/dist/{ones-Bf3YR48P.js → ones-D6kB8bdY.js} +2 -2
  28. package/dist/ops/appendCache.js +3 -3
  29. package/dist/ops/attentionMask.js +1 -1
  30. package/dist/ops/cpu/appendCache.js +2 -2
  31. package/dist/ops/cpu/attentionMask.js +2 -2
  32. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  33. package/dist/ops/cpu/gatherSub.js +4 -4
  34. package/dist/ops/cpu/gelu.js +1 -1
  35. package/dist/ops/cpu/matMulGelu.d.ts +1 -0
  36. package/dist/ops/cpu/matMulGelu.js +40 -0
  37. package/dist/ops/cpu/mulDropout.js +1 -1
  38. package/dist/ops/cpu/qkv.js +3 -3
  39. package/dist/ops/cpu/rope.js +5 -5
  40. package/dist/ops/cpu/scatterSub.js +4 -4
  41. package/dist/ops/fusedSoftmax.js +1 -1
  42. package/dist/ops/gatherSub.js +1 -1
  43. package/dist/ops/gelu.js +2 -2
  44. package/dist/ops/grads/attentionMask.js +1 -1
  45. package/dist/ops/grads/fusedSoftmax.js +2 -2
  46. package/dist/ops/grads/gelu.js +24 -3
  47. package/dist/ops/grads/matMulGelu.d.ts +1 -0
  48. package/dist/ops/grads/matMulGelu.js +17 -0
  49. package/dist/ops/grads/qkv.js +1 -1
  50. package/dist/ops/grads/rope.js +1 -1
  51. package/dist/ops/matMulGelu.d.ts +3 -0
  52. package/dist/ops/matMulGelu.js +14 -0
  53. package/dist/ops/mulDrop.js +1 -1
  54. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  55. package/dist/ops/qkv.js +1 -1
  56. package/dist/ops/scatterSub.js +1 -1
  57. package/dist/ops/webgl/appendCache.js +1 -1
  58. package/dist/ops/webgl/attentionMask.js +1 -1
  59. package/dist/ops/webgl/fusedSoftmax.js +689 -895
  60. package/dist/ops/webgl/gatherSub.js +1 -1
  61. package/dist/ops/webgl/gelu.js +2 -2
  62. package/dist/ops/webgl/matMulGelu.d.ts +20 -0
  63. package/dist/ops/webgl/matMulGelu.js +166 -0
  64. package/dist/ops/webgl/mulDropout.js +1 -1
  65. package/dist/ops/webgl/qkv.js +1 -1
  66. package/dist/ops/webgl/rope.js +1 -1
  67. package/dist/ops/webgl/scatterSub.js +1 -1
  68. package/dist/{range-9AzeApCc.js → range-C_vpUjBu.js} +1 -1
  69. package/dist/{reshape-Boe4DuIO.js → reshape-z51Eu-re.js} +1 -1
  70. package/dist/{sin-KmhiDuMa.js → sin-H567uayl.js} +1 -1
  71. package/dist/{slice_util-19zDNNSn.js → slice_util-BdhYwFY_.js} +2 -2
  72. package/dist/{softmax-Cujsg4ay.js → softmax-Dsxflvdl.js} +1 -1
  73. package/dist/{split-DbcNm1-i.js → split-B_k_jwud.js} +1 -1
  74. package/dist/{stack-D1YjmgKN.js → stack-CmqSdsfs.js} +1 -1
  75. package/dist/{sum-R28pucR5.js → sum-DdkDf2MG.js} +1 -1
  76. package/dist/{tensor-BVeHdl7V.js → tensor-BGYi41cj.js} +1 -1
  77. package/dist/{tensor2d-DqFGNs_K.js → tensor2d-DUr_htjt.js} +1 -1
  78. package/dist/{tfjs_backend-Cug-PH75.js → tfjs_backend-DuKis_xG.js} +46 -46
  79. package/dist/training/AdamExt.js +1 -1
  80. package/dist/training/DatasetBuilder.js +18 -18
  81. package/dist/training/FullTrainer.js +1 -1
  82. package/dist/training/Trainer.js +5 -5
  83. package/dist/training/sparseCrossEntropy.js +4 -4
  84. package/dist/utilities/dummy.js +2 -2
  85. package/dist/utilities/generate.js +3 -3
  86. package/dist/utilities/load.js +1 -1
  87. package/dist/utilities/profile.js +1 -1
  88. package/dist/utilities/weights.js +2 -2
  89. package/dist/{variable-LJT9Ld63.js → variable-BJTZ3jOy.js} +1 -1
  90. package/dist/{zeros-dnQxFgAD.js → zeros-8xl-W2DC.js} +1 -1
  91. package/package.json +1 -1
  92. package/dist/gelu-CnCt17Lk.js +0 -26
@@ -1,11 +1,11 @@
1
- import { t as _, c as M, e as d, H as v } from "../index-C4JCoBvj.js";
2
- import x from "./BaseLayer.js";
3
- import { g as L } from "../gelu-CnCt17Lk.js";
4
- import { v as n } from "../variable-LJT9Ld63.js";
5
- import { r as p, d as u } from "../dropout-DfDdklfL.js";
6
- import { r as l } from "../reshape-Boe4DuIO.js";
7
- import { m as f } from "../mat_mul-415y5Qn2.js";
8
- class V extends x {
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 = n(
19
- p([this.config.gpt.nEmbed, this.hiddenUnits], 0, 0.02),
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 = n(
23
- p(
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 = n(i, !0), this.cProj ? this.cProj.assign(s) : this.cProj = n(s, !0);
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, o] = t.shape, r = l(t, [s * i, o]), e = f(r, this.cFc), c = L(e);
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 = f(c, this.cProj);
56
- c.dispose();
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 o = M(
61
+ const r = _(
64
62
  // @ts-expect-error Invalid params
65
- (r, e, c, a) => {
66
- const h = this.forward(r);
67
- return a([r]), { value: h, gradFunc: (g, m) => {
68
- const [b] = m, P = d().state.activeTape;
69
- d().state.activeTape = [];
70
- const j = v((F, w, T) => this.forward(F))([b, e, c], g);
71
- return d().state.activeTape = P, j;
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 r = u(o, this.config.gpt.dropout);
77
- return o.dispose(), r;
74
+ const o = u(r, this.config.gpt.dropout);
75
+ return r.dispose(), o;
78
76
  }
79
- return o;
77
+ return r;
80
78
  } else {
81
79
  const i = this.forward(t);
82
80
  if (s && this.config.gpt.dropout > 0) {
83
- const o = u(i, this.config.gpt.dropout);
84
- return i.dispose(), o;
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
- V as default
92
+ G as default
95
93
  };
@@ -1,7 +1,7 @@
1
- import { t as r } from "../index-C4JCoBvj.js";
1
+ import { t as r } from "../index--6vO-cOz.js";
2
2
  import m from "./BaseLayer.js";
3
- import { v as i } from "../variable-LJT9Ld63.js";
4
- import { o } from "../ones-Bf3YR48P.js";
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;
@@ -1,6 +1,6 @@
1
- import { o as h, h as c, E as f, N as l, f as n, O as m, t as u, F as p } from "../index-C4JCoBvj.js";
2
- import { c as d, s as C } from "../sin-KmhiDuMa.js";
3
- import { r as a } from "../range-9AzeApCc.js";
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-CnJ1bx4q.js";
2
- import "../index-C4JCoBvj.js";
3
- import "../tfjs_backend-Cug-PH75.js";
4
- import "../variable-LJT9Ld63.js";
5
- import "../gather-ZYRWhmXR.js";
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-C4JCoBvj.js";
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, a3 as h, a4 as E, Y as S, s as $, a5 as d } from "./index-C4JCoBvj.js";
2
- import { e as K } from "./axis_util-BgTGy5w8.js";
3
- import { m as T } from "./max-CP_9O2Yd.js";
4
- import { r as m } from "./reshape-Boe4DuIO.js";
5
- import { s as _ } from "./sum-R28pucR5.js";
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 = S(n, a.shape), x = 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 = $(a, x), l = N(i), f = _(l, t), c = w(f), e = d(m(x, c.shape), c);
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 k } from "./NanoGPTModel.js";
2
- import { default as L } from "./TeachableLLM.js";
3
- import { default as b } from "./tokeniser/CharTokeniser.js";
4
- import { default as w } from "./tokeniser/bpe.js";
5
- import { default as D } from "./utilities/waitForModel.js";
6
- import { default as F } from "./data/textLoader.js";
7
- import { estimateMemoryUsage as N, estimateParameterCount as R, estimateResources as j, estimateTrainingMemoryUsage as q, validateConfig as z } from "./utilities/parameters.js";
8
- import "./index-C4JCoBvj.js";
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
- w as BPETokeniser,
30
- b as CharTokeniser,
31
- k as NanoGPT,
32
- L as TeachableLLM,
33
- N as estimateMemoryUsage,
34
- R as estimateParameterCount,
35
- j as estimateResources,
36
- q as estimateTrainingMemoryUsage,
37
- F as loadTextData,
38
- z as validateConfig,
39
- D as waitForModel
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,4 +1,4 @@
1
- import { o as m, h as s, p as c, E as M, B as p } from "./index-C4JCoBvj.js";
1
+ import { o as m, h as s, p as c, E as M, B as p } from "./index--6vO-cOz.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { o as r, h as e, E as x, M as c } from "./index-C4JCoBvj.js";
1
+ import { o as r, h as e, E as x, M as c } from "./index--6vO-cOz.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,6 +1,6 @@
1
- import { o as m, h as c, E as f, X as i, Y as l, Z as h, s as x, x as d } from "./index-C4JCoBvj.js";
2
- import { e as v } from "./axis_util-BgTGy5w8.js";
3
- import { r as E } from "./reshape-Boe4DuIO.js";
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 N = /* @__PURE__ */ m({ moments_: T });
49
+ const K = /* @__PURE__ */ m({ moments_: T });
50
50
  export {
51
- N as a,
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, _ as E, Y as w, $ as o, a0 as u, O as v, f as I, Z as $ } from "./index-C4JCoBvj.js";
2
- import { e as A } from "./axis_util-BgTGy5w8.js";
3
- import { m as f } from "./max-CP_9O2Yd.js";
4
- import { r as h } from "./reshape-Boe4DuIO.js";
5
- import { s as t } from "./sum-R28pucR5.js";
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 i = { x: c(n, "x", "min") }, a = { axis: e, keepDims: r };
24
- return y.runKernel(E, i, a);
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 i = d(n, e, r);
46
- let a = i.shape;
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
- a = A(i.shape, p);
49
+ i = A(a.shape, p);
50
50
  }
51
- return h(i, a);
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 K = /* @__PURE__ */ l({ norm_: T });
82
+ const N = /* @__PURE__ */ l({ norm_: T });
83
83
  export {
84
84
  s as m,
85
- K as n
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-C4JCoBvj.js";
2
- import { z as l, c } from "./zeros-dnQxFgAD.js";
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.
@@ -1,8 +1,8 @@
1
- import { e as a } from "../index-C4JCoBvj.js";
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-dnQxFgAD.js";
5
- import { c } from "../concat-CuRsVY-K.js";
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,4 +1,4 @@
1
- import { e as i } from "../index-C4JCoBvj.js";
1
+ import { e as i } from "../index--6vO-cOz.js";
2
2
  import "./cpu/attentionMask.js";
3
3
  import "./webgl/attentionMask.js";
4
4
  import "./grads/attentionMask.js";
@@ -1,5 +1,5 @@
1
- import { r as d } from "../../index-C4JCoBvj.js";
2
- import { c as h } from "../../concat-CuRsVY-K.js";
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-C4JCoBvj.js";
2
- import { m as d } from "../../mat_mul-415y5Qn2.js";
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-C4JCoBvj.js";
2
- import { s as f } from "../../softmax-Cujsg4ay.js";
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, L as h, r as m, s as p } from "../../index-C4JCoBvj.js";
2
- import { r as l } from "../../range-9AzeApCc.js";
3
- import { s as N } from "../../stack-D1YjmgKN.js";
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 = l(0, t, 1, "int32"), a = N([o, n], 1), i = b(r, a);
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 = {
@@ -1,4 +1,4 @@
1
- import { r as t, t as d } from "../../index-C4JCoBvj.js";
1
+ import { r as t, t as d } from "../../index--6vO-cOz.js";
2
2
  const o = 0.7978845608028654, c = 0.044715;
3
3
  function m(u) {
4
4
  const { inputs: l } = u, { x: e } = l, n = e;
@@ -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-C4JCoBvj.js";
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);
@@ -1,6 +1,6 @@
1
- import { r as q } from "../../index-C4JCoBvj.js";
2
- import { r as o } from "../../reshape-Boe4DuIO.js";
3
- import { s as x } from "../../split-DbcNm1-i.js";
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();
@@ -1,8 +1,8 @@
1
- import { r as S } from "../../index-C4JCoBvj.js";
2
- import { r as F } from "../../range-9AzeApCc.js";
3
- import { g as I } from "../../gather-ZYRWhmXR.js";
4
- import { s as E } from "../../stack-D1YjmgKN.js";
5
- import { c as T } from "../../concat-CuRsVY-K.js";
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, a2 as w, r as $, s as d, b as m } from "../../index-C4JCoBvj.js";
2
- import { r as b } from "../../range-9AzeApCc.js";
3
- import { s as E } from "../../stack-D1YjmgKN.js";
4
- import { o as D } from "../../ones-Bf3YR48P.js";
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)
@@ -1,4 +1,4 @@
1
- import { e as t } from "../index-C4JCoBvj.js";
1
+ import { e as t } from "../index--6vO-cOz.js";
2
2
  import "./cpu/fusedSoftmax.js";
3
3
  import "./webgl/fusedSoftmax.js";
4
4
  import "./grads/fusedSoftmax.js";
@@ -1,4 +1,4 @@
1
- import { e as n } from "../index-C4JCoBvj.js";
1
+ import { e as n } from "../index--6vO-cOz.js";
2
2
  import "./cpu/gatherSub.js";
3
3
  import "./webgl/gatherSub.js";
4
4
  function f(r, e, t) {
package/dist/ops/gelu.js CHANGED
@@ -1,7 +1,7 @@
1
- import "../index-C4JCoBvj.js";
1
+ import "../index--6vO-cOz.js";
2
2
  import "./cpu/gelu.js";
3
3
  import "./webgl/gelu.js";
4
- import { d as e, g as i } from "../gelu-CnCt17Lk.js";
4
+ import { d as e, g as i } from "./grads/gelu.js";
5
5
  export {
6
6
  e as dGelu,
7
7
  i as gelu
@@ -1,4 +1,4 @@
1
- import { g as i } from "../../index-C4JCoBvj.js";
1
+ import { g as i } from "../../index--6vO-cOz.js";
2
2
  const u = {
3
3
  kernelName: "AttentionMask",
4
4
  inputsToSave: ["q", "k"],
@@ -1,6 +1,6 @@
1
- import { g as p, b as m, s as d } from "../../index-C4JCoBvj.js";
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-R28pucR5.js";
3
+ import { s as f } from "../../sum-DdkDf2MG.js";
4
4
  const g = {
5
5
  kernelName: "FusedSoftmax",
6
6
  outputsToSave: [!0],
@@ -1,5 +1,26 @@
1
- import "../../index-C4JCoBvj.js";
2
- import { a as e } from "../../gelu-CnCt17Lk.js";
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
- e as geluGradConfig
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);
@@ -1,4 +1,4 @@
1
- import { g as v } from "../../index-C4JCoBvj.js";
1
+ import { g as v } from "../../index--6vO-cOz.js";
2
2
  const g = {
3
3
  kernelName: "QKV",
4
4
  inputsToSave: ["x", "kernel"],
@@ -1,4 +1,4 @@
1
- import { g as a, e as i } from "../../index-C4JCoBvj.js";
1
+ import { g as a, e as i } from "../../index--6vO-cOz.js";
2
2
  function p(n, e, s, o) {
3
3
  return i().runKernel("Rope", { x: n, sin: e, cos: s }, { pastLen: o });
4
4
  }
@@ -0,0 +1,3 @@
1
+ import { Tensor } from '@tensorflow/tfjs-core';
2
+ export declare function matMulGelu(x: Tensor, kernel: Tensor): Tensor;
3
+ export declare function dMatMulGelu(dy: Tensor, x: Tensor, kernel: Tensor): Tensor;
@@ -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
+ };