@genai-fi/nanogpt 0.10.2 → 0.11.0

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 (262) hide show
  1. package/dist/Generator.d.ts +10 -5
  2. package/dist/Generator.js +11760 -146
  3. package/dist/{RealDiv-zz7FpkKX.js → RealDiv-Ds-jvL09.js} +28 -30
  4. package/dist/Reshape-Cd6e-Otn.js +14 -0
  5. package/dist/{Reshape-CHdUjC72.js → Reshape-Ct266DEk.js} +21 -23
  6. package/dist/TeachableLLM.d.ts +4 -3
  7. package/dist/TeachableLLM.js +15 -16
  8. package/dist/Trainer.d.ts +2 -2
  9. package/dist/Trainer.js +6 -6
  10. package/dist/{axis_util-BsIr9ZNu.js → axis_util-DofAuy0p.js} +1 -1
  11. package/dist/backend.js +2 -2
  12. package/dist/{backend_util-B1XRLuq9.js → backend_util-C7NWHpv7.js} +72 -73
  13. package/dist/{backend_webgpu-CqpfEImu.js → backend_webgpu-B0Vls736.js} +52 -54
  14. package/dist/broadcast_to-DDaNMbX7.js +28 -0
  15. package/dist/checks/appendCache.js +2 -2
  16. package/dist/checks/attentionMask.js +3 -3
  17. package/dist/checks/gelu.js +2 -2
  18. package/dist/checks/matMulGelu.js +7 -11
  19. package/dist/checks/normRMS.js +9 -9
  20. package/dist/checks/normRMSGrad.js +3 -3
  21. package/dist/checks/packUnpack.js +2 -2
  22. package/dist/checks/qkv.js +11 -12
  23. package/dist/checks/rope.js +2 -2
  24. package/dist/clip_by_value-Dn5tzexi.js +12 -0
  25. package/dist/complex-DClmWqJt.js +11 -0
  26. package/dist/concat-C6X3AAlQ.js +17 -0
  27. package/dist/{concat_util-iBYIyuQe.js → concat_util-CHsJFZJJ.js} +1 -1
  28. package/dist/{dataset-D2P7rHAw.js → dataset-DcjWqUVQ.js} +135 -137
  29. package/dist/dropout-OxuaJz6z.js +92 -0
  30. package/dist/expand_dims-BzfJK2uc.js +11 -0
  31. package/dist/{exports_initializers-CZSUJoVE.js → exports_initializers-eS9QJ6ut.js} +1 -1
  32. package/dist/floor-DIb-lN_u.js +9 -0
  33. package/dist/gather-BcO5UQNJ.js +9 -0
  34. package/dist/{gelu-Bmhopi0J.js → gelu-DqTbCx5x.js} +10 -11
  35. package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-CJcbnKPC.js} +841 -1015
  36. package/dist/index-D0RBWjq8.js +3520 -0
  37. package/dist/{index-DRyE072i.js → index-Dj5TkmPY.js} +330 -331
  38. package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CSaumNDs.js} +132 -134
  39. package/dist/layers/BaseLayer.js +15 -16
  40. package/dist/layers/CausalSelfAttention.js +6 -6
  41. package/dist/layers/MLP.js +4 -4
  42. package/dist/layers/PositionEmbedding.js +7 -7
  43. package/dist/layers/RMSNorm.js +3 -3
  44. package/dist/layers/RoPECache.js +9 -9
  45. package/dist/layers/TiedEmbedding.js +6 -6
  46. package/dist/layers/TransformerBlock.js +1 -1
  47. package/dist/loader/loadTransformers.js +1 -1
  48. package/dist/loader/oldZipLoad.js +21 -22
  49. package/dist/log_sum_exp-VLZgbFAH.js +39 -0
  50. package/dist/main.d.ts +1 -1
  51. package/dist/main.js +49 -50
  52. package/dist/{matMul16-fEAJ4smh.js → matMul16-cDxwemKj.js} +14 -15
  53. package/dist/matMulGelu-B2s_80-H.js +163 -0
  54. package/dist/mat_mul-DxpNTCRz.js +11 -0
  55. package/dist/mod-PrOKlFxH.js +11 -0
  56. package/dist/models/NanoGPTV1.js +2 -2
  57. package/dist/models/model.js +13 -14
  58. package/dist/ones-BX_wEgzB.js +14 -0
  59. package/dist/ops/adamAdjust.js +1 -1
  60. package/dist/ops/adamMoments.js +1 -1
  61. package/dist/ops/add16.js +1 -1
  62. package/dist/ops/appendCache.js +3 -3
  63. package/dist/ops/attentionMask.js +1 -1
  64. package/dist/ops/concat16.js +2 -2
  65. package/dist/ops/cpu/adamAdjust.js +12 -13
  66. package/dist/ops/cpu/adamMoments.js +6 -7
  67. package/dist/ops/cpu/appendCache.js +7 -8
  68. package/dist/ops/cpu/attentionMask.js +11 -11
  69. package/dist/ops/cpu/fusedSoftmax.js +10 -11
  70. package/dist/ops/cpu/gatherSub.js +10 -11
  71. package/dist/ops/cpu/gelu.js +14 -15
  72. package/dist/ops/cpu/matMul16.js +6 -7
  73. package/dist/ops/cpu/matMulGelu.js +5 -6
  74. package/dist/ops/cpu/matMulMul.js +3 -4
  75. package/dist/ops/cpu/mulDropout.js +3 -4
  76. package/dist/ops/cpu/normRMS.js +11 -12
  77. package/dist/ops/cpu/qkv.js +8 -9
  78. package/dist/ops/cpu/rope.js +9 -10
  79. package/dist/ops/cpu/scatterSub.js +14 -16
  80. package/dist/ops/dot16.js +2 -2
  81. package/dist/ops/gatherSub.js +1 -1
  82. package/dist/ops/gelu.js +2 -2
  83. package/dist/ops/grads/add16.js +10 -11
  84. package/dist/ops/grads/attentionMask.js +5 -6
  85. package/dist/ops/grads/gelu.js +3 -4
  86. package/dist/ops/grads/matMul16.js +4 -5
  87. package/dist/ops/grads/matMulGelu.js +8 -9
  88. package/dist/ops/grads/normRMS.js +9 -10
  89. package/dist/ops/grads/pack16.js +4 -5
  90. package/dist/ops/grads/qkv.js +17 -19
  91. package/dist/ops/grads/rope.js +3 -5
  92. package/dist/ops/grads/softmax16.js +3 -4
  93. package/dist/ops/grads/unpack16.js +3 -4
  94. package/dist/ops/grads/utils.d.ts +1 -0
  95. package/dist/ops/grads/utils.js +8 -4
  96. package/dist/ops/matMul16.js +3 -3
  97. package/dist/ops/matMulGelu.js +2 -2
  98. package/dist/ops/matMulMul.js +1 -1
  99. package/dist/ops/mul16.js +1 -1
  100. package/dist/ops/mulDrop.js +1 -1
  101. package/dist/ops/normRMS.js +1 -1
  102. package/dist/ops/pack16.js +3 -4
  103. package/dist/ops/qkv.js +4 -8
  104. package/dist/ops/reshape16.js +16 -18
  105. package/dist/ops/rope.d.ts +1 -1
  106. package/dist/ops/rope.js +3 -8
  107. package/dist/ops/scatterSub.js +1 -1
  108. package/dist/ops/slice16.js +2 -2
  109. package/dist/ops/softmax16.js +5 -8
  110. package/dist/ops/sub16.js +1 -1
  111. package/dist/ops/sum16.js +2 -2
  112. package/dist/ops/transpose16.js +23 -24
  113. package/dist/ops/unpack16.js +2 -2
  114. package/dist/ops/webgl/adamAdjust.js +2 -3
  115. package/dist/ops/webgl/adamMoments.js +1 -2
  116. package/dist/ops/webgl/appendCache.js +1 -2
  117. package/dist/ops/webgl/attentionMask.js +5 -6
  118. package/dist/ops/webgl/fusedSoftmax.js +6 -8
  119. package/dist/ops/webgl/gatherSub.js +6 -7
  120. package/dist/ops/webgl/gelu.js +2 -3
  121. package/dist/ops/webgl/log.js +11 -12
  122. package/dist/ops/webgl/matMul16.js +15 -16
  123. package/dist/ops/webgl/matMulGelu.js +7 -111
  124. package/dist/ops/webgl/matMulMul.js +14 -15
  125. package/dist/ops/webgl/mulDropout.js +8 -9
  126. package/dist/ops/webgl/normRMS.js +7 -8
  127. package/dist/ops/webgl/qkv.js +5 -6
  128. package/dist/ops/webgl/rope.js +7 -8
  129. package/dist/ops/webgl/scatterSub.js +5 -6
  130. package/dist/ops/webgpu/adamAdjust.js +10 -12
  131. package/dist/ops/webgpu/adamMoments.js +8 -10
  132. package/dist/ops/webgpu/add16.js +8 -9
  133. package/dist/ops/webgpu/appendCache.js +23 -25
  134. package/dist/ops/webgpu/attentionMask.js +10 -12
  135. package/dist/ops/webgpu/attentionMask32_program.js +2 -2
  136. package/dist/ops/webgpu/concat16.js +12 -14
  137. package/dist/ops/webgpu/gatherSub.js +9 -11
  138. package/dist/ops/webgpu/gelu.js +28 -29
  139. package/dist/ops/webgpu/matMul16.js +26 -28
  140. package/dist/ops/webgpu/matMul16_program.js +4 -5
  141. package/dist/ops/webgpu/mul16.js +7 -8
  142. package/dist/ops/webgpu/normRMS.js +17 -19
  143. package/dist/ops/webgpu/normRMSGrad.js +21 -28
  144. package/dist/ops/webgpu/pack16.js +12 -13
  145. package/dist/ops/webgpu/pack16_program.js +2 -2
  146. package/dist/ops/webgpu/qkv.js +13 -15
  147. package/dist/ops/webgpu/rope.js +25 -27
  148. package/dist/ops/webgpu/scatterSub.js +7 -9
  149. package/dist/ops/webgpu/slice16.js +21 -23
  150. package/dist/ops/webgpu/softmax16.js +17 -19
  151. package/dist/ops/webgpu/softmax16_program.js +2 -2
  152. package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
  153. package/dist/ops/webgpu/softmax16grad.js +7 -8
  154. package/dist/ops/webgpu/sub16.js +8 -9
  155. package/dist/ops/webgpu/sum16.js +19 -21
  156. package/dist/ops/webgpu/transpose16.js +19 -20
  157. package/dist/ops/webgpu/transpose16_program.js +2 -2
  158. package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
  159. package/dist/ops/webgpu/unpack16.js +3 -4
  160. package/dist/ops/webgpu/utils/binary_op.js +7 -8
  161. package/dist/ops/webgpu/utils/reductions.js +14 -22
  162. package/dist/ops-FJapAPfm.js +476 -0
  163. package/dist/pack16-k4jq6aMX.js +39 -0
  164. package/dist/patches/webgpu_backend.js +19 -20
  165. package/dist/patches/webgpu_base.js +1 -1
  166. package/dist/patches/webgpu_program.js +15 -16
  167. package/dist/{random_width-BVV9HveY.js → random_width-UGQn4OWb.js} +2506 -2761
  168. package/dist/range-CuGvVN2c.js +10 -0
  169. package/dist/relu-Cf80uA2p.js +9 -0
  170. package/dist/reshape-CkjKPPqB.js +9 -0
  171. package/dist/resize_nearest_neighbor-DB8k9KN_.js +175 -0
  172. package/dist/rope-BmZmp9uP.js +24 -0
  173. package/dist/{scatter_nd_util-C7zXRT_h.js → scatter_nd_util-BY22Cc-C.js} +1 -1
  174. package/dist/selu_util-BuLbmbrl.js +44 -0
  175. package/dist/{shared-CHhxz-O5.js → shared-B7USJZgw.js} +1 -1
  176. package/dist/{shared-D2NP_CpY.js → shared-BQboIImQ.js} +379 -381
  177. package/dist/slice-Aqy7KbJh.js +12 -0
  178. package/dist/{slice_util-DyjSAD0u.js → slice_util-D8CQRenR.js} +7 -7
  179. package/dist/{softmax-C9JQEtnO.js → softmax-faLoUZVT.js} +4 -5
  180. package/dist/split-BNz5jcGc.js +9 -0
  181. package/dist/squeeze--YMgaAAf.js +10 -0
  182. package/dist/stack-WJK22CFn.js +11 -0
  183. package/dist/step-dXR33iOg.js +261 -0
  184. package/dist/sum-BdplSvq_.js +11 -0
  185. package/dist/{tensor-0r5yOo2R.js → tensor-BQqrDvpx.js} +1 -1
  186. package/dist/tensor1d-LxP9asMm.js +11 -0
  187. package/dist/{tensor2d-CSB4KOb0.js → tensor2d-BN1sSfQO.js} +6 -7
  188. package/dist/{tensor4d-D7bLqGqz.js → tensor4d-DVwr7pLF.js} +6 -7
  189. package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-Vi4JfLzT.js} +256 -265
  190. package/dist/tile-CvN_LyVr.js +11 -0
  191. package/dist/tokeniser/BaseTokeniser.d.ts +27 -0
  192. package/dist/tokeniser/BaseTokeniser.js +94 -0
  193. package/dist/tokeniser/CharTokeniser.d.ts +4 -3
  194. package/dist/tokeniser/CharTokeniser.js +46 -32
  195. package/dist/tokeniser/bpe.d.ts +4 -3
  196. package/dist/tokeniser/bpe.js +60 -45
  197. package/dist/tokeniser/type.d.ts +11 -0
  198. package/dist/training/Adam.js +2 -2
  199. package/dist/training/AdamExt.js +1 -1
  200. package/dist/training/DatasetBuilder.d.ts +2 -2
  201. package/dist/training/DatasetBuilder.js +32 -36
  202. package/dist/training/FullTrainer.js +1 -1
  203. package/dist/training/Trainer.d.ts +3 -3
  204. package/dist/training/Trainer.js +2 -2
  205. package/dist/training/sparseCrossEntropy.js +5 -5
  206. package/dist/transpose-JawVKyZy.js +36 -0
  207. package/dist/unsorted_segment_sum-LAbmE9G4.js +277 -0
  208. package/dist/utilities/dummy.js +3 -3
  209. package/dist/utilities/multinomialCPU.js +2 -2
  210. package/dist/utilities/packed.d.ts +1 -4
  211. package/dist/utilities/packed.js +10 -745
  212. package/dist/utilities/performance.js +1 -1
  213. package/dist/utilities/profile.js +1 -1
  214. package/dist/utilities/safetensors.js +2 -2
  215. package/dist/utilities/sentences.js +5 -5
  216. package/dist/utilities/weights.js +2 -2
  217. package/dist/{variable-DzfrwYuP.js → variable-DQ9yYgEU.js} +1 -1
  218. package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-CAE4RICo.js} +177 -171
  219. package/dist/{webgpu_util-0_ubCEHJ.js → webgpu_util-BdovYhXr.js} +34 -35
  220. package/dist/zeros-DeiE2zTa.js +13 -0
  221. package/dist/zeros_like-BAz3iKru.js +721 -0
  222. package/package.json +4 -2
  223. package/dist/Reshape-CDVLyVfz.js +0 -16
  224. package/dist/broadcast_to-B0ChcDaz.js +0 -30
  225. package/dist/complex-BBiRlsVq.js +0 -13
  226. package/dist/concat-DmBLPVGC.js +0 -19
  227. package/dist/dropout-B1x1kYMa.js +0 -99
  228. package/dist/expand_dims-ouvfxQ1n.js +0 -13
  229. package/dist/gather-CH9sdacz.js +0 -10
  230. package/dist/index-D6Q1lPZO.js +0 -2157
  231. package/dist/log_sum_exp-D3ftBNY5.js +0 -41
  232. package/dist/mat_mul-C59XWcJd.js +0 -12
  233. package/dist/mod-DESSvHIU.js +0 -12
  234. package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
  235. package/dist/ones-jU9jlQvM.js +0 -15
  236. package/dist/ops-BFDtP6th.js +0 -645
  237. package/dist/pack16-CmVZs6af.js +0 -41
  238. package/dist/patches/PackedTensor.d.ts +0 -12
  239. package/dist/patches/PackedTensor.js +0 -11
  240. package/dist/patches/engine.d.ts +0 -261
  241. package/dist/patches/engine.js +0 -12
  242. package/dist/patches/tape.d.ts +0 -12
  243. package/dist/patches/tape.js +0 -5
  244. package/dist/range-ZZZD60Fx.js +0 -11
  245. package/dist/reciprocal-CrYlsAGD.js +0 -10
  246. package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
  247. package/dist/relu-BYDneVPn.js +0 -10
  248. package/dist/reshape-CaPQzFvz.js +0 -10
  249. package/dist/rope-s4W2XO9B.js +0 -32
  250. package/dist/selu_util-BGPXmd4B.js +0 -303
  251. package/dist/sin-Djs4aQiu.js +0 -16
  252. package/dist/slice-DvovR5wq.js +0 -13
  253. package/dist/split-DBck65sX.js +0 -10
  254. package/dist/squeeze-C00Ipm_7.js +0 -11
  255. package/dist/stack-ChnHwRpX.js +0 -13
  256. package/dist/sum-ywRJj3Zr.js +0 -12
  257. package/dist/tensor-CzmOBsdf.js +0 -909
  258. package/dist/tensor1d-BlUT89BP.js +0 -12
  259. package/dist/tensor_util-DfwaWayG.js +0 -523
  260. package/dist/tile-CR074jmp.js +0 -13
  261. package/dist/transpose-DH4gmHvu.js +0 -38
  262. package/dist/zeros-DBFVbpv5.js +0 -14
@@ -0,0 +1,12 @@
1
+ import { q as c, u as e, E as a, S as l } from "./index-D0RBWjq8.js";
2
+ function u(r, n, o) {
3
+ const s = e(r, "x", "slice", "string_or_numeric");
4
+ if (s.rank === 0)
5
+ throw new Error("Slicing scalar is not possible");
6
+ const t = { x: s }, i = { begin: n, size: o };
7
+ return a.runKernel(l, t, i);
8
+ }
9
+ const x = /* @__PURE__ */ c({ slice_: u });
10
+ export {
11
+ x as s
12
+ };
@@ -1,4 +1,4 @@
1
- import { a as E, k as x } from "./tensor-CzmOBsdf.js";
1
+ import { y as E, a6 as x } from "./index-D0RBWjq8.js";
2
2
  const N = -2, L = -1;
3
3
  function P(n, e, i) {
4
4
  const r = n.shape.length;
@@ -157,7 +157,7 @@ function q(n, e, i, r, t, o, a, f, c) {
157
157
  endValid: !1
158
158
  };
159
159
  J(g, s);
160
- let u = !0, p = !0, M = !0;
160
+ let u = !0, p = !0, y = !0;
161
161
  const I = [], w = [];
162
162
  for (let l = 0; l < n.length; ++l) {
163
163
  if (s.strides[l] === 0)
@@ -173,8 +173,8 @@ function q(n, e, i, r, t, o, a, f, c) {
173
173
  ];
174
174
  if (m && s.strides[l] <= 0)
175
175
  throw Error("only stride 1 allowed on non-range indexing.");
176
- M = M && s.strides[l] === 1;
177
- const y = !!(s.beginMask & 1 << l && s.endMask & 1 << l);
176
+ y = y && s.strides[l] === 1;
177
+ const M = !!(s.beginMask & 1 << l && s.endMask & 1 << l);
178
178
  if (s.beginValid && s.endValid) {
179
179
  if (m) {
180
180
  const G = s.begin[l] < 0 ? d + s.begin[l] : s.begin[l];
@@ -185,9 +185,9 @@ function q(n, e, i, r, t, o, a, f, c) {
185
185
  const b = s.strides[l] === 1 && s.begin[l] === 0 && s.end[l] === d;
186
186
  u = u && b, p = p && (l === 0 && s.strides[l] === 1 || b);
187
187
  } else
188
- u = u && s.strides[l] === 1 && y, p = p && (l === 0 && s.strides[l] === 1 || y);
188
+ u = u && s.strides[l] === 1 && M, p = p && (l === 0 && s.strides[l] === 1 || M);
189
189
  let A, k = !1;
190
- if (s.beginValid && s.endValid ? (A = s.end[l] - s.begin[l], k = !0) : m ? (A = 1, k = !0) : y && d >= 0 && (s.strides[l] < 0 ? A = -d : A = d, k = !0), k) {
190
+ if (s.beginValid && s.endValid ? (A = s.end[l] - s.begin[l], k = !0) : m ? (A = 1, k = !0) : M && d >= 0 && (s.strides[l] < 0 ? A = -d : A = d, k = !0), k) {
191
191
  let b;
192
192
  A === 0 || A < 0 != s.strides[l] < 0 ? b = 0 : b = Math.trunc(A / s.strides[l]) + (A % s.strides[l] !== 0 ? 1 : 0), I.push(b);
193
193
  } else
@@ -202,7 +202,7 @@ function q(n, e, i, r, t, o, a, f, c) {
202
202
  finalShape: w,
203
203
  isIdentity: u,
204
204
  sliceDim0: p,
205
- isSimpleSlice: M,
205
+ isSimpleSlice: y,
206
206
  begin: s.begin,
207
207
  end: s.end,
208
208
  strides: s.strides
@@ -1,13 +1,12 @@
1
- import { A as r, B as f, E as i } from "./index-D6Q1lPZO.js";
2
- import { S as e } from "./tensor_util-DfwaWayG.js";
1
+ import { q as r, u as f, E as e, J as i } from "./index-D0RBWjq8.js";
3
2
  function l(s, o = -1) {
4
3
  const t = f(s, "logits", "softmax", "float32");
5
4
  if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
6
5
  throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
7
6
  const n = { logits: t }, a = { dim: o };
8
- return i.runKernel(e, n, a);
7
+ return e.runKernel(i, n, a);
9
8
  }
10
- const c = /* @__PURE__ */ r({ softmax_: l });
9
+ const p = /* @__PURE__ */ r({ softmax_: l });
11
10
  export {
12
- c as s
11
+ p as s
13
12
  };
@@ -0,0 +1,9 @@
1
+ import { q as p, u as i, E as a, K as c } from "./index-D0RBWjq8.js";
2
+ function e(t, s, n = 0) {
3
+ const o = { x: i(t, "x", "split") }, r = { numOrSizeSplits: s, axis: n };
4
+ return a.runKernel(c, o, r);
5
+ }
6
+ const x = /* @__PURE__ */ p({ split_: e });
7
+ export {
8
+ x as s
9
+ };
@@ -0,0 +1,10 @@
1
+ import { q as o, u as n, L as a } from "./index-D0RBWjq8.js";
2
+ import { r as t } from "./reshape-CkjKPPqB.js";
3
+ function p(s, r) {
4
+ const e = n(s, "x", "squeeze", "string_or_numeric");
5
+ return t(e, a(e.shape, r).newShape);
6
+ }
7
+ const i = /* @__PURE__ */ o({ squeeze_: p });
8
+ export {
9
+ i as s
10
+ };
@@ -0,0 +1,11 @@
1
+ import { q as e, z as c, y as n, E as k, P as i } from "./index-D0RBWjq8.js";
2
+ function u(r, t = 0) {
3
+ const s = c(r, "tensors", "stack", "string_or_numeric");
4
+ n(s.length >= 1, () => "Pass at least one tensor to tf.stack"), s.length > 0 && n(t <= s[0].rank, () => "Axis must be <= rank of the tensor");
5
+ const o = s, a = { axis: t };
6
+ return k.runKernel(i, o, a);
7
+ }
8
+ const l = /* @__PURE__ */ e({ stack_: u });
9
+ export {
10
+ l as s
11
+ };
@@ -0,0 +1,261 @@
1
+ import { y as _, aG as P, q as A, u as M, E as v, aH as q, aI as F, aJ as J, aK as X, aL as Q, aM as Y } from "./index-D0RBWjq8.js";
2
+ function it(t, n, e, o, s = "NHWC", f) {
3
+ const l = t[3], r = [...n, l], c = nt(s);
4
+ return j(t, r, e, f, o, null, null, c);
5
+ }
6
+ function ft(t, n, e, o, s, f, l = "channelsLast") {
7
+ const [r, c] = T(n);
8
+ let u;
9
+ if (l === "channelsLast")
10
+ u = [r, c, t[3], t[3]];
11
+ else if (l === "channelsFirst")
12
+ u = [r, c, t[1], t[1]];
13
+ else
14
+ throw new Error(`Unknown dataFormat ${l}`);
15
+ return j(t, u, e, o, s, f, !1, l);
16
+ }
17
+ function ht(t, n, e, o, s, f, l = "NDHWC") {
18
+ const [r, c, u] = K(n);
19
+ let h, i;
20
+ if (l === "NDHWC")
21
+ i = "channelsLast", h = [r, c, u, t[4], t[4]];
22
+ else if (l === "NCDHW")
23
+ i = "channelsFirst", h = [r, c, u, t[1], t[1]];
24
+ else
25
+ throw new Error(`Unknown dataFormat ${l}`);
26
+ return Z(t, h, e, o, s, !1, i, f);
27
+ }
28
+ function j(t, n, e, o, s, f, l = !1, r = "channelsLast") {
29
+ let [c, u, h, i] = [-1, -1, -1, -1];
30
+ if (r === "channelsLast")
31
+ [c, u, h, i] = t;
32
+ else if (r === "channelsFirst")
33
+ [c, i, u, h] = t;
34
+ else
35
+ throw new Error(`Unknown dataFormat ${r}`);
36
+ const [a, p, , $] = n, [w, g] = T(e), [x, E] = T(o), L = k(a, x), b = k(p, E), { padInfo: C, outHeight: y, outWidth: D } = d(s, u, h, w, g, L, b, f, r), I = l ? $ * i : $;
37
+ let m;
38
+ return r === "channelsFirst" ? m = [c, I, y, D] : r === "channelsLast" && (m = [c, y, D, I]), {
39
+ batchSize: c,
40
+ dataFormat: r,
41
+ inHeight: u,
42
+ inWidth: h,
43
+ inChannels: i,
44
+ outHeight: y,
45
+ outWidth: D,
46
+ outChannels: I,
47
+ padInfo: C,
48
+ strideHeight: w,
49
+ strideWidth: g,
50
+ filterHeight: a,
51
+ filterWidth: p,
52
+ effectiveFilterHeight: L,
53
+ effectiveFilterWidth: b,
54
+ dilationHeight: x,
55
+ dilationWidth: E,
56
+ inShape: t,
57
+ outShape: m,
58
+ filterShape: n
59
+ };
60
+ }
61
+ function Z(t, n, e, o, s, f = !1, l = "channelsLast", r) {
62
+ let [c, u, h, i, a] = [-1, -1, -1, -1, -1];
63
+ if (l === "channelsLast")
64
+ [c, u, h, i, a] = t;
65
+ else if (l === "channelsFirst")
66
+ [c, a, u, h, i] = t;
67
+ else
68
+ throw new Error(`Unknown dataFormat ${l}`);
69
+ const [p, $, w, , g] = n, [x, E, L] = K(e), [b, C, y] = K(o), D = k(p, b), I = k($, C), m = k(w, y), { padInfo: G, outDepth: N, outHeight: R, outWidth: W } = tt(s, u, h, i, x, E, L, D, I, m, r), H = f ? g * a : g;
70
+ let O;
71
+ return l === "channelsFirst" ? O = [c, H, N, R, W] : l === "channelsLast" && (O = [c, N, R, W, H]), {
72
+ batchSize: c,
73
+ dataFormat: l,
74
+ inDepth: u,
75
+ inHeight: h,
76
+ inWidth: i,
77
+ inChannels: a,
78
+ outDepth: N,
79
+ outHeight: R,
80
+ outWidth: W,
81
+ outChannels: H,
82
+ padInfo: G,
83
+ strideDepth: x,
84
+ strideHeight: E,
85
+ strideWidth: L,
86
+ filterDepth: p,
87
+ filterHeight: $,
88
+ filterWidth: w,
89
+ effectiveFilterDepth: D,
90
+ effectiveFilterHeight: I,
91
+ effectiveFilterWidth: m,
92
+ dilationDepth: b,
93
+ dilationHeight: C,
94
+ dilationWidth: y,
95
+ inShape: t,
96
+ outShape: O,
97
+ filterShape: n
98
+ };
99
+ }
100
+ function z(t, n, e, o, s) {
101
+ o == null && (o = B(t, n, e));
102
+ const f = t[0], l = t[1], r = U((f - n + 2 * o) / e + 1, s), c = U((l - n + 2 * o) / e + 1, s);
103
+ return [r, c];
104
+ }
105
+ function S(t, n, e, o, s, f) {
106
+ s == null && (s = B(t, n[0], o[0]));
107
+ const l = [0, 0, 0, e];
108
+ for (let r = 0; r < 3; r++)
109
+ t[r] + 2 * s >= n[r] && (l[r] = U((t[r] - n[r] + 2 * s) / o[r] + 1, f));
110
+ return l;
111
+ }
112
+ function B(t, n, e, o = 1) {
113
+ const s = k(n, o);
114
+ return Math.floor((t[0] * (e - 1) - e + s) / 2);
115
+ }
116
+ function T(t) {
117
+ return typeof t == "number" ? [t, t, t] : t.length === 2 ? [t[0], t[1], 1] : t;
118
+ }
119
+ function K(t) {
120
+ return typeof t == "number" ? [t, t, t] : t;
121
+ }
122
+ function k(t, n) {
123
+ return n <= 1 ? t : t + (t - 1) * (n - 1);
124
+ }
125
+ function d(t, n, e, o, s, f, l, r, c) {
126
+ let u, h, i;
127
+ if (typeof t == "number") {
128
+ u = { top: t, bottom: t, left: t, right: t, type: t === 0 ? "VALID" : "NUMBER" };
129
+ const p = z([n, e], f, o, t, r);
130
+ h = p[0], i = p[1];
131
+ } else if (t === "same") {
132
+ h = Math.ceil(n / o), i = Math.ceil(e / s);
133
+ const a = Math.max(0, (h - 1) * o + f - n), p = Math.max(0, (i - 1) * s + l - e), $ = Math.floor(a / 2), w = a - $, g = Math.floor(p / 2), x = p - g;
134
+ u = { top: $, bottom: w, left: g, right: x, type: "SAME" };
135
+ } else if (t === "valid")
136
+ u = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, h = Math.ceil((n - f + 1) / o), i = Math.ceil((e - l + 1) / s);
137
+ else if (typeof t == "object") {
138
+ const a = c === "channelsLast" ? t[1][0] : t[2][0], p = c === "channelsLast" ? t[1][1] : t[2][1], $ = c === "channelsLast" ? t[2][0] : t[3][0], w = c === "channelsLast" ? t[2][1] : t[3][1];
139
+ u = { top: a, bottom: p, left: $, right: w, type: a === 0 && p === 0 && $ === 0 && w === 0 ? "VALID" : "EXPLICIT" }, h = U((n - f + a + p) / o + 1, r), i = U((e - l + $ + w) / s + 1, r);
140
+ } else
141
+ throw Error(`Unknown padding parameter: ${t}`);
142
+ return { padInfo: u, outHeight: h, outWidth: i };
143
+ }
144
+ function tt(t, n, e, o, s, f, l, r, c, u, h) {
145
+ let i, a, p, $;
146
+ if (t === "valid" && (t = 0), typeof t == "number") {
147
+ i = {
148
+ top: t,
149
+ bottom: t,
150
+ left: t,
151
+ right: t,
152
+ front: t,
153
+ back: t,
154
+ type: t === 0 ? "VALID" : "NUMBER"
155
+ };
156
+ const g = S([n, e, o, 1], [r, c, u], 1, [s, f, l], t, h);
157
+ a = g[0], p = g[1], $ = g[2];
158
+ } else if (t === "same") {
159
+ a = Math.ceil(n / s), p = Math.ceil(e / f), $ = Math.ceil(o / l);
160
+ const w = (a - 1) * s + r - n, g = (p - 1) * f + c - e, x = ($ - 1) * l + u - o, E = Math.floor(w / 2), L = w - E, b = Math.floor(g / 2), C = g - b, y = Math.floor(x / 2), D = x - y;
161
+ i = { top: b, bottom: C, left: y, right: D, front: E, back: L, type: "SAME" };
162
+ } else
163
+ throw Error(`Unknown padding parameter: ${t}`);
164
+ return { padInfo: i, outDepth: a, outHeight: p, outWidth: $ };
165
+ }
166
+ function U(t, n) {
167
+ if (!n)
168
+ return Math.trunc(t);
169
+ switch (n) {
170
+ case "round":
171
+ return Math.round(t);
172
+ case "ceil":
173
+ return Math.ceil(t);
174
+ case "floor":
175
+ return Math.floor(t);
176
+ default:
177
+ throw new Error(`Unknown roundingMode ${n}`);
178
+ }
179
+ }
180
+ function V(t) {
181
+ const [n, e, o] = T(t);
182
+ return n === 1 && e === 1 && o === 1;
183
+ }
184
+ function at(t, n) {
185
+ return V(t) || V(n);
186
+ }
187
+ function pt(t) {
188
+ return T(t).every((n) => n > 0);
189
+ }
190
+ function nt(t) {
191
+ if (t === "NHWC")
192
+ return "channelsLast";
193
+ if (t === "NCHW")
194
+ return "channelsFirst";
195
+ throw new Error(`Unknown dataFormat ${t}`);
196
+ }
197
+ function $t(t, n, e) {
198
+ if (e != null) {
199
+ if (typeof n == "string")
200
+ throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
201
+ if (typeof n == "number")
202
+ _(P(n), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
203
+ else if (typeof n == "object")
204
+ n.forEach((o) => {
205
+ o.forEach((s) => {
206
+ _(P(s), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${s}.`);
207
+ });
208
+ });
209
+ else
210
+ throw Error(`Error in ${t}: Unknown padding parameter: ${n}`);
211
+ }
212
+ }
213
+ function et(t) {
214
+ const e = { x: M(t, "x", "sigmoid", "float32") };
215
+ return v.runKernel(q, e);
216
+ }
217
+ const gt = /* @__PURE__ */ A({ sigmoid_: et });
218
+ function ot(t) {
219
+ const e = { x: M(t, "x", "elu", "float32") };
220
+ return v.runKernel(F, e);
221
+ }
222
+ const wt = /* @__PURE__ */ A({ elu_: ot });
223
+ function st(t, n = 0.2) {
224
+ const o = { x: M(t, "x", "leakyRelu") }, s = { alpha: n };
225
+ return v.runKernel(J, o, s);
226
+ }
227
+ const xt = /* @__PURE__ */ A({ leakyRelu_: st });
228
+ function rt(t, n) {
229
+ const e = M(t, "x", "prelu"), o = M(n, "alpha", "prelu"), s = { x: e, alpha: o };
230
+ return v.runKernel(X, s);
231
+ }
232
+ const yt = /* @__PURE__ */ A({ prelu_: rt });
233
+ function lt(t) {
234
+ const e = { x: M(t, "x", "relu6") };
235
+ return v.runKernel(Q, e);
236
+ }
237
+ const Et = /* @__PURE__ */ A({ relu6_: lt });
238
+ function ct(t, n = 0) {
239
+ const o = { x: M(t, "x", "step") }, s = { alpha: n };
240
+ return v.runKernel(Y, o, s);
241
+ }
242
+ const bt = /* @__PURE__ */ A({ step_: ct });
243
+ export {
244
+ bt as a,
245
+ j as b,
246
+ $t as c,
247
+ Z as d,
248
+ wt as e,
249
+ B as f,
250
+ it as g,
251
+ ft as h,
252
+ ht as i,
253
+ nt as j,
254
+ at as k,
255
+ xt as l,
256
+ pt as m,
257
+ yt as p,
258
+ Et as r,
259
+ gt as s,
260
+ V as t
261
+ };
@@ -0,0 +1,11 @@
1
+ import { q as a, u as e, N as c, E as l, Q as m } from "./index-D0RBWjq8.js";
2
+ function i(t, n = null, o = !1) {
3
+ let s = e(t, "x", "sum");
4
+ s.dtype === "bool" && (s = c(s, "int32"));
5
+ const r = { x: s }, u = { axis: n, keepDims: o };
6
+ return l.runKernel(m, r, u);
7
+ }
8
+ const f = /* @__PURE__ */ a({ sum_: i });
9
+ export {
10
+ f as s
11
+ };
@@ -1,4 +1,4 @@
1
- import { x as t, y as a } from "./index-D6Q1lPZO.js";
1
+ import { Y as t, Z as a } from "./index-D0RBWjq8.js";
2
2
  function f(r, n, e) {
3
3
  const o = t(r, e);
4
4
  return a(r, n, o, e);
@@ -0,0 +1,11 @@
1
+ import { X as o, Y as s, Z as t } from "./index-D0RBWjq8.js";
2
+ function h(r, e) {
3
+ o(r);
4
+ const n = s(r, e);
5
+ if (n.length !== 1)
6
+ throw new Error("tensor1d() requires values to be a flat/TypedArray");
7
+ return t(r, null, n, e);
8
+ }
9
+ export {
10
+ h as t
11
+ };
@@ -1,15 +1,14 @@
1
- import { x as t, y as s } from "./index-D6Q1lPZO.js";
2
- import { c as a } from "./tensor-CzmOBsdf.js";
3
- function f(o, r, n) {
4
- if (a(o), r != null && r.length !== 2)
1
+ import { X as t, Y as s, Z as a } from "./index-D0RBWjq8.js";
2
+ function i(n, r, o) {
3
+ if (t(n), r != null && r.length !== 2)
5
4
  throw new Error("tensor2d() requires shape to have two numbers");
6
- const e = t(o, n);
5
+ const e = s(n, o);
7
6
  if (e.length !== 2 && e.length !== 1)
8
7
  throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");
9
8
  if (e.length === 1 && r == null)
10
9
  throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");
11
- return s(o, r, e, n);
10
+ return a(n, r, e, o);
12
11
  }
13
12
  export {
14
- f as t
13
+ i as t
15
14
  };
@@ -1,15 +1,14 @@
1
- import { x as t, y as a } from "./index-D6Q1lPZO.js";
2
- import { c as s } from "./tensor-CzmOBsdf.js";
3
- function f(o, r, n) {
4
- if (s(o), r != null && r.length !== 4)
1
+ import { X as t, Y as a, Z as s } from "./index-D0RBWjq8.js";
2
+ function i(n, r, o) {
3
+ if (t(n), r != null && r.length !== 4)
5
4
  throw new Error("tensor4d() requires shape to have four numbers");
6
- const e = t(o, n);
5
+ const e = a(n, o);
7
6
  if (e.length !== 4 && e.length !== 1)
8
7
  throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
9
8
  if (e.length === 1 && r == null)
10
9
  throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
11
- return a(o, r, e, n);
10
+ return s(n, r, e, o);
12
11
  }
13
12
  export {
14
- f as t
13
+ i as t
15
14
  };