@genai-fi/nanogpt 0.10.1 → 0.10.3

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 (249) hide show
  1. package/dist/Generator.js +11761 -171
  2. package/dist/{RealDiv-DgA3z9oO.js → RealDiv-KAPDe8zB.js} +28 -30
  3. package/dist/Reshape-BYkmUnAv.js +14 -0
  4. package/dist/{Reshape-_kILl6tK.js → Reshape-Zt6eb7yh.js} +18 -20
  5. package/dist/TeachableLLM.js +10 -11
  6. package/dist/{axis_util-BvHEw88j.js → axis_util-BaG7mf5A.js} +3 -3
  7. package/dist/backend.js +2 -2
  8. package/dist/{backend_util-D-rUb2ty.js → backend_util-RCe-rHaj.js} +59 -60
  9. package/dist/{backend_webgpu-B0u2ndUn.js → backend_webgpu-DE3ACOLx.js} +45 -47
  10. package/dist/broadcast_to-B3eYlZm7.js +28 -0
  11. package/dist/checks/appendCache.js +2 -2
  12. package/dist/checks/attentionMask.js +3 -3
  13. package/dist/checks/gelu.js +2 -2
  14. package/dist/checks/matMulGelu.js +7 -11
  15. package/dist/checks/normRMS.js +9 -9
  16. package/dist/checks/normRMSGrad.js +3 -3
  17. package/dist/checks/packUnpack.js +2 -2
  18. package/dist/checks/qkv.js +12 -13
  19. package/dist/checks/rope.js +2 -2
  20. package/dist/clip_by_value-BnO7-a88.js +12 -0
  21. package/dist/complex-DjxcVmoX.js +11 -0
  22. package/dist/concat-BV8bt5H-.js +17 -0
  23. package/dist/{concat_util-DcJk7YHS.js → concat_util-DpW8mL_l.js} +1 -1
  24. package/dist/{dataset-0xP8GjwI.js → dataset-BcwmTGYc.js} +137 -139
  25. package/dist/dropout-BcvN9JYi.js +92 -0
  26. package/dist/expand_dims-DT4tEPwA.js +11 -0
  27. package/dist/{exports_initializers-xuidcwI4.js → exports_initializers-Hta_rEnm.js} +1 -1
  28. package/dist/floor-D5QdR_le.js +9 -0
  29. package/dist/gather-D3JcZUaI.js +9 -0
  30. package/dist/{gelu-CNLFZWea.js → gelu-CjNPL4OH.js} +10 -11
  31. package/dist/{gpgpu_math-DDVJCn6-.js → gpgpu_math-DAOmgtXR.js} +841 -1015
  32. package/dist/{index-CjOj7j-u.js → index-BwexR4lA.js} +262 -263
  33. package/dist/index-DOvlwCh-.js +3520 -0
  34. package/dist/{kernel_funcs_utils-Dg_-E44D.js → kernel_funcs_utils-CCzYdUZg.js} +129 -131
  35. package/dist/layers/BaseLayer.js +14 -15
  36. package/dist/layers/CausalSelfAttention.js +6 -6
  37. package/dist/layers/MLP.js +4 -4
  38. package/dist/layers/PositionEmbedding.js +7 -7
  39. package/dist/layers/RMSNorm.js +3 -3
  40. package/dist/layers/RoPECache.js +9 -9
  41. package/dist/layers/TiedEmbedding.js +6 -6
  42. package/dist/layers/TransformerBlock.js +1 -1
  43. package/dist/loader/loadTransformers.js +1 -1
  44. package/dist/loader/oldZipLoad.js +13 -14
  45. package/dist/log_sum_exp-ngO0-4pK.js +39 -0
  46. package/dist/main.js +49 -50
  47. package/dist/{matMul16--R5hOwDG.js → matMul16-BWRSOCWB.js} +14 -15
  48. package/dist/matMulGelu-CzfgT6Wq.js +163 -0
  49. package/dist/mat_mul-SjpJRLyL.js +11 -0
  50. package/dist/mod-AnXEvvpo.js +11 -0
  51. package/dist/models/NanoGPTV1.js +2 -2
  52. package/dist/models/model.js +13 -14
  53. package/dist/ones-D2rT0xk2.js +14 -0
  54. package/dist/ops/adamAdjust.js +1 -1
  55. package/dist/ops/adamMoments.js +1 -1
  56. package/dist/ops/add16.js +1 -1
  57. package/dist/ops/appendCache.js +3 -3
  58. package/dist/ops/attentionMask.js +1 -1
  59. package/dist/ops/concat16.js +2 -2
  60. package/dist/ops/cpu/adamAdjust.js +13 -14
  61. package/dist/ops/cpu/adamMoments.js +6 -7
  62. package/dist/ops/cpu/appendCache.js +7 -8
  63. package/dist/ops/cpu/attentionMask.js +7 -7
  64. package/dist/ops/cpu/fusedSoftmax.js +10 -11
  65. package/dist/ops/cpu/gatherSub.js +9 -10
  66. package/dist/ops/cpu/gelu.js +9 -10
  67. package/dist/ops/cpu/matMul16.js +6 -7
  68. package/dist/ops/cpu/matMulGelu.js +5 -6
  69. package/dist/ops/cpu/matMulMul.js +3 -4
  70. package/dist/ops/cpu/mulDropout.js +3 -4
  71. package/dist/ops/cpu/normRMS.js +10 -11
  72. package/dist/ops/cpu/qkv.js +8 -9
  73. package/dist/ops/cpu/rope.js +5 -6
  74. package/dist/ops/cpu/scatterSub.js +17 -19
  75. package/dist/ops/dot16.js +2 -2
  76. package/dist/ops/gatherSub.js +1 -1
  77. package/dist/ops/gelu.js +2 -2
  78. package/dist/ops/grads/add16.js +11 -12
  79. package/dist/ops/grads/attentionMask.js +5 -6
  80. package/dist/ops/grads/gelu.js +3 -4
  81. package/dist/ops/grads/matMul16.js +4 -5
  82. package/dist/ops/grads/matMulGelu.js +9 -10
  83. package/dist/ops/grads/normRMS.js +7 -8
  84. package/dist/ops/grads/pack16.js +4 -5
  85. package/dist/ops/grads/qkv.js +17 -19
  86. package/dist/ops/grads/rope.js +3 -5
  87. package/dist/ops/grads/softmax16.js +3 -4
  88. package/dist/ops/grads/unpack16.js +3 -4
  89. package/dist/ops/grads/utils.d.ts +1 -0
  90. package/dist/ops/grads/utils.js +8 -4
  91. package/dist/ops/matMul16.js +3 -3
  92. package/dist/ops/matMulGelu.js +2 -2
  93. package/dist/ops/matMulMul.js +1 -1
  94. package/dist/ops/mul16.js +1 -1
  95. package/dist/ops/mulDrop.js +1 -1
  96. package/dist/ops/normRMS.js +1 -1
  97. package/dist/ops/pack16.js +3 -4
  98. package/dist/ops/qkv.js +4 -8
  99. package/dist/ops/reshape16.js +14 -16
  100. package/dist/ops/rope.d.ts +1 -1
  101. package/dist/ops/rope.js +3 -8
  102. package/dist/ops/scatterSub.js +1 -1
  103. package/dist/ops/slice16.js +2 -2
  104. package/dist/ops/softmax16.js +5 -8
  105. package/dist/ops/sub16.js +1 -1
  106. package/dist/ops/sum16.js +2 -2
  107. package/dist/ops/transpose16.js +23 -24
  108. package/dist/ops/unpack16.js +2 -2
  109. package/dist/ops/webgl/adamAdjust.js +2 -3
  110. package/dist/ops/webgl/adamMoments.js +1 -2
  111. package/dist/ops/webgl/appendCache.js +1 -2
  112. package/dist/ops/webgl/attentionMask.js +4 -5
  113. package/dist/ops/webgl/fusedSoftmax.js +4 -6
  114. package/dist/ops/webgl/gatherSub.js +6 -7
  115. package/dist/ops/webgl/gelu.js +2 -3
  116. package/dist/ops/webgl/log.js +11 -12
  117. package/dist/ops/webgl/matMul16.js +10 -11
  118. package/dist/ops/webgl/matMulGelu.js +7 -111
  119. package/dist/ops/webgl/matMulMul.js +9 -10
  120. package/dist/ops/webgl/mulDropout.js +8 -9
  121. package/dist/ops/webgl/normRMS.js +2 -3
  122. package/dist/ops/webgl/qkv.js +5 -6
  123. package/dist/ops/webgl/rope.js +7 -8
  124. package/dist/ops/webgl/scatterSub.js +5 -6
  125. package/dist/ops/webgpu/adamAdjust.js +10 -12
  126. package/dist/ops/webgpu/adamMoments.js +8 -10
  127. package/dist/ops/webgpu/add16.js +8 -9
  128. package/dist/ops/webgpu/appendCache.js +23 -25
  129. package/dist/ops/webgpu/attentionMask.js +8 -10
  130. package/dist/ops/webgpu/attentionMask32_program.js +2 -2
  131. package/dist/ops/webgpu/concat16.js +12 -14
  132. package/dist/ops/webgpu/gatherSub.js +11 -13
  133. package/dist/ops/webgpu/gelu.js +28 -29
  134. package/dist/ops/webgpu/matMul16.js +26 -28
  135. package/dist/ops/webgpu/matMul16_program.js +4 -5
  136. package/dist/ops/webgpu/mul16.js +9 -10
  137. package/dist/ops/webgpu/normRMS.js +15 -17
  138. package/dist/ops/webgpu/normRMSGrad.js +21 -28
  139. package/dist/ops/webgpu/pack16.js +12 -13
  140. package/dist/ops/webgpu/pack16_program.js +2 -2
  141. package/dist/ops/webgpu/qkv.js +16 -18
  142. package/dist/ops/webgpu/rope.js +25 -27
  143. package/dist/ops/webgpu/scatterSub.js +7 -9
  144. package/dist/ops/webgpu/slice16.js +21 -23
  145. package/dist/ops/webgpu/softmax16.js +17 -19
  146. package/dist/ops/webgpu/softmax16_program.js +2 -2
  147. package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
  148. package/dist/ops/webgpu/softmax16grad.js +7 -8
  149. package/dist/ops/webgpu/sub16.js +7 -8
  150. package/dist/ops/webgpu/sum16.js +18 -20
  151. package/dist/ops/webgpu/transpose16.js +19 -20
  152. package/dist/ops/webgpu/transpose16_program.js +2 -2
  153. package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
  154. package/dist/ops/webgpu/unpack16.js +3 -4
  155. package/dist/ops/webgpu/utils/binary_op.js +7 -8
  156. package/dist/ops/webgpu/utils/reductions.js +14 -22
  157. package/dist/ops-B5yanEdW.js +476 -0
  158. package/dist/pack16-nQ6JaLo-.js +39 -0
  159. package/dist/patches/webgpu_backend.js +19 -20
  160. package/dist/patches/webgpu_base.js +1 -1
  161. package/dist/patches/webgpu_program.js +21 -22
  162. package/dist/{random_width-DY6Kk2Dl.js → random_width-or-CEftb.js} +2506 -2761
  163. package/dist/range-BklejeeW.js +10 -0
  164. package/dist/relu-CP0ZcxWO.js +9 -0
  165. package/dist/reshape-ByE68wS9.js +9 -0
  166. package/dist/resize_nearest_neighbor-B19mCEg2.js +175 -0
  167. package/dist/rope-Ir4mTyD1.js +24 -0
  168. package/dist/{scatter_nd_util-5EL-8VAQ.js → scatter_nd_util-lvSiX8q4.js} +1 -1
  169. package/dist/selu_util-kbhpTdYD.js +44 -0
  170. package/dist/{shared-BRksrJb3.js → shared-DT1TkE6w.js} +1 -1
  171. package/dist/{shared-BuAXb4CI.js → shared-dntlHIDQ.js} +343 -345
  172. package/dist/slice-BfEGSH82.js +12 -0
  173. package/dist/{slice_util-DtEldBfK.js → slice_util-uTKwiEpW.js} +1 -1
  174. package/dist/{softmax-ZHVebtR1.js → softmax-CA5jFsLR.js} +4 -5
  175. package/dist/split-CVLc0w--.js +9 -0
  176. package/dist/squeeze-C7Z2srUo.js +10 -0
  177. package/dist/stack-Cf4n9h0N.js +11 -0
  178. package/dist/step-CINUs5QB.js +261 -0
  179. package/dist/sum-DWAtNGez.js +11 -0
  180. package/dist/tensor-DJoc7gJU.js +8 -0
  181. package/dist/tensor1d-D11P_7Dp.js +11 -0
  182. package/dist/{tensor2d-G4Ys2GxX.js → tensor2d-Bs9wZRc7.js} +6 -7
  183. package/dist/{tensor4d-B8roDgtc.js → tensor4d-BARPdTaS.js} +6 -7
  184. package/dist/{tfjs_backend-kNyO5L2d.js → tfjs_backend-y1cvNhLA.js} +244 -253
  185. package/dist/tile-mbfagpsB.js +11 -0
  186. package/dist/training/Adam.js +2 -2
  187. package/dist/training/AdamExt.js +1 -1
  188. package/dist/training/DatasetBuilder.js +2 -2
  189. package/dist/training/FullTrainer.js +1 -1
  190. package/dist/training/Trainer.js +2 -2
  191. package/dist/training/sparseCrossEntropy.js +5 -5
  192. package/dist/transpose-ClWiBS_b.js +36 -0
  193. package/dist/unsorted_segment_sum-BDDhB_E6.js +277 -0
  194. package/dist/utilities/dummy.js +3 -3
  195. package/dist/utilities/multinomialCPU.js +2 -2
  196. package/dist/utilities/packed.d.ts +1 -4
  197. package/dist/utilities/packed.js +10 -711
  198. package/dist/utilities/performance.js +1 -1
  199. package/dist/utilities/profile.js +1 -1
  200. package/dist/utilities/safetensors.js +2 -2
  201. package/dist/utilities/sentences.js +5 -5
  202. package/dist/utilities/weights.js +2 -2
  203. package/dist/{variable-Bhn5bHYv.js → variable-WawDEaAb.js} +1 -1
  204. package/dist/{webgpu_program-Cigz-7RF.js → webgpu_program-DuOXPQol.js} +178 -172
  205. package/dist/{webgpu_util-BBCnKm2X.js → webgpu_util-RxEF33Rj.js} +34 -35
  206. package/dist/zeros-KnWaWf-X.js +13 -0
  207. package/dist/zeros_like-DvE73F4e.js +721 -0
  208. package/package.json +4 -2
  209. package/dist/Reshape-CF6odzV4.js +0 -16
  210. package/dist/broadcast_to-CwF7XIeu.js +0 -30
  211. package/dist/complex-CSlYz-2T.js +0 -13
  212. package/dist/concat-BHlIJeyT.js +0 -19
  213. package/dist/dropout-C1pM3f11.js +0 -99
  214. package/dist/expand_dims-BPG4fwBP.js +0 -13
  215. package/dist/gather-DykLGqmW.js +0 -10
  216. package/dist/index-ZyQhjEPo.js +0 -2157
  217. package/dist/log_sum_exp-DWI-76TI.js +0 -41
  218. package/dist/mat_mul-DeAh4uTH.js +0 -12
  219. package/dist/mod-Gt1rMB4n.js +0 -12
  220. package/dist/mulmat_packed_gpu-BMFhLwta.js +0 -55
  221. package/dist/ones-CAMiP4I2.js +0 -15
  222. package/dist/ops-CNI3TwqM.js +0 -645
  223. package/dist/pack16-CFUqumar.js +0 -41
  224. package/dist/patches/PackedTensor.d.ts +0 -12
  225. package/dist/patches/PackedTensor.js +0 -11
  226. package/dist/patches/engine.d.ts +0 -261
  227. package/dist/patches/engine.js +0 -10
  228. package/dist/patches/tape.d.ts +0 -12
  229. package/dist/patches/tape.js +0 -5
  230. package/dist/range-BMS52eQi.js +0 -11
  231. package/dist/reciprocal-CTmshQ9J.js +0 -10
  232. package/dist/register_all_kernels-Bwu1PTuU.js +0 -12307
  233. package/dist/relu-yZ2-7WxU.js +0 -10
  234. package/dist/reshape-DevtBWtf.js +0 -10
  235. package/dist/rope-B5UUMsPi.js +0 -32
  236. package/dist/selu_util-D1w6yyTO.js +0 -303
  237. package/dist/sin-BGfy2HZo.js +0 -16
  238. package/dist/slice-D_gkkqZK.js +0 -13
  239. package/dist/split-DrfihRpZ.js +0 -10
  240. package/dist/squeeze-DZEpeblb.js +0 -11
  241. package/dist/stack-yOIAalTq.js +0 -13
  242. package/dist/sum-_fzj5ZTB.js +0 -12
  243. package/dist/tensor-DdQUJZlz.js +0 -909
  244. package/dist/tensor-f35l8Odg.js +0 -8
  245. package/dist/tensor1d-CeZuc-Rv.js +0 -12
  246. package/dist/tensor_util-DV-FP5Q3.js +0 -523
  247. package/dist/tile-BzyEiF-F.js +0 -13
  248. package/dist/transpose-DKELTqhe.js +0 -38
  249. package/dist/zeros-2gldETuK.js +0 -14
@@ -1,12 +1,10 @@
1
- import "./index-ZyQhjEPo.js";
2
- import { r as $ } from "./Reshape-_kILl6tK.js";
3
- import { _ as T, g as E, y as B, $ as F } from "./tensor_util-DV-FP5Q3.js";
4
- import { H as _, e as K, p as O, s as V } from "./tensor-DdQUJZlz.js";
5
- import { a as A, b as k, d as C, c as N, e as R } from "./axis_util-BvHEw88j.js";
6
- import { t as U, m as W } from "./shared-BRksrJb3.js";
7
- import { c as j } from "./backend_util-D-rUb2ty.js";
8
- import { f as y } from "./gpgpu_math-DDVJCn6-.js";
9
- import { g as G, b as L } from "./kernel_funcs_utils-Dg_-E44D.js";
1
+ import { aG as T, j as E, af as O, h as V, aS as B, Y as F, am as j, aT as G } from "./index-DOvlwCh-.js";
2
+ import { r as $ } from "./Reshape-Zt6eb7yh.js";
3
+ import { a as A, b as k, d as C, c as N, e as R } from "./axis_util-BaG7mf5A.js";
4
+ import { t as K, m as U } from "./shared-DT1TkE6w.js";
5
+ import { c as W } from "./backend_util-RCe-rHaj.js";
6
+ import { f as y } from "./gpgpu_math-DAOmgtXR.js";
7
+ import { g as _, b as L } from "./kernel_funcs_utils-CCzYdUZg.js";
10
8
  class w {
11
9
  constructor(s, e) {
12
10
  this.variableNames = ["x"];
@@ -16,7 +14,7 @@ class w {
16
14
  let o = "sumValue += dot(values, ones);";
17
15
  if (e != null) {
18
16
  const p = 1 / e;
19
- o = `sumValue += dot(values * ${_(p) ? p.toPrecision(2) : p}, ones);`;
17
+ o = `sumValue += dot(values * ${T(p) ? p.toPrecision(2) : p}, ones);`;
20
18
  }
21
19
  let u = "";
22
20
  l % t > 0 && (u = `
@@ -183,10 +181,10 @@ class X {
183
181
  `;
184
182
  }
185
183
  }
186
- function q(a) {
184
+ function Y(a) {
187
185
  const s = [];
188
186
  for (; s.length === 0 || s[s.length - 1].outSize !== 1; ) {
189
- const e = s.length ? s[s.length - 1].outSize : a[1], t = j(e);
187
+ const e = s.length ? s[s.length - 1].outSize : a[1], t = W(e);
190
188
  s.push({
191
189
  inSize: e,
192
190
  windowSize: t,
@@ -196,7 +194,7 @@ function q(a) {
196
194
  return s;
197
195
  }
198
196
  function P(a, s, e, t) {
199
- const n = q(a.shape);
197
+ const n = Y(a.shape);
200
198
  let l = a;
201
199
  for (let r = 0; r < n.length; r++) {
202
200
  const { inSize: i, windowSize: c, outSize: o } = n[r];
@@ -205,14 +203,14 @@ function P(a, s, e, t) {
205
203
  }
206
204
  return l;
207
205
  }
208
- class H {
206
+ class q {
209
207
  constructor(s, e) {
210
208
  this.variableNames = ["A"];
211
209
  const t = new Array(s.length);
212
210
  for (let r = 0; r < t.length; r++)
213
211
  t[r] = s[e[r]];
214
212
  this.outputShape = t, this.rank = t.length;
215
- const n = y(this.rank), l = Y(e);
213
+ const n = y(this.rank), l = H(e);
216
214
  this.userCode = `
217
215
  void main() {
218
216
  ${n} resRC = getOutputCoords();
@@ -221,7 +219,7 @@ class H {
221
219
  `;
222
220
  }
223
221
  }
224
- function Y(a) {
222
+ function H(a) {
225
223
  const s = a.length;
226
224
  if (s > 6)
227
225
  throw Error(`Transpose for rank ${s} is not yet supported`);
@@ -238,7 +236,7 @@ class J {
238
236
  t[u] = s[e[u]];
239
237
  if (this.outputShape = t, this.rank = t.length, this.rank > 6)
240
238
  throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);
241
- const n = y(this.rank), l = G("rc", this.rank), r = new Array(this.rank);
239
+ const n = y(this.rank), l = _("rc", this.rank), r = new Array(this.rank);
242
240
  for (let u = 0; u < e.length; u++)
243
241
  r[e[u]] = l[u];
244
242
  const i = `vec2(${r.slice(-2).join()})`, c = `++${l[this.rank - 1]} < ${t[this.rank - 1]}`, o = `getChannel(getA(${r.join()}), ${i})`;
@@ -263,7 +261,7 @@ class J {
263
261
  }
264
262
  }
265
263
  function D(a, s, e) {
266
- const t = K().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new J(a.shape, s) : new H(a.shape, s);
264
+ const t = E().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new J(a.shape, s) : new q(a.shape, s);
267
265
  return e.runWebGLProgram(t, [a], a.dtype);
268
266
  }
269
267
  function Q(a, s, e, t) {
@@ -275,15 +273,15 @@ function Q(a, s, e, t) {
275
273
  const [p, h] = N(u.shape, i);
276
274
  let d = p;
277
275
  e && (d = R(p, r));
278
- const f = V(h), g = V(a.shape) / f, x = $({ inputs: { x: u }, attrs: { shape: [g, f] }, backend: t }), b = T(a.dtype), I = P(x, b, "sum", t), m = $({ inputs: { x: I }, attrs: { shape: d }, backend: t });
276
+ const f = V(h), g = V(a.shape) / f, x = $({ inputs: { x: u }, attrs: { shape: [g, f] }, backend: t }), b = B(a.dtype), I = P(x, b, "sum", t), m = $({ inputs: { x: I }, attrs: { shape: d }, backend: t });
279
277
  return t.disposeIntermediateTensorInfo(x), t.disposeIntermediateTensorInfo(I), o && t.disposeIntermediateTensorInfo(u), m;
280
278
  }
281
279
  function Z(a) {
282
280
  const { inputs: s, backend: e, attrs: t } = a, { x: n } = s, { axis: l, keepDims: r } = t;
283
281
  return Q(n, l, r, e);
284
282
  }
285
- const fe = {
286
- kernelName: E,
283
+ const pe = {
284
+ kernelName: F,
287
285
  backendName: "webgl",
288
286
  kernelFunc: Z
289
287
  };
@@ -301,7 +299,7 @@ function te(a) {
301
299
  const I = e.texData.get(d.dataId).values, m = new Array(i);
302
300
  for (let v = 0; v < m.length; v++)
303
301
  m[v] = n.shape[u[v]];
304
- const z = U(I, n.shape, n.dtype, u, m);
302
+ const z = K(I, n.shape, n.dtype, u, m);
305
303
  d = e.makeTensorInfo(m, n.dtype);
306
304
  const M = e.texData.get(d.dataId);
307
305
  M.values = z;
@@ -315,7 +313,7 @@ function te(a) {
315
313
  r && (g = R(f, c));
316
314
  let x;
317
315
  if (h) {
318
- const I = e.texData.get(d.dataId).values, m = W(I, V(S), g, n.dtype);
316
+ const I = e.texData.get(d.dataId).values, m = U(I, V(S), g, n.dtype);
319
317
  x = e.makeTensorInfo(g, n.dtype);
320
318
  const z = e.texData.get(x.dataId);
321
319
  z.values = m;
@@ -323,8 +321,8 @@ function te(a) {
323
321
  x = ee(d, S, g, e);
324
322
  return p && e.disposeIntermediateTensorInfo(d), x;
325
323
  }
326
- const me = {
327
- kernelName: B,
324
+ const he = {
325
+ kernelName: j,
328
326
  backendName: "webgl",
329
327
  kernelFunc: te
330
328
  };
@@ -350,16 +348,16 @@ return a / b;`, se = `
350
348
  }
351
349
 
352
350
  return result;
353
- `, ne = L({ opSnippet: ae, packedOpSnippet: se, checkOutOfBounds: !0 }), xe = {
354
- kernelName: F,
351
+ `, ne = L({ opSnippet: ae, packedOpSnippet: se, checkOutOfBounds: !0 }), fe = {
352
+ kernelName: G,
355
353
  backendName: "webgl",
356
354
  kernelFunc: ne
357
355
  };
358
356
  export {
359
357
  P as a,
360
- me as b,
361
- xe as c,
362
- fe as d,
358
+ he as b,
359
+ fe as c,
360
+ pe as d,
363
361
  te as m,
364
362
  ne as r,
365
363
  Z as s,
@@ -0,0 +1,14 @@
1
+ import { h, ah as d, l as c, R as m } from "./index-DOvlwCh-.js";
2
+ function i(n) {
3
+ const { inputs: p, attrs: o } = n, { x: e } = p, { shape: r } = o, a = h(e.shape), s = d(r, a), t = h(s);
4
+ 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 };
5
+ }
6
+ const u = {
7
+ kernelName: m,
8
+ backendName: "webgpu",
9
+ kernelFunc: i
10
+ };
11
+ export {
12
+ u as a,
13
+ i as r
14
+ };
@@ -1,10 +1,8 @@
1
- import "./index-ZyQhjEPo.js";
2
- import { u as C, g as f, a as R, b as g, c as I, d as c, e as u, i as m } from "./gpgpu_math-DDVJCn6-.js";
3
- import { b as x } from "./tensor_util-DV-FP5Q3.js";
4
- import { s as l, n as F, a as $ } from "./tensor-DdQUJZlz.js";
1
+ import { R as C, h as c, ah as R, l as f } from "./index-DOvlwCh-.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-DAOmgtXR.js";
5
3
  class S {
6
4
  constructor(t, i) {
7
- this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = t, this.enableShapeUniforms = C(this.outputShape.length);
5
+ this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = t, this.enableShapeUniforms = g(this.outputShape.length);
8
6
  let a = "";
9
7
  for (let e = 0; e < 4; e++) {
10
8
  let o = "thisRC = rc;";
@@ -22,8 +20,8 @@ class S {
22
20
  `;
23
21
  }
24
22
  this.userCode = `
25
- ${b(i, this.enableShapeUniforms)}
26
- ${this.enableShapeUniforms ? f() : R(t)}
23
+ ${v(i, this.enableShapeUniforms)}
24
+ ${this.enableShapeUniforms ? I() : x(t)}
27
25
 
28
26
  void main() {
29
27
  ivec3 rc = getOutputCoords();
@@ -41,41 +39,41 @@ class S {
41
39
  `;
42
40
  }
43
41
  }
44
- function b(s, t) {
42
+ function v(s, t) {
45
43
  return `
46
44
  ivec3 inputCoordsFromReshapedOutCoords(int index) {
47
- ${t ? g(["r", "c", "d"], "inputShape") : I(["r", "c", "d"], s)}
45
+ ${t ? F(["r", "c", "d"], "inputShape") : $(["r", "c", "d"], s)}
48
46
  return ivec3(r, c, d);
49
47
  }
50
48
  `;
51
49
  }
52
- function v(s, t, i) {
50
+ function b(s, t, i) {
53
51
  const a = [
54
- c(s.shape),
55
- ...u(s.shape)
52
+ u(s.shape),
53
+ ...l(s.shape)
56
54
  ], e = {
57
55
  dtype: s.dtype,
58
56
  shape: a,
59
57
  dataId: s.dataId
60
58
  }, o = [
61
- c(t),
62
- ...u(t)
59
+ u(t),
60
+ ...l(t)
63
61
  ], r = new S(o, a), p = !0, n = [a], h = i.runWebGLProgram(r, [e], s.dtype, n, p);
64
62
  return { dataId: h.dataId, shape: t, dtype: h.dtype };
65
63
  }
66
64
  function y(s) {
67
- const { inputs: t, backend: i, attrs: a } = s, { x: e } = t, { shape: o } = a, r = i, p = l(e.shape), n = F(o, p), h = l(n);
68
- $(p === h, () => `The new shape (${n}) has ${h} elements and the old shape (${e.shape}) has ${p} elements. The new shape and old shape must have the same number of elements.`);
65
+ const { inputs: t, backend: i, attrs: a } = s, { x: e } = t, { shape: o } = a, r = i, p = c(e.shape), n = R(o, p), h = c(n);
66
+ f(p === h, () => `The new shape (${n}) has ${h} elements and the old shape (${e.shape}) has ${p} elements. The new shape and old shape must have the same number of elements.`);
69
67
  const d = r.texData.get(e.dataId);
70
- return d.isPacked && !m(e.shape, n) && !(d.texture !== null && m(d.shape, n)) ? v(e, n, r) : (r.incRef(e.dataId), { dataId: e.dataId, shape: n, dtype: e.dtype });
68
+ return d.isPacked && !m(e.shape, n) && !(d.texture !== null && m(d.shape, n)) ? b(e, n, r) : (r.incRef(e.dataId), { dataId: e.dataId, shape: n, dtype: e.dtype });
71
69
  }
72
- const O = {
73
- kernelName: x,
70
+ const U = {
71
+ kernelName: C,
74
72
  backendName: "webgl",
75
73
  kernelFunc: y
76
74
  };
77
75
  export {
78
76
  S as R,
79
- O as a,
77
+ U as a,
80
78
  y as r
81
79
  };
@@ -5,25 +5,24 @@ import u from "./Generator.js";
5
5
  import p from "./Trainer.js";
6
6
  import { E as f } from "./index-DvYrXKkX.js";
7
7
  import { dummyPassTrainAsync as m } from "./utilities/dummy.js";
8
- import "./utilities/packed.js";
9
- import "./index-ZyQhjEPo.js";
8
+ import "./index-DOvlwCh-.js";
9
+ import "./random_width-or-CEftb.js";
10
+ import "./zeros_like-DvE73F4e.js";
11
+ import "./index-Cp39cXWe.js";
12
+ import "./dataset-BcwmTGYc.js";
10
13
  import "./ops/cpu/attentionMask.js";
11
14
  import "./ops/webgl/attentionMask.js";
12
15
  import "./ops/grads/attentionMask.js";
13
- import "./random_width-DY6Kk2Dl.js";
14
- import "./register_all_kernels-Bwu1PTuU.js";
15
- import "./index-Cp39cXWe.js";
16
- import "./dataset-0xP8GjwI.js";
17
16
  import "./ops/cpu/rope.js";
18
17
  import "./ops/webgl/rope.js";
19
- import "./rope-B5UUMsPi.js";
18
+ import "./rope-Ir4mTyD1.js";
20
19
  import "./ops/cpu/appendCache.js";
21
20
  import "./ops/webgl/appendCache.js";
22
21
  import "./ops/grads/softmax16.js";
23
- import "./matMul16--R5hOwDG.js";
22
+ import "./matMul16-BWRSOCWB.js";
24
23
  import "./ops/webgl/matMul16.js";
25
24
  import "./ops/cpu/matMul16.js";
26
- import "./pack16-CFUqumar.js";
25
+ import "./pack16-nQ6JaLo-.js";
27
26
  import "./ops/transpose16.js";
28
27
  import "./ops/reshape16.js";
29
28
  import "./ops/cpu/qkv.js";
@@ -42,11 +41,11 @@ import g from "./tokeniser/bpe.js";
42
41
  import "./papaparse.min-C0cScC2i.js";
43
42
  import "./jszip.min-Bz5-11Bk.js";
44
43
  import "./ops/cpu/matMulGelu.js";
45
- import "./ops/webgl/matMulGelu.js";
44
+ import "./matMulGelu-CzfgT6Wq.js";
46
45
  import "./ops/grads/matMulGelu.js";
47
46
  import "./ops/cpu/gelu.js";
48
47
  import "./ops/webgl/gelu.js";
49
- import "./gelu-CNLFZWea.js";
48
+ import "./gelu-CjNPL4OH.js";
50
49
  import "./ops/webgl/log.js";
51
50
  import "./ops/cpu/adamMoments.js";
52
51
  import "./ops/webgl/adamMoments.js";
@@ -1,4 +1,4 @@
1
- import { a as c } from "./tensor-DdQUJZlz.js";
1
+ import { l as c } from "./index-DOvlwCh-.js";
2
2
  function i(e, n) {
3
3
  for (let t = 0; t < e.length; ++t)
4
4
  if (e[e.length - t - 1] !== n - 1 - t)
@@ -12,7 +12,7 @@ function a(e, n, t) {
12
12
  t.indexOf(u) === -1 ? s.push(e[o++]) : s.push(n[f++]);
13
13
  return s;
14
14
  }
15
- function l(e, n) {
15
+ function p(e, n) {
16
16
  const t = [], r = e.length;
17
17
  for (let o = 0; o < r; o++)
18
18
  n.indexOf(o) === -1 && t.push(e[o]);
@@ -46,7 +46,7 @@ function x(e, n) {
46
46
  export {
47
47
  d as a,
48
48
  x as b,
49
- l as c,
49
+ p as c,
50
50
  m as d,
51
51
  h as e,
52
52
  i as f,
package/dist/backend.js CHANGED
@@ -1,9 +1,9 @@
1
- import { g as o, s as e, r as s } from "./index-ZyQhjEPo.js";
1
+ import { g as o, s as e, r as s } from "./index-DOvlwCh-.js";
2
2
  async function c(t, a) {
3
3
  if (o() !== t) {
4
4
  if (t === "webgpu") {
5
5
  const { registerWebGPUBackend: i } = await import("./patches/webgpu_base.js");
6
- i(a), await import("./index-CjOj7j-u.js"), await import("./ops/webgpu/index.js");
6
+ i(a), await import("./index-BwexR4lA.js"), await import("./ops/webgpu/index.js");
7
7
  }
8
8
  await e(t), await s(), console.log(`Backend set to ${t}`);
9
9
  }
@@ -1,11 +1,10 @@
1
- import { s as m, i as w, L as I, a as d, A, t as _ } from "./tensor-DdQUJZlz.js";
2
- import { d as y, f as M, h as T, c as b, e as D, a as L, b as x, g as W } from "./axis_util-BvHEw88j.js";
3
- import { j as v, h as F, q as N } from "./index-ZyQhjEPo.js";
4
- import { a as C, c as P } from "./concat_util-DcJk7YHS.js";
5
- import { S as z, a as B, b as U, c as j, d as q, e as G, f as H, g as V, h as Z, i as k, j as J, k as K, l as X, m as Y, s as Q, n as ee, t as te } from "./selu_util-D1w6yyTO.js";
6
- import { s as se } from "./slice_util-DtEldBfK.js";
7
- import { a0 as ne, u as re, w as oe } from "./tensor_util-DV-FP5Q3.js";
8
- import { c as ae, v as ie, a as ue } from "./scatter_nd_util-5EL-8VAQ.js";
1
+ import { h as m, ad as w, aU as I, l as d, ax as A, aB as _, a3 as y, o as M, a4 as T, aV as b, ak as D, aW as x } from "./index-DOvlwCh-.js";
2
+ import { d as L, f as W, h as v, c as F, e as N, a as C, b as P, g as z } from "./axis_util-BaG7mf5A.js";
3
+ import { a as B, c as U } from "./concat_util-DpW8mL_l.js";
4
+ import { c as V, b as G, d as H, f as j, g as q, h as Z, i as k, j as J, k as K, m as X, t as Y } from "./step-CINUs5QB.js";
5
+ import { S as Q, a as ee, b as te, g as se, c as ne, s as re } from "./selu_util-kbhpTdYD.js";
6
+ import { s as oe } from "./slice_util-uTKwiEpW.js";
7
+ import { c as ae, v as ie, a as ue } from "./scatter_nd_util-lvSiX8q4.js";
9
8
  import { a as le, c as pe, b as ce, e as he, d as fe, g as ge, m as de, s as me } from "./complex_util-Yc1A_gV1.js";
10
9
  function Ee(e, t) {
11
10
  const r = e.shape.length, s = t.shape.length;
@@ -147,7 +146,7 @@ function Te(e, t, r) {
147
146
  s.push(e[n + 1] - t[n][0] - t[n][1]);
148
147
  return s;
149
148
  }
150
- const be = 0.3275911, De = 0.254829592, Le = -0.284496736, xe = 1.421413741, We = -1.453152027, ve = 1.061405429;
149
+ const be = 0.3275911, De = 0.254829592, xe = -0.284496736, Le = 1.421413741, We = -1.453152027, ve = 1.061405429;
151
150
  const E = "->", Fe = /->/g, S = ",", R = "...";
152
151
  function Ne(e, t) {
153
152
  e = e.replace(/\s/g, "");
@@ -228,7 +227,7 @@ function Ue(e, t) {
228
227
  (e[s].length === 0 || e[s].indexOf(t) !== -1 || t === -1) && r.push(s);
229
228
  return r;
230
229
  }
231
- function je(e, t, r = 0) {
230
+ function Ve(e, t, r = 0) {
232
231
  let s = [];
233
232
  if (typeof t == "number")
234
233
  d(e.shape[r] % t === 0, () => "Number of splits must evenly divide the axis."), s = new Array(t).fill(e.shape[r] / t);
@@ -244,17 +243,17 @@ function je(e, t, r = 0) {
244
243
  }
245
244
  return s;
246
245
  }
247
- function qe(e) {
246
+ function Ge(e) {
248
247
  return `Received SparseTensor with denseShape[0] = 0 but
249
248
  indices.shape[0] = ${e}`;
250
249
  }
251
- function Ge(e, t) {
250
+ function He(e, t) {
252
251
  return `indices(${e}, 0) is invalid: ${t} < 0`;
253
252
  }
254
- function He(e, t, r) {
253
+ function je(e, t, r) {
255
254
  return `indices(${e}, 0) is invalid: ${t} >= ${r}`;
256
255
  }
257
- function Ve(e, t) {
256
+ function qe(e, t) {
258
257
  return `only one output dimension may be -1, not both ${e} and ${t}`;
259
258
  }
260
259
  function Ze(e, t) {
@@ -336,11 +335,11 @@ function ot(e) {
336
335
  function at(e) {
337
336
  return e.map((t) => _(t));
338
337
  }
339
- const mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
338
+ const dt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
340
339
  __proto__: null,
341
340
  ERF_A1: De,
342
- ERF_A2: Le,
343
- ERF_A3: xe,
341
+ ERF_A2: xe,
342
+ ERF_A3: Le,
344
343
  ERF_A4: We,
345
344
  ERF_A5: ve,
346
345
  ERF_P: be,
@@ -348,84 +347,84 @@ const mt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
348
347
  get RowPartitionType() {
349
348
  return f;
350
349
  },
351
- SELU_SCALE: z,
352
- SELU_SCALEALPHA: B,
353
- applyActivation: U,
354
- assertAndGetBroadcastShape: v,
355
- assertAxesAreInnerMostDims: y,
356
- assertParamsConsistent: C,
350
+ SELU_SCALE: Q,
351
+ SELU_SCALEALPHA: ee,
352
+ applyActivation: te,
353
+ assertAndGetBroadcastShape: y,
354
+ assertAxesAreInnerMostDims: L,
355
+ assertParamsConsistent: B,
357
356
  assignToTypedArray: le,
358
- axesAreInnerMostDims: M,
357
+ axesAreInnerMostDims: W,
359
358
  calculateShapes: ae,
360
359
  checkEinsumDimSizes: Pe,
361
- checkPadOnDimRoundingMode: j,
362
- combineLocations: T,
360
+ checkPadOnDimRoundingMode: V,
361
+ combineLocations: v,
363
362
  combineRaggedTensorToTensorShapes: Ie,
364
363
  complexWithEvenIndex: pe,
365
364
  complexWithOddIndex: ce,
366
- computeConv2DInfo: q,
367
- computeConv3DInfo: G,
368
- computeDefaultPad: H,
369
- computeDilation2DInfo: V,
365
+ computeConv2DInfo: G,
366
+ computeConv3DInfo: H,
367
+ computeDefaultPad: j,
368
+ computeDilation2DInfo: q,
370
369
  computeOptimalWindowSize: Oe,
371
- computeOutAndReduceShapes: b,
372
- computeOutShape: P,
370
+ computeOutAndReduceShapes: F,
371
+ computeOutShape: U,
373
372
  computePool2DInfo: Z,
374
373
  computePool3DInfo: k,
375
374
  convertConv2DDataFormat: J,
376
375
  decodeEinsumEquation: Ne,
377
376
  eitherStridesOrDilationsAreOne: K,
378
- expandShapeToKeepDim: D,
377
+ expandShapeToKeepDim: N,
379
378
  exponent: he,
380
379
  exponents: fe,
381
380
  fromStringArrayToUint8: at,
382
381
  fromUint8ToStringArray: ot,
383
- getAxesPermutation: L,
384
- getBroadcastDims: F,
382
+ getAxesPermutation: C,
383
+ getBroadcastDims: M,
385
384
  getComplexWithIndex: ge,
386
385
  getEinsumComputePath: ze,
387
386
  getEinsumPermutation: Ce,
388
- getFusedBiasGradient: X,
389
- getFusedDyActivation: Y,
387
+ getFusedBiasGradient: se,
388
+ getFusedDyActivation: ne,
390
389
  getImageCenter: we,
391
- getInnerMostAxes: x,
390
+ getInnerMostAxes: P,
392
391
  getPermuted: _e,
393
392
  getRaggedRank: Se,
394
- getReductionAxes: N,
393
+ getReductionAxes: T,
395
394
  getReshaped: Ae,
396
395
  getReshapedPermuted: ye,
397
396
  getRowPartitionTypesHelper: $e,
398
397
  getSliceBeginCoords: Me,
399
398
  getSliceSize: Te,
400
- getSparseFillEmptyRowsIndicesDenseShapeMismatch: qe,
401
- getSparseFillEmptyRowsNegativeIndexErrorMessage: Ge,
402
- getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: He,
399
+ getSparseFillEmptyRowsIndicesDenseShapeMismatch: Ge,
400
+ getSparseFillEmptyRowsNegativeIndexErrorMessage: He,
401
+ getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: je,
403
402
  getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: ke,
404
403
  getSparseReshapeInputOutputMismatchErrorMessage: Ke,
405
404
  getSparseReshapeInputOutputMultipleErrorMessage: Je,
406
- getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: Ve,
405
+ getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: qe,
407
406
  getSparseReshapeNegativeOutputDimErrorMessage: Ze,
408
407
  getSparseSegmentReductionIndicesOutOfRangeErrorMessage: et,
409
408
  getSparseSegmentReductionNegativeSegmentIdsErrorMessage: Xe,
410
409
  getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: Ye,
411
410
  getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: Qe,
412
- getUndoAxesPermutation: W,
411
+ getUndoAxesPermutation: z,
413
412
  isIdentityPermutation: Be,
414
- log: ne,
413
+ log: b,
415
414
  mergeRealAndImagArrays: de,
416
415
  prepareAndValidate: Ee,
417
- prepareSplitSize: je,
416
+ prepareSplitSize: Ve,
418
417
  segment_util: rt,
419
- shouldFuse: Q,
420
- slice_util: se,
418
+ shouldFuse: re,
419
+ slice_util: oe,
421
420
  splitRealAndImagArrays: me,
422
- stridesOrDilationsArePositive: ee,
423
- tupleValuesAreOne: te,
424
- upcastType: re,
421
+ stridesOrDilationsArePositive: X,
422
+ tupleValuesAreOne: Y,
423
+ upcastType: D,
425
424
  validateDefaultValueShape: Re,
426
425
  validateInput: ie,
427
426
  validateUpdateShape: ue,
428
- warn: oe
427
+ warn: x
429
428
  }, Symbol.toStringTag, { value: "Module" }));
430
429
  export {
431
430
  _e as A,
@@ -441,21 +440,21 @@ export {
441
440
  Ee as K,
442
441
  nt as L,
443
442
  we as M,
444
- je as N,
443
+ Ve as N,
445
444
  st as O,
446
445
  tt as P,
447
446
  f as R,
448
447
  Se as a,
449
- mt as b,
448
+ dt as b,
450
449
  Oe as c,
451
450
  Ie as d,
452
451
  at as e,
453
452
  ot as f,
454
453
  $e as g,
455
- qe as h,
456
- Ge as i,
457
- He as j,
458
- Ve as k,
454
+ Ge as h,
455
+ He as i,
456
+ je as j,
457
+ qe as k,
459
458
  Ze as l,
460
459
  ke as m,
461
460
  Je as n,
@@ -465,9 +464,9 @@ export {
465
464
  Qe as r,
466
465
  et as s,
467
466
  De as t,
468
- Le as u,
467
+ xe as u,
469
468
  Re as v,
470
- xe as w,
469
+ Le as w,
471
470
  We as x,
472
471
  ve as y,
473
472
  Ae as z