@genai-fi/nanogpt 1.5.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (319) hide show
  1. package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
  2. package/dist/Generator-8IK28IWR.js +316 -0
  3. package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
  4. package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
  5. package/dist/Reshape-H5zZRgr9.js +16 -0
  6. package/dist/RoPECache-dYscFINl.js +722 -0
  7. package/dist/TeachableLLM.js +29 -34
  8. package/dist/api/beamer.js +5 -6
  9. package/dist/api/responses.js +11 -12
  10. package/dist/api/training.js +12 -14
  11. package/dist/axis_util-rF9RnwKE.js +37 -0
  12. package/dist/backend.js +5 -6
  13. package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
  14. package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
  15. package/dist/broadcast_to-CGvLNiQ0.js +20 -0
  16. package/dist/checks/appendCache.js +7 -7
  17. package/dist/checks/attentionMask.js +9 -8
  18. package/dist/checks/check.js +1 -2
  19. package/dist/checks/gelu.js +6 -6
  20. package/dist/checks/index.js +24 -25
  21. package/dist/checks/matMulGelu.js +7 -7
  22. package/dist/checks/normRMS.js +14 -12
  23. package/dist/checks/normRMSGrad.js +9 -8
  24. package/dist/checks/packUnpack.js +7 -7
  25. package/dist/checks/qkv.js +1 -34
  26. package/dist/checks/rope.js +6 -6
  27. package/dist/checks/weights.js +1 -2
  28. package/dist/clip_by_value-D-UX9am5.js +13 -0
  29. package/dist/complex-Cl904TqN.js +13 -0
  30. package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
  31. package/dist/concat-Oip5acVY.js +14 -0
  32. package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
  33. package/dist/data/docx.js +3 -4
  34. package/dist/data/pdf.js +11 -14
  35. package/dist/data/stream.js +1 -2
  36. package/dist/data/textLoader.js +16 -15
  37. package/dist/data-CV_i_H6B.js +11 -0
  38. package/dist/data.js +5 -12
  39. package/dist/dist-CMMLi-qO.js +2675 -0
  40. package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
  41. package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
  42. package/dist/dropout16-CA31Ud5a.js +20 -0
  43. package/dist/dropout_util-SiFMbFXz.js +22 -0
  44. package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
  45. package/dist/expand_dims-Dh3Fulyn.js +10 -0
  46. package/dist/floor-BwjmUb7X.js +8 -0
  47. package/dist/gather-B5Z1RFt5.js +14 -0
  48. package/dist/gatherSub-CRUfUzBa.js +22 -0
  49. package/dist/gelu-Xx9-ohH9.js +25 -0
  50. package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
  51. package/dist/inference/Beamer.js +34 -27
  52. package/dist/inference/Generator.js +1 -273
  53. package/dist/inference/tokenisePrompt.js +5 -4
  54. package/dist/inference/types.d.ts +6 -0
  55. package/dist/inference/utilities.js +1 -2
  56. package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
  57. package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
  58. package/dist/layers/BaseLayer.js +9 -10
  59. package/dist/layers/GQA.js +45 -44
  60. package/dist/layers/HeadLayer.js +13 -13
  61. package/dist/layers/LoRA.js +17 -20
  62. package/dist/layers/MHA.d.ts +2 -2
  63. package/dist/layers/MHA.js +46 -45
  64. package/dist/layers/MLP.js +22 -21
  65. package/dist/layers/PositionEmbedding.js +14 -13
  66. package/dist/layers/RMSNorm.js +14 -13
  67. package/dist/layers/RoPECache.js +1 -338
  68. package/dist/layers/TiedEmbedding.js +15 -14
  69. package/dist/layers/TransformerBlock.d.ts +3 -9
  70. package/dist/layers/TransformerBlock.js +29 -30
  71. package/dist/layers/WeightStore.js +4 -5
  72. package/dist/layers-CFqEip3s.js +13 -0
  73. package/dist/layers.js +3 -11
  74. package/dist/loader/load.js +27 -24
  75. package/dist/loader/loadHF.js +3 -3
  76. package/dist/loader/loadTransformers.js +5 -6
  77. package/dist/loader/loadZipMeta.js +1 -2
  78. package/dist/loader/newZipLoad.js +1 -2
  79. package/dist/loader/oldZipLoad.js +8 -9
  80. package/dist/loader/save.js +15 -16
  81. package/dist/main.js +3281 -3463
  82. package/dist/{matMul16-CO1QhsRt.js → matMul16-tE26fnhf.js} +29 -27
  83. package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
  84. package/dist/mat_mul-R9_DWmIT.js +16 -0
  85. package/dist/models/Llama.js +48 -49
  86. package/dist/models/NanoGPTV1.js +53 -54
  87. package/dist/models/NanoGPTV2.js +48 -49
  88. package/dist/models/Qwen3.js +48 -49
  89. package/dist/models/config.js +3 -8
  90. package/dist/models/factory.js +7 -8
  91. package/dist/models/model.d.ts +5 -7
  92. package/dist/models/model.js +1 -2
  93. package/dist/models-DyBpJJwM.js +13 -0
  94. package/dist/models.js +6 -14
  95. package/dist/mul16-C7sqgqik.js +41 -0
  96. package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
  97. package/dist/not_equal-Bu3O8rh_.js +67 -0
  98. package/dist/one_hot-TEMPumJj.js +14 -0
  99. package/dist/ones-DpPXWa6A.js +13 -0
  100. package/dist/ops/adamAdjust.js +2 -3
  101. package/dist/ops/adamMoments.js +2 -3
  102. package/dist/ops/add16.js +2 -3
  103. package/dist/ops/appendCache.js +9 -8
  104. package/dist/ops/attentionMask.d.ts +1 -1
  105. package/dist/ops/attentionMask.js +8 -5
  106. package/dist/ops/concat16.js +5 -5
  107. package/dist/ops/cpu/adamAdjust.js +7 -8
  108. package/dist/ops/cpu/adamMoments.js +5 -5
  109. package/dist/ops/cpu/appendCache.js +3 -3
  110. package/dist/ops/cpu/attentionMask.js +12 -8
  111. package/dist/ops/cpu/fusedSoftmax.js +3 -3
  112. package/dist/ops/cpu/gatherSub.js +1 -12
  113. package/dist/ops/cpu/gelu.js +12 -13
  114. package/dist/ops/cpu/matMul16.js +7 -7
  115. package/dist/ops/cpu/matMulGelu.js +21 -18
  116. package/dist/ops/cpu/matMulMul.js +8 -9
  117. package/dist/ops/cpu/mulDropout.js +8 -9
  118. package/dist/ops/cpu/normRMS.js +12 -13
  119. package/dist/ops/cpu/qkv.js +14 -13
  120. package/dist/ops/cpu/rope.js +11 -8
  121. package/dist/ops/cpu/scatterSub.js +1 -12
  122. package/dist/ops/dot16.js +16 -17
  123. package/dist/ops/dropout.js +9 -8
  124. package/dist/ops/dropout16.js +1 -22
  125. package/dist/ops/gatherSub.js +3 -4
  126. package/dist/ops/gelu.js +1 -2
  127. package/dist/ops/globalNorm.js +10 -10
  128. package/dist/ops/grads/add16.js +16 -17
  129. package/dist/ops/grads/attentionMask.js +6 -7
  130. package/dist/ops/grads/dropout16.js +1 -1
  131. package/dist/ops/grads/gelu.js +1 -2
  132. package/dist/ops/grads/matMul16.js +1 -2
  133. package/dist/ops/grads/matMulGelu.js +6 -7
  134. package/dist/ops/grads/mul16.js +1 -1
  135. package/dist/ops/grads/normRMS.js +8 -9
  136. package/dist/ops/grads/pack16.js +1 -2
  137. package/dist/ops/grads/qkv.js +10 -10
  138. package/dist/ops/grads/rope.js +1 -2
  139. package/dist/ops/grads/silu.js +1 -2
  140. package/dist/ops/grads/softmax16.js +6 -7
  141. package/dist/ops/grads/unpack16.js +1 -2
  142. package/dist/ops/grads/utils.js +1 -2
  143. package/dist/ops/matMul16.d.ts +1 -1
  144. package/dist/ops/matMul16.js +1 -2
  145. package/dist/ops/matMulGelu.js +3 -4
  146. package/dist/ops/matMulMul.js +2 -3
  147. package/dist/ops/mul16.js +1 -43
  148. package/dist/ops/mulDrop.js +2 -3
  149. package/dist/ops/normRMS.js +2 -3
  150. package/dist/ops/pack16.js +1 -2
  151. package/dist/ops/qkv.js +2 -3
  152. package/dist/ops/reshape16.js +11 -11
  153. package/dist/ops/rope.js +1 -2
  154. package/dist/ops/scatterSub.js +3 -4
  155. package/dist/ops/silu.js +1 -2
  156. package/dist/ops/slice16.js +5 -5
  157. package/dist/ops/softmax16.js +3 -4
  158. package/dist/ops/sub16.js +3 -4
  159. package/dist/ops/sum16.js +3 -3
  160. package/dist/ops/transpose16.js +16 -15
  161. package/dist/ops/unpack16.js +1 -2
  162. package/dist/ops/webgl/adamAdjust.js +8 -9
  163. package/dist/ops/webgl/adamMoments.js +2 -3
  164. package/dist/ops/webgl/appendCache.js +2 -3
  165. package/dist/ops/webgl/attentionMask.js +2 -3
  166. package/dist/ops/webgl/dropout16.js +2 -3
  167. package/dist/ops/webgl/fusedSoftmax.js +13 -13
  168. package/dist/ops/webgl/gatherSub.js +2 -3
  169. package/dist/ops/webgl/gelu.js +11 -12
  170. package/dist/ops/webgl/log.js +10 -10
  171. package/dist/ops/webgl/matMul16.js +31 -24
  172. package/dist/ops/webgl/matMulGelu.js +1 -2
  173. package/dist/ops/webgl/matMulMul.js +3 -4
  174. package/dist/ops/webgl/mulDropout.js +2 -3
  175. package/dist/ops/webgl/normRMS.js +11 -10
  176. package/dist/ops/webgl/qkv.js +2 -3
  177. package/dist/ops/webgl/rope.js +4 -5
  178. package/dist/ops/webgl/scatterSub.js +2 -3
  179. package/dist/ops/webgpu/adamAdjust.js +13 -14
  180. package/dist/ops/webgpu/adamMoments.js +13 -14
  181. package/dist/ops/webgpu/add16.js +3 -4
  182. package/dist/ops/webgpu/appendCache.js +20 -21
  183. package/dist/ops/webgpu/attentionMask.js +18 -19
  184. package/dist/ops/webgpu/attentionMask32_program.js +7 -8
  185. package/dist/ops/webgpu/clipScale.js +11 -12
  186. package/dist/ops/webgpu/concat16.js +17 -18
  187. package/dist/ops/webgpu/dropout16.js +6 -7
  188. package/dist/ops/webgpu/gatherSub.js +11 -12
  189. package/dist/ops/webgpu/gelu.js +10 -11
  190. package/dist/ops/webgpu/index.js +17 -17
  191. package/dist/ops/webgpu/matMul16.js +74 -63
  192. package/dist/ops/webgpu/matMul16_program.d.ts +2 -1
  193. package/dist/ops/webgpu/matMul16_program.js +29 -21
  194. package/dist/ops/webgpu/mul16.js +3 -4
  195. package/dist/ops/webgpu/norm2.js +9 -10
  196. package/dist/ops/webgpu/normRMS.js +9 -10
  197. package/dist/ops/webgpu/normRMS16_program.js +1 -2
  198. package/dist/ops/webgpu/normRMS32_program.js +1 -2
  199. package/dist/ops/webgpu/normRMSGrad.js +30 -30
  200. package/dist/ops/webgpu/pack16.js +2 -3
  201. package/dist/ops/webgpu/pack16_program.js +3 -4
  202. package/dist/ops/webgpu/qkv.js +10 -11
  203. package/dist/ops/webgpu/rope.js +26 -27
  204. package/dist/ops/webgpu/scatterSub.js +12 -13
  205. package/dist/ops/webgpu/silu.js +10 -11
  206. package/dist/ops/webgpu/slice16.js +17 -18
  207. package/dist/ops/webgpu/softmax16.js +9 -9
  208. package/dist/ops/webgpu/softmax16_program.js +9 -10
  209. package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
  210. package/dist/ops/webgpu/softmax16grad.js +8 -9
  211. package/dist/ops/webgpu/sub16.js +3 -4
  212. package/dist/ops/webgpu/sum16.js +16 -15
  213. package/dist/ops/webgpu/transpose16.js +13 -12
  214. package/dist/ops/webgpu/transpose16_program.js +3 -4
  215. package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
  216. package/dist/ops/webgpu/unpack16.js +8 -9
  217. package/dist/ops/webgpu/utils/binary_op.js +20 -21
  218. package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
  219. package/dist/ops/webgpu/utils/reductions.js +21 -20
  220. package/dist/ops-Be5ACU5R.js +13 -0
  221. package/dist/ops-C1UpdEYM.js +509 -0
  222. package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
  223. package/dist/pad-Dy-1IP3A.js +13 -0
  224. package/dist/patches/webgpu_backend.js +18 -19
  225. package/dist/patches/webgpu_base.js +2 -3
  226. package/dist/patches/webgpu_program.js +21 -22
  227. package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
  228. package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
  229. package/dist/qkv-BQfNPucX.js +42 -0
  230. package/dist/rand_util-_vCY93Uw.js +44 -0
  231. package/dist/random_normal-DUIT8kyC.js +11 -0
  232. package/dist/range-CYvQC3fW.js +13 -0
  233. package/dist/relu-C4XULT8A.js +8 -0
  234. package/dist/reshape-DJb1jgMt.js +8 -0
  235. package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
  236. package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
  237. package/dist/{rope-BPu_uooz.js → rope-JjBVufF_.js} +6 -8
  238. package/dist/scatterSub-BOnqk-uY.js +27 -0
  239. package/dist/scatter_nd_util-BepMCpLY.js +34 -0
  240. package/dist/seedrandom-SHEGFK6H.js +282 -0
  241. package/dist/selu_util-DeOTf-sc.js +27 -0
  242. package/dist/shared-BIDMUBCs.js +1864 -0
  243. package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
  244. package/dist/silu-DsAE2cJ5.js +23 -0
  245. package/dist/slice-Dlb1FlzG.js +13 -0
  246. package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
  247. package/dist/softmax-Dpav_dWw.js +10 -0
  248. package/dist/split-DYnT8chz.js +11 -0
  249. package/dist/squeeze-B3XYGAlg.js +9 -0
  250. package/dist/stack-Dbbt9mIk.js +10 -0
  251. package/dist/step-DA-5DNu9.js +348 -0
  252. package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
  253. package/dist/sum-C8qNbFNp.js +13 -0
  254. package/dist/tensor-ALxWZfmz.js +7 -0
  255. package/dist/tensor1d-BHgkkhTE.js +9 -0
  256. package/dist/tensor2d-ARItvqVn.js +10 -0
  257. package/dist/tensor4d-D1zRBipJ.js +10 -0
  258. package/dist/tfjs_backend-CsXOum0h.js +685 -0
  259. package/dist/tile-DfyQ0KX-.js +10 -0
  260. package/dist/tokenise-DbS2Ea-T.js +14 -0
  261. package/dist/tokenise.js +6 -15
  262. package/dist/tokeniser/BaseTokeniser.js +5 -9
  263. package/dist/tokeniser/CharTokeniser.js +1 -2
  264. package/dist/tokeniser/bpe.js +19 -20
  265. package/dist/topk-BrU2pkrR.js +19 -0
  266. package/dist/training/AdamW.js +35 -31
  267. package/dist/training/BasicTrainer.js +56 -56
  268. package/dist/training/DatasetBuilder.js +1 -2
  269. package/dist/training/Evaluator.js +4 -4
  270. package/dist/training/LRScheduler.js +1 -2
  271. package/dist/training/PreTrainer.js +7 -8
  272. package/dist/training/SFTTrainer.js +7 -8
  273. package/dist/training/configure.js +16 -15
  274. package/dist/training/factory.js +1 -2
  275. package/dist/training/loss.js +1 -2
  276. package/dist/training/orthoGrad.js +2 -3
  277. package/dist/training/prepareData.js +18 -17
  278. package/dist/training/sparseCrossEntropy.js +38 -32
  279. package/dist/training/tasks/TokenStore.js +21 -22
  280. package/dist/training/tasks/tokenStream.js +1 -2
  281. package/dist/training/validateOptions.js +1 -2
  282. package/dist/training/validation.js +1 -2
  283. package/dist/transpose-BC-M_OoT.js +34 -0
  284. package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
  285. package/dist/utilities/arrayClose.js +5 -4
  286. package/dist/utilities/arrayShape.js +1 -2
  287. package/dist/utilities/datasetID.js +1 -2
  288. package/dist/utilities/dummy.js +15 -15
  289. package/dist/utilities/float16.js +10 -10
  290. package/dist/utilities/maxHeap.js +1 -2
  291. package/dist/utilities/multinomialCPU.d.ts +1 -2
  292. package/dist/utilities/multinomialCPU.js +6 -8
  293. package/dist/utilities/packed.js +2 -3
  294. package/dist/utilities/parameters.js +3 -4
  295. package/dist/utilities/performance.js +2 -3
  296. package/dist/utilities/profile.js +3 -4
  297. package/dist/utilities/random.js +1 -2
  298. package/dist/utilities/safetensors.js +14 -14
  299. package/dist/utilities/sentences.js +16 -13
  300. package/dist/utilities/tokenParse.js +1 -2
  301. package/dist/utilities/tokens.js +5 -6
  302. package/dist/utilities/topP.d.ts +1 -0
  303. package/dist/utilities/topP.js +20 -13
  304. package/dist/utilities/waitForModel.js +1 -2
  305. package/dist/utilities/weights.js +4 -4
  306. package/dist/utilities/yielder.js +1 -2
  307. package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
  308. package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
  309. package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
  310. package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
  311. package/dist/zeros-hxKGkRfl.js +12 -0
  312. package/package.json +3 -3
  313. package/dist/Reshape-CwxdaU8n.js +0 -17
  314. package/dist/dist-Da20xy8E.js +0 -6375
  315. package/dist/gelu-B6637MKa.js +0 -27
  316. package/dist/selu_util-B_AFEfoz.js +0 -24
  317. package/dist/shared-24EoeHJl.js +0 -1314
  318. package/dist/silu-B6bvCgJ7.js +0 -25
  319. package/dist/tfjs_backend-h5weiy1O.js +0 -614
@@ -0,0 +1,509 @@
1
+ import { B as e, Bt as t, D as n, E as r, M as i, N as a, O as o, P as s, Q as c, Si as l, Sn as u, Z as d, b as f, cr as p, gn as m, j as h, jr as g, k as _, m as v, or as y, p as b, rn as x, rt as S, sr as C, ui as w, v as ee, yi as T } from "./dist-CMMLi-qO.js";
2
+ import { t as E } from "./tile-DfyQ0KX-.js";
3
+ import { t as D } from "./expand_dims-Dh3Fulyn.js";
4
+ import { t as O } from "./tensor1d-BHgkkhTE.js";
5
+ import { n as te, r as ne, t as re } from "./non_max_suppression_impl-B0H318rb.js";
6
+ import { a as ie, c as ae, d as oe, f as k, i as se, l as A, n as ce, o as j, p as M, r as N, s as le, t as ue, u as P } from "./resize_nearest_neighbor-DAqcTYUe.js";
7
+ import { t as F } from "./split-DYnT8chz.js";
8
+ import { t as I } from "./sum-C8qNbFNp.js";
9
+ import { a as L, i as R, n as de, r as fe, s as z, t as pe } from "./not_equal-Bu3O8rh_.js";
10
+ import { t as B } from "./slice-Dlb1FlzG.js";
11
+ import { t as V } from "./range-CYvQC3fW.js";
12
+ import { t as me } from "./tensor-ALxWZfmz.js";
13
+ import { r as H, t as U } from "./transpose-BC-M_OoT.js";
14
+ import { t as W } from "./reshape-DJb1jgMt.js";
15
+ import { t as G } from "./stack-Dbbt9mIk.js";
16
+ import { t as he } from "./zeros-hxKGkRfl.js";
17
+ import { t as ge } from "./squeeze-B3XYGAlg.js";
18
+ import { t as K } from "./concat-Oip5acVY.js";
19
+ import { t as q } from "./mat_mul-R9_DWmIT.js";
20
+ import { t as J } from "./tensor2d-ARItvqVn.js";
21
+ import { t as _e } from "./ones-DpPXWa6A.js";
22
+ import { t as ve } from "./relu-C4XULT8A.js";
23
+ import { a as ye } from "./axis_util-rF9RnwKE.js";
24
+ // node_modules/@tensorflow/tfjs-core/dist/ops/bincount.js
25
+ function be(e, n, r) {
26
+ let i = c(e, "x", "bincount"), a = c(n, "weights", "bincount");
27
+ T(i.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${i.dtype}`), T(r >= 0, () => `size must be non-negative, but got ${r}.`), T(a.size === i.size || a.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${i.shape}, weights shape: ${a.shape}.`);
28
+ let o = {
29
+ x: i,
30
+ weights: a
31
+ }, s = { size: r };
32
+ return S.runKernel(t, o, s);
33
+ }
34
+ var xe = /* @__PURE__ */ d({ bincount_: be });
35
+ // node_modules/@tensorflow/tfjs-core/dist/ops/einsum.js
36
+ function Se(e, ...t) {
37
+ let n = t.map((e, t) => c(e, `tensors${t}`, "einsum")), r = { equation: e };
38
+ return S.runKernel(m, n, r);
39
+ }
40
+ var Y = /* @__PURE__ */ d({ einsum_: Se });
41
+ // node_modules/@tensorflow/tfjs-core/dist/ops/eye.js
42
+ function Ce(e, t, n, r = "float32") {
43
+ t ??= e;
44
+ let i = s([e, t], r), a = e <= t ? e : t;
45
+ for (let e = 0; e < a; ++e) i.set(1, e, e);
46
+ let o = W(i.toTensor(), [e, t]);
47
+ if (n == null) return o;
48
+ if (n.length === 1) return E(D(o, 0), [
49
+ n[0],
50
+ 1,
51
+ 1
52
+ ]);
53
+ if (n.length === 2) return E(D(D(o, 0), 0), [
54
+ n[0],
55
+ n[1],
56
+ 1,
57
+ 1
58
+ ]);
59
+ if (n.length === 3) return E(D(D(D(o, 0), 0), 0), [
60
+ n[0],
61
+ n[1],
62
+ n[2],
63
+ 1,
64
+ 1
65
+ ]);
66
+ throw Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`);
67
+ }
68
+ var we = /* @__PURE__ */ d({ eye_: Ce });
69
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/crop_and_resize.js
70
+ function Te(e, t, n, r, i = "bilinear", a = 0) {
71
+ let o = c(e, "image", "cropAndResize"), s = c(t, "boxes", "cropAndResize", "float32"), l = c(n, "boxInd", "cropAndResize", "int32"), u = s.shape[0];
72
+ T(o.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`), T(s.rank === 2 && s.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${u},4] but had shape ${s.shape}.`), T(l.rank === 1 && l.shape[0] === u, () => `Error in cropAndResize: boxInd must be have size [${u}] but had shape ${s.shape}.`), T(r.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`), T(r[0] >= 1 && r[1] >= 1, () => `cropSize must be atleast [1,1], but was ${r}`), T(i === "bilinear" || i === "nearest", () => `method must be bilinear or nearest, but was ${i}`);
73
+ let d = {
74
+ image: o,
75
+ boxes: s,
76
+ boxInd: l
77
+ }, f = {
78
+ method: i,
79
+ extrapolationValue: a,
80
+ cropSize: r
81
+ };
82
+ return S.runKernel(x, d, f);
83
+ }
84
+ var Ee = /* @__PURE__ */ d({ cropAndResize_: Te });
85
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/flip_left_right.js
86
+ function De(e) {
87
+ let t = c(e, "image", "flipLeftRight", "float32");
88
+ T(t.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`);
89
+ let n = { image: t };
90
+ return S.runKernel(u, n, {});
91
+ }
92
+ var Oe = /* @__PURE__ */ d({ flipLeftRight_: De });
93
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/grayscale_to_rgb.js
94
+ function ke(e) {
95
+ let t = c(e, "image", "grayscaleToRGB"), n = t.rank - 1, r = t.shape[n];
96
+ T(t.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`), T(r === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`);
97
+ let i = Array(t.rank);
98
+ return i.fill(1, 0, n), i[n] = 3, E(t, i);
99
+ }
100
+ var Ae = /* @__PURE__ */ d({ grayscaleToRGB_: ke });
101
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/rgb_to_grayscale.js
102
+ function je(e) {
103
+ let t = c(e, "image", "RGBToGrayscale"), n = t.rank - 1, r = t.shape[n];
104
+ T(t.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${t.rank}.`), T(r === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`);
105
+ let i = t.dtype, o = a(t, "float32"), s = O([
106
+ .2989,
107
+ .587,
108
+ .114
109
+ ]), l;
110
+ switch (t.rank) {
111
+ case 2:
112
+ l = Y("ij,j->i", o, s);
113
+ break;
114
+ case 3:
115
+ l = Y("ijk,k->ij", o, s);
116
+ break;
117
+ case 4:
118
+ l = Y("ijkl,l->ijk", o, s);
119
+ break;
120
+ case 5:
121
+ l = Y("ijklm,m->ijkl", o, s);
122
+ break;
123
+ case 6:
124
+ l = Y("ijklmn,n->ijklm", o, s);
125
+ break;
126
+ default: throw Error("Not a valid tensor rank.");
127
+ }
128
+ return l = D(l, -1), a(l, i);
129
+ }
130
+ var Me = /* @__PURE__ */ d({ rgbToGrayscale_: je });
131
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/rotate_with_offset.js
132
+ function Ne(e, t, n = 0, r = .5) {
133
+ let i = c(e, "image", "rotateWithOffset", "float32");
134
+ T(i.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${i.rank}.`);
135
+ let a = { image: i }, o = {
136
+ radians: t,
137
+ fillValue: n,
138
+ center: r
139
+ };
140
+ return S.runKernel(g, a, o);
141
+ }
142
+ var Pe = /* @__PURE__ */ d({ rotateWithOffset_: Ne });
143
+ // node_modules/@tensorflow/tfjs-core/dist/ops/nonmax_util.js
144
+ function X(e, t, n, r, i, a) {
145
+ r ??= .5, i ??= -Infinity, a ??= 0;
146
+ let o = e.shape[0];
147
+ return n = Math.min(n, o), T(0 <= r && r <= 1, () => `iouThreshold must be in [0, 1], but was '${r}'`), T(e.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${e.rank}'`), T(e.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`), T(t.rank === 1, () => "scores must be a 1D tensor"), T(t.shape[0] === o, () => `scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`), T(0 <= a && a <= 1, () => `softNmsSigma must be in [0, 1], but was '${a}'`), {
148
+ maxOutputSize: n,
149
+ iouThreshold: r,
150
+ scoreThreshold: i,
151
+ softNmsSigma: a
152
+ };
153
+ }
154
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression.js
155
+ function Fe(e, t, n, r = .5, i = -Infinity) {
156
+ let a = c(e, "boxes", "nonMaxSuppression", "float32"), o = c(t, "scores", "nonMaxSuppression", "float32"), s = X(a, o, n, r, i);
157
+ n = s.maxOutputSize, r = s.iouThreshold, i = s.scoreThreshold;
158
+ let l = {
159
+ maxOutputSize: n,
160
+ iouThreshold: r,
161
+ scoreThreshold: i
162
+ };
163
+ return S.runKernel(y, {
164
+ boxes: a,
165
+ scores: o
166
+ }, l);
167
+ }
168
+ var Ie = /* @__PURE__ */ d({ nonMaxSuppression_: Fe });
169
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_async.js
170
+ async function Le(e, t, n, r = .5, i = -Infinity) {
171
+ let a = c(e, "boxes", "nonMaxSuppressionAsync"), o = c(t, "scores", "nonMaxSuppressionAsync"), s = X(a, o, n, r, i);
172
+ n = s.maxOutputSize, r = s.iouThreshold, i = s.scoreThreshold;
173
+ let l = await Promise.all([a.data(), o.data()]), u = l[0], d = l[1], { selectedIndices: f } = re(u, d, n, r, i);
174
+ return a !== e && a.dispose(), o !== t && o.dispose(), O(f, "int32");
175
+ }
176
+ var Re = Le;
177
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_with_score.js
178
+ function ze(e, t, n, r = .5, i = -Infinity, a = 0) {
179
+ let o = c(e, "boxes", "nonMaxSuppression"), s = c(t, "scores", "nonMaxSuppression"), l = X(o, s, n, r, i, a);
180
+ n = l.maxOutputSize, r = l.iouThreshold, i = l.scoreThreshold, a = l.softNmsSigma;
181
+ let u = {
182
+ boxes: o,
183
+ scores: s
184
+ }, d = {
185
+ maxOutputSize: n,
186
+ iouThreshold: r,
187
+ scoreThreshold: i,
188
+ softNmsSigma: a
189
+ }, f = S.runKernel(p, u, d);
190
+ return {
191
+ selectedIndices: f[0],
192
+ selectedScores: f[1]
193
+ };
194
+ }
195
+ var Be = /* @__PURE__ */ d({ nonMaxSuppressionWithScore_: ze });
196
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_with_score_async.js
197
+ async function Ve(e, t, n, r = .5, i = -Infinity, a = 0) {
198
+ let o = c(e, "boxes", "nonMaxSuppressionAsync"), s = c(t, "scores", "nonMaxSuppressionAsync"), l = X(o, s, n, r, i, a);
199
+ n = l.maxOutputSize, r = l.iouThreshold, i = l.scoreThreshold, a = l.softNmsSigma;
200
+ let u = await Promise.all([o.data(), s.data()]), d = u[0], f = u[1], { selectedIndices: p, selectedScores: m } = ne(d, f, n, r, i, a);
201
+ return o !== e && o.dispose(), s !== t && s.dispose(), {
202
+ selectedIndices: O(p, "int32"),
203
+ selectedScores: O(m)
204
+ };
205
+ }
206
+ var He = Ve;
207
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_padded.js
208
+ function Ue(e, t, n, r = .5, i = -Infinity, a = !1) {
209
+ let o = c(e, "boxes", "nonMaxSuppression"), s = c(t, "scores", "nonMaxSuppression"), l = X(o, s, n, r, i, null), u = l.maxOutputSize, d = l.iouThreshold, f = l.scoreThreshold, p = {
210
+ boxes: o,
211
+ scores: s
212
+ }, m = {
213
+ maxOutputSize: u,
214
+ iouThreshold: d,
215
+ scoreThreshold: f,
216
+ padToMaxOutputSize: a
217
+ }, h = S.runKernel(C, p, m);
218
+ return {
219
+ selectedIndices: h[0],
220
+ validOutputs: h[1]
221
+ };
222
+ }
223
+ var We = /* @__PURE__ */ d({ nonMaxSuppressionPadded_: Ue });
224
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/non_max_suppression_padded_async.js
225
+ async function Ge(e, t, n, r = .5, i = -Infinity, a = !1) {
226
+ let o = c(e, "boxes", "nonMaxSuppressionAsync"), s = c(t, "scores", "nonMaxSuppressionAsync"), l = X(o, s, n, r, i, null), u = l.maxOutputSize, d = l.iouThreshold, p = l.scoreThreshold, [m, h] = await Promise.all([o.data(), s.data()]), { selectedIndices: g, validOutputs: _ } = te(m, h, u, d, p, a);
227
+ return o !== e && o.dispose(), s !== t && s.dispose(), {
228
+ selectedIndices: O(g, "int32"),
229
+ validOutputs: f(_, "int32")
230
+ };
231
+ }
232
+ var Ke = Ge;
233
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/threshold.js
234
+ function qe(e, t = "binary", n = !1, r = .5) {
235
+ let i = c(e, "image", "threshold"), s = i.shape[0] * i.shape[1], l = o(O([r]), 255), u, d, f, p;
236
+ if (T(i.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${i.rank}.`), T(i.shape[2] === 3 || i.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${i.shape[2]}.`), T(i.dtype === "int32" || i.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${i.dtype}.`), T(t === "otsu" || t === "binary", () => `Method must be binary or otsu, but was ${t}`), i.shape[2] === 3) {
237
+ [u, d, f] = F(i, [
238
+ 1,
239
+ 1,
240
+ 1
241
+ ], -1);
242
+ let e = o(u, .2989), t = o(d, .587), n = o(f, .114);
243
+ p = h(h(e, t), n);
244
+ } else p = e;
245
+ t === "otsu" && (l = Je(xe(a(ie(p), "int32"), me([]), 256), s));
246
+ let m = n ? A(p, l) : k(p, l);
247
+ return a(o(m, 255), "int32");
248
+ }
249
+ function Je(e, t) {
250
+ let n = O([-1]), i = O([0]), a = O([0]), s, c, l, u, d, f;
251
+ for (let p = 0; p < e.size - 1; p++) {
252
+ s = B(e, 0, p + 1), c = B(e, p + 1), d = _(I(s), t), f = _(I(c), t);
253
+ let m = I(o(s, V(0, s.size)));
254
+ l = _(m, I(s));
255
+ let g = r(c.shape, s.size), v = h(V(0, c.size), g), y = o(c, v);
256
+ u = _(I(y), I(c));
257
+ let x = b(l, u), S = b(l, u), C = o(d, f);
258
+ a = o(o(C, x), S);
259
+ let w = k(a, i);
260
+ i = z(w, a, i), n = z(w, O([p]), n);
261
+ }
262
+ return n;
263
+ }
264
+ var Ye = /* @__PURE__ */ d({ threshold_: qe });
265
+ // node_modules/@tensorflow/tfjs-core/dist/ops/image/transform.js
266
+ function Xe(e, t, n = "nearest", r = "constant", i = 0, a) {
267
+ let o = c(e, "image", "transform", "float32"), s = c(t, "transforms", "transform", "float32");
268
+ T(o.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${o.rank}.`), T(s.rank === 2 && (s.shape[0] === o.shape[0] || s.shape[0] === 1) && s.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), T(a == null || a.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${a}.`);
269
+ let l = {
270
+ image: o,
271
+ transforms: s
272
+ }, u = {
273
+ interpolation: n,
274
+ fillMode: r,
275
+ fillValue: i,
276
+ outputShape: a
277
+ };
278
+ return S.runKernel(w, l, u);
279
+ }
280
+ var Ze = /* @__PURE__ */ d({ transform_: Xe });
281
+ // node_modules/@tensorflow/tfjs-core/dist/ops/linalg/band_part.js
282
+ function Qe(e, t, n) {
283
+ let r = c(e, "a", "bandPart");
284
+ T(r.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${r.rank}.`);
285
+ let i = r.shape, [a, o] = r.shape.slice(-2), s, l;
286
+ typeof t == "number" ? (T(t % 1 == 0, () => `bandPart(): numLower must be an integer, got ${t}.`), T(t <= a, () => `bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`), s = c(t < 0 ? a : t, "numLower", "bandPart")) : (T(t.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), s = z(P(t, 0), a, j(t, a))), typeof n == "number" ? (T(n % 1 == 0, () => `bandPart(): numUpper must be an integer, got ${n}.`), T(n <= o, () => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`), l = c(n < 0 ? o : n, "numUpper", "bandPart")) : (T(n.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), l = z(P(n, 0), o, j(n, o)));
287
+ let u = W(V(0, a, 1, "int32"), [-1, 1]), d = V(0, o, 1, "int32"), f = b(u, d), p = le(A(f, s), oe(f, H(l))), m = he([a, o], r.dtype);
288
+ return W(G(N(W(r, [
289
+ -1,
290
+ a,
291
+ o
292
+ ])).map((e) => z(p, e, m))), i);
293
+ }
294
+ var $e = /* @__PURE__ */ d({ bandPart_: Qe });
295
+ // node_modules/@tensorflow/tfjs-core/dist/ops/linalg/gram_schmidt.js
296
+ function et(e) {
297
+ let t;
298
+ if (Array.isArray(e)) {
299
+ t = !1, T(e != null && e.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
300
+ let n = e[0].shape[0];
301
+ for (let t = 1; t < e.length; ++t) T(e[t].shape[0] === n, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`);
302
+ } else t = !0, e = F(e, e.shape[0], 0).map((e) => ge(e, [0]));
303
+ T(e.length <= e[0].shape[0], () => `Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);
304
+ let n = [], r = e;
305
+ for (let t = 0; t < e.length; ++t) n.push(S.tidy(() => {
306
+ let e = r[t];
307
+ if (t > 0) for (let r = 0; r < t; ++r) {
308
+ let t = o(I(o(n[r], e)), n[r]);
309
+ e = b(e, t);
310
+ }
311
+ return _(e, M(e, "euclidean"));
312
+ }));
313
+ return t ? G(n, 0) : n;
314
+ }
315
+ var tt = /* @__PURE__ */ d({ gramSchmidt_: et });
316
+ // node_modules/@tensorflow/tfjs-core/dist/ops/linalg/qr.js
317
+ function nt(e, t = !1) {
318
+ if (T(e.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`), e.rank === 2) return Z(e, t);
319
+ {
320
+ let n = e.shape.slice(0, e.shape.length - 2).reduce((e, t) => e * t), r = N(W(e, [
321
+ n,
322
+ e.shape[e.shape.length - 2],
323
+ e.shape[e.shape.length - 1]
324
+ ]), 0), i = [], a = [];
325
+ return r.forEach((e) => {
326
+ let [n, r] = Z(e, t);
327
+ i.push(n), a.push(r);
328
+ }), [W(G(i, 0), e.shape), W(G(a, 0), e.shape)];
329
+ }
330
+ }
331
+ function Z(t, n = !1) {
332
+ return S.tidy(() => {
333
+ T(t.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${t.shape.length}D Tensor.`);
334
+ let r = t.shape[0], a = t.shape[1], s = we(r), c = i(t), l = J([[1]], [1, 1]), u = i(l), d = r >= a ? a : r;
335
+ for (let t = 0; t < d; ++t) {
336
+ let n = c, d = u, f = s;
337
+ [u, c, s] = S.tidy(() => {
338
+ let e = B(c, [t, t], [r - t, 1]), n = M(e), d = B(c, [t, t], [1, 1]), f = z(k(d, 0), J([[-1]]), J([[1]])), p = b(d, o(f, n)), m = _(e, p);
339
+ u = m.shape[0] === 1 ? i(l) : K([l, B(m, [1, 0], [m.shape[0] - 1, m.shape[1]])], 0);
340
+ let h = H(_(q(f, p), n)), g = B(c, [t, 0], [r - t, a]), v = o(h, u), y = U(u);
341
+ if (t === 0) c = b(g, q(v, q(y, g)));
342
+ else {
343
+ let e = b(g, q(v, q(y, g)));
344
+ c = K([B(c, [0, 0], [t, a]), e], 0);
345
+ }
346
+ let x = U(v), S = B(s, [0, t], [r, s.shape[1] - t]);
347
+ if (t === 0) s = b(S, q(q(S, u), x));
348
+ else {
349
+ let e = b(S, q(q(S, u), x));
350
+ s = K([B(s, [0, 0], [r, t]), e], 1);
351
+ }
352
+ return [
353
+ u,
354
+ c,
355
+ s
356
+ ];
357
+ }), e([
358
+ n,
359
+ d,
360
+ f
361
+ ]);
362
+ }
363
+ return !n && r > a && (s = B(s, [0, 0], [r, a]), c = B(c, [0, 0], [a, a])), [s, c];
364
+ });
365
+ }
366
+ var rt = /* @__PURE__ */ d({ qr_: nt }), Q;
367
+ (function(e) {
368
+ e[e.NONE = 0] = "NONE", e[e.MEAN = 1] = "MEAN", e[e.SUM = 2] = "SUM", e[e.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS";
369
+ })(Q ||= {});
370
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/compute_weighted_loss.js
371
+ function it(e, t, n = Q.SUM_BY_NONZERO_WEIGHTS) {
372
+ let r = c(e, "losses", "computeWeightedLoss"), i = null;
373
+ t != null && (i = c(t, "weights", "computeWeightedLoss"));
374
+ let s = i == null ? r : o(r, i);
375
+ if (n === Q.NONE) return s;
376
+ if (n === Q.SUM) return I(s);
377
+ if (n === Q.MEAN) {
378
+ if (i == null) return de(s);
379
+ {
380
+ let e = r.size / i.size, t = _(I(s), I(i));
381
+ return e > 1 ? _(t, f(e)) : t;
382
+ }
383
+ }
384
+ if (n === Q.SUM_BY_NONZERO_WEIGHTS) {
385
+ if (i == null) return _(I(s), f(r.size));
386
+ {
387
+ let e = o(i, _e(r.shape)), t = a(I(pe(e, f(0))), "float32");
388
+ return _(I(s), t);
389
+ }
390
+ }
391
+ throw Error(`Unknown reduction: ${n}`);
392
+ }
393
+ var $ = /* @__PURE__ */ d({ computeWeightedLoss_: it });
394
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/absolute_difference.js
395
+ function at(e, t, r, i = Q.SUM_BY_NONZERO_WEIGHTS) {
396
+ let a = c(e, "labels", "absoluteDifference"), o = c(t, "predictions", "absoluteDifference"), s = null;
397
+ return r != null && (s = c(r, "weights", "absoluteDifference")), l(a.shape, o.shape, "Error in absoluteDifference: "), $(n(b(a, o)), s, i);
398
+ }
399
+ var ot = /* @__PURE__ */ d({ absoluteDifference_: at });
400
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/cosine_distance.js
401
+ function st(e, t, n, r, i = Q.SUM_BY_NONZERO_WEIGHTS) {
402
+ let a = c(e, "labels", "cosineDistance"), s = c(t, "predictions", "cosineDistance"), u = null;
403
+ r != null && (u = c(r, "weights", "cosineDistance")), l(a.shape, s.shape, "Error in cosineDistance: ");
404
+ let d = f(1);
405
+ return $(b(d, I(o(a, s), n, !0)), u, i);
406
+ }
407
+ var ct = /* @__PURE__ */ d({ cosineDistance_: st });
408
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/hinge_loss.js
409
+ function lt(e, t, n, r = Q.SUM_BY_NONZERO_WEIGHTS) {
410
+ let i = c(e, "labels", "hingeLoss"), a = c(t, "predictions", "hingeLoss"), s = null;
411
+ n != null && (s = c(n, "weights", "hingeLoss")), l(i.shape, a.shape, "Error in hingeLoss: ");
412
+ let u = f(1);
413
+ return i = b(o(f(2), i), u), $(ve(b(u, o(i, a))), s, r);
414
+ }
415
+ var ut = /* @__PURE__ */ d({ hingeLoss_: lt });
416
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/huber_loss.js
417
+ function dt(e, t, r, i = 1, a = Q.SUM_BY_NONZERO_WEIGHTS) {
418
+ let s = c(e, "labels", "huberLoss"), u = c(t, "predictions", "huberLoss"), d = null;
419
+ r != null && (d = c(r, "weights", "huberLoss")), l(s.shape, u.shape, "Error in huberLoss: ");
420
+ let p = f(i), m = n(b(u, s)), g = j(m, p), _ = b(m, g);
421
+ return $(h(o(f(.5), ee(g)), o(p, _)), d, a);
422
+ }
423
+ var ft = /* @__PURE__ */ d({ huberLoss_: dt });
424
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/log_loss.js
425
+ function pt(e, t, n, r = 1e-7, i = Q.SUM_BY_NONZERO_WEIGHTS) {
426
+ let a = c(e, "labels", "logLoss"), s = c(t, "predictions", "logLoss"), u = null;
427
+ n != null && (u = c(n, "weights", "logLoss")), l(a.shape, s.shape, "Error in logLoss: ");
428
+ let d = f(1), p = f(r), m = H(o(a, R(h(s, p)))), g = o(b(d, a), R(h(b(d, s), p)));
429
+ return $(b(m, g), u, i);
430
+ }
431
+ var mt = /* @__PURE__ */ d({ logLoss_: pt });
432
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/mean_squared_error.js
433
+ function ht(e, t, n, r = Q.SUM_BY_NONZERO_WEIGHTS) {
434
+ let i = c(e, "labels", "meanSquaredError"), a = c(t, "predictions", "meanSquaredError"), o = null;
435
+ return n != null && (o = c(n, "weights", "meanSquaredError")), l(i.shape, a.shape, "Error in meanSquaredError: "), $(se(i, a), o, r);
436
+ }
437
+ var gt = /* @__PURE__ */ d({ meanSquaredError_: ht });
438
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/sigmoid_cross_entropy.js
439
+ function _t(e, t) {
440
+ let r = c(e, "labels", "sigmoidCrossEntropyWithLogits"), i = c(t, "logits", "sigmoidCrossEntropyWithLogits");
441
+ l(r.shape, i.shape, "Error in sigmoidCrossEntropyWithLogits: ");
442
+ let a = ve(i), s = o(i, r), u = ae(L(H(n(i))));
443
+ return h(b(a, s), u);
444
+ }
445
+ function vt(e, t, n, r = 0, i = Q.SUM_BY_NONZERO_WEIGHTS) {
446
+ let a = c(e, "multiClassLabels", "sigmoidCrossEntropy"), s = c(t, "logits", "sigmoidCrossEntropy"), u = null;
447
+ if (n != null && (u = c(n, "weights", "sigmoidCrossEntropy")), l(a.shape, s.shape, "Error in sigmoidCrossEntropy: "), r > 0) {
448
+ let e = f(r), t = f(1), n = f(.5);
449
+ a = h(o(a, b(t, e)), o(n, e));
450
+ }
451
+ return $(_t(a, s), u, i);
452
+ }
453
+ var yt = /* @__PURE__ */ d({ sigmoidCrossEntropy_: vt });
454
+ // node_modules/@tensorflow/tfjs-core/dist/ops/losses/softmax_cross_entropy.js
455
+ function bt(e, t, n = -1) {
456
+ if (n === -1 && (n = t.rank - 1), n !== t.rank - 1) throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`);
457
+ return v((e, t, r) => {
458
+ let i = fe(t, [n], !0), s = b(a(t, "float32"), i);
459
+ r([e, s]);
460
+ let c = H(o(s, e));
461
+ return {
462
+ value: I(c, [n]),
463
+ gradFunc: (e, t) => {
464
+ let [r, i] = t, s = ye(e.shape, [n]);
465
+ return [o(W(e, s), b(a(r, "float32"), L(i))), o(W(e, s), b(L(i), a(r, "float32")))];
466
+ }
467
+ };
468
+ })(e, t);
469
+ }
470
+ function xt(e, t, n, r = 0, i = Q.SUM_BY_NONZERO_WEIGHTS) {
471
+ let a = c(e, "onehotLabels", "softmaxCrossEntropy"), s = c(t, "logits", "softmaxCrossEntropy"), u = null;
472
+ if (n != null && (u = c(n, "weights", "softmaxCrossEntropy")), l(a.shape, s.shape, "Error in softmaxCrossEntropy: "), r > 0) {
473
+ let e = f(r), t = f(1), n = f(a.shape[1]);
474
+ a = h(o(a, b(t, e)), _(e, n));
475
+ }
476
+ return $(bt(a, s), u, i);
477
+ }
478
+ var St = /* @__PURE__ */ d({ softmaxCrossEntropy_: xt }), Ct = {
479
+ flipLeftRight: Oe,
480
+ grayscaleToRGB: Ae,
481
+ resizeNearestNeighbor: ue,
482
+ resizeBilinear: ce,
483
+ rgbToGrayscale: Me,
484
+ rotateWithOffset: Pe,
485
+ cropAndResize: Ee,
486
+ nonMaxSuppression: Ie,
487
+ nonMaxSuppressionAsync: Re,
488
+ nonMaxSuppressionWithScore: Be,
489
+ nonMaxSuppressionWithScoreAsync: He,
490
+ nonMaxSuppressionPadded: We,
491
+ nonMaxSuppressionPaddedAsync: Ke,
492
+ threshold: Ye,
493
+ transform: Ze
494
+ }, wt = {
495
+ bandPart: $e,
496
+ gramSchmidt: tt,
497
+ qr: rt
498
+ }, Tt = {
499
+ absoluteDifference: ot,
500
+ computeWeightedLoss: $,
501
+ cosineDistance: ct,
502
+ hingeLoss: ut,
503
+ huberLoss: ft,
504
+ logLoss: mt,
505
+ meanSquaredError: gt,
506
+ sigmoidCrossEntropy: yt,
507
+ softmaxCrossEntropy: St
508
+ };
509
+ export { we as i, wt as n, Tt as r, Ct as t };
@@ -1,22 +1,21 @@
1
- import { Fi as e, ii as t, mr as n } from "./dist-Da20xy8E.js";
1
+ import { H as e, bt as t } from "./dist-CMMLi-qO.js";
2
+ import { t as n } from "./slice-Dlb1FlzG.js";
2
3
  import { isPackedTensor as r } from "./utilities/packed.js";
3
- //#region lib/ops/grads/unpack16.ts
4
+ // lib/ops/grads/unpack16.ts
4
5
  var i = {
5
6
  kernelName: "Unpack16",
6
7
  inputsToSave: [],
7
8
  outputsToSave: [],
8
9
  gradFunc: (e) => ({ x: () => s(e) })
9
10
  };
10
- e(i);
11
- //#endregion
12
- //#region lib/ops/unpack16.ts
13
- function a(e, n = 1, i = !1) {
14
- if (!r(e)) return e;
15
- let a = t().runKernel("Unpack16", { x: e }, { scaling: n });
16
- return i && e.dispose(), a;
11
+ t(i);
12
+ // lib/ops/unpack16.ts
13
+ function a(t, n = 1, i = !1) {
14
+ if (!r(t)) return t;
15
+ let a = e().runKernel("Unpack16", { x: t }, { scaling: n });
16
+ return i && t.dispose(), a;
17
17
  }
18
- //#endregion
19
- //#region lib/ops/grads/pack16.ts
18
+ // lib/ops/grads/pack16.ts
20
19
  var o = {
21
20
  kernelName: "Pack16",
22
21
  inputsToSave: [],
@@ -26,14 +25,12 @@ var o = {
26
25
  return r.originalShape && r.padding && r.padding > 0 ? n(t, Array(t.shape.length).fill(0), r.originalShape) : t;
27
26
  } })
28
27
  };
29
- e(o);
30
- //#endregion
31
- //#region lib/ops/pack16.ts
32
- function s(e, n = 1, r = 0) {
33
- return t().runKernel("Pack16", { x: e }, {
28
+ t(o);
29
+ // lib/ops/pack16.ts
30
+ function s(t, n = 1, r = 0) {
31
+ return e().runKernel("Pack16", { x: t }, {
34
32
  scaling: n,
35
33
  padding: r
36
34
  });
37
35
  }
38
- //#endregion
39
36
  export { i, o as n, a as r, s as t };
@@ -0,0 +1,13 @@
1
+ import { Q as e, Z as t, pr as n, rt as r } from "./dist-CMMLi-qO.js";
2
+ // node_modules/@tensorflow/tfjs-core/dist/ops/pad.js
3
+ function i(t, i, a = 0) {
4
+ let o = e(t, "x", "pad");
5
+ if (o.rank === 0) throw Error("pad(scalar) is not defined. Pass non-scalar to pad");
6
+ let s = {
7
+ paddings: i,
8
+ constantValue: a
9
+ }, c = { x: o };
10
+ return r.runKernel(n, c, s);
11
+ }
12
+ var a = /* @__PURE__ */ t({ pad_: i });
13
+ export { a as t };
@@ -1,14 +1,14 @@
1
- import { Ms as e, Ps as t, Vs as n, oc as r } from "../dist-Da20xy8E.js";
2
- import { t as i } from "../webgpu-IAn9VotJ.js";
3
- import { l as a } from "../webgpu_program-B0PokuRJ.js";
4
- import { compileProgram as o } from "./webgpu_program.js";
5
- //#region lib/patches/webgpu_backend.ts
6
- var s = (e, n) => {
7
- let r = e.limits.maxComputeWorkgroupsPerDimension, i = n.dispatchLayout, a = n.dispatch;
8
- if (a.every((e) => e <= r)) return a;
9
- t(a[0] > r && i.y === void 0 && i.z === void 0, () => "Dispatch size exceeds WebGPU limits in Y or Z dimension.");
1
+ import { Oi as e, _i as t, qi as n, yi as r } from "../dist-CMMLi-qO.js";
2
+ import { t as i } from "../webgpu-BHX-uBym.js";
3
+ import { compileProgram as a } from "./webgpu_program.js";
4
+ import { l as o } from "../webgpu_program-DvkFqRlR.js";
5
+ // lib/patches/webgpu_backend.ts
6
+ var s = (e, t) => {
7
+ let n = e.limits.maxComputeWorkgroupsPerDimension, i = t.dispatchLayout, a = t.dispatch;
8
+ if (a.every((e) => e <= n)) return a;
9
+ r(a[0] > n && i.y === void 0 && i.z === void 0, () => "Dispatch size exceeds WebGPU limits in Y or Z dimension.");
10
10
  let o = Math.ceil(Math.sqrt(a[0]));
11
- return o > r ? (o = Math.ceil(Math.cbrt(a[0])), t(o <= r, () => "Total dispatch size exceeds WebGPU maximum."), [
11
+ return o > n ? (o = Math.ceil(Math.cbrt(a[0])), r(o <= n, () => "Total dispatch size exceeds WebGPU maximum."), [
12
12
  o,
13
13
  o,
14
14
  o
@@ -23,21 +23,20 @@ var s = (e, n) => {
23
23
  constructor(e, t) {
24
24
  super(e, t), this.subgroupMaxSize = t?.subgroupMaxSize ?? 0, this.subgroupMinSize = t?.subgroupMinSize ?? 0;
25
25
  }
26
- runWebGPUProgram(t, i, c, l, u) {
27
- if (u ||= this.makeTensorInfo(t.outputShape, c), r(u.shape) === 0) return this.tensorMap.get(u.dataId).values = n(u.dtype, 0), u;
28
- this.uploadToGPU(u.dataId), t.dispatch = s(this.device, t);
29
- let d = i.map((e, n) => {
26
+ runWebGPUProgram(r, i, c, l, u) {
27
+ if (u ||= this.makeTensorInfo(r.outputShape, c), n(u.shape) === 0) return this.tensorMap.get(u.dataId).values = e(u.dtype, 0), u;
28
+ this.uploadToGPU(u.dataId), r.dispatch = s(this.device, r);
29
+ let d = i.map((e, t) => {
30
30
  if (e.dtype === "complex64") throw Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts.");
31
31
  return this.uploadToGPU(e.dataId), {
32
32
  dtype: this.tensorMap.get(e.dataId).dtype,
33
33
  shape: e.shape,
34
- name: t.variableNames[n]
34
+ name: r.variableNames[t]
35
35
  };
36
36
  });
37
- t.shaderKey = a(t, d, u);
38
- let f = e().getBool("WEBGPU_ENGINE_COMPILE_ONLY");
39
- return t.shaderKey in this.pipelineCache || (this.pipelineCache[t.shaderKey] = o(this.device, t, d, u, f)), t.pipeline = this.pipelineCache[t.shaderKey], f || this.recordAndSubmit(t, u, i, l), u;
37
+ r.shaderKey = o(r, d, u);
38
+ let f = t().getBool("WEBGPU_ENGINE_COMPILE_ONLY");
39
+ return r.shaderKey in this.pipelineCache || (this.pipelineCache[r.shaderKey] = a(this.device, r, d, u, f)), r.pipeline = this.pipelineCache[r.shaderKey], f || this.recordAndSubmit(r, u, i, l), u;
40
40
  }
41
41
  };
42
- //#endregion
43
42
  export { c as default };
@@ -1,6 +1,6 @@
1
- import { li as e } from "../dist-Da20xy8E.js";
1
+ import { q as e } from "../dist-CMMLi-qO.js";
2
2
  import t from "./webgpu_backend.js";
3
- //#region lib/patches/webgpu_base.ts
3
+ // lib/patches/webgpu_base.ts
4
4
  var n;
5
5
  function r() {
6
6
  return n;
@@ -24,5 +24,4 @@ function i(r) {
24
24
  return n = c, new t(c, l);
25
25
  }, 3);
26
26
  }
27
- //#endregion
28
27
  export { r as getBackendDevice, i as registerWebGPUBackend };