@genai-fi/nanogpt 0.10.2 → 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-zz7FpkKX.js → RealDiv-KAPDe8zB.js} +23 -25
  3. package/dist/Reshape-BYkmUnAv.js +14 -0
  4. package/dist/{Reshape-CHdUjC72.js → Reshape-Zt6eb7yh.js} +18 -20
  5. package/dist/TeachableLLM.js +10 -11
  6. package/dist/{axis_util-BsIr9ZNu.js → axis_util-BaG7mf5A.js} +3 -3
  7. package/dist/backend.js +2 -2
  8. package/dist/{backend_util-B1XRLuq9.js → backend_util-RCe-rHaj.js} +72 -73
  9. package/dist/{backend_webgpu-CqpfEImu.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-iBYIyuQe.js → concat_util-DpW8mL_l.js} +1 -1
  24. package/dist/{dataset-D2P7rHAw.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-CZSUJoVE.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-Bmhopi0J.js → gelu-CjNPL4OH.js} +10 -11
  31. package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-DAOmgtXR.js} +841 -1015
  32. package/dist/{index-DRyE072i.js → index-BwexR4lA.js} +262 -263
  33. package/dist/index-DOvlwCh-.js +3520 -0
  34. package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CCzYdUZg.js} +130 -132
  35. package/dist/layers/BaseLayer.js +15 -16
  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-fEAJ4smh.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-BVV9HveY.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-C7zXRT_h.js → scatter_nd_util-lvSiX8q4.js} +1 -1
  169. package/dist/selu_util-kbhpTdYD.js +44 -0
  170. package/dist/{shared-CHhxz-O5.js → shared-DT1TkE6w.js} +1 -1
  171. package/dist/{shared-D2NP_CpY.js → shared-dntlHIDQ.js} +343 -345
  172. package/dist/slice-BfEGSH82.js +12 -0
  173. package/dist/{slice_util-DyjSAD0u.js → slice_util-uTKwiEpW.js} +1 -1
  174. package/dist/{softmax-C9JQEtnO.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-CSB4KOb0.js → tensor2d-Bs9wZRc7.js} +6 -7
  183. package/dist/{tensor4d-D7bLqGqz.js → tensor4d-BARPdTaS.js} +6 -7
  184. package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-y1cvNhLA.js} +255 -264
  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 -745
  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-DzfrwYuP.js → variable-WawDEaAb.js} +1 -1
  204. package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-DuOXPQol.js} +178 -172
  205. package/dist/{webgpu_util-0_ubCEHJ.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-CDVLyVfz.js +0 -16
  210. package/dist/broadcast_to-B0ChcDaz.js +0 -30
  211. package/dist/complex-BBiRlsVq.js +0 -13
  212. package/dist/concat-DmBLPVGC.js +0 -19
  213. package/dist/dropout-B1x1kYMa.js +0 -99
  214. package/dist/expand_dims-ouvfxQ1n.js +0 -13
  215. package/dist/gather-CH9sdacz.js +0 -10
  216. package/dist/index-D6Q1lPZO.js +0 -2157
  217. package/dist/log_sum_exp-D3ftBNY5.js +0 -41
  218. package/dist/mat_mul-C59XWcJd.js +0 -12
  219. package/dist/mod-DESSvHIU.js +0 -12
  220. package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
  221. package/dist/ones-jU9jlQvM.js +0 -15
  222. package/dist/ops-BFDtP6th.js +0 -645
  223. package/dist/pack16-CmVZs6af.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 -12
  228. package/dist/patches/tape.d.ts +0 -12
  229. package/dist/patches/tape.js +0 -5
  230. package/dist/range-ZZZD60Fx.js +0 -11
  231. package/dist/reciprocal-CrYlsAGD.js +0 -10
  232. package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
  233. package/dist/relu-BYDneVPn.js +0 -10
  234. package/dist/reshape-CaPQzFvz.js +0 -10
  235. package/dist/rope-s4W2XO9B.js +0 -32
  236. package/dist/selu_util-BGPXmd4B.js +0 -303
  237. package/dist/sin-Djs4aQiu.js +0 -16
  238. package/dist/slice-DvovR5wq.js +0 -13
  239. package/dist/split-DBck65sX.js +0 -10
  240. package/dist/squeeze-C00Ipm_7.js +0 -11
  241. package/dist/stack-ChnHwRpX.js +0 -13
  242. package/dist/sum-ywRJj3Zr.js +0 -12
  243. package/dist/tensor-0r5yOo2R.js +0 -8
  244. package/dist/tensor-CzmOBsdf.js +0 -909
  245. package/dist/tensor1d-BlUT89BP.js +0 -12
  246. package/dist/tensor_util-DfwaWayG.js +0 -523
  247. package/dist/tile-CR074jmp.js +0 -13
  248. package/dist/transpose-DH4gmHvu.js +0 -38
  249. package/dist/zeros-DBFVbpv5.js +0 -14
@@ -1,84 +1,82 @@
1
- import { d as v, t as y } from "./index-D6Q1lPZO.js";
2
- import { s as g } from "./index-CieiGp4Y.js";
3
- import { C as S, T as h, e as N, v as R, a as k } from "./tensor-CzmOBsdf.js";
4
- import { t as o, O as p } from "./tensor_util-DfwaWayG.js";
5
- import { s as $ } from "./stack-ChnHwRpX.js";
6
- import { t as B } from "./tensor-0r5yOo2R.js";
7
- function _(r, t) {
8
- return b(r, t);
1
+ import { aC as S, a8 as h, j as N, d as v, aD as o, aE as p, aF as g, l as k, t as y } from "./index-DOvlwCh-.js";
2
+ import { s as R } from "./index-CieiGp4Y.js";
3
+ import { s as $ } from "./stack-Cf4n9h0N.js";
4
+ import { t as B } from "./tensor-DJoc7gJU.js";
5
+ function _(s, t) {
6
+ return b(s, t);
9
7
  }
10
- function b(r, t, e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Set()) {
11
- if (r == null)
8
+ function b(s, t, e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Set()) {
9
+ if (s == null)
12
10
  return null;
13
- if (typeof Blob == "function" && r instanceof Blob)
14
- return r.slice();
15
- if (s.has(r))
11
+ if (typeof Blob == "function" && s instanceof Blob)
12
+ return s.slice();
13
+ if (r.has(s))
16
14
  throw new Error("Circular references are not supported.");
17
- if (e.has(r))
18
- return e.get(r);
19
- const n = t(r);
15
+ if (e.has(s))
16
+ return e.get(s);
17
+ const n = t(s);
20
18
  if (n.recurse && n.value !== null)
21
19
  throw new Error("A deep map function may not return both a value and recurse=true.");
22
20
  if (n.recurse)
23
- if (c(r)) {
24
- const i = Array.isArray(r) ? [] : {};
25
- s.add(r);
26
- for (const l in r) {
27
- const m = r[l], d = b(m, t, e, s);
28
- i[l] = d;
21
+ if (c(s)) {
22
+ const a = Array.isArray(s) ? [] : {};
23
+ r.add(s);
24
+ for (const l in s) {
25
+ const d = s[l], m = b(d, t, e, r);
26
+ a[l] = m;
29
27
  }
30
- return s.delete(r), r.__proto__ && (i.__proto__ = r.__proto__), i;
28
+ return r.delete(s), s.__proto__ && (a.__proto__ = s.__proto__), a;
31
29
  } else
32
- throw new Error(`Can't recurse into non-iterable type: ${r}`);
33
- else return e.set(r, n.value), n.value;
30
+ throw new Error(`Can't recurse into non-iterable type: ${s}`);
31
+ else return e.set(s, n.value), n.value;
34
32
  }
35
- function P(r, t = I) {
36
- return E(r, t);
33
+ function P(s, t = I) {
34
+ return E(s, t);
37
35
  }
38
- function E(r, t, e = /* @__PURE__ */ new Set()) {
39
- const s = r[0];
40
- if (e.has(s))
36
+ function E(s, t, e = /* @__PURE__ */ new Set()) {
37
+ const r = s[0];
38
+ if (e.has(r))
41
39
  throw new Error("Circular references are not supported.");
42
- const n = t(r);
40
+ const n = t(s);
43
41
  if (n.recurse && n.value !== null)
44
42
  throw new Error("A deep zip function may not return both a value and recurse=true.");
45
43
  if (n.recurse)
46
- if (c(s)) {
47
- const i = Array.isArray(s) ? [] : {};
48
- e.add(s);
49
- for (const l in s) {
50
- const m = r.map((F) => F[l]), d = E(m, t, e);
51
- i[l] = d;
44
+ if (c(r)) {
45
+ const a = Array.isArray(r) ? [] : {};
46
+ e.add(r);
47
+ for (const l in r) {
48
+ const d = s.map((T) => T[l]), m = E(d, t, e);
49
+ a[l] = m;
52
50
  }
53
- return e.delete(s), i;
51
+ return e.delete(r), a;
54
52
  } else
55
- throw new Error(`Can't recurse into non-iterable type: ${s}`);
53
+ throw new Error(`Can't recurse into non-iterable type: ${r}`);
56
54
  else return n.value;
57
55
  }
58
- function I(r) {
59
- return r === null ? null : c(r[0]) ? { value: null, recurse: !0 } : { value: r, recurse: !1 };
56
+ function I(s) {
57
+ return s === null ? null : c(s[0]) ? { value: null, recurse: !0 } : { value: s, recurse: !1 };
60
58
  }
61
- function c(r) {
59
+ function c(s) {
62
60
  let t = !1;
63
61
  if (N().get("IS_BROWSER"))
64
- t = r instanceof TextDecoder;
62
+ t = s instanceof TextDecoder;
65
63
  else {
66
64
  const { StringDecoder: e } = require("string_decoder");
67
- t = r instanceof e;
65
+ t = s instanceof e;
68
66
  }
69
- return r != null && !ArrayBuffer.isView(r) && (Array.isArray(r) || typeof r == "object" && !(r instanceof h) && !(r instanceof Promise) && !t);
67
+ return s != null && !ArrayBuffer.isView(s) && (Array.isArray(s) || typeof s == "object" && !(s instanceof h) && !(s instanceof Promise) && !t);
70
68
  }
71
- function M(r) {
72
- return r == null || L(r) || Array.isArray(r) || typeof r == "object" && r instanceof h || S(r);
69
+ function M(s) {
70
+ return s == null || L(s) || Array.isArray(s) || typeof s == "object" && s instanceof h || S(s);
73
71
  }
74
- function L(r) {
75
- return r === null || typeof r != "object" && typeof r != "function";
72
+ function L(s) {
73
+ return s === null || typeof s != "object" && typeof s != "function";
76
74
  }
77
- function D(r) {
78
- return _(r, O);
75
+ function D(s) {
76
+ return _(s, O);
79
77
  }
80
- function O(r) {
81
- return r instanceof h ? { value: r.clone(), recurse: !1 } : c(r) ? { value: null, recurse: !0 } : { value: r, recurse: !1 };
78
+ function O(s) {
79
+ return s instanceof h ? { value: s.clone(), recurse: !1 } : c(s) ? { value: null, recurse: !0 } : { value: s, recurse: !1 };
82
80
  }
83
81
  class z {
84
82
  /**
@@ -187,8 +185,8 @@ class z {
187
185
  shuffleExcise(t) {
188
186
  if (this.isEmpty())
189
187
  throw new RangeError("Ring buffer is empty.");
190
- const e = this.wrap(this.begin + t), s = this.get(e);
191
- return this.set(e, this.pop()), s;
188
+ const e = this.wrap(this.begin + t), r = this.get(e);
189
+ return this.set(e, this.pop()), r;
192
190
  }
193
191
  }
194
192
  class f extends z {
@@ -211,23 +209,23 @@ class f extends z {
211
209
  * Doubles the capacity of the buffer.
212
210
  */
213
211
  expand() {
214
- const t = this.capacity * 2, e = new Array(t), s = this.length();
215
- for (let n = 0; n < s; n++)
212
+ const t = this.capacity * 2, e = new Array(t), r = this.length();
213
+ for (let n = 0; n < r; n++)
216
214
  e[n] = this.get(this.wrap(this.begin + n));
217
- this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = s;
215
+ this.data = e, this.capacity = t, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = r;
218
216
  }
219
217
  }
220
218
  f.INITIAL_CAPACITY = 32;
221
- function H(r) {
222
- return new G(r);
219
+ function H(s) {
220
+ return new G(s);
223
221
  }
224
- function q(r) {
225
- return new W(r);
222
+ function q(s) {
223
+ return new W(s);
226
224
  }
227
- function Q(r, t) {
228
- return new A(r, t);
225
+ function Q(s, t) {
226
+ return new A(s, t);
229
227
  }
230
- class a {
228
+ class i {
231
229
  /**
232
230
  * Collect all remaining elements of a bounded stream into an array.
233
231
  * Obviously this will succeed only for small streams that fit in memory.
@@ -256,9 +254,9 @@ class a {
256
254
  */
257
255
  async toArrayForTest() {
258
256
  const t = this.prefetch(100), e = [];
259
- let s = await t.next();
260
- for (; !s.done; )
261
- e.push(s.value), s = await t.next();
257
+ let r = await t.next();
258
+ for (; !r.done; )
259
+ e.push(r.value), r = await t.next();
262
260
  return e;
263
261
  }
264
262
  /**
@@ -281,9 +279,9 @@ class a {
281
279
  * fully processed.
282
280
  */
283
281
  async resolveWhile(t) {
284
- let e = await this.next(), s = t(e.value);
285
- for (; !e.done && s; )
286
- e = await this.next(), s = t(e.value);
282
+ let e = await this.next(), r = t(e.value);
283
+ for (; !e.done && r; )
284
+ e = await this.next(), r = t(e.value);
287
285
  }
288
286
  /**
289
287
  * Handles errors thrown on this stream using a provided handler function.
@@ -298,7 +296,7 @@ class a {
298
296
  * throw an `Error`.
299
297
  */
300
298
  handleErrors(t) {
301
- return new Z(this, t);
299
+ return new j(this, t);
302
300
  }
303
301
  // TODO(soergel): Implement reduce() etc.
304
302
  /**
@@ -427,8 +425,8 @@ class a {
427
425
  * @returns A `LazyIterator` of batches of elements, represented as an object
428
426
  * with collections at the leaves.
429
427
  */
430
- columnMajorBatch(t, e = !0, s = I) {
431
- return this.rowMajorBatch(t, e).map((i) => P(i, s));
428
+ columnMajorBatch(t, e = !0, r = I) {
429
+ return this.rowMajorBatch(t, e).map((a) => P(a, r));
432
430
  }
433
431
  /**
434
432
  * Concatenate this `LazyIterator` with another.
@@ -494,7 +492,7 @@ class a {
494
492
  return new U(this);
495
493
  }
496
494
  }
497
- class G extends a {
495
+ class G extends i {
498
496
  constructor(t) {
499
497
  super(), this.items = t, this.trav = 0;
500
498
  }
@@ -508,7 +506,7 @@ class G extends a {
508
506
  return this.trav++, { value: D(t), done: !1 };
509
507
  }
510
508
  }
511
- class W extends a {
509
+ class W extends i {
512
510
  constructor(t) {
513
511
  super(), this.nextFn = t;
514
512
  }
@@ -523,7 +521,7 @@ class W extends a {
523
521
  }
524
522
  }
525
523
  }
526
- class U extends a {
524
+ class U extends i {
527
525
  constructor(t) {
528
526
  super(), this.upstream = t, this.lastRead = Promise.resolve({ value: null, done: !1 });
529
527
  }
@@ -537,7 +535,7 @@ class U extends a {
537
535
  return this.upstream.next();
538
536
  }
539
537
  }
540
- class Y extends a {
538
+ class Y extends i {
541
539
  constructor(t, e) {
542
540
  super(), this.upstream = t, this.maxCount = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
543
541
  }
@@ -557,7 +555,7 @@ class Y extends a {
557
555
  return this.upstream.next();
558
556
  }
559
557
  }
560
- class J extends a {
558
+ class J extends i {
561
559
  constructor(t, e) {
562
560
  super(), this.upstream = t, this.maxCount = e, this.count = 0;
563
561
  }
@@ -568,9 +566,9 @@ class J extends a {
568
566
  return this.count++ >= this.maxCount ? { value: null, done: !0 } : this.upstream.next();
569
567
  }
570
568
  }
571
- class V extends a {
572
- constructor(t, e, s = !0) {
573
- super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch = s, this.lastRead = Promise.resolve({ value: null, done: !1 });
569
+ class V extends i {
570
+ constructor(t, e, r = !0) {
571
+ super(), this.upstream = t, this.batchSize = e, this.enableSmallLastBatch = r, this.lastRead = Promise.resolve({ value: null, done: !1 });
574
572
  }
575
573
  summary() {
576
574
  return `${this.upstream.summary()} -> RowMajorBatch`;
@@ -589,7 +587,7 @@ class V extends a {
589
587
  return { value: t, done: !1 };
590
588
  }
591
589
  }
592
- class X extends a {
590
+ class X extends i {
593
591
  constructor(t, e) {
594
592
  super(), this.upstream = t, this.predicate = e, this.lastRead = Promise.resolve({ value: null, done: !1 });
595
593
  }
@@ -608,7 +606,7 @@ class X extends a {
608
606
  }
609
607
  }
610
608
  }
611
- class K extends a {
609
+ class K extends i {
612
610
  constructor(t, e) {
613
611
  super(), this.upstream = t, this.transform = e;
614
612
  }
@@ -619,13 +617,13 @@ class K extends a {
619
617
  const t = await this.upstream.next();
620
618
  if (t.done)
621
619
  return { value: null, done: !0 };
622
- const e = o(t.value), s = this.transform(t.value), n = o(s);
623
- for (const i of e)
624
- p(i, n) || i.dispose();
625
- return { value: s, done: !1 };
620
+ const e = o(t.value), r = this.transform(t.value), n = o(r);
621
+ for (const a of e)
622
+ p(a, n) || a.dispose();
623
+ return { value: r, done: !1 };
626
624
  }
627
625
  }
628
- class Z extends a {
626
+ class j extends i {
629
627
  constructor(t, e) {
630
628
  super(), this.upstream = t, this.handler = e, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 });
631
629
  }
@@ -645,7 +643,7 @@ class Z extends a {
645
643
  }
646
644
  }
647
645
  }
648
- class w extends a {
646
+ class w extends i {
649
647
  constructor(t, e) {
650
648
  super(), this.upstream = t, this.transform = e;
651
649
  }
@@ -656,13 +654,13 @@ class w extends a {
656
654
  const t = await this.upstream.next();
657
655
  if (t.done)
658
656
  return { value: null, done: !0 };
659
- const e = o(t.value), s = await this.transform(t.value), n = o(s);
660
- for (const i of e)
661
- p(i, n) || i.dispose();
662
- return { value: s, done: !1 };
657
+ const e = o(t.value), r = await this.transform(t.value), n = o(r);
658
+ for (const a of e)
659
+ p(a, n) || a.dispose();
660
+ return { value: r, done: !1 };
663
661
  }
664
662
  }
665
- class j extends a {
663
+ class Z extends i {
666
664
  constructor() {
667
665
  super(), this.outputQueue = new f(), this.lastRead = Promise.resolve({ value: null, done: !1 });
668
666
  }
@@ -676,7 +674,7 @@ class j extends a {
676
674
  return { value: this.outputQueue.shift(), done: !1 };
677
675
  }
678
676
  }
679
- class tt extends j {
677
+ class tt extends Z {
680
678
  constructor(t, e) {
681
679
  super(), this.upstream = t, this.transform = e;
682
680
  }
@@ -687,14 +685,14 @@ class tt extends j {
687
685
  const t = await this.upstream.next();
688
686
  if (t.done)
689
687
  return !1;
690
- const e = o(t.value), s = this.transform(t.value), n = o(s);
691
- this.outputQueue.pushAll(s);
692
- for (const i of e)
693
- p(i, n) || i.dispose();
688
+ const e = o(t.value), r = this.transform(t.value), n = o(r);
689
+ this.outputQueue.pushAll(r);
690
+ for (const a of e)
691
+ p(a, n) || a.dispose();
694
692
  return !0;
695
693
  }
696
694
  }
697
- class A extends a {
695
+ class A extends i {
698
696
  constructor(t, e) {
699
697
  super(), this.baseErrorHandler = e, this.lastRead = null, this.iterator = null, this.moreIterators = t;
700
698
  }
@@ -706,20 +704,20 @@ class A extends a {
706
704
  }
707
705
  async readFromChain(t) {
708
706
  if (await t, this.iterator == null) {
709
- const s = await this.moreIterators.next();
710
- if (s.done)
707
+ const r = await this.moreIterators.next();
708
+ if (r.done)
711
709
  return { value: null, done: !0 };
712
- this.iterator = s.value, this.baseErrorHandler != null && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler));
710
+ this.iterator = r.value, this.baseErrorHandler != null && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler));
713
711
  }
714
712
  const e = await this.iterator.next();
715
713
  return e.done ? (this.iterator = null, this.readFromChain(t)) : e;
716
714
  }
717
715
  }
718
716
  var x;
719
- (function(r) {
720
- r[r.FAIL = 0] = "FAIL", r[r.SHORTEST = 1] = "SHORTEST", r[r.LONGEST = 2] = "LONGEST";
717
+ (function(s) {
718
+ s[s.FAIL = 0] = "FAIL", s[s.SHORTEST = 1] = "SHORTEST", s[s.LONGEST = 2] = "LONGEST";
721
719
  })(x || (x = {}));
722
- class C extends a {
720
+ class C extends i {
723
721
  constructor(t, e) {
724
722
  super(), this.upstream = t, this.bufferSize = e, this.buffer = new z(e);
725
723
  }
@@ -741,8 +739,8 @@ class C extends a {
741
739
  }
742
740
  }
743
741
  class et extends C {
744
- constructor(t, e, s) {
745
- super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random = g.alea(s || R().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 });
742
+ constructor(t, e, r) {
743
+ super(t, e), this.upstream = t, this.windowSize = e, this.upstreamExhausted = !1, this.random = R.alea(r || g().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 });
746
744
  }
747
745
  async next() {
748
746
  return this.lastRead = this.lastRead.then(() => this.serialNext()), this.lastRead;
@@ -764,7 +762,7 @@ class et extends C {
764
762
  return { value: null, done: !0 };
765
763
  }
766
764
  }
767
- class T {
765
+ class F {
768
766
  constructor() {
769
767
  this.size = null;
770
768
  }
@@ -829,11 +827,11 @@ class T {
829
827
  * @doc {heading: 'Data', subheading: 'Classes'}
830
828
  */
831
829
  batch(t, e = !0) {
832
- const s = this;
830
+ const r = this;
833
831
  k(t > 0, () => `batchSize needs to be positive, but it is
834
832
  ${t}`);
835
833
  let n;
836
- return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await s.iterator()).columnMajorBatch(t, e, rt), n);
834
+ return this.size === 1 / 0 || this.size == null ? n = this.size : e ? n = Math.ceil(this.size / t) : n = Math.floor(this.size / t), u(async () => (await r.iterator()).columnMajorBatch(t, e, st), n);
837
835
  }
838
836
  /**
839
837
  * Concatenates this `Dataset` with another.
@@ -852,8 +850,8 @@ class T {
852
850
  */
853
851
  concatenate(t) {
854
852
  const e = this;
855
- let s;
856
- return this.size === 1 / 0 || t.size === 1 / 0 ? s = 1 / 0 : this.size != null && t.size != null ? s = this.size + t.size : s = null, u(async () => (await e.iterator()).concatenate(await t.iterator()), s);
853
+ let r;
854
+ return this.size === 1 / 0 || t.size === 1 / 0 ? r = 1 / 0 : this.size != null && t.size != null ? r = this.size + t.size : r = null, u(async () => (await e.iterator()).concatenate(await t.iterator()), r);
857
855
  }
858
856
  /**
859
857
  * Filters this dataset according to `predicate`.
@@ -873,8 +871,8 @@ class T {
873
871
  */
874
872
  filter(t) {
875
873
  const e = this;
876
- let s;
877
- return this.size === 1 / 0 ? s = 1 / 0 : s = null, u(async () => (await e.iterator()).filter((n) => y(() => t(n))), s);
874
+ let r;
875
+ return this.size === 1 / 0 ? r = 1 / 0 : r = null, u(async () => (await e.iterator()).filter((n) => y(() => t(n))), r);
878
876
  }
879
877
  /**
880
878
  * Apply a function to every element of the dataset.
@@ -912,7 +910,7 @@ class T {
912
910
  */
913
911
  map(t) {
914
912
  const e = this;
915
- return u(async () => (await e.iterator()).map((s) => y(() => t(s))), this.size);
913
+ return u(async () => (await e.iterator()).map((r) => y(() => t(r))), this.size);
916
914
  }
917
915
  /**
918
916
  * Maps this dataset through an async 1-to-1 transform.
@@ -976,11 +974,11 @@ class T {
976
974
  */
977
975
  repeat(t) {
978
976
  const e = this;
979
- let s;
980
- return this.size != null && t > 0 ? s = this.size * t : t === 0 ? s = 0 : this.size != null && (t === void 0 || t < 0) ? s = 1 / 0 : s = null, u(async () => {
977
+ let r;
978
+ return this.size != null && t > 0 ? r = this.size * t : t === 0 ? r = 0 : this.size != null && (t === void 0 || t < 0) ? r = 1 / 0 : r = null, u(async () => {
981
979
  const n = q(async () => ({ value: await e.iterator(), done: !1 }));
982
980
  return Q(n.take(t));
983
- }, s);
981
+ }, r);
984
982
  }
985
983
  /**
986
984
  * Creates a `Dataset` that skips `count` initial elements from this dataset.
@@ -1001,8 +999,8 @@ class T {
1001
999
  */
1002
1000
  skip(t) {
1003
1001
  const e = this;
1004
- let s;
1005
- return this.size != null && t >= 0 && this.size >= t ? s = this.size - t : this.size != null && (this.size < t || t === void 0 || t < 0) ? s = 0 : s = null, u(async () => (await e.iterator()).skip(t), s);
1002
+ let r;
1003
+ return this.size != null && t >= 0 && this.size >= t ? r = this.size - t : this.size != null && (this.size < t || t === void 0 || t < 0) ? r = 0 : r = null, u(async () => (await e.iterator()).skip(t), r);
1006
1004
  }
1007
1005
  /**
1008
1006
  * Pseudorandomly shuffles the elements of this dataset. This is done in a
@@ -1025,13 +1023,13 @@ class T {
1025
1023
  *
1026
1024
  * @doc {heading: 'Data', subheading: 'Classes'}
1027
1025
  */
1028
- shuffle(t, e, s = !0) {
1026
+ shuffle(t, e, r = !0) {
1029
1027
  if (t == null || t < 0)
1030
1028
  throw this.size == null ? new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`);
1031
- const n = this, i = g.alea(e || R().toString());
1029
+ const n = this, a = R.alea(e || g().toString());
1032
1030
  return u(async () => {
1033
- let l = i.int32();
1034
- return s && (l += i.int32()), (await n.iterator()).shuffle(t, l.toString());
1031
+ let l = a.int32();
1032
+ return r && (l += a.int32()), (await n.iterator()).shuffle(t, l.toString());
1035
1033
  }, this.size);
1036
1034
  }
1037
1035
  /**
@@ -1053,8 +1051,8 @@ class T {
1053
1051
  */
1054
1052
  take(t) {
1055
1053
  const e = this;
1056
- let s;
1057
- return this.size != null && this.size > t ? s = t : this.size != null && this.size <= t ? s = this.size : s = null, u(async () => (await e.iterator()).take(t), s);
1054
+ let r;
1055
+ return this.size != null && this.size > t ? r = t : this.size != null && this.size <= t ? r = this.size : r = null, u(async () => (await e.iterator()).take(t), r);
1058
1056
  }
1059
1057
  /**
1060
1058
  * Collect all elements of this dataset into an array.
@@ -1094,9 +1092,9 @@ class T {
1094
1092
  return (await this.iterator()).toArrayForTest();
1095
1093
  }
1096
1094
  }
1097
- T.MAX_BUFFER_SIZE = 1e4;
1098
- function u(r, t = null) {
1099
- return new class extends T {
1095
+ F.MAX_BUFFER_SIZE = 1e4;
1096
+ function u(s, t = null) {
1097
+ return new class extends F {
1100
1098
  constructor() {
1101
1099
  super(...arguments), this.size = t;
1102
1100
  }
@@ -1105,20 +1103,20 @@ function u(r, t = null) {
1105
1103
  * from any underlying `Dataset`s.
1106
1104
  */
1107
1105
  async iterator() {
1108
- return r();
1106
+ return s();
1109
1107
  }
1110
1108
  }();
1111
1109
  }
1112
- function rt(r) {
1113
- if (r === null)
1110
+ function st(s) {
1111
+ if (s === null)
1114
1112
  return null;
1115
- const t = r[0];
1116
- return M(t) ? { value: st(r), recurse: !1 } : { value: null, recurse: !0 };
1113
+ const t = s[0];
1114
+ return M(t) ? { value: rt(s), recurse: !1 } : { value: null, recurse: !0 };
1117
1115
  }
1118
- function st(r) {
1119
- if (r.length === 0)
1116
+ function rt(s) {
1117
+ if (s.length === 0)
1120
1118
  throw new Error("Can't make a batch of zero elements.");
1121
- return r[0] instanceof h ? $(r) : B(r);
1119
+ return s[0] instanceof h ? $(s) : B(s);
1122
1120
  }
1123
1121
  export {
1124
1122
  u as d,
@@ -0,0 +1,92 @@
1
+ import { A as l, C as h, at as d, n as f, B as m, l as u, a8 as p, w as g, x as V, m as v } from "./index-DOvlwCh-.js";
2
+ import { f as w } from "./floor-D5QdR_le.js";
3
+ import { s as c } from "./index-CieiGp4Y.js";
4
+ class N {
5
+ constructor(t, e, s, n, o) {
6
+ this.mean = t, this.stdDev = e, this.dtype = s, this.nextVal = NaN, this.truncated = n, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
7
+ const a = o || Math.random();
8
+ this.random = c.alea(a.toString());
9
+ }
10
+ /** Returns next sample from a Gaussian distribution. */
11
+ nextValue() {
12
+ if (!isNaN(this.nextVal)) {
13
+ const n = this.nextVal;
14
+ return this.nextVal = NaN, n;
15
+ }
16
+ let t, e, s = !1;
17
+ for (; !s; ) {
18
+ let n, o, a;
19
+ do
20
+ n = 2 * this.random() - 1, o = 2 * this.random() - 1, a = n * n + o * o;
21
+ while (a >= 1 || a === 0);
22
+ const i = Math.sqrt(-2 * Math.log(a) / a);
23
+ t = this.mean + this.stdDev * n * i, e = this.mean + this.stdDev * o * i, (!this.truncated || this.isValidTruncated(t)) && (s = !0);
24
+ }
25
+ return (!this.truncated || this.isValidTruncated(e)) && (this.nextVal = this.convertValue(e)), this.convertValue(t);
26
+ }
27
+ /** Handles proper rounding for non-floating-point numbers. */
28
+ convertValue(t) {
29
+ return this.dtype == null || this.dtype === "float32" ? t : Math.round(t);
30
+ }
31
+ /** Returns true if less than 2-standard-deviations from the mean. */
32
+ isValidTruncated(t) {
33
+ return t <= this.upper && t >= this.lower;
34
+ }
35
+ }
36
+ class b {
37
+ constructor(t = 0, e = 1, s, n) {
38
+ 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)
39
+ throw new Error(`The difference between ${t} - ${e} <= 1 and dtype is not float`);
40
+ this.random = c.alea(n);
41
+ }
42
+ convertValue(t) {
43
+ return this.canReturnFloat() ? t : Math.round(t);
44
+ }
45
+ nextValue() {
46
+ return this.convertValue(this.min + this.range * this.random());
47
+ }
48
+ }
49
+ function T(r, t = 0, e = 1, s, n) {
50
+ if (h(r), s != null && s === "bool")
51
+ throw new Error(`Unsupported data type ${s}`);
52
+ const o = new N(t, e, s, !1, n), a = d(r, s);
53
+ for (let i = 0; i < a.values.length; i++)
54
+ a.values[i] = o.nextValue();
55
+ return a.toTensor();
56
+ }
57
+ const U = /* @__PURE__ */ l({ randomNormal_: T });
58
+ function x(r, t = 0, e = 1, s = "float32", n) {
59
+ h(r);
60
+ const o = d(r, s), a = new b(t, e, null, n);
61
+ for (let i = 0; i < o.values.length; i++)
62
+ o.values[i] = a.nextValue();
63
+ return o.toTensor();
64
+ }
65
+ const y = /* @__PURE__ */ l({ randomUniform_: x });
66
+ function M(r, t) {
67
+ if (t == null)
68
+ return r.shape.slice();
69
+ if (f(r.shape, t))
70
+ return t;
71
+ if (r.shape.length === t.length) {
72
+ const e = [];
73
+ for (let s = 0; s < r.shape.length; s++)
74
+ t[s] == null && r.shape[s] != null ? e.push(r.shape[s]) : e.push(t[s]);
75
+ return e;
76
+ }
77
+ return t;
78
+ }
79
+ function D(r, t, e, s) {
80
+ const n = m(r, "x", "dropout");
81
+ 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)
82
+ return r instanceof p ? n.clone() : n;
83
+ const o = M(n, e), a = 1 - t, i = g(w(V(y(o, 0, 1, "float32", s), a)), a);
84
+ return v(n, i);
85
+ }
86
+ const F = /* @__PURE__ */ l({ dropout_: D });
87
+ export {
88
+ N as M,
89
+ y as a,
90
+ F as d,
91
+ U as r
92
+ };
@@ -0,0 +1,11 @@
1
+ import { A as o, B as a, l as i, E as m, I as p } from "./index-DOvlwCh-.js";
2
+ function c(t, n = 0) {
3
+ const s = a(t, "x", "expandDims", "string_or_numeric");
4
+ i(n <= s.rank, () => "Axis must be <= rank of the tensor");
5
+ const r = { input: s }, e = { dim: n };
6
+ return m.runKernel(p, r, e);
7
+ }
8
+ const x = /* @__PURE__ */ o({ expandDims_: c });
9
+ export {
10
+ x as e
11
+ };
@@ -1,4 +1,4 @@
1
- import { R as o } from "./random_width-BVV9HveY.js";
1
+ import { R as o } from "./random_width-or-CEftb.js";
2
2
  function m(r) {
3
3
  return new o(r);
4
4
  }