@genai-fi/nanogpt 0.8.0 → 0.8.1

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 (160) hide show
  1. package/dist/Generator.js +29 -27
  2. package/dist/{RealDiv-N8TpOMYv.js → RealDiv-D_q39E3A.js} +14 -14
  3. package/dist/{Reshape-B-lWQRnF.js → Reshape-41YpQqEo.js} +1 -1
  4. package/dist/{Reshape-Bo8HzP8V.js → Reshape-Bh_jzKzV.js} +2 -2
  5. package/dist/TeachableLLM.js +7 -5
  6. package/dist/{axis_util-DubwyOhW.js → axis_util-Did9235A.js} +1 -1
  7. package/dist/backend.js +2 -2
  8. package/dist/{backend_util-BJ-_jSeK.js → backend_util-yC3YH1jo.js} +17 -17
  9. package/dist/{broadcast_to-BYfCp5iL.js → broadcast_to-CUvOdOT5.js} +2 -2
  10. package/dist/checks/appendCache.d.ts +1 -0
  11. package/dist/checks/appendCache.js +22 -0
  12. package/dist/checks/attentionMask.d.ts +1 -0
  13. package/dist/checks/attentionMask.js +37 -0
  14. package/dist/checks/check.d.ts +9 -0
  15. package/dist/checks/check.js +20 -0
  16. package/dist/checks/gelu.d.ts +1 -0
  17. package/dist/checks/gelu.js +18 -0
  18. package/dist/checks/index.d.ts +19 -0
  19. package/dist/checks/index.js +21 -0
  20. package/dist/checks/normRMS.d.ts +1 -0
  21. package/dist/checks/normRMS.js +16 -0
  22. package/dist/checks/normRMSGrad.d.ts +1 -0
  23. package/dist/checks/normRMSGrad.js +12 -0
  24. package/dist/checks/qkv.d.ts +1 -0
  25. package/dist/checks/qkv.js +25 -0
  26. package/dist/checks/rope.d.ts +1 -0
  27. package/dist/checks/rope.js +21 -0
  28. package/dist/{concat-BmDqqFsa.js → concat-pHiVqR3L.js} +1 -1
  29. package/dist/{dataset-CJmEGu6D.js → dataset-DPPl-iLT.js} +7 -7
  30. package/dist/{dropout-sx0sjVAT.js → dropout-CcKSfOYE.js} +11 -11
  31. package/dist/{exports_initializers-DAKM8UO9.js → exports_initializers-DKk7-bsx.js} +1 -1
  32. package/dist/{gather-C1siEkdp.js → gather-CPg6ZlQA.js} +1 -1
  33. package/dist/{gelu-Bd3UBBxg.js → gelu-BkcmEEyD.js} +1 -1
  34. package/dist/{gpgpu_math-TFLxaLkw.js → gpgpu_math-D_ODOLix.js} +2 -2
  35. package/dist/{index-CUQrfsw_.js → index-DdmHGZjq.js} +655 -647
  36. package/dist/{index-BaPo_0H8.js → index-evZ57wr4.js} +10 -10
  37. package/dist/{kernel_funcs_utils-P9aFa232.js → kernel_funcs_utils-CDfFpUab.js} +15 -15
  38. package/dist/layers/BaseLayer.js +2 -2
  39. package/dist/layers/CausalSelfAttention.js +6 -6
  40. package/dist/layers/MLP.js +5 -5
  41. package/dist/layers/PositionEmbedding.js +5 -5
  42. package/dist/layers/RMSNorm.js +3 -3
  43. package/dist/layers/RoPECache.js +4 -4
  44. package/dist/layers/TiedEmbedding.js +5 -5
  45. package/dist/layers/TransformerBlock.js +1 -1
  46. package/dist/loader/loadTransformers.js +1 -1
  47. package/dist/loader/oldZipLoad.js +9 -7
  48. package/dist/{log_sum_exp-C142qZqY.js → log_sum_exp-C8yFJfZz.js} +45 -24
  49. package/dist/main.d.ts +1 -0
  50. package/dist/main.js +9 -7
  51. package/dist/{mat_mul-DMkduNJu.js → mat_mul-Dpy2mMRu.js} +1 -1
  52. package/dist/{mod-uUuj4gSb.js → mod-CbibJi3D.js} +1 -1
  53. package/dist/models/NanoGPTV1.js +1 -1
  54. package/dist/models/model.js +9 -7
  55. package/dist/{mulmat_packed_gpu-Cm2gw-c8.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
  56. package/dist/{ones-ZdgQGBCP.js → ones-BAqVh-eA.js} +2 -2
  57. package/dist/ops/adamAdjust.js +1 -1
  58. package/dist/ops/adamMoments.js +1 -1
  59. package/dist/ops/appendCache.js +3 -3
  60. package/dist/ops/attentionMask.js +1 -1
  61. package/dist/ops/cpu/adamAdjust.js +1 -1
  62. package/dist/ops/cpu/adamMoments.js +2 -2
  63. package/dist/ops/cpu/appendCache.js +2 -2
  64. package/dist/ops/cpu/attentionMask.js +5 -5
  65. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  66. package/dist/ops/cpu/gatherSub.js +5 -5
  67. package/dist/ops/cpu/gelu.js +1 -1
  68. package/dist/ops/cpu/matMulGelu.js +2 -2
  69. package/dist/ops/cpu/matMulMul.js +1 -1
  70. package/dist/ops/cpu/mulDropout.js +1 -1
  71. package/dist/ops/cpu/normRMS.js +1 -1
  72. package/dist/ops/cpu/qkv.js +3 -3
  73. package/dist/ops/cpu/rope.js +5 -5
  74. package/dist/ops/cpu/scatterSub.js +13 -13
  75. package/dist/ops/fusedSoftmax.js +1 -1
  76. package/dist/ops/gatherSub.js +1 -1
  77. package/dist/ops/gelu.js +2 -2
  78. package/dist/ops/grads/attentionMask.js +1 -1
  79. package/dist/ops/grads/fusedSoftmax.js +2 -2
  80. package/dist/ops/grads/gelu.js +2 -2
  81. package/dist/ops/grads/matMulGelu.js +1 -1
  82. package/dist/ops/grads/normRMS.js +1 -1
  83. package/dist/ops/grads/qkv.js +1 -1
  84. package/dist/ops/grads/rope.js +1 -1
  85. package/dist/ops/matMulGelu.js +1 -1
  86. package/dist/ops/matMulMul.js +1 -1
  87. package/dist/ops/mulDrop.js +1 -1
  88. package/dist/ops/normRMS.js +1 -1
  89. package/dist/ops/qkv.js +1 -1
  90. package/dist/ops/rope.js +4 -4
  91. package/dist/ops/scatterSub.js +1 -1
  92. package/dist/ops/webgl/adamAdjust.js +2 -2
  93. package/dist/ops/webgl/adamMoments.js +1 -1
  94. package/dist/ops/webgl/appendCache.js +1 -1
  95. package/dist/ops/webgl/attentionMask.js +1 -1
  96. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  97. package/dist/ops/webgl/gatherSub.js +1 -1
  98. package/dist/ops/webgl/gelu.js +2 -2
  99. package/dist/ops/webgl/log.js +3 -3
  100. package/dist/ops/webgl/matMulGelu.js +4 -4
  101. package/dist/ops/webgl/matMulMul.js +1 -1
  102. package/dist/ops/webgl/mulDropout.js +1 -1
  103. package/dist/ops/webgl/normRMS.js +2 -2
  104. package/dist/ops/webgl/qkv.js +1 -1
  105. package/dist/ops/webgl/rope.js +1 -1
  106. package/dist/ops/webgl/scatterSub.js +1 -1
  107. package/dist/ops/webgpu/adamAdjust.js +3 -3
  108. package/dist/ops/webgpu/adamMoments.js +3 -3
  109. package/dist/ops/webgpu/appendCache.js +3 -3
  110. package/dist/ops/webgpu/attentionMask.js +3 -3
  111. package/dist/ops/webgpu/gatherSub.js +3 -3
  112. package/dist/ops/webgpu/gelu.js +3 -3
  113. package/dist/ops/webgpu/normRMS.js +2 -2
  114. package/dist/ops/webgpu/normRMSGrad.js +5 -5
  115. package/dist/ops/webgpu/qkv.js +3 -3
  116. package/dist/ops/webgpu/rope.js +3 -3
  117. package/dist/ops/webgpu/scatterSub.js +3 -3
  118. package/dist/ops/webgpu/utils/reductions.js +4 -4
  119. package/dist/ops-542ai2vG.js +1525 -0
  120. package/dist/{random_width-D8Pwy_na.js → random_width-DKGeiFuR.js} +1514 -1581
  121. package/dist/{range-LVHrSLdi.js → range-BcUvLuf5.js} +1 -1
  122. package/dist/{reciprocal-CaR9e67G.js → reciprocal-DhDWSKiD.js} +1 -1
  123. package/dist/{register_all_kernels-DUshvVWP.js → register_all_kernels-Do9VvZmo.js} +2312 -2335
  124. package/dist/{max-B3JOcNGb.js → relu-B1AXs7p5.js} +6 -6
  125. package/dist/{reshape-DEfQGSin.js → reshape-WeJkT3ja.js} +1 -1
  126. package/dist/{scatter_nd_util-CUPPNLaA.js → scatter_nd_util-B7yDhiQr.js} +1 -1
  127. package/dist/{selu_util-8vv5JxQV.js → selu_util-BgUO9gHY.js} +125 -146
  128. package/dist/{shared-D1elLckx.js → shared-CZiWmQCI.js} +1 -1
  129. package/dist/{shared-CkNorDcU.js → shared-V6D_md-c.js} +120 -120
  130. package/dist/{sin-D2CKKmyR.js → sin-CPxad7Am.js} +1 -1
  131. package/dist/{slice-BnyE-M_7.js → slice-B7jXtPnp.js} +1 -1
  132. package/dist/{softmax-DLoZWYBx.js → softmax-BfsyI4As.js} +1 -1
  133. package/dist/{split-By_n4TKP.js → split-BPxr8_8m.js} +1 -1
  134. package/dist/{stack-DkdFLq37.js → stack-BNwLzE43.js} +1 -1
  135. package/dist/{sum-l_0SqM4h.js → sum-ByFINZgi.js} +1 -1
  136. package/dist/{tensor-BAQdLqoU.js → tensor-DbqgIV9B.js} +1 -1
  137. package/dist/tensor1d-CtJq5BOv.js +27 -0
  138. package/dist/{tensor2d-BHy261cI.js → tensor2d-CObBWBkW.js} +1 -1
  139. package/dist/tensor3d-BOukqWwr.js +30 -0
  140. package/dist/tensor4d-DLtk7Nxh.js +30 -0
  141. package/dist/training/Adam.js +2 -2
  142. package/dist/training/AdamExt.js +1 -1
  143. package/dist/training/DatasetBuilder.js +2 -2
  144. package/dist/training/FullTrainer.js +1 -1
  145. package/dist/training/Trainer.js +2 -2
  146. package/dist/training/sparseCrossEntropy.js +8 -9
  147. package/dist/utilities/arrayClose.d.ts +1 -1
  148. package/dist/utilities/arrayClose.js +16 -7
  149. package/dist/utilities/dummy.js +2 -2
  150. package/dist/utilities/multinomialCPU.js +2 -2
  151. package/dist/utilities/performance.js +1 -1
  152. package/dist/utilities/profile.js +1 -1
  153. package/dist/utilities/safetensors.js +2 -2
  154. package/dist/utilities/weights.js +2 -2
  155. package/dist/{variable-C9hihzDB.js → variable-DPFOJyRG.js} +1 -1
  156. package/dist/{webgpu_program-dFEVbDPL.js → webgpu_program-Dhk9R5aG.js} +1 -1
  157. package/dist/{webgpu_util-DLImlSc6.js → webgpu_util-BqGnZg8t.js} +1 -1
  158. package/dist/{zeros-VZ72lWXM.js → zeros-Dnwix0p4.js} +1 -1
  159. package/package.json +1 -1
  160. package/dist/ops-C_1K_-35.js +0 -1202
package/dist/Generator.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { E as z } from "./index-Dwqa6Zy2.js";
2
- import { B as A, C as L, E as C, a5 as I, t as O, k as R } from "./index-CUQrfsw_.js";
2
+ import { C as A, D as L, E as C, a6 as I, t as O, k as R } from "./index-DdmHGZjq.js";
3
3
  import "./ops/cpu/attentionMask.js";
4
4
  import "./ops/webgl/attentionMask.js";
5
5
  import "./ops/grads/attentionMask.js";
6
6
  import "./ops/cpu/qkv.js";
7
7
  import "./ops/webgl/qkv.js";
8
8
  import "./ops/grads/qkv.js";
9
- import { p as _ } from "./random_width-D8Pwy_na.js";
10
- import { t as K } from "./register_all_kernels-DUshvVWP.js";
9
+ import { p as _ } from "./random_width-DKGeiFuR.js";
10
+ import { t as K } from "./register_all_kernels-Do9VvZmo.js";
11
11
  import "./index-Tf7vU29b.js";
12
- import "./dataset-CJmEGu6D.js";
12
+ import "./dataset-DPPl-iLT.js";
13
13
  import "./ops/cpu/rope.js";
14
14
  import "./ops/webgl/rope.js";
15
15
  import "./ops/grads/rope.js";
@@ -37,14 +37,16 @@ import "./ops/webgl/adamMoments.js";
37
37
  import "./papaparse.min-C8l2Kvo1.js";
38
38
  import "./ops/cpu/gelu.js";
39
39
  import "./ops/webgl/gelu.js";
40
- import "./gelu-Bd3UBBxg.js";
40
+ import "./gelu-BkcmEEyD.js";
41
41
  import "./ops/webgl/log.js";
42
+ import "./checks/normRMS.js";
43
+ import "./checks/normRMSGrad.js";
42
44
  import $ from "./utilities/multinomialCPU.js";
43
- import { r as x } from "./reshape-DEfQGSin.js";
44
- import { t as P } from "./tensor2d-BHy261cI.js";
45
- import { s as v } from "./softmax-DLoZWYBx.js";
46
- import { g as q } from "./gather-C1siEkdp.js";
47
- import { c as G } from "./concat-BmDqqFsa.js";
45
+ import { r as x } from "./reshape-WeJkT3ja.js";
46
+ import { t as P } from "./tensor2d-CObBWBkW.js";
47
+ import { s as v } from "./softmax-BfsyI4As.js";
48
+ import { g as q } from "./gather-CPg6ZlQA.js";
49
+ import { c as G } from "./concat-pHiVqR3L.js";
48
50
  /**
49
51
  * @license
50
52
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -61,8 +63,8 @@ import { c as G } from "./concat-BmDqqFsa.js";
61
63
  * limitations under the License.
62
64
  * =============================================================================
63
65
  */
64
- function N(h, t, e, i = !1) {
65
- const o = L(h, "logits", "multinomial"), s = o.size, n = o.rank;
66
+ function N(m, t, e, i = !1) {
67
+ const o = L(m, "logits", "multinomial"), s = o.size, n = o.rank;
66
68
  if (s < 2)
67
69
  throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);
68
70
  if (n > 2)
@@ -71,8 +73,8 @@ function N(h, t, e, i = !1) {
71
73
  const a = { logits: n === 1 ? x(o, [1, -1]) : o }, p = { numSamples: t, seed: e, normalized: i }, l = C.runKernel(I, a, p);
72
74
  return n === 1 ? x(l, [l.size]) : l;
73
75
  }
74
- const S = /* @__PURE__ */ A({ multinomial_: N }), B = [
75
- ...Array.from({ length: 95 }, (h, t) => String.fromCharCode(t + 32)),
76
+ const S = /* @__PURE__ */ A({ multinomial_: N }), H = [
77
+ ...Array.from({ length: 95 }, (m, t) => String.fromCharCode(t + 32)),
76
78
  // ASCII
77
79
  // Spanish accented letters and punctuation
78
80
  ..."áéíóúüñ¿¡",
@@ -83,10 +85,10 @@ const S = /* @__PURE__ */ A({ multinomial_: N }), B = [
83
85
  // Cyrillic letters
84
86
  ..."абвгдеёжзийклмнопрстуфхцчшщъыьэюяАБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ"
85
87
  ];
86
- function H(h, t) {
87
- return h.length === t ? h : h.length > t ? h.slice(0, t) : h.concat(Array(t - h.length).fill(""));
88
+ function U(m, t) {
89
+ return m.length === t ? m : m.length > t ? m.slice(0, t) : m.concat(Array(t - m.length).fill(""));
88
90
  }
89
- class Mt extends z {
91
+ class qt extends z {
90
92
  constructor(t, e) {
91
93
  super(), this.model = t, this.tokeniser = e, this.actualTokeniser = e;
92
94
  }
@@ -129,8 +131,8 @@ class Mt extends z {
129
131
  cache: e,
130
132
  outputEmbeddings: i?.embeddings ?? !1
131
133
  }, p = O(() => {
132
- const r = t, m = r.shape[1], u = m <= this.model.config.blockSize ? r : r.slice(
133
- [0, m - this.model.config.blockSize],
134
+ const r = t, h = r.shape[1], u = h <= this.model.config.blockSize ? r : r.slice(
135
+ [0, h - this.model.config.blockSize],
134
136
  [r.shape[0], this.model.config.blockSize]
135
137
  ), k = d ? this.model.config.blockSize - u.shape[1] : 0, b = k > 0 ? _(u, [
136
138
  [0, 0],
@@ -144,9 +146,9 @@ class Mt extends z {
144
146
  });
145
147
  let l;
146
148
  if (n) {
147
- const r = v(p), m = await r.array();
149
+ const r = v(p), h = await r.array();
148
150
  r.dispose();
149
- const u = m[0].map((c, g) => ({ prob: c, index: g })).sort((c, g) => g.prob - c.prob);
151
+ const u = h[0].map((c, g) => ({ prob: c, index: g })).sort((c, g) => g.prob - c.prob);
150
152
  let k = 0;
151
153
  const b = new Array(u.length).fill(0);
152
154
  for (const c of u)
@@ -155,16 +157,16 @@ class Mt extends z {
155
157
  const f = b.reduce((c, g) => c + g, 0), y = b.map((c) => c / f);
156
158
  l = $(y);
157
159
  } else if (s) {
158
- const { values: r, indices: m } = K(p, s), u = S(r, 1);
159
- l = q(m, u, 1), r.dispose(), m.dispose(), u.dispose();
160
+ const { values: r, indices: h } = K(p, s), u = S(r, 1);
161
+ l = q(h, u, 1), r.dispose(), h.dispose(), u.dispose();
160
162
  } else
161
163
  l = S(p, 1);
162
164
  let w;
163
165
  i?.includeProbabilities && (w = v(p)), a.embeddings && this.embeddingsData.push(
164
166
  await Promise.all(
165
167
  a.embeddings.map(async (r) => {
166
- const m = await r.array();
167
- return r.dispose(), m;
168
+ const h = await r.array();
169
+ return r.dispose(), h;
168
170
  })
169
171
  )
170
172
  );
@@ -213,7 +215,7 @@ class Mt extends z {
213
215
  s[n] = { k: void 0, v: void 0, length: 0, cumulativeLength: 0 };
214
216
  this.cache = s, this.lastToken = -1;
215
217
  }
216
- const o = this.tokeniser.trained ? this.tokeniser : new M(H(B, this.tokeniser.vocabSize));
218
+ const o = this.tokeniser.trained ? this.tokeniser : new M(U(H, this.tokeniser.vocabSize));
217
219
  this.actualTokeniser = o;
218
220
  }
219
221
  async step(t, e) {
@@ -242,5 +244,5 @@ class Mt extends z {
242
244
  }
243
245
  }
244
246
  export {
245
- Mt as default
247
+ qt as default
246
248
  };
@@ -1,10 +1,10 @@
1
- import { as as T, af as E, p as O, j as V, aA as B, a0 as F, X as j, aB as K } from "./index-CUQrfsw_.js";
2
- import { r as $ } from "./Reshape-Bo8HzP8V.js";
3
- import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-DubwyOhW.js";
4
- import { t as U, m as W } from "./shared-D1elLckx.js";
5
- import { c as _ } from "./backend_util-BJ-_jSeK.js";
6
- import { f as y } from "./gpgpu_math-TFLxaLkw.js";
7
- import { g as G, b as L } from "./kernel_funcs_utils-P9aFa232.js";
1
+ import { aq as T, ag as E, p as O, j as V, aB as B, a1 as F, ah as j, aC as K } from "./index-DdmHGZjq.js";
2
+ import { r as $ } from "./Reshape-Bh_jzKzV.js";
3
+ import { g as A, a as C, b as k, c as N, e as R } from "./axis_util-Did9235A.js";
4
+ import { t as U, m as W } from "./shared-CZiWmQCI.js";
5
+ import { c as _ } from "./backend_util-yC3YH1jo.js";
6
+ import { f as y } from "./gpgpu_math-D_ODOLix.js";
7
+ import { g as G, b as L } from "./kernel_funcs_utils-CDfFpUab.js";
8
8
  /**
9
9
  * @license
10
10
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -105,7 +105,7 @@ class w {
105
105
  * limitations under the License.
106
106
  * =============================================================================
107
107
  */
108
- class X {
108
+ class q {
109
109
  constructor(s, e) {
110
110
  this.variableNames = ["x"];
111
111
  const { windowSize: t, batchSize: n, inSize: l, outSize: r } = s;
@@ -229,7 +229,7 @@ class X {
229
229
  * limitations under the License.
230
230
  * =============================================================================
231
231
  */
232
- function q(a) {
232
+ function X(a) {
233
233
  const s = [];
234
234
  for (; s.length === 0 || s[s.length - 1].outSize !== 1; ) {
235
235
  const e = s.length ? s[s.length - 1].outSize : a[1], t = _(e);
@@ -242,12 +242,12 @@ function q(a) {
242
242
  return s;
243
243
  }
244
244
  function P(a, s, e, t) {
245
- const n = q(a.shape);
245
+ const n = X(a.shape);
246
246
  let l = a;
247
247
  for (let r = 0; r < n.length; r++) {
248
248
  const { inSize: i, windowSize: c, outSize: o } = n[r];
249
249
  let u, p;
250
- e === "mean" ? u = r === 0 ? new w({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }, i) : new w({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }) : u = new X({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }, e), p = l, l = t.runWebGLProgram(u, [l], s), p.dataId !== a.dataId && t.disposeIntermediateTensorInfo(p);
250
+ e === "mean" ? u = r === 0 ? new w({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }, i) : new w({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }) : u = new q({ windowSize: c, inSize: i, batchSize: a.shape[0], outSize: o }, e), p = l, l = t.runWebGLProgram(u, [l], s), p.dataId !== a.dataId && t.disposeIntermediateTensorInfo(p);
251
251
  }
252
252
  return l;
253
253
  }
@@ -381,7 +381,7 @@ function Q(a, s, e, t) {
381
381
  let i = r;
382
382
  const c = A(i, l), o = c != null;
383
383
  let u = a;
384
- o && (u = D(a, c, t), i = k(i.length, l)), C("sum", i, l);
384
+ o && (u = D(a, c, t), i = C(i.length, l)), k("sum", i, l);
385
385
  const [p, h] = N(u.shape, i);
386
386
  let d = p;
387
387
  e && (d = R(p, r));
@@ -465,9 +465,9 @@ function te(a) {
465
465
  M.values = z;
466
466
  } else
467
467
  d = D(n, u, e);
468
- o = k(o.length, i);
468
+ o = C(o.length, i);
469
469
  }
470
- C("max", o, i);
470
+ k("max", o, i);
471
471
  const [f, S] = N(d.shape, o);
472
472
  let g = f;
473
473
  r && (g = R(f, c));
@@ -1,4 +1,4 @@
1
- import { j as h, a4 as d, n as c, U as m } from "./index-CUQrfsw_.js";
1
+ import { j as h, a5 as d, n as c, V as m } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1,5 +1,5 @@
1
- import { j as c, a4 as C, n as f, U as R } from "./index-CUQrfsw_.js";
2
- import { u as g, g as I, a as x, b as F, c as $, d as u, e as m, i as l } from "./gpgpu_math-TFLxaLkw.js";
1
+ import { j as c, a5 as C, n as f, V as R } from "./index-DdmHGZjq.js";
2
+ import { u as g, g as I, a as x, b as F, c as $, d as u, e as m, i as l } from "./gpgpu_math-D_ODOLix.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -5,17 +5,17 @@ import u from "./Generator.js";
5
5
  import f from "./Trainer.js";
6
6
  import { E as p } from "./index-Dwqa6Zy2.js";
7
7
  import { dummyPassTrainAsync as m } from "./utilities/dummy.js";
8
- import "./index-CUQrfsw_.js";
8
+ import "./index-DdmHGZjq.js";
9
9
  import "./ops/cpu/attentionMask.js";
10
10
  import "./ops/webgl/attentionMask.js";
11
11
  import "./ops/grads/attentionMask.js";
12
12
  import "./ops/cpu/qkv.js";
13
13
  import "./ops/webgl/qkv.js";
14
14
  import "./ops/grads/qkv.js";
15
- import "./random_width-D8Pwy_na.js";
16
- import "./register_all_kernels-DUshvVWP.js";
15
+ import "./random_width-DKGeiFuR.js";
16
+ import "./register_all_kernels-Do9VvZmo.js";
17
17
  import "./index-Tf7vU29b.js";
18
- import "./dataset-CJmEGu6D.js";
18
+ import "./dataset-DPPl-iLT.js";
19
19
  import "./ops/cpu/rope.js";
20
20
  import "./ops/webgl/rope.js";
21
21
  import "./ops/grads/rope.js";
@@ -40,12 +40,14 @@ import "./papaparse.min-C8l2Kvo1.js";
40
40
  import "./jszip.min-CjP2V1VV.js";
41
41
  import "./ops/cpu/gelu.js";
42
42
  import "./ops/webgl/gelu.js";
43
- import "./gelu-Bd3UBBxg.js";
43
+ import "./gelu-BkcmEEyD.js";
44
44
  import "./ops/webgl/log.js";
45
45
  import "./ops/cpu/adamMoments.js";
46
46
  import "./ops/webgl/adamMoments.js";
47
47
  import "./ops/cpu/adamAdjust.js";
48
48
  import "./ops/webgl/adamAdjust.js";
49
+ import "./checks/normRMS.js";
50
+ import "./checks/normRMSGrad.js";
49
51
  import k from "./utilities/profile.js";
50
52
  import w from "./models/factory.js";
51
53
  class a {
@@ -1,4 +1,4 @@
1
- import { n as c } from "./index-CUQrfsw_.js";
1
+ import { n as c } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2017 Google LLC. All Rights Reserved.
package/dist/backend.js CHANGED
@@ -1,6 +1,6 @@
1
- import { g as a, s as i, r as o } from "./index-CUQrfsw_.js";
1
+ import { g as a, s as i, r as o } from "./index-DdmHGZjq.js";
2
2
  async function e(t) {
3
- a() !== t && (t === "webgpu" && (await import("./index-BaPo_0H8.js"), await import("./ops/webgpu/index.js")), await i(t), await o(), console.log(`Backend set to ${t}`));
3
+ a() !== t && (t === "webgpu" && (await import("./index-evZ57wr4.js"), await import("./ops/webgpu/index.js")), await i(t), await o(), console.log(`Backend set to ${t}`));
4
4
  }
5
5
  export {
6
6
  e as selectBackend
@@ -1,7 +1,7 @@
1
- import { j as m, a2 as O, n as g, aM as $, aN as R, aO as M, l as _, ad as y, ay as D, aP as T, u as b, aQ as F } from "./index-CUQrfsw_.js";
2
- import { b as L, d as W, f as v, c as N, e as x, g as P, a as C, h as z } from "./axis_util-DubwyOhW.js";
3
- import { S as U, a as B, b as V, c as j, d as G, e as H, f as k, g as q, h as Z, i as X, j as J, k as K, l as Q, m as Y, s as ee, n as te, o as ne, t as se } from "./selu_util-8vv5JxQV.js";
4
- import { c as re, v as oe, a as ae } from "./scatter_nd_util-CUPPNLaA.js";
1
+ import { j as m, a3 as R, n as g, aN as $, aO as O, aP as _, l as M, ae as y, ax as D, aQ as T, u as b, aR as F } from "./index-DdmHGZjq.js";
2
+ import { b as L, d as W, f as v, c as N, e as x, g as P, a as C, h as z } from "./axis_util-Did9235A.js";
3
+ import { S as U, a as B, b as V, c as j, d as G, e as H, f as k, g as q, h as Z, i as X, j as J, k as K, l as Q, m as Y, s as ee, n as te, o as ne, t as se } from "./selu_util-BgUO9gHY.js";
4
+ import { c as re, v as oe, a as ae } from "./scatter_nd_util-B7yDhiQr.js";
5
5
  function ie(e, n) {
6
6
  const r = e.shape.length, t = n.shape.length;
7
7
  if (r < 1)
@@ -24,7 +24,7 @@ function ie(e, n) {
24
24
  for (let i = o; i < r; ++i)
25
25
  h *= u[i], c.push(u[i]);
26
26
  const d = [
27
- ...O(e.shape).map((i) => i / h),
27
+ ...R(e.shape).map((i) => i / h),
28
28
  1
29
29
  ].slice(0, o);
30
30
  return [c, a, h, d];
@@ -255,7 +255,7 @@ function Se(e, n, r) {
255
255
  * limitations under the License.
256
256
  * =============================================================================
257
257
  */
258
- const we = 0.3275911, Ae = 0.254829592, Oe = -0.284496736, Re = 1.421413741, Me = -1.453152027, _e = 1.061405429;
258
+ const we = 0.3275911, Ae = 0.254829592, Re = -0.284496736, Oe = 1.421413741, _e = -1.453152027, Me = 1.061405429;
259
259
  /**
260
260
  * @license
261
261
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -593,21 +593,21 @@ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
593
593
  */
594
594
  function ot(e) {
595
595
  try {
596
- return e.map((n) => R(n));
596
+ return e.map((n) => O(n));
597
597
  } catch (n) {
598
598
  throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${n}`);
599
599
  }
600
600
  }
601
601
  function at(e) {
602
- return e.map((n) => M(n));
602
+ return e.map((n) => _(n));
603
603
  }
604
604
  const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
605
605
  __proto__: null,
606
606
  ERF_A1: Ae,
607
- ERF_A2: Oe,
608
- ERF_A3: Re,
609
- ERF_A4: Me,
610
- ERF_A5: _e,
607
+ ERF_A2: Re,
608
+ ERF_A3: Oe,
609
+ ERF_A4: _e,
610
+ ERF_A5: Me,
611
611
  ERF_P: we,
612
612
  PARALLELIZE_THRESHOLD: I,
613
613
  get RowPartitionType() {
@@ -616,7 +616,7 @@ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
616
616
  SELU_SCALE: U,
617
617
  SELU_SCALEALPHA: B,
618
618
  applyActivation: V,
619
- assertAndGetBroadcastShape: _,
619
+ assertAndGetBroadcastShape: M,
620
620
  assertAxesAreInnerMostDims: L,
621
621
  assertParamsConsistent: ue,
622
622
  assignToTypedArray: Le,
@@ -742,8 +742,8 @@ export {
742
742
  et as t,
743
743
  Ae as u,
744
744
  pe as v,
745
- Oe as w,
746
- Re as x,
747
- Me as y,
748
- _e as z
745
+ Re as w,
746
+ Oe as x,
747
+ _e as y,
748
+ Me as z
749
749
  };
@@ -1,5 +1,5 @@
1
- import { B as h, C as f, L as p, F as g, E as u, W as b } from "./index-CUQrfsw_.js";
2
- import { r as T } from "./reshape-DEfQGSin.js";
1
+ import { C as h, D as f, M as p, H as g, E as u, X as b } from "./index-DdmHGZjq.js";
2
+ import { r as T } from "./reshape-WeJkT3ja.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,22 @@
1
+ import { s, e as a } from "../index-DdmHGZjq.js";
2
+ import { t } from "../tensor4d-DLtk7Nxh.js";
3
+ async function u(e) {
4
+ await s(e);
5
+ const n = t(
6
+ [
7
+ [
8
+ [
9
+ [0.1, 0.2, 0, 0],
10
+ [0.1, 0.2, 0, 0],
11
+ [0, 0, 0, 0],
12
+ [0, 0, 0, 0]
13
+ ]
14
+ ]
15
+ ],
16
+ [1, 1, 4, 4]
17
+ ), r = t([[[[0.1, 0.2, 0.3, 0.4]]]], [1, 1, 1, 4]);
18
+ return await a().runKernel("AppendCache", { cache: n, item: r }, { maxSize: 4, pastLen: 2 }).array();
19
+ }
20
+ export {
21
+ u as execute
22
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,37 @@
1
+ import { s as i, e } from "../index-DdmHGZjq.js";
2
+ import { t } from "../tensor4d-DLtk7Nxh.js";
3
+ import { t as a } from "../tensor2d-CObBWBkW.js";
4
+ async function k(n) {
5
+ await i(n);
6
+ const s = t(
7
+ [
8
+ [
9
+ [
10
+ [0.1, 0.2, 0.3, 0.4],
11
+ [0.3, 0.4, 0.5, 0.6]
12
+ ]
13
+ ]
14
+ ],
15
+ [1, 1, 2, 4]
16
+ ), o = t(
17
+ [
18
+ [
19
+ [
20
+ [0.5, 0.6, 0.5, 0.6],
21
+ [0.7, 0.8, 0.7, 0.8]
22
+ ]
23
+ ]
24
+ ],
25
+ [1, 1, 2, 4]
26
+ ), r = a(
27
+ [
28
+ [0, -1 / 0, -1 / 0, -1 / 0],
29
+ [0, 0, 0, -1 / 0]
30
+ ],
31
+ [2, 4]
32
+ );
33
+ return await e().runKernel("AttentionMask", { q: s, k: o, mask: r }, { divisor: 0.5, pastLen: 0 }).array();
34
+ }
35
+ export {
36
+ k as execute
37
+ };
@@ -0,0 +1,9 @@
1
+ interface Result {
2
+ backend: string;
3
+ result: unknown;
4
+ error?: string;
5
+ passed: boolean;
6
+ maxError?: number;
7
+ }
8
+ export default function runCheck(check: (backend: string) => Promise<unknown>, epsilon?: number): Promise<Result[]>;
9
+ export {};
@@ -0,0 +1,20 @@
1
+ import { arraysClose as l } from "../utilities/arrayClose.js";
2
+ async function f(c, a) {
3
+ const n = ["cpu", "webgl", "webgpu"], t = [];
4
+ for (const e of n)
5
+ try {
6
+ const r = await c(e);
7
+ t.push({ backend: e, result: r, passed: !0 });
8
+ } catch (r) {
9
+ t.push({ backend: e, error: r.message, result: [], passed: !1 });
10
+ }
11
+ const s = await Promise.all(t), u = s[0].result;
12
+ for (let e = 1; e < s.length; e++) {
13
+ const r = s[e].result, o = l(u, r);
14
+ s[e].passed = o <= (a ?? 1e-6), s[e].maxError = o;
15
+ }
16
+ return s;
17
+ }
18
+ export {
19
+ f as default
20
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,18 @@
1
+ import { s as e, e as o } from "../index-DdmHGZjq.js";
2
+ import { t as s } from "../tensor2d-CObBWBkW.js";
3
+ async function m(t) {
4
+ await e(t);
5
+ const r = s(
6
+ [
7
+ [0.1, 0.2, 0, 0],
8
+ [0.1, 0.2, 0, 0],
9
+ [0, 0, 0, 0],
10
+ [0, 0, 0, 0]
11
+ ],
12
+ [4, 4]
13
+ );
14
+ return await o().runKernel("Gelu", { x: r }).array();
15
+ }
16
+ export {
17
+ m as execute
18
+ };
@@ -0,0 +1,19 @@
1
+ import { execute as rope } from './rope';
2
+ import { execute as normRMS } from './normRMS';
3
+ import { execute as qkv } from './qkv';
4
+ import { execute as gelu } from './gelu';
5
+ import { execute as normRMSGrad } from './normRMSGrad';
6
+ import { execute as appendCache } from './appendCache';
7
+ import { execute as attentionMask } from './attentionMask';
8
+ import { default as runCheck } from './check';
9
+ declare const checks: {
10
+ rope: typeof rope;
11
+ qkv: typeof qkv;
12
+ gelu: typeof gelu;
13
+ normRMS: typeof normRMS;
14
+ normRMSGrad: typeof normRMSGrad;
15
+ appendCache: typeof appendCache;
16
+ attentionMask: typeof attentionMask;
17
+ runCheck: typeof runCheck;
18
+ };
19
+ export default checks;
@@ -0,0 +1,21 @@
1
+ import { execute as e } from "./rope.js";
2
+ import { execute as t } from "./normRMS.js";
3
+ import { execute as o } from "./qkv.js";
4
+ import { execute as r } from "./gelu.js";
5
+ import { execute as c } from "./normRMSGrad.js";
6
+ import { execute as m } from "./appendCache.js";
7
+ import { execute as u } from "./attentionMask.js";
8
+ import x from "./check.js";
9
+ const d = {
10
+ rope: e,
11
+ qkv: o,
12
+ gelu: r,
13
+ normRMS: t,
14
+ normRMSGrad: c,
15
+ appendCache: m,
16
+ attentionMask: u,
17
+ runCheck: x
18
+ };
19
+ export {
20
+ d as default
21
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<(number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][])[]>;
@@ -0,0 +1,16 @@
1
+ import { s as u, y as A, e as y } from "../index-DdmHGZjq.js";
2
+ import { a as h } from "../ops-542ai2vG.js";
3
+ import { t as p } from "../tensor1d-CtJq5BOv.js";
4
+ import { t as a } from "../tensor-DbqgIV9B.js";
5
+ const w = Array.from({ length: 2048 * 192 }, () => Math.random()), x = Array.from({ length: 192 }, () => Math.random()), M = Array.from({ length: 2048 * 192 }, () => Math.random());
6
+ async function k(t) {
7
+ await u(t);
8
+ const o = p(x, "float32"), n = a(w, [16, 128, 192], "float32"), s = a(M, [16, 128, 192], "float32"), e = (d, g) => {
9
+ const i = y().runKernel("RMSNorm", { x: d, gamma: g });
10
+ return h.meanSquaredError(i, s);
11
+ }, { value: m, grads: r } = A(e)([n, o]), c = await m.array(), f = await r[0].array(), l = await r[1].array();
12
+ return [c, f, l];
13
+ }
14
+ export {
15
+ k as execute
16
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<(number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][])[]>;
@@ -0,0 +1,12 @@
1
+ import { s as c, e as d } from "../index-DdmHGZjq.js";
2
+ import { t as f } from "../tensor1d-CtJq5BOv.js";
3
+ import { t as r } from "../tensor-DbqgIV9B.js";
4
+ const y = Array.from({ length: 2048 * 192 }, () => Math.random()), i = Array.from({ length: 192 }, () => Math.random()), l = Array.from({ length: 2048 * 192 }, () => Math.random());
5
+ async function x(t) {
6
+ await c(t);
7
+ const o = f(i, "float32"), n = r(y, [16, 128, 192], "float32"), m = r(l, [16, 128, 192], "float32"), a = d().runKernel("RMSNormGrad", { x: n, gamma: o, dy: m }), s = await a[0].array(), e = await a[1].array();
8
+ return [s, e];
9
+ }
10
+ export {
11
+ x as execute
12
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<(number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][])[]>;
@@ -0,0 +1,25 @@
1
+ import { s as c, e as m } from "../index-DdmHGZjq.js";
2
+ import { t as i } from "../tensor3d-BOukqWwr.js";
3
+ import { t as u } from "../tensor2d-CObBWBkW.js";
4
+ async function w(a) {
5
+ await c(a);
6
+ const o = i(
7
+ [
8
+ [
9
+ [0.1, 0.2],
10
+ [0.3, 0.4]
11
+ ]
12
+ ],
13
+ [1, 2, 2]
14
+ ), r = u(
15
+ [
16
+ [0.5, 0.6, 0.9, 1, 1.3, 1.4],
17
+ [0.7, 0.8, 1.1, 1.2, 1.5, 1.6]
18
+ ],
19
+ [2, 6]
20
+ ), t = m().runKernel("QKV", { x: o, kernel: r }, { heads: 1 }), s = await t[0].array(), n = await t[1].array(), e = await t[2].array();
21
+ return [s, n, e];
22
+ }
23
+ export {
24
+ w as execute
25
+ };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][] | Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>[]>;
@@ -0,0 +1,21 @@
1
+ import { s as c, e as i } from "../index-DdmHGZjq.js";
2
+ import { t as m } from "../tensor4d-DLtk7Nxh.js";
3
+ import { t } from "../tensor3d-BOukqWwr.js";
4
+ async function y(n) {
5
+ await c(n);
6
+ const s = m(
7
+ [
8
+ [
9
+ [
10
+ [0.1, 0.2],
11
+ [0.3, 0.4]
12
+ ]
13
+ ]
14
+ ],
15
+ [1, 1, 2, 2]
16
+ ), e = t([0.5, 0.6], [2, 1, 1]), o = t([0.9, 1], [2, 1, 1]), r = i().runKernel("Rope", { x: s, sin: e, cos: o }, { pastLen: 0 });
17
+ return Array.isArray(r) ? r.map((a) => a.array()) : r.array();
18
+ }
19
+ export {
20
+ y as execute
21
+ };
@@ -1,4 +1,4 @@
1
- import { B as s, n as a, D as p, F as i, E as l, H as f } from "./index-CUQrfsw_.js";
1
+ import { C as s, n as a, F as p, H as i, E as l, I as f } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.