@genai-fi/nanogpt 0.7.0 → 0.7.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 (152) hide show
  1. package/dist/Generator.js +13 -9
  2. package/dist/NanoGPTModel.js +10 -10
  3. package/dist/{RealDiv-C4hOvYOZ.js → RealDiv-CVYNbZxu.js} +11 -11
  4. package/dist/{Reshape-BLijOA8h.js → Reshape-CEsEp0AI.js} +2 -2
  5. package/dist/Reshape-Do18N3gO.js +30 -0
  6. package/dist/TeachableLLM.js +9 -5
  7. package/dist/{TiedEmbedding-BLltddza.js → TiedEmbedding-ccLBFiZi.js} +4 -4
  8. package/dist/{axis_util-DaAl5MER.js → axis_util-5DTW2tFV.js} +1 -1
  9. package/dist/backend.js +2 -2
  10. package/dist/{backend_util-DWiwsi2N.js → backend_util-C9Ut8n0Q.js} +40 -40
  11. package/dist/{broadcast_to-C4v-j9yA.js → broadcast_to-Ba9h_8DO.js} +2 -2
  12. package/dist/{concat-CsHeR4zV.js → concat-CbXTetof.js} +1 -1
  13. package/dist/{dataset-JDyjG3QR.js → dataset-U3PrjwgU.js} +7 -7
  14. package/dist/{dropout-hpDwECTe.js → dropout-DPfPgWWe.js} +11 -11
  15. package/dist/{gather-D0_gPiBz.js → gather-Bbh8DHhM.js} +4 -4
  16. package/dist/{gelu-uyHP1x1f.js → gelu-BFwVnd1r.js} +1 -1
  17. package/dist/{gpgpu_math-DJm3ZTAf.js → gpgpu_math-DffelNS-.js} +2 -2
  18. package/dist/{index-BPPzKVdR.js → index-DYD_yPa-.js} +1083 -1106
  19. package/dist/{index-C0dhsYom.js → index-UdZhlibC.js} +126 -126
  20. package/dist/{kernel_funcs_utils-CwRTFqrc.js → kernel_funcs_utils-CXDy3EN7.js} +3 -3
  21. package/dist/layers/BaseLayer.js +2 -2
  22. package/dist/layers/CausalSelfAttention.js +8 -8
  23. package/dist/layers/MLP.js +5 -5
  24. package/dist/layers/RMSNorm.js +3 -3
  25. package/dist/layers/RoPECache.js +4 -4
  26. package/dist/layers/TiedEmbedding.js +5 -5
  27. package/dist/layers/TransformerBlock.js +1 -1
  28. package/dist/loader/loadTransformers.js +1 -1
  29. package/dist/loader/oldZipLoad.js +11 -7
  30. package/dist/{log_sum_exp-D086OgZJ.js → log_sum_exp-BnmCkHWl.js} +8 -8
  31. package/dist/main.d.ts +11 -0
  32. package/dist/main.js +44 -27
  33. package/dist/{mat_mul-1nwdPkQ_.js → mat_mul-dwmZz69e.js} +1 -1
  34. package/dist/{max-BQc2Aj-I.js → max-ByjEGoFx.js} +3 -3
  35. package/dist/{mulmat_packed_gpu-Gzf3I9UV.js → mulmat_packed_gpu-IGPBp6h9.js} +1 -1
  36. package/dist/{ones-D63HpSF_.js → ones-C8Mfln6-.js} +2 -2
  37. package/dist/ops/adamAdjust.d.ts +2 -0
  38. package/dist/ops/adamAdjust.js +9 -0
  39. package/dist/ops/adamMoments.d.ts +2 -0
  40. package/dist/ops/adamMoments.js +9 -0
  41. package/dist/ops/appendCache.js +3 -3
  42. package/dist/ops/attentionMask.js +1 -1
  43. package/dist/ops/cpu/adamAdjust.d.ts +1 -0
  44. package/dist/ops/cpu/adamAdjust.js +18 -0
  45. package/dist/ops/cpu/adamMoments.d.ts +1 -0
  46. package/dist/ops/cpu/adamMoments.js +16 -0
  47. package/dist/ops/cpu/appendCache.js +2 -2
  48. package/dist/ops/cpu/attentionMask.js +5 -5
  49. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  50. package/dist/ops/cpu/gatherSub.js +3 -3
  51. package/dist/ops/cpu/gelu.js +1 -1
  52. package/dist/ops/cpu/matMulGelu.js +2 -2
  53. package/dist/ops/cpu/matMulMul.js +1 -1
  54. package/dist/ops/cpu/mulDropout.js +1 -1
  55. package/dist/ops/cpu/normRMS.js +1 -1
  56. package/dist/ops/cpu/qkv.js +3 -3
  57. package/dist/ops/cpu/rope.js +5 -5
  58. package/dist/ops/cpu/scatterSub.js +11 -11
  59. package/dist/ops/fusedSoftmax.js +1 -1
  60. package/dist/ops/gatherSub.js +1 -1
  61. package/dist/ops/gelu.js +2 -2
  62. package/dist/ops/grads/attentionMask.js +1 -1
  63. package/dist/ops/grads/fusedSoftmax.js +2 -2
  64. package/dist/ops/grads/gelu.js +2 -2
  65. package/dist/ops/grads/matMulGelu.js +1 -1
  66. package/dist/ops/grads/normRMS.js +1 -1
  67. package/dist/ops/grads/qkv.js +1 -1
  68. package/dist/ops/grads/rope.js +1 -1
  69. package/dist/ops/matMulGelu.js +1 -1
  70. package/dist/ops/matMulMul.js +1 -1
  71. package/dist/ops/mulDrop.js +1 -1
  72. package/dist/ops/normRMS.js +1 -1
  73. package/dist/ops/qkv.js +1 -1
  74. package/dist/ops/rope.js +4 -4
  75. package/dist/ops/scatterSub.js +1 -1
  76. package/dist/ops/webgl/adamAdjust.d.ts +1 -0
  77. package/dist/ops/webgl/adamAdjust.js +50 -0
  78. package/dist/ops/webgl/adamMoments.d.ts +1 -0
  79. package/dist/ops/webgl/adamMoments.js +38 -0
  80. package/dist/ops/webgl/appendCache.js +1 -1
  81. package/dist/ops/webgl/attentionMask.js +1 -1
  82. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  83. package/dist/ops/webgl/gatherSub.js +8 -8
  84. package/dist/ops/webgl/gelu.js +2 -2
  85. package/dist/ops/webgl/log.js +3 -3
  86. package/dist/ops/webgl/matMulGelu.js +4 -4
  87. package/dist/ops/webgl/matMulMul.js +1 -1
  88. package/dist/ops/webgl/mulDropout.js +1 -1
  89. package/dist/ops/webgl/normRMS.js +2 -2
  90. package/dist/ops/webgl/qkv.js +1 -1
  91. package/dist/ops/webgl/rope.js +1 -1
  92. package/dist/ops/webgl/scatterSub.js +1 -1
  93. package/dist/ops/webgpu/adamAdjust.d.ts +1 -0
  94. package/dist/ops/webgpu/adamAdjust.js +52 -0
  95. package/dist/ops/webgpu/adamMoments.d.ts +1 -0
  96. package/dist/ops/webgpu/adamMoments.js +51 -0
  97. package/dist/ops/webgpu/appendCache.js +13 -12
  98. package/dist/ops/webgpu/attentionMask.js +11 -10
  99. package/dist/ops/webgpu/gatherSub.js +26 -11
  100. package/dist/ops/webgpu/gelu.js +7 -6
  101. package/dist/ops/webgpu/index.js +3 -0
  102. package/dist/ops/webgpu/normRMS.js +27 -101
  103. package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
  104. package/dist/ops/webgpu/normRMSGrad.js +128 -0
  105. package/dist/ops/webgpu/qkv.js +9 -8
  106. package/dist/ops/webgpu/rope.js +8 -7
  107. package/dist/ops/webgpu/scatterSub.js +8 -7
  108. package/dist/ops/webgpu/utils/reductions.d.ts +9 -0
  109. package/dist/ops/webgpu/utils/reductions.js +68 -0
  110. package/dist/{ops-CIQLNshk.js → ops-aRTXR2Sr.js} +195 -219
  111. package/dist/{random_width-DkYP8W8N.js → random_width-DbSpgl4o.js} +22 -21
  112. package/dist/{range-CYzpQY53.js → range-D9CZhVlR.js} +1 -1
  113. package/dist/{reciprocal-_A9yv27J.js → reciprocal-CGB48wZB.js} +1 -1
  114. package/dist/{register_all_kernels-guvSxp7M.js → register_all_kernels-DnbAyBXt.js} +30 -29
  115. package/dist/{reshape-BMUzc1UY.js → reshape-BR0eoLYN.js} +3 -3
  116. package/dist/{scatter_nd_util-IRBqKz_b.js → scatter_nd_util-OjyAxku2.js} +1 -1
  117. package/dist/{selu_util-Dt_iuXaq.js → selu_util-Ce6pu9IM.js} +41 -41
  118. package/dist/{shared-CDu9S76h.js → shared-Czipaeb6.js} +6 -6
  119. package/dist/{shared-BNa2q6jD.js → shared-DS5waSIY.js} +1 -1
  120. package/dist/{sin-Cocju-BY.js → sin-CiBxrDqX.js} +6 -6
  121. package/dist/slice-BHbDHObE.js +28 -0
  122. package/dist/{softmax-GPNK3o-U.js → softmax-JMEIUo2J.js} +3 -3
  123. package/dist/{split-CHzJjxDv.js → split-CRU0PjVV.js} +1 -1
  124. package/dist/{stack-Dpgg_1W1.js → stack-ikk2Y8_P.js} +1 -1
  125. package/dist/{sum-B8wEpKsg.js → sum-NLYbiDag.js} +3 -3
  126. package/dist/{tensor-RvZVNmg0.js → tensor-Do9PKbIE.js} +1 -1
  127. package/dist/{tensor2d-B_kyod7_.js → tensor2d-CWHxHpLh.js} +1 -1
  128. package/dist/training/Adam.d.ts +22 -0
  129. package/dist/training/Adam.js +93 -0
  130. package/dist/training/AdamExt.d.ts +1 -1
  131. package/dist/training/AdamExt.js +13 -12
  132. package/dist/training/DatasetBuilder.js +2 -2
  133. package/dist/training/FullTrainer.js +22 -22
  134. package/dist/training/Trainer.d.ts +1 -1
  135. package/dist/training/Trainer.js +32 -32
  136. package/dist/training/sparseCrossEntropy.d.ts +0 -4
  137. package/dist/training/sparseCrossEntropy.js +7 -7
  138. package/dist/utilities/arrayClose.d.ts +1 -0
  139. package/dist/utilities/arrayClose.js +11 -0
  140. package/dist/utilities/dummy.js +2 -2
  141. package/dist/utilities/generate.js +3 -3
  142. package/dist/utilities/multinomialCPU.js +2 -2
  143. package/dist/utilities/performance.d.ts +1 -1
  144. package/dist/utilities/performance.js +11 -11
  145. package/dist/utilities/profile.js +1 -1
  146. package/dist/utilities/safetensors.js +2 -2
  147. package/dist/utilities/weights.js +2 -2
  148. package/dist/{variable-DXEUOwew.js → variable-BTBkayv_.js} +1 -1
  149. package/dist/{webgpu_util-g13LvDIv.js → webgpu_program-WaoMq-WD.js} +138 -215
  150. package/dist/webgpu_util-DhSeP4b6.js +80 -0
  151. package/dist/{zeros-DCPCdFGq.js → zeros-DnPT2nD4.js} +4 -4
  152. package/package.json +1 -1
package/dist/Generator.js CHANGED
@@ -1,15 +1,15 @@
1
1
  import { E as u } from "./index-Dwqa6Zy2.js";
2
- import "./index-C0dhsYom.js";
2
+ import "./index-UdZhlibC.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 "./random_width-DkYP8W8N.js";
10
- import "./register_all_kernels-guvSxp7M.js";
9
+ import "./random_width-DbSpgl4o.js";
10
+ import "./register_all_kernels-DnbAyBXt.js";
11
11
  import "./index-Tf7vU29b.js";
12
- import "./dataset-JDyjG3QR.js";
12
+ import "./dataset-U3PrjwgU.js";
13
13
  import "./ops/cpu/rope.js";
14
14
  import "./ops/webgl/rope.js";
15
15
  import "./ops/grads/rope.js";
@@ -30,13 +30,17 @@ import "./ops/cpu/scatterSub.js";
30
30
  import "./ops/webgl/scatterSub.js";
31
31
  import "./jszip.min-CjP2V1VV.js";
32
32
  import f from "./tokeniser/CharTokeniser.js";
33
+ import "./ops/cpu/adamAdjust.js";
34
+ import "./ops/webgl/adamAdjust.js";
35
+ import "./ops/cpu/adamMoments.js";
36
+ import "./ops/webgl/adamMoments.js";
33
37
  import "./papaparse.min-C8l2Kvo1.js";
34
38
  import "./ops/cpu/gelu.js";
35
39
  import "./ops/webgl/gelu.js";
36
- import "./gelu-uyHP1x1f.js";
40
+ import "./gelu-BFwVnd1r.js";
37
41
  import "./ops/webgl/log.js";
38
- import { t as d } from "./tensor2d-B_kyod7_.js";
39
- import { c as g } from "./concat-CsHeR4zV.js";
42
+ import { t as d } from "./tensor2d-CWHxHpLh.js";
43
+ import { c as g } from "./concat-CbXTetof.js";
40
44
  const k = [
41
45
  ...Array.from({ length: 95 }, (a, t) => String.fromCharCode(t + 32)),
42
46
  // ASCII
@@ -52,7 +56,7 @@ const k = [
52
56
  function w(a, t) {
53
57
  return a.length === t ? a : a.length > t ? a.slice(0, t) : a.concat(Array(t - a.length).fill(""));
54
58
  }
55
- class rt extends u {
59
+ class pt extends u {
56
60
  constructor(t, o) {
57
61
  super(), this.model = t, this.tokeniser = o;
58
62
  }
@@ -124,5 +128,5 @@ class rt extends u {
124
128
  }
125
129
  }
126
130
  export {
127
- rt as default
131
+ pt as default
128
132
  };
@@ -1,19 +1,19 @@
1
1
  import { defaultConfig as M } from "./config.js";
2
2
  import v from "./layers/TransformerBlock.js";
3
- import { T as x, r as T } from "./TiedEmbedding-BLltddza.js";
3
+ import { T as x, r as T } from "./TiedEmbedding-ccLBFiZi.js";
4
4
  import F from "./layers/RoPECache.js";
5
5
  import O from "./layers/RMSNorm.js";
6
6
  import { estimateParameterCount as _ } from "./utilities/parameters.js";
7
7
  import { createSoftmaxCrossEntropyWithGrad as D } from "./training/sparseCrossEntropy.js";
8
8
  import K from "./layers/BaseLayer.js";
9
- import { E as N, D as R, p as q } from "./random_width-DkYP8W8N.js";
10
- import { x as A, y as G, E as B, a5 as V, t as C, a6 as j, b as z, o as U } from "./index-C0dhsYom.js";
9
+ import { E as N, D as R, p as q } from "./random_width-DbSpgl4o.js";
10
+ import { B as A, C as B, E as G, ad as V, t as C, o as j, b as z, w as U } from "./index-UdZhlibC.js";
11
11
  import W from "./utilities/multinomialCPU.js";
12
- import { m as H, t as J } from "./register_all_kernels-guvSxp7M.js";
13
- import { r as P } from "./reshape-BMUzc1UY.js";
14
- import { r as Q } from "./range-CYzpQY53.js";
15
- import { s as $ } from "./softmax-GPNK3o-U.js";
16
- import { g as X } from "./gather-D0_gPiBz.js";
12
+ import { m as H, t as J } from "./register_all_kernels-DnbAyBXt.js";
13
+ import { r as P } from "./reshape-BR0eoLYN.js";
14
+ import { r as Q } from "./range-D9CZhVlR.js";
15
+ import { s as $ } from "./softmax-JMEIUo2J.js";
16
+ import { g as X } from "./gather-Bbh8DHhM.js";
17
17
  /**
18
18
  * @license
19
19
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -31,13 +31,13 @@ import { g as X } from "./gather-D0_gPiBz.js";
31
31
  * =============================================================================
32
32
  */
33
33
  function Y(u, t, o, e = !1) {
34
- const l = G(u, "logits", "multinomial"), s = l.size, r = l.rank;
34
+ const l = B(u, "logits", "multinomial"), s = l.size, r = l.rank;
35
35
  if (s < 2)
36
36
  throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${s}.`);
37
37
  if (r > 2)
38
38
  throw new Error(`Rank of probabilities must be 1 or 2, but is ${r}`);
39
39
  o = o || Math.random();
40
- const n = { logits: r === 1 ? P(l, [1, -1]) : l }, a = { numSamples: t, seed: o, normalized: e }, i = B.runKernel(V, n, a);
40
+ const n = { logits: r === 1 ? P(l, [1, -1]) : l }, a = { numSamples: t, seed: o, normalized: e }, i = G.runKernel(V, n, a);
41
41
  return r === 1 ? P(i, [i.size]) : i;
42
42
  }
43
43
  const I = /* @__PURE__ */ A({ multinomial_: Y });
@@ -1,10 +1,10 @@
1
- import { ao as T, ac as E, p as O, j as V, aw as B, U as F, N as U, ax as j } from "./index-C0dhsYom.js";
2
- import { r as $ } from "./Reshape-BLijOA8h.js";
3
- import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-DaAl5MER.js";
4
- import { t as K, m as W } from "./shared-BNa2q6jD.js";
5
- import { c as _ } from "./backend_util-DWiwsi2N.js";
6
- import { f as y } from "./gpgpu_math-DJm3ZTAf.js";
7
- import { g as G, b as L } from "./kernel_funcs_utils-CwRTFqrc.js";
1
+ import { aq as T, ac as E, p as O, j as V, ay as B, Y as F, U, az as j } from "./index-UdZhlibC.js";
2
+ import { r as $ } from "./Reshape-CEsEp0AI.js";
3
+ import { g as A, a as k, b as C, c as N, e as R } from "./axis_util-5DTW2tFV.js";
4
+ import { t as K, m as W } from "./shared-DS5waSIY.js";
5
+ import { c as _ } from "./backend_util-C9Ut8n0Q.js";
6
+ import { f as y } from "./gpgpu_math-DffelNS-.js";
7
+ import { g as G, b as L } from "./kernel_funcs_utils-CXDy3EN7.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
  }
@@ -1,5 +1,5 @@
1
- import { j as c, a9 as C, l as f, I as R } from "./index-C0dhsYom.js";
2
- import { u as g, g as I, a as x, b as F, c as $, d as u, e as l, i as m } from "./gpgpu_math-DJm3ZTAf.js";
1
+ import { j as c, a2 as C, l as f, K as R } from "./index-UdZhlibC.js";
2
+ import { u as g, g as I, a as x, b as F, c as $, d as u, e as l, i as m } from "./gpgpu_math-DffelNS-.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -0,0 +1,30 @@
1
+ import { j as h, a2 as d, l as c, K as m } from "./index-UdZhlibC.js";
2
+ /**
3
+ * @license
4
+ * Copyright 2021 Google LLC. All Rights Reserved.
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ * =============================================================================
17
+ */
18
+ function i(n) {
19
+ const { inputs: p, attrs: o } = n, { x: e } = p, { shape: r } = o, a = h(e.shape), s = d(r, a), t = h(s);
20
+ return c(a === t, () => `The new shape (${s}) has ${t} elements and the old shape (${e.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`), n.backend.incRef(e.dataId), { dataId: e.dataId, shape: s, dtype: e.dtype };
21
+ }
22
+ const u = {
23
+ kernelName: m,
24
+ backendName: "webgpu",
25
+ kernelFunc: i
26
+ };
27
+ export {
28
+ u as a,
29
+ i as r
30
+ };
@@ -11,7 +11,7 @@ import k from "./tokeniser/bpe.js";
11
11
  import "./papaparse.min-C8l2Kvo1.js";
12
12
  import "./index-Tf7vU29b.js";
13
13
  import "./jszip.min-CjP2V1VV.js";
14
- import "./index-C0dhsYom.js";
14
+ import "./index-UdZhlibC.js";
15
15
  import "./ops/cpu/scatterSub.js";
16
16
  import "./ops/webgl/scatterSub.js";
17
17
  import "./ops/cpu/gatherSub.js";
@@ -22,9 +22,9 @@ import "./ops/grads/attentionMask.js";
22
22
  import "./ops/cpu/qkv.js";
23
23
  import "./ops/webgl/qkv.js";
24
24
  import "./ops/grads/qkv.js";
25
- import "./random_width-DkYP8W8N.js";
26
- import "./register_all_kernels-guvSxp7M.js";
27
- import "./dataset-JDyjG3QR.js";
25
+ import "./random_width-DbSpgl4o.js";
26
+ import "./register_all_kernels-DnbAyBXt.js";
27
+ import "./dataset-U3PrjwgU.js";
28
28
  import "./ops/cpu/rope.js";
29
29
  import "./ops/webgl/rope.js";
30
30
  import "./ops/grads/rope.js";
@@ -38,11 +38,15 @@ import "./ops/webgl/matMulGelu.js";
38
38
  import "./ops/grads/matMulGelu.js";
39
39
  import "./ops/cpu/gelu.js";
40
40
  import "./ops/webgl/gelu.js";
41
- import "./gelu-uyHP1x1f.js";
41
+ import "./gelu-BFwVnd1r.js";
42
42
  import "./ops/cpu/normRMS.js";
43
43
  import "./ops/webgl/normRMS.js";
44
44
  import "./ops/grads/normRMS.js";
45
45
  import "./ops/webgl/log.js";
46
+ import "./ops/cpu/adamMoments.js";
47
+ import "./ops/webgl/adamMoments.js";
48
+ import "./ops/cpu/adamAdjust.js";
49
+ import "./ops/webgl/adamAdjust.js";
46
50
  import w from "./utilities/profile.js";
47
51
  class a {
48
52
  ee = new g();
@@ -1,8 +1,8 @@
1
- import { R as a, d as s } from "./random_width-DkYP8W8N.js";
2
- import "./index-C0dhsYom.js";
1
+ import { R as a, d as s } from "./random_width-DbSpgl4o.js";
2
+ import "./index-UdZhlibC.js";
3
3
  import o from "./layers/BaseLayer.js";
4
- import { v as m } from "./variable-DXEUOwew.js";
5
- import { g as d } from "./gather-D0_gPiBz.js";
4
+ import { v as m } from "./variable-BTBkayv_.js";
5
+ import { g as d } from "./gather-Bbh8DHhM.js";
6
6
  /**
7
7
  * @license
8
8
  * Copyright 2018 Google LLC
@@ -1,4 +1,4 @@
1
- import { l as c } from "./index-C0dhsYom.js";
1
+ import { l as c } from "./index-UdZhlibC.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-C0dhsYom.js";
1
+ import { g as a, s as i, r as o } from "./index-UdZhlibC.js";
2
2
  async function e(t) {
3
- a() !== t && (t === "webgpu" && (await import("./index-BPPzKVdR.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-DYD_yPa-.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, Z as R, l as g, aI as $, aJ as O, aK as M, k as _, aa as y, au as D, aL as T, u as b, aM as F } from "./index-C0dhsYom.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-DaAl5MER.js";
3
- import { S as U, a as B, b as V, c as j, d as k, e as G, f as H, g as Z, h as q, i as J, j as K, k as X, l as Y, m as Q, s as ee, n as te, o as ne, t as se } from "./selu_util-Dt_iuXaq.js";
4
- import { c as re, v as oe, a as ae } from "./scatter_nd_util-IRBqKz_b.js";
1
+ import { j as m, a1 as O, l as g, aK as $, aL as R, aM as M, k as _, aa as y, aw as D, aN as T, u as b, aO as F } from "./index-UdZhlibC.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-5DTW2tFV.js";
3
+ import { S as U, a as B, b as V, c as j, d as k, e as G, f as H, g as q, h as Z, i as K, j as X, k as J, l as Y, m as Q, s as ee, n as te, o as ne, t as se } from "./selu_util-Ce6pu9IM.js";
4
+ import { c as re, v as oe, a as ae } from "./scatter_nd_util-OjyAxku2.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
- ...R(e.shape).map((i) => i / h),
27
+ ...O(e.shape).map((i) => i / h),
28
28
  1
29
29
  ].slice(0, o);
30
30
  return [c, a, h, d];
@@ -233,7 +233,7 @@ function Ie(e, n) {
233
233
  r.push(e[t][0]);
234
234
  return r;
235
235
  }
236
- function Se(e, n, r) {
236
+ function we(e, n, r) {
237
237
  const t = e.slice(0, 1);
238
238
  for (let s = 0; s < r; ++s)
239
239
  t.push(e[s + 1] - n[s][0] - n[s][1]);
@@ -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, Re = -0.284496736, Oe = 1.421413741, Me = -1.453152027, _e = 1.061405429;
258
+ const Se = 0.3275911, Ae = 0.254829592, Oe = -0.284496736, Re = 1.421413741, Me = -1.453152027, _e = 1.061405429;
259
259
  /**
260
260
  * @license
261
261
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -333,7 +333,7 @@ function ve(e, n, r) {
333
333
  * limitations under the License.
334
334
  * =============================================================================
335
335
  */
336
- const E = "->", Ne = /->/g, S = ",", w = "...";
336
+ const E = "->", Ne = /->/g, w = ",", S = "...";
337
337
  function xe(e, n) {
338
338
  e = e.replace(/\s/g, "");
339
339
  const r = (e.length - e.replace(Ne, "").length) / E.length;
@@ -342,8 +342,8 @@ function xe(e, n) {
342
342
  if (r > 1)
343
343
  throw new Error(`Equation must contain exactly one arrow ("${E}").`);
344
344
  const [t, s] = e.split(E);
345
- g(t.indexOf(w) === -1, () => `The ellipsis notation ("${w}") is not supported yet.`);
346
- const o = t.split(S), a = o.length;
345
+ g(t.indexOf(S) === -1, () => `The ellipsis notation ("${S}") is not supported yet.`);
346
+ const o = t.split(w), a = o.length;
347
347
  if (n !== a)
348
348
  throw new Error(`Expected ${a} input tensors, received ${n}`);
349
349
  if (a > 2)
@@ -357,7 +357,7 @@ function xe(e, n) {
357
357
  }
358
358
  for (let l = 0; l < t.length; ++l) {
359
359
  const f = t[l];
360
- u.indexOf(f) === -1 && f !== S && u.push(f);
360
+ u.indexOf(f) === -1 && f !== w && u.push(f);
361
361
  }
362
362
  const c = new Array(o.length);
363
363
  for (let l = 0; l < a; ++l) {
@@ -474,18 +474,18 @@ function Ge(e, n, r) {
474
474
  function He(e, n) {
475
475
  return `only one output dimension may be -1, not both ${e} and ${n}`;
476
476
  }
477
- function Ze(e, n) {
477
+ function qe(e, n) {
478
478
  return `size ${e} must be non-negative, not ${n}`;
479
479
  }
480
- function qe() {
480
+ function Ze() {
481
481
  return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
482
482
  }
483
- function Je(e, n) {
483
+ function Ke(e, n) {
484
484
  const r = m(e), t = m(n);
485
485
  return `Input to reshape is a SparseTensor with ${r}
486
486
  dense values, but the requested shape requires a multiple of ${t}. inputShape=${e} outputShape= ${n}`;
487
487
  }
488
- function Ke(e, n) {
488
+ function Xe(e, n) {
489
489
  const r = m(e), t = m(n);
490
490
  return `Input to reshape is a tensor with ${r} dense values, but the requested shape has ${t}. inputShape=${e} outputShape=${n}`;
491
491
  }
@@ -505,7 +505,7 @@ function Ke(e, n) {
505
505
  * limitations under the License.
506
506
  * =============================================================================
507
507
  */
508
- function Xe() {
508
+ function Je() {
509
509
  return "segment ids must be >= 0";
510
510
  }
511
511
  function Ye() {
@@ -593,7 +593,7 @@ const rt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
593
593
  */
594
594
  function ot(e) {
595
595
  try {
596
- return e.map((n) => O(n));
596
+ return e.map((n) => R(n));
597
597
  } catch (n) {
598
598
  throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${n}`);
599
599
  }
@@ -604,11 +604,11 @@ function at(e) {
604
604
  const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
605
605
  __proto__: null,
606
606
  ERF_A1: Ae,
607
- ERF_A2: Re,
608
- ERF_A3: Oe,
607
+ ERF_A2: Oe,
608
+ ERF_A3: Re,
609
609
  ERF_A4: Me,
610
610
  ERF_A5: _e,
611
- ERF_P: we,
611
+ ERF_P: Se,
612
612
  PARALLELIZE_THRESHOLD: I,
613
613
  get RowPartitionType() {
614
614
  return p;
@@ -631,15 +631,15 @@ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
631
631
  computeConv2DInfo: k,
632
632
  computeConv3DInfo: G,
633
633
  computeDefaultPad: H,
634
- computeDilation2DInfo: Z,
634
+ computeDilation2DInfo: q,
635
635
  computeOptimalWindowSize: ge,
636
636
  computeOutAndReduceShapes: N,
637
637
  computeOutShape: le,
638
- computePool2DInfo: q,
639
- computePool3DInfo: J,
640
- convertConv2DDataFormat: K,
638
+ computePool2DInfo: Z,
639
+ computePool3DInfo: K,
640
+ convertConv2DDataFormat: X,
641
641
  decodeEinsumEquation: xe,
642
- eitherStridesOrDilationsAreOne: X,
642
+ eitherStridesOrDilationsAreOne: J,
643
643
  expandShapeToKeepDim: x,
644
644
  exponent: ve,
645
645
  exponents: We,
@@ -661,17 +661,17 @@ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
661
661
  getReshapedPermuted: $e,
662
662
  getRowPartitionTypesHelper: he,
663
663
  getSliceBeginCoords: Ie,
664
- getSliceSize: Se,
664
+ getSliceSize: we,
665
665
  getSparseFillEmptyRowsIndicesDenseShapeMismatch: je,
666
666
  getSparseFillEmptyRowsNegativeIndexErrorMessage: ke,
667
667
  getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: Ge,
668
- getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: qe,
669
- getSparseReshapeInputOutputMismatchErrorMessage: Ke,
670
- getSparseReshapeInputOutputMultipleErrorMessage: Je,
668
+ getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: Ze,
669
+ getSparseReshapeInputOutputMismatchErrorMessage: Xe,
670
+ getSparseReshapeInputOutputMultipleErrorMessage: Ke,
671
671
  getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: He,
672
- getSparseReshapeNegativeOutputDimErrorMessage: Ze,
672
+ getSparseReshapeNegativeOutputDimErrorMessage: qe,
673
673
  getSparseSegmentReductionIndicesOutOfRangeErrorMessage: et,
674
- getSparseSegmentReductionNegativeSegmentIdsErrorMessage: Xe,
674
+ getSparseSegmentReductionNegativeSegmentIdsErrorMessage: Je,
675
675
  getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: Ye,
676
676
  getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: Qe,
677
677
  getUndoAxesPermutation: z,
@@ -697,8 +697,8 @@ export {
697
697
  Ee as B,
698
698
  $e as C,
699
699
  Ie as D,
700
- we as E,
701
- Se as F,
700
+ Se as E,
701
+ we as F,
702
702
  le as G,
703
703
  ue as H,
704
704
  xe as I,
@@ -731,19 +731,19 @@ export {
731
731
  ke as i,
732
732
  Ge as j,
733
733
  He as k,
734
- Ze as l,
734
+ qe as l,
735
735
  ye as m,
736
- qe as n,
737
- Je as o,
738
- Ke as p,
739
- Xe as q,
736
+ Ze as n,
737
+ Ke as o,
738
+ Xe as p,
739
+ Je as q,
740
740
  Ye as r,
741
741
  Qe as s,
742
742
  et as t,
743
743
  Ae as u,
744
744
  pe as v,
745
- Re as w,
746
- Oe as x,
745
+ Oe as w,
746
+ Re as x,
747
747
  Me as y,
748
748
  _e as z
749
749
  };
@@ -1,5 +1,5 @@
1
- import { x as h, y as f, C as p, K as g, E as u, L as b } from "./index-C0dhsYom.js";
2
- import { r as T } from "./reshape-BMUzc1UY.js";
1
+ import { B as h, C as f, F as p, M as g, E as u, N as b } from "./index-UdZhlibC.js";
2
+ import { r as T } from "./reshape-BR0eoLYN.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { x as s, l as a, B as p, K as i, E as l, M as f } from "./index-C0dhsYom.js";
1
+ import { B as s, l as a, D as p, M as i, E as l, Q as f } from "./index-UdZhlibC.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,7 +1,7 @@
1
- import { ad as S, T as h, ac as N, d as v, ae as o, af as p, ag as g, l as k, t as y } from "./index-C0dhsYom.js";
1
+ import { ag as S, T as h, ac as N, d as v, ah as o, ai as p, aj as g, l as k, t as y } from "./index-UdZhlibC.js";
2
2
  import { s as R } from "./index-C4L8Cm77.js";
3
- import { s as $ } from "./stack-Dpgg_1W1.js";
4
- import { t as B } from "./tensor-RvZVNmg0.js";
3
+ import { s as $ } from "./stack-ikk2Y8_P.js";
4
+ import { t as B } from "./tensor-Do9PKbIE.js";
5
5
  /**
6
6
  * @license
7
7
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -381,7 +381,7 @@ class i {
381
381
  * throw an `Error`.
382
382
  */
383
383
  handleErrors(t) {
384
- return new Z(this, t);
384
+ return new j(this, t);
385
385
  }
386
386
  // TODO(soergel): Implement reduce() etc.
387
387
  /**
@@ -708,7 +708,7 @@ class K extends i {
708
708
  return { value: r, done: !1 };
709
709
  }
710
710
  }
711
- class Z extends i {
711
+ class j extends i {
712
712
  constructor(t, e) {
713
713
  super(), this.upstream = t, this.handler = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
714
714
  }
@@ -745,7 +745,7 @@ class w extends i {
745
745
  return { value: r, done: !1 };
746
746
  }
747
747
  }
748
- class j extends i {
748
+ class Z extends i {
749
749
  constructor() {
750
750
  super(), this.outputQueue = new f(), this.lastRead = Promise.resolve({ value: null, done: !1 });
751
751
  }
@@ -759,7 +759,7 @@ class j extends i {
759
759
  return { value: this.outputQueue.shift(), done: !1 };
760
760
  }
761
761
  }
762
- class tt extends j {
762
+ class tt extends Z {
763
763
  constructor(t, e) {
764
764
  super(), this.upstream = t, this.transform = e;
765
765
  }
@@ -1,4 +1,4 @@
1
- import { x as l, y as h, E as m, ah as p, C as c, ai as d, ab as g, l as u, T as V, aj as v, a6 as N, a as w } from "./index-C0dhsYom.js";
1
+ import { B as l, C as h, E as m, ak as p, F as c, al as d, ab as g, l as u, T as V, n as v, o as N, a as w } from "./index-UdZhlibC.js";
2
2
  import { s as f } from "./index-C4L8Cm77.js";
3
3
  /**
4
4
  * @license
@@ -16,11 +16,11 @@ import { s as f } from "./index-C4L8Cm77.js";
16
16
  * limitations under the License.
17
17
  * =============================================================================
18
18
  */
19
- function x(r) {
19
+ function b(r) {
20
20
  const e = { x: h(r, "x", "floor", "float32") };
21
21
  return m.runKernel(p, e);
22
22
  }
23
- const b = /* @__PURE__ */ l({ floor_: x });
23
+ const x = /* @__PURE__ */ l({ floor_: b });
24
24
  /**
25
25
  * @license
26
26
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -69,7 +69,7 @@ class T {
69
69
  return t <= this.upper && t >= this.lower;
70
70
  }
71
71
  }
72
- class y {
72
+ class $ {
73
73
  constructor(t = 0, e = 1, s, n) {
74
74
  if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = t, this.range = e - t, this.dtype = s, n == null && (n = Math.random()), typeof n == "number" && (n = n.toString()), !this.canReturnFloat() && this.range <= 1)
75
75
  throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
@@ -98,7 +98,7 @@ class y {
98
98
  * limitations under the License.
99
99
  * =============================================================================
100
100
  */
101
- function $(r, t = 0, e = 1, s, n) {
101
+ function y(r, t = 0, e = 1, s, n) {
102
102
  if (c(r), s != null && s === "bool")
103
103
  throw new Error(`Unsupported data type ${s}`);
104
104
  const o = new T(t, e, s, !1, n), a = d(r, s);
@@ -106,7 +106,7 @@ function $(r, t = 0, e = 1, s, n) {
106
106
  a.values[i] = o.nextValue();
107
107
  return a.toTensor();
108
108
  }
109
- const _ = /* @__PURE__ */ l({ randomNormal_: $ });
109
+ const _ = /* @__PURE__ */ l({ randomNormal_: y });
110
110
  /**
111
111
  * @license
112
112
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -125,7 +125,7 @@ const _ = /* @__PURE__ */ l({ randomNormal_: $ });
125
125
  */
126
126
  function M(r, t = 0, e = 1, s = "float32", n) {
127
127
  c(r);
128
- const o = d(r, s), a = new y(t, e, null, n);
128
+ const o = d(r, s), a = new $(t, e, null, n);
129
129
  for (let i = 0; i < o.values.length; i++)
130
130
  o.values[i] = a.nextValue();
131
131
  return o.toTensor();
@@ -176,18 +176,18 @@ function E(r, t) {
176
176
  * limitations under the License.
177
177
  * =============================================================================
178
178
  */
179
- function R(r, t, e, s) {
179
+ function F(r, t, e, s) {
180
180
  const n = h(r, "x", "dropout");
181
181
  if (u(n.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${n.dtype} tensor instead.`), u(t >= 0 && t < 1, () => `rate must be a float in the range [0, 1), but got ${t}.`), t === 0)
182
182
  return r instanceof V ? n.clone() : n;
183
- const o = E(n, e), a = 1 - t, i = v(b(N(D(o, 0, 1, "float32", s), a)), a);
183
+ const o = E(n, e), a = 1 - t, i = v(x(N(D(o, 0, 1, "float32", s), a)), a);
184
184
  return w(n, i);
185
185
  }
186
- const G = /* @__PURE__ */ l({ dropout_: R });
186
+ const G = /* @__PURE__ */ l({ dropout_: F });
187
187
  export {
188
188
  T as M,
189
189
  D as a,
190
190
  G as d,
191
- b as f,
191
+ x as f,
192
192
  _ as r
193
193
  };
@@ -1,4 +1,4 @@
1
- import { x as g, y as t, E as h, G as x } from "./index-C0dhsYom.js";
1
+ import { B as g, C as t, E as h, G as p } from "./index-UdZhlibC.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -15,11 +15,11 @@ import { x as g, y as t, E as h, G as x } from "./index-C0dhsYom.js";
15
15
  * limitations under the License.
16
16
  * =============================================================================
17
17
  */
18
- function p(n, s, r = 0, e = 0) {
18
+ function u(n, s, r = 0, e = 0) {
19
19
  const o = t(n, "x", "gather"), a = t(s, "indices", "gather", "int32"), c = { x: o, indices: a }, i = { axis: r, batchDims: e };
20
- return h.runKernel(x, c, i);
20
+ return h.runKernel(p, c, i);
21
21
  }
22
- const d = /* @__PURE__ */ g({ gather_: p });
22
+ const d = /* @__PURE__ */ g({ gather_: u });
23
23
  export {
24
24
  d as g
25
25
  };
@@ -1,4 +1,4 @@
1
- import { i as t, e as n } from "./index-C0dhsYom.js";
1
+ import { i as t, e as n } from "./index-UdZhlibC.js";
2
2
  import "./ops/cpu/gelu.js";
3
3
  import "./ops/webgl/gelu.js";
4
4
  const a = {
@@ -1,6 +1,6 @@
1
- import { ay as z, ac as v, az as oe, aA as ie, aB as ae, l as F, aC as me, aD as J, Z as B, aE as I, ab as T, j as E, aF as H, aG as $e, aH as Y, aa as Te } from "./index-C0dhsYom.js";
1
+ import { aA as z, ac as v, aB as oe, aC as ie, aD as ae, l as F, aE as me, aF as J, a1 as B, aG as I, ab as T, j as E, aH as H, aI as $e, aJ as Y, aa as Te } from "./index-UdZhlibC.js";
2
2
  import "./index-Tf7vU29b.js";
3
- import { b as Se } from "./backend_util-DWiwsi2N.js";
3
+ import { b as Se } from "./backend_util-C9Ut8n0Q.js";
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2018 Google LLC. All Rights Reserved.