@genai-fi/nanogpt 1.4.1 → 1.6.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 (341) hide show
  1. package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
  2. package/dist/Generator-BcR_14Cj.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.d.ts +1 -0
  9. package/dist/api/beamer.js +19 -10
  10. package/dist/api/responses.js +11 -12
  11. package/dist/api/training.js +12 -14
  12. package/dist/axis_util-rF9RnwKE.js +37 -0
  13. package/dist/backend.js +5 -6
  14. package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
  15. package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
  16. package/dist/broadcast_to-CGvLNiQ0.js +20 -0
  17. package/dist/checks/appendCache.js +7 -7
  18. package/dist/checks/attentionMask.js +9 -8
  19. package/dist/checks/check.js +1 -2
  20. package/dist/checks/gelu.js +6 -6
  21. package/dist/checks/index.js +24 -25
  22. package/dist/checks/matMulGelu.js +7 -7
  23. package/dist/checks/normRMS.js +14 -12
  24. package/dist/checks/normRMSGrad.js +9 -8
  25. package/dist/checks/packUnpack.js +7 -7
  26. package/dist/checks/qkv.js +1 -34
  27. package/dist/checks/rope.js +6 -6
  28. package/dist/checks/weights.js +1 -2
  29. package/dist/clip_by_value-D-UX9am5.js +13 -0
  30. package/dist/complex-Cl904TqN.js +13 -0
  31. package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
  32. package/dist/concat-Oip5acVY.js +14 -0
  33. package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
  34. package/dist/data/docx.js +3 -4
  35. package/dist/data/pdf.js +11 -14
  36. package/dist/data/stream.js +1 -2
  37. package/dist/data/textLoader.js +16 -15
  38. package/dist/data-CV_i_H6B.js +11 -0
  39. package/dist/data.js +5 -12
  40. package/dist/dist-CMMLi-qO.js +2675 -0
  41. package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
  42. package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
  43. package/dist/dropout16-CA31Ud5a.js +20 -0
  44. package/dist/dropout_util-SiFMbFXz.js +22 -0
  45. package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
  46. package/dist/expand_dims-Dh3Fulyn.js +10 -0
  47. package/dist/floor-BwjmUb7X.js +8 -0
  48. package/dist/gather-B5Z1RFt5.js +14 -0
  49. package/dist/gatherSub-CRUfUzBa.js +22 -0
  50. package/dist/gelu-Xx9-ohH9.js +25 -0
  51. package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
  52. package/dist/inference/Beamer.d.ts +14 -2
  53. package/dist/inference/Beamer.js +170 -105
  54. package/dist/inference/Generator.js +1 -259
  55. package/dist/inference/tokenisePrompt.d.ts +2 -1
  56. package/dist/inference/tokenisePrompt.js +15 -11
  57. package/dist/inference/types.d.ts +7 -0
  58. package/dist/inference/utilities.js +1 -2
  59. package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
  60. package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
  61. package/dist/layers/BaseLayer.js +9 -10
  62. package/dist/layers/{CausalSelfAttention.d.ts → GQA.d.ts} +8 -3
  63. package/dist/layers/GQA.js +102 -0
  64. package/dist/layers/HeadLayer.d.ts +12 -0
  65. package/dist/layers/HeadLayer.js +28 -0
  66. package/dist/layers/LoRA.js +17 -20
  67. package/dist/layers/MHA.d.ts +43 -0
  68. package/dist/layers/MHA.js +102 -0
  69. package/dist/layers/MLP.d.ts +5 -1
  70. package/dist/layers/MLP.js +33 -20
  71. package/dist/layers/PositionEmbedding.js +14 -13
  72. package/dist/layers/RMSNorm.d.ts +2 -0
  73. package/dist/layers/RMSNorm.js +16 -11
  74. package/dist/layers/RoPECache.js +1 -337
  75. package/dist/layers/TiedEmbedding.js +15 -14
  76. package/dist/layers/TransformerBlock.d.ts +4 -10
  77. package/dist/layers/TransformerBlock.js +29 -30
  78. package/dist/layers/WeightStore.js +4 -5
  79. package/dist/layers-CFqEip3s.js +13 -0
  80. package/dist/layers.d.ts +1 -1
  81. package/dist/layers.js +4 -12
  82. package/dist/loader/load.js +27 -24
  83. package/dist/loader/loadHF.js +3 -3
  84. package/dist/loader/loadTransformers.js +22 -7
  85. package/dist/loader/loadZipMeta.js +1 -2
  86. package/dist/loader/newZipLoad.js +1 -2
  87. package/dist/loader/oldZipLoad.js +8 -9
  88. package/dist/loader/save.js +31 -17
  89. package/dist/loader/types.d.ts +8 -2
  90. package/dist/main.js +3281 -3463
  91. package/dist/matMul16-tE26fnhf.js +87 -0
  92. package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
  93. package/dist/mat_mul-R9_DWmIT.js +16 -0
  94. package/dist/models/Llama.d.ts +16 -0
  95. package/dist/models/Llama.js +88 -0
  96. package/dist/models/NanoGPTV1.js +53 -54
  97. package/dist/models/NanoGPTV2.js +48 -49
  98. package/dist/models/Qwen3.d.ts +16 -0
  99. package/dist/models/Qwen3.js +88 -0
  100. package/dist/models/config.d.ts +18 -1
  101. package/dist/models/config.js +3 -8
  102. package/dist/models/factory.js +14 -11
  103. package/dist/models/model.d.ts +5 -7
  104. package/dist/models/model.js +1 -2
  105. package/dist/models-DyBpJJwM.js +13 -0
  106. package/dist/models.js +6 -14
  107. package/dist/mul16-C7sqgqik.js +41 -0
  108. package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
  109. package/dist/not_equal-Bu3O8rh_.js +67 -0
  110. package/dist/one_hot-TEMPumJj.js +14 -0
  111. package/dist/ones-DpPXWa6A.js +13 -0
  112. package/dist/ops/adamAdjust.js +2 -3
  113. package/dist/ops/adamMoments.js +2 -3
  114. package/dist/ops/add16.js +2 -3
  115. package/dist/ops/appendCache.js +9 -8
  116. package/dist/ops/attentionMask.d.ts +1 -1
  117. package/dist/ops/attentionMask.js +8 -5
  118. package/dist/ops/concat16.js +5 -5
  119. package/dist/ops/cpu/adamAdjust.js +7 -8
  120. package/dist/ops/cpu/adamMoments.js +5 -5
  121. package/dist/ops/cpu/appendCache.js +3 -3
  122. package/dist/ops/cpu/attentionMask.js +12 -8
  123. package/dist/ops/cpu/fusedSoftmax.js +3 -3
  124. package/dist/ops/cpu/gatherSub.js +1 -12
  125. package/dist/ops/cpu/gelu.js +12 -13
  126. package/dist/ops/cpu/matMul16.js +7 -7
  127. package/dist/ops/cpu/matMulGelu.js +21 -18
  128. package/dist/ops/cpu/matMulMul.js +8 -9
  129. package/dist/ops/cpu/mulDropout.js +8 -9
  130. package/dist/ops/cpu/normRMS.js +12 -13
  131. package/dist/ops/cpu/qkv.js +14 -13
  132. package/dist/ops/cpu/rope.js +11 -8
  133. package/dist/ops/cpu/scatterSub.js +1 -12
  134. package/dist/ops/dot16.js +16 -17
  135. package/dist/ops/dropout.js +9 -8
  136. package/dist/ops/dropout16.js +1 -22
  137. package/dist/ops/gatherSub.js +3 -4
  138. package/dist/ops/gelu.js +1 -2
  139. package/dist/ops/globalNorm.js +14 -14
  140. package/dist/ops/grads/add16.js +16 -17
  141. package/dist/ops/grads/attentionMask.js +6 -7
  142. package/dist/ops/grads/dropout16.js +1 -1
  143. package/dist/ops/grads/gelu.js +1 -2
  144. package/dist/ops/grads/matMul16.js +1 -2
  145. package/dist/ops/grads/matMulGelu.js +6 -7
  146. package/dist/ops/grads/mul16.js +1 -1
  147. package/dist/ops/grads/normRMS.js +8 -9
  148. package/dist/ops/grads/pack16.js +1 -2
  149. package/dist/ops/grads/qkv.js +10 -10
  150. package/dist/ops/grads/rope.js +1 -2
  151. package/dist/ops/grads/silu.d.ts +2 -0
  152. package/dist/ops/grads/silu.js +1 -0
  153. package/dist/ops/grads/softmax16.js +6 -7
  154. package/dist/ops/grads/unpack16.js +1 -2
  155. package/dist/ops/grads/utils.js +1 -2
  156. package/dist/ops/matMul16.d.ts +2 -2
  157. package/dist/ops/matMul16.js +1 -2
  158. package/dist/ops/matMulGelu.js +3 -4
  159. package/dist/ops/matMulMul.js +2 -3
  160. package/dist/ops/mul16.js +1 -43
  161. package/dist/ops/mulDrop.js +2 -3
  162. package/dist/ops/normRMS.d.ts +1 -1
  163. package/dist/ops/normRMS.js +10 -11
  164. package/dist/ops/pack16.js +1 -2
  165. package/dist/ops/qkv.js +2 -3
  166. package/dist/ops/reshape16.js +11 -11
  167. package/dist/ops/rope.d.ts +1 -1
  168. package/dist/ops/rope.js +1 -2
  169. package/dist/ops/scatterSub.js +3 -4
  170. package/dist/ops/silu.d.ts +3 -0
  171. package/dist/ops/silu.js +1 -0
  172. package/dist/ops/slice16.js +5 -5
  173. package/dist/ops/softmax16.js +3 -4
  174. package/dist/ops/sub16.js +3 -4
  175. package/dist/ops/sum16.js +3 -3
  176. package/dist/ops/transpose16.js +16 -15
  177. package/dist/ops/unpack16.js +1 -2
  178. package/dist/ops/webgl/adamAdjust.js +8 -9
  179. package/dist/ops/webgl/adamMoments.js +2 -3
  180. package/dist/ops/webgl/appendCache.js +2 -3
  181. package/dist/ops/webgl/attentionMask.js +2 -3
  182. package/dist/ops/webgl/dropout16.js +2 -3
  183. package/dist/ops/webgl/fusedSoftmax.js +13 -13
  184. package/dist/ops/webgl/gatherSub.js +2 -3
  185. package/dist/ops/webgl/gelu.js +11 -12
  186. package/dist/ops/webgl/log.js +10 -10
  187. package/dist/ops/webgl/matMul16.js +31 -24
  188. package/dist/ops/webgl/matMulGelu.js +1 -2
  189. package/dist/ops/webgl/matMulMul.js +3 -4
  190. package/dist/ops/webgl/mulDropout.js +2 -3
  191. package/dist/ops/webgl/normRMS.js +11 -10
  192. package/dist/ops/webgl/qkv.js +2 -3
  193. package/dist/ops/webgl/rope.js +10 -9
  194. package/dist/ops/webgl/scatterSub.js +2 -3
  195. package/dist/ops/webgpu/adamAdjust.js +13 -14
  196. package/dist/ops/webgpu/adamMoments.js +13 -14
  197. package/dist/ops/webgpu/add16.js +3 -4
  198. package/dist/ops/webgpu/appendCache.js +20 -21
  199. package/dist/ops/webgpu/attentionMask.js +18 -19
  200. package/dist/ops/webgpu/attentionMask32_program.js +7 -8
  201. package/dist/ops/webgpu/clipScale.js +11 -12
  202. package/dist/ops/webgpu/concat16.js +17 -18
  203. package/dist/ops/webgpu/dropout16.js +6 -7
  204. package/dist/ops/webgpu/gatherSub.js +11 -12
  205. package/dist/ops/webgpu/gelu.js +10 -11
  206. package/dist/ops/webgpu/index.js +17 -16
  207. package/dist/ops/webgpu/matMul16.js +74 -57
  208. package/dist/ops/webgpu/matMul16_program.d.ts +4 -3
  209. package/dist/ops/webgpu/matMul16_program.js +30 -22
  210. package/dist/ops/webgpu/mul16.js +3 -4
  211. package/dist/ops/webgpu/norm2.js +9 -10
  212. package/dist/ops/webgpu/normRMS.js +13 -14
  213. package/dist/ops/webgpu/normRMS16_program.d.ts +2 -1
  214. package/dist/ops/webgpu/normRMS16_program.js +5 -5
  215. package/dist/ops/webgpu/normRMS32_program.d.ts +2 -1
  216. package/dist/ops/webgpu/normRMS32_program.js +5 -5
  217. package/dist/ops/webgpu/normRMSGrad.js +30 -30
  218. package/dist/ops/webgpu/pack16.js +2 -3
  219. package/dist/ops/webgpu/pack16_program.js +3 -4
  220. package/dist/ops/webgpu/qkv.js +10 -11
  221. package/dist/ops/webgpu/rope.js +113 -49
  222. package/dist/ops/webgpu/scatterSub.js +12 -13
  223. package/dist/ops/webgpu/silu.d.ts +14 -0
  224. package/dist/ops/webgpu/silu.js +117 -0
  225. package/dist/ops/webgpu/slice16.js +17 -18
  226. package/dist/ops/webgpu/softmax16.js +9 -9
  227. package/dist/ops/webgpu/softmax16_program.js +9 -10
  228. package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
  229. package/dist/ops/webgpu/softmax16grad.js +8 -9
  230. package/dist/ops/webgpu/sub16.js +3 -4
  231. package/dist/ops/webgpu/sum16.js +16 -15
  232. package/dist/ops/webgpu/transpose16.js +13 -12
  233. package/dist/ops/webgpu/transpose16_program.js +3 -4
  234. package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
  235. package/dist/ops/webgpu/unpack16.js +8 -9
  236. package/dist/ops/webgpu/utils/binary_op.js +20 -21
  237. package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
  238. package/dist/ops/webgpu/utils/reductions.js +21 -20
  239. package/dist/ops-Be5ACU5R.js +13 -0
  240. package/dist/ops-C1UpdEYM.js +509 -0
  241. package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
  242. package/dist/pad-Dy-1IP3A.js +13 -0
  243. package/dist/patches/webgpu_backend.js +18 -19
  244. package/dist/patches/webgpu_base.js +2 -3
  245. package/dist/patches/webgpu_program.js +21 -22
  246. package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
  247. package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
  248. package/dist/qkv-BQfNPucX.js +42 -0
  249. package/dist/rand_util-_vCY93Uw.js +44 -0
  250. package/dist/random_normal-DUIT8kyC.js +11 -0
  251. package/dist/range-CYvQC3fW.js +13 -0
  252. package/dist/relu-C4XULT8A.js +8 -0
  253. package/dist/reshape-DJb1jgMt.js +8 -0
  254. package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
  255. package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
  256. package/dist/rope-JjBVufF_.js +24 -0
  257. package/dist/scatterSub-BOnqk-uY.js +27 -0
  258. package/dist/scatter_nd_util-BepMCpLY.js +34 -0
  259. package/dist/seedrandom-SHEGFK6H.js +282 -0
  260. package/dist/selu_util-DeOTf-sc.js +27 -0
  261. package/dist/shared-BIDMUBCs.js +1864 -0
  262. package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
  263. package/dist/silu-DsAE2cJ5.js +23 -0
  264. package/dist/slice-Dlb1FlzG.js +13 -0
  265. package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
  266. package/dist/softmax-Dpav_dWw.js +10 -0
  267. package/dist/split-DYnT8chz.js +11 -0
  268. package/dist/squeeze-B3XYGAlg.js +9 -0
  269. package/dist/stack-Dbbt9mIk.js +10 -0
  270. package/dist/step-DA-5DNu9.js +348 -0
  271. package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
  272. package/dist/sum-C8qNbFNp.js +13 -0
  273. package/dist/tensor-ALxWZfmz.js +7 -0
  274. package/dist/tensor1d-BHgkkhTE.js +9 -0
  275. package/dist/tensor2d-ARItvqVn.js +10 -0
  276. package/dist/tensor4d-D1zRBipJ.js +10 -0
  277. package/dist/tfjs_backend-CsXOum0h.js +685 -0
  278. package/dist/tile-DfyQ0KX-.js +10 -0
  279. package/dist/tokenise-DbS2Ea-T.js +14 -0
  280. package/dist/tokenise.js +6 -15
  281. package/dist/tokeniser/BaseTokeniser.js +5 -9
  282. package/dist/tokeniser/CharTokeniser.js +1 -2
  283. package/dist/tokeniser/bpe.js +19 -20
  284. package/dist/topk-BrU2pkrR.js +19 -0
  285. package/dist/training/AdamW.js +35 -31
  286. package/dist/training/BasicTrainer.js +56 -56
  287. package/dist/training/DatasetBuilder.js +1 -2
  288. package/dist/training/Evaluator.js +8 -5
  289. package/dist/training/LRScheduler.js +1 -2
  290. package/dist/training/PreTrainer.js +7 -8
  291. package/dist/training/SFTTrainer.js +7 -8
  292. package/dist/training/configure.js +16 -15
  293. package/dist/training/factory.js +1 -2
  294. package/dist/training/loss.js +1 -2
  295. package/dist/training/orthoGrad.js +2 -3
  296. package/dist/training/prepareData.js +18 -17
  297. package/dist/training/sparseCrossEntropy.js +38 -32
  298. package/dist/training/tasks/TokenStore.js +21 -22
  299. package/dist/training/tasks/tokenStream.js +1 -2
  300. package/dist/training/validateOptions.js +1 -2
  301. package/dist/training/validation.js +1 -2
  302. package/dist/transpose-BC-M_OoT.js +34 -0
  303. package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
  304. package/dist/utilities/arrayClose.js +5 -4
  305. package/dist/utilities/arrayShape.js +1 -2
  306. package/dist/utilities/datasetID.js +1 -2
  307. package/dist/utilities/dummy.js +15 -15
  308. package/dist/utilities/float16.js +10 -10
  309. package/dist/utilities/maxHeap.d.ts +16 -0
  310. package/dist/utilities/maxHeap.js +54 -0
  311. package/dist/utilities/multinomialCPU.d.ts +1 -2
  312. package/dist/utilities/multinomialCPU.js +6 -8
  313. package/dist/utilities/packed.js +2 -3
  314. package/dist/utilities/parameters.js +34 -19
  315. package/dist/utilities/performance.js +2 -3
  316. package/dist/utilities/profile.js +3 -4
  317. package/dist/utilities/random.js +1 -2
  318. package/dist/utilities/safetensors.js +14 -14
  319. package/dist/utilities/sentences.js +16 -13
  320. package/dist/utilities/tokenParse.js +1 -2
  321. package/dist/utilities/tokens.js +5 -6
  322. package/dist/utilities/topP.d.ts +1 -0
  323. package/dist/utilities/topP.js +20 -13
  324. package/dist/utilities/waitForModel.js +1 -2
  325. package/dist/utilities/weights.js +4 -4
  326. package/dist/utilities/yielder.js +1 -2
  327. package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
  328. package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
  329. package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
  330. package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
  331. package/dist/zeros-hxKGkRfl.js +12 -0
  332. package/package.json +3 -3
  333. package/dist/Reshape-CwxdaU8n.js +0 -17
  334. package/dist/dist-Da20xy8E.js +0 -6375
  335. package/dist/gelu-B6637MKa.js +0 -27
  336. package/dist/layers/CausalSelfAttention.js +0 -99
  337. package/dist/matMul16-DGtlziMn.js +0 -81
  338. package/dist/rope-C8EAiSGY.js +0 -25
  339. package/dist/selu_util-B_AFEfoz.js +0 -24
  340. package/dist/shared-24EoeHJl.js +0 -1314
  341. package/dist/tfjs_backend-h5weiy1O.js +0 -614
@@ -0,0 +1,722 @@
1
+ import { A as e, At as t, C as n, D as r, Gt as i, In as a, Jn as o, Ln as s, Mt as c, N as l, Ni as u, Nn as d, Nt as f, O as p, Ot as ee, Q as m, Rn as h, S as g, Sr as _, Tt as v, W as y, Y as b, Z as x, b as S, bn as te, f as ne, fi as re, fn as ie, ft as C, hr as ae, j as oe, jt as se, k as w, kt as ce, m as le, ni as ue, p as de, rr as fe, rt as T, sn as pe, st as E, ut as D, v as me, wt as he, x as O, y as ge, yi as k, zr as _e } from "./dist-CMMLi-qO.js";
2
+ import { A as ve, C as ye, D as be, E as A, O as j, T as xe, _ as Se, a as Ce, b as M, c as N, d as P, f as we, g as Te, h as F, i as Ee, j as De, k as Oe, l as ke, m as Ae, n as je, o as Me, p as I, r as L, s as R, t as Ne, u as z, v as Pe, w as Fe, x as Ie, y as Le } from "./unsorted_segment_sum-BelC7R-q.js";
3
+ import { t as B } from "./reshape-DJb1jgMt.js";
4
+ import { t as Re } from "./broadcast_to-CGvLNiQ0.js";
5
+ import { t as ze } from "./clip_by_value-D-UX9am5.js";
6
+ import { t as V } from "./concat-Oip5acVY.js";
7
+ import { a as Be, i as Ve, n as He, o as Ue, r as We, s as H, t as Ge } from "./not_equal-Bu3O8rh_.js";
8
+ import { t as U } from "./mat_mul-R9_DWmIT.js";
9
+ import { a as Ke, f as qe, h as Je, i as Ye, n as Xe, o as W, r as Ze, t as Qe } from "./step-DA-5DNu9.js";
10
+ import { a as $e, c as et, d as tt, f as nt, i as rt, l as it, m as at, n as ot, o as st, p as G, r as ct, s as K, t as lt, u as ut } from "./resize_nearest_neighbor-DAqcTYUe.js";
11
+ import { t as dt } from "./expand_dims-Dh3Fulyn.js";
12
+ import { t as ft } from "./floor-BwjmUb7X.js";
13
+ import { t as pt } from "./gather-B5Z1RFt5.js";
14
+ import { t as q } from "./complex-Cl904TqN.js";
15
+ import { i as mt, n as J, r as Y, t as ht } from "./transpose-BC-M_OoT.js";
16
+ import { t as X } from "./slice-Dlb1FlzG.js";
17
+ import { t as gt } from "./ops-Be5ACU5R.js";
18
+ import { t as _t } from "./one_hot-TEMPumJj.js";
19
+ import { t as vt } from "./pad-Dy-1IP3A.js";
20
+ import { t as yt } from "./relu-C4XULT8A.js";
21
+ import { t as Z } from "./split-DYnT8chz.js";
22
+ import { t as bt } from "./zeros-hxKGkRfl.js";
23
+ import { t as xt } from "./range-CYvQC3fW.js";
24
+ import { t as St } from "./softmax-Dpav_dWw.js";
25
+ import { t as Ct } from "./squeeze-B3XYGAlg.js";
26
+ import { t as wt } from "./stack-Dbbt9mIk.js";
27
+ import { t as Tt } from "./sum-C8qNbFNp.js";
28
+ import { t as Et } from "./tile-DfyQ0KX-.js";
29
+ import { t as Dt } from "./topk-BrU2pkrR.js";
30
+ // node_modules/@tensorflow/tfjs-core/dist/ops/acos.js
31
+ function Ot(e) {
32
+ let t = { x: m(e, "x", "acos") };
33
+ return T.runKernel(he, t);
34
+ }
35
+ var kt = /* @__PURE__ */ x({ acos_: Ot });
36
+ // node_modules/@tensorflow/tfjs-core/dist/ops/acosh.js
37
+ function At(e) {
38
+ let t = { x: m(e, "x", "acosh") };
39
+ return T.runKernel(v, t);
40
+ }
41
+ var jt = /* @__PURE__ */ x({ acosh_: At });
42
+ // node_modules/@tensorflow/tfjs-core/dist/ops/arg_min.js
43
+ function Mt(e, t = 0) {
44
+ let n = { x: m(e, "x", "argMin") }, r = { axis: t };
45
+ return T.runKernel(ee, n, r);
46
+ }
47
+ var Nt = /* @__PURE__ */ x({ argMin_: Mt });
48
+ // node_modules/@tensorflow/tfjs-core/dist/ops/asin.js
49
+ function Pt(e) {
50
+ let t = { x: m(e, "x", "asin") };
51
+ return T.runKernel(ce, t);
52
+ }
53
+ var Ft = /* @__PURE__ */ x({ asin_: Pt });
54
+ // node_modules/@tensorflow/tfjs-core/dist/ops/asinh.js
55
+ function It(e) {
56
+ let n = { x: m(e, "x", "asinh") };
57
+ return T.runKernel(t, n);
58
+ }
59
+ var Lt = /* @__PURE__ */ x({ asinh_: It });
60
+ // node_modules/@tensorflow/tfjs-core/dist/ops/atan.js
61
+ function Rt(e) {
62
+ let t = { x: m(e, "x", "atan") };
63
+ return T.runKernel(se, t);
64
+ }
65
+ var zt = /* @__PURE__ */ x({ atan_: Rt });
66
+ // node_modules/@tensorflow/tfjs-core/dist/ops/atan2.js
67
+ function Bt(e, t) {
68
+ let n = m(e, "a", "atan2"), r = m(t, "b", "atan2");
69
+ [n, r] = E(n, r);
70
+ let i = {
71
+ a: n,
72
+ b: r
73
+ };
74
+ return T.runKernel(c, i);
75
+ }
76
+ var Vt = /* @__PURE__ */ x({ atan2_: Bt });
77
+ // node_modules/@tensorflow/tfjs-core/dist/ops/atanh.js
78
+ function Ht(e) {
79
+ let t = { x: m(e, "x", "atanh") };
80
+ return T.runKernel(f, t);
81
+ }
82
+ var Ut = /* @__PURE__ */ x({ atanh_: Ht });
83
+ // node_modules/@tensorflow/tfjs-core/dist/ops/ceil.js
84
+ function Wt(e) {
85
+ let t = { x: m(e, "x", "ceil", "float32") };
86
+ return T.runKernel(i, t);
87
+ }
88
+ var Gt = /* @__PURE__ */ x({ ceil_: Wt });
89
+ // node_modules/@tensorflow/tfjs-core/dist/ops/depth_to_space.js
90
+ function Kt(e, t, n = "NHWC") {
91
+ let r = m(e, "x", "depthToSpace", "float32"), i = n === "NHWC" ? r.shape[1] : r.shape[2], a = n === "NHWC" ? r.shape[2] : r.shape[3], o = n === "NHWC" ? r.shape[3] : r.shape[1];
92
+ k(t > 1, () => `blockSize should be > 1 for depthToSpace, but was: ${t}`), k(i * t >= 0, () => `Negative dimension size caused by overflow when multiplying
93
+ ${i} and ${t} for depthToSpace with input shape
94
+ ${r.shape}`), k(a * t >= 0, () => `Negative dimension size caused by overflow when multiplying
95
+ ${a} and ${t} for depthToSpace with input shape
96
+ ${r.shape}`), k(o % (t * t) === 0, () => `Dimension size must be evenly divisible by ${t * t} but is ${o} for depthToSpace with input shape ${r.shape}`);
97
+ let s = { x: r }, c = {
98
+ blockSize: t,
99
+ dataFormat: n
100
+ };
101
+ return T.runKernel(pe, s, c);
102
+ }
103
+ var qt = /* @__PURE__ */ x({ depthToSpace_: Kt });
104
+ // node_modules/@tensorflow/tfjs-core/dist/ops/dilation2d.js
105
+ function Jt(e, t, n, r, i = [1, 1], a = "NHWC") {
106
+ let o = m(e, "x", "dilation2d"), s = m(t, "filter", "dilation2d");
107
+ k(o.rank === 3 || o.rank === 4, () => `Error in dilation2d: input must be rank 3 or 4, but got rank ${o.rank}.`), k(s.rank === 3, () => `Error in dilation2d: filter must be rank 3, but got rank ${s.rank}.`), k(a === "NHWC", () => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${a}`);
108
+ let c = o, l = !1;
109
+ o.rank === 3 && (c = B(o, [
110
+ 1,
111
+ o.shape[0],
112
+ o.shape[1],
113
+ o.shape[2]
114
+ ]), l = !0), k(c.shape[3] === s.shape[2], () => `Error in dilation2d: input and filter must have the same depth: ${c.shape[3]} vs ${s.shape[2]}`);
115
+ let u = {
116
+ x: c,
117
+ filter: s
118
+ }, d = {
119
+ strides: n,
120
+ pad: r,
121
+ dilations: i
122
+ }, f = T.runKernel(ie, u, d);
123
+ return l ? B(f, [
124
+ f.shape[1],
125
+ f.shape[2],
126
+ f.shape[3]
127
+ ]) : f;
128
+ }
129
+ var Yt = /* @__PURE__ */ x({ dilation2d_: Jt });
130
+ // node_modules/@tensorflow/tfjs-core/dist/ops/div_no_nan.js
131
+ function Xt(e, t) {
132
+ let n = m(e, "a", "div"), r = m(t, "b", "div");
133
+ [n, r] = E(n, r);
134
+ let i = w(n, r), a = g(i), o = F(r, a);
135
+ return H(o, a, i);
136
+ }
137
+ var Zt = /* @__PURE__ */ x({ divNoNan_: Xt });
138
+ // node_modules/@tensorflow/tfjs-core/dist/ops/dot.js
139
+ function Qt(e, t) {
140
+ let n = m(e, "t1", "dot"), r = m(t, "t2", "dot");
141
+ k((n.rank === 1 || n.rank === 2) && (r.rank === 1 || r.rank === 2), () => `Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${r.rank}.`);
142
+ let i = n.rank === 1 ? n.size : n.shape[1], a = r.rank === 1 ? r.size : r.shape[0];
143
+ if (k(i === a, () => `Error in dot: inner dimensions of inputs must match, but got ${i} and ${a}.`), n.rank === 1 && r.rank === 1) {
144
+ let e = B(n, [1, -1]), t = B(r, [-1, 1]), i = U(e, t);
145
+ return B(i, []);
146
+ }
147
+ if (n.rank === 1 && r.rank === 2) {
148
+ let e = B(n, [1, -1]), t = B(r, [r.shape[0], r.shape[1]]), i = U(e, t);
149
+ return B(i, [i.size]);
150
+ }
151
+ if (n.rank === 2 && r.rank === 1) {
152
+ let e = B(r, [-1, 1]), t = U(n, e);
153
+ return B(t, [t.size]);
154
+ }
155
+ {
156
+ let e = B(r, [r.shape[0], r.shape[1]]);
157
+ return U(n, e);
158
+ }
159
+ }
160
+ var $t = /* @__PURE__ */ x({ dot_: Qt });
161
+ // node_modules/@tensorflow/tfjs-core/dist/ops/euclidean_norm.js
162
+ function en(e, t = null, n = !1) {
163
+ return G(e, "euclidean", t, n);
164
+ }
165
+ var tn = /* @__PURE__ */ x({ euclideanNorm_: en });
166
+ // node_modules/@tensorflow/tfjs-core/dist/ops/expm1.js
167
+ function nn(e) {
168
+ let t = { x: m(e, "x", "expm1") };
169
+ return T.runKernel(te, t);
170
+ }
171
+ var rn = /* @__PURE__ */ x({ expm1_: nn });
172
+ // node_modules/@tensorflow/tfjs-core/dist/ops/is_finite.js
173
+ function an(e) {
174
+ let t = { x: m(e, "x", "isFinite") };
175
+ return T.runKernel(a, t);
176
+ }
177
+ var on = /* @__PURE__ */ x({ isFinite_: an });
178
+ // node_modules/@tensorflow/tfjs-core/dist/ops/is_inf.js
179
+ function sn(e) {
180
+ let t = { x: m(e, "x", "isInf") };
181
+ return T.runKernel(s, t);
182
+ }
183
+ var cn = /* @__PURE__ */ x({ isInf_: sn });
184
+ // node_modules/@tensorflow/tfjs-core/dist/ops/is_nan.js
185
+ function ln(e) {
186
+ let t = { x: m(e, "x", "isNaN") };
187
+ return T.runKernel(h, t);
188
+ }
189
+ var un = /* @__PURE__ */ x({ isNaN_: ln });
190
+ // node_modules/@tensorflow/tfjs-core/dist/ops/local_response_normalization.js
191
+ function dn(e, t = 5, n = 1, r = 1, i = .5) {
192
+ let a = m(e, "x", "localResponseNormalization");
193
+ k(a.rank === 4 || a.rank === 3, () => `Error in localResponseNormalization: x must be rank 3 or 4 but got
194
+ rank ${a.rank}.`), k(u(t), () => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`);
195
+ let o = a, s = !1;
196
+ a.rank === 3 && (s = !0, o = B(a, [
197
+ 1,
198
+ a.shape[0],
199
+ a.shape[1],
200
+ a.shape[2]
201
+ ]));
202
+ let c = { x: o }, l = {
203
+ depthRadius: t,
204
+ bias: n,
205
+ alpha: r,
206
+ beta: i
207
+ }, d = T.runKernel("LRN", c, l);
208
+ return s ? B(d, [
209
+ d.shape[1],
210
+ d.shape[2],
211
+ d.shape[3]
212
+ ]) : d;
213
+ }
214
+ var fn = /* @__PURE__ */ x({ localResponseNormalization_: dn });
215
+ // node_modules/@tensorflow/tfjs-core/dist/ops/log_sigmoid.js
216
+ function pn(e) {
217
+ let t = m(e, "x", "logSigmoid");
218
+ return le((e) => ({
219
+ value: Y(I(Y(e))),
220
+ gradFunc: (t) => p(t, W(Y(e)))
221
+ }))(t);
222
+ }
223
+ var mn = /* @__PURE__ */ x({ logSigmoid_: pn });
224
+ // node_modules/@tensorflow/tfjs-core/dist/ops/logical_or.js
225
+ function hn(e, t) {
226
+ let r = m(e, "a", "logicalOr", "bool"), i = m(t, "b", "logicalOr", "bool");
227
+ n(r.shape, i.shape);
228
+ let a = {
229
+ a: r,
230
+ b: i
231
+ };
232
+ return T.runKernel(o, a);
233
+ }
234
+ var Q = /* @__PURE__ */ x({ logicalOr_: hn });
235
+ // node_modules/@tensorflow/tfjs-core/dist/ops/logical_xor.js
236
+ function gn(e, t) {
237
+ let r = m(e, "a", "logicalXor", "bool"), i = m(t, "b", "logicalXor", "bool");
238
+ return n(r.shape, i.shape), K(Q(e, t), P(K(e, t)));
239
+ }
240
+ var _n = /* @__PURE__ */ x({ logicalXor_: gn });
241
+ // node_modules/@tensorflow/tfjs-core/dist/ops/mirror_pad.js
242
+ function vn(e, t, n) {
243
+ k(n === "reflect" || n === "symmetric", () => `Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`);
244
+ let r = m(e, "x", "mirrorPad");
245
+ if (r.rank === 0) throw Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad");
246
+ k(t.length === r.rank, () => `Padding doesn't match input. Must be ${r.rank}. Got ${t.length}.`);
247
+ let i = +(n === "reflect");
248
+ for (let e = 0; e < r.rank; e++) k(t[e].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), k(t[e][0] >= 0 && t[e][0] <= r.shape[e] - i && t[e][1] >= 0 && t[e][1] <= r.shape[e] - i, () => `Padding in dimension ${e} cannot be greater than or equal to ${r.shape[e] - i} or less than 0 for input of shape ${r.shape}`);
249
+ let a = {
250
+ paddings: t,
251
+ mode: n
252
+ }, o = { x: r };
253
+ return T.runKernel(fe, o, a);
254
+ }
255
+ var yn = /* @__PURE__ */ x({ mirrorPad_: vn });
256
+ // node_modules/@tensorflow/tfjs-core/dist/ops/pool.js
257
+ function bn(e, t, n, r, i, a, o) {
258
+ i ??= [1, 1], a ??= 1, r === 0 && (r = "valid");
259
+ let s = m(e, "x", "maxPool"), c = s, l = !1;
260
+ s.rank === 3 && (l = !0, c = B(s, [
261
+ 1,
262
+ s.shape[0],
263
+ s.shape[1],
264
+ s.shape[2]
265
+ ])), k(Je(a, i), () => `Error in pool: Either strides or dilations must be 1. Got strides ${a} and dilations '${i}'`);
266
+ let u = qe(c.shape, t, a, i, r), d = [u.dilationHeight, u.dilationWidth], f;
267
+ f = r === "same" ? Sn([u.filterHeight, u.filterWidth], d) : [[0, 0], [0, 0]];
268
+ let p = d[0] === 1 && d[1] === 1, [ee, h] = xn([u.inHeight, u.inWidth], d, f), g = p ? r : "valid", _ = p ? c : N(c, d, ee), v = (n === "avg" ? () => j(_, t, a, g, o) : () => z(_, t, a, g, o))(), y = p ? v : A(v, d, h);
269
+ return l ? B(y, [
270
+ y.shape[1],
271
+ y.shape[2],
272
+ y.shape[3]
273
+ ]) : y;
274
+ }
275
+ function xn(e, t, n) {
276
+ let r = n.map((e) => e[0]), i = n.map((e) => e[1]), a = e.concat(r, i), o = t.map((e, t) => (e - a[t] % e) % e), s = i.map((e, t) => e + o[t]);
277
+ return [t.map((e, t) => [r[t], s[t]]), t.map((e, t) => [0, o[t]])];
278
+ }
279
+ function Sn(e, t) {
280
+ let n = e.map((e, n) => e + (e - 1) * (t[n] - 1)).map((e) => e - 1), r = n.map((e) => Math.floor(e / 2)), i = n.map((e, t) => e - r[t]);
281
+ return n.map((e, t) => [r[t], i[t]]);
282
+ }
283
+ var Cn = /* @__PURE__ */ x({ pool_: bn });
284
+ // node_modules/@tensorflow/tfjs-core/dist/ops/prod.js
285
+ function wn(e, t = null, n = !1) {
286
+ let r = m(e, "x", "prod");
287
+ r.dtype === "bool" && (r = l(r, "int32"));
288
+ let i = { x: r }, a = {
289
+ axis: t,
290
+ keepDims: n
291
+ };
292
+ return T.runKernel(ae, i, a);
293
+ }
294
+ var Tn = /* @__PURE__ */ x({ prod_: wn });
295
+ // node_modules/@tensorflow/tfjs-core/dist/ops/reciprocal.js
296
+ function En(e) {
297
+ let t = { x: m(e, "x", "reciprocal") };
298
+ return T.runKernel(_, t);
299
+ }
300
+ var Dn = /* @__PURE__ */ x({ reciprocal_: En });
301
+ // node_modules/@tensorflow/tfjs-core/dist/ops/sign.js
302
+ function On(e) {
303
+ let t = { x: m(e, "x", "sign") };
304
+ return T.runKernel(_e, t);
305
+ }
306
+ var kn = /* @__PURE__ */ x({ sign_: On });
307
+ // node_modules/@tensorflow/tfjs-core/dist/ops/spectral/fft.js
308
+ function An(e) {
309
+ k(e.dtype === "complex64", () => `The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`);
310
+ let t = { input: e };
311
+ return T.runKernel("FFT", t);
312
+ }
313
+ var jn = /* @__PURE__ */ x({ fft_: An });
314
+ // node_modules/@tensorflow/tfjs-core/dist/ops/spectral/ifft.js
315
+ function Mn(e) {
316
+ k(e.dtype === "complex64", () => `The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`);
317
+ let t = { input: e };
318
+ return T.runKernel(d, t);
319
+ }
320
+ var $ = /* @__PURE__ */ x({ ifft_: Mn });
321
+ // node_modules/@tensorflow/tfjs-core/dist/ops/spectral/irfft.js
322
+ function Nn(e) {
323
+ let t = e.shape[e.shape.length - 1], n = e.size / t, r;
324
+ if (t <= 2) r = $(B(e, [n, t]));
325
+ else {
326
+ let i = [n, 2 * (t - 1)], a = B(J(e), [n, t]), o = B(mt(e), [n, t]), s = R(X(a, [0, 1], [n, t - 2]), 1), c = p(R(X(o, [0, 1], [n, t - 2]), 1), S(-1)), l = V([a, s], 1), u = V([o, c], 1);
327
+ r = $(B(q(l, u), [i[0], i[1]]));
328
+ }
329
+ if (r = J(r), e.rank === 3 && e.shape[0] !== 0) {
330
+ let t = r, n = e.shape[0];
331
+ r = B(r, [
332
+ n,
333
+ r.shape[0] / n,
334
+ r.shape[1]
335
+ ]), t.dispose();
336
+ }
337
+ return r;
338
+ }
339
+ var Pn = /* @__PURE__ */ x({ irfft_: Nn });
340
+ // node_modules/@tensorflow/tfjs-core/dist/ops/spectral/rfft.js
341
+ function Fn(e, t) {
342
+ k(e.dtype === "float32", () => `The dtype for rfft() must be real value but got ${e.dtype}`);
343
+ let n = e.shape[e.shape.length - 1], r = e.size / n, i;
344
+ if (t != null && t < n) {
345
+ let r = e.shape.map((e) => 0), a = e.shape.map((e) => e);
346
+ a[e.shape.length - 1] = t, i = X(e, r, a), n = t;
347
+ } else if (t != null && t > n) {
348
+ let r = e.shape.map((e) => e);
349
+ r[e.shape.length - 1] = t - n, i = V([e, bt(r)], e.shape.length - 1), n = t;
350
+ } else i = e;
351
+ let a = g(i), o = jn(B(q(i, a), [r, n])), s = Math.floor(n / 2) + 1, c = J(o), l = mt(o), u = Z(c, [s, n - s], c.shape.length - 1), d = Z(l, [s, n - s], l.shape.length - 1), f = i.shape.slice();
352
+ return f[i.shape.length - 1] = s, B(q(u[0], d[0]), f);
353
+ }
354
+ var In = /* @__PURE__ */ x({ rfft_: Fn });
355
+ // node_modules/@tensorflow/tfjs-core/dist/ops/strided_slice.js
356
+ function Ln(e, t, n, r, i = 0, a = 0, o = 0, s = 0, c = 0) {
357
+ let l = { x: m(e, "x", "stridedSlice", "string_or_numeric") }, u = {
358
+ begin: t,
359
+ end: n,
360
+ strides: r,
361
+ beginMask: i,
362
+ endMask: a,
363
+ ellipsisMask: o,
364
+ newAxisMask: s,
365
+ shrinkAxisMask: c
366
+ };
367
+ return T.runKernel(ue, l, u);
368
+ }
369
+ var Rn = /* @__PURE__ */ x({ stridedSlice_: Ln });
370
+ // node_modules/@tensorflow/tfjs-core/dist/ops/tan.js
371
+ function zn(e) {
372
+ let t = { x: m(e, "x", "tan", "float32") };
373
+ return T.runKernel("Tan", t);
374
+ }
375
+ var Bn = /* @__PURE__ */ x({ tan_: zn });
376
+ // node_modules/@tensorflow/tfjs-core/dist/ops/unique.js
377
+ function Vn(e, t = 0) {
378
+ let n = m(e, "x", "unique", "string_or_numeric");
379
+ k(n.rank > 0, () => "The input tensor must be at least 1D");
380
+ let r = { x: n }, i = { axis: t }, [a, o] = T.runKernel(re, r, i);
381
+ return {
382
+ values: a,
383
+ indices: o
384
+ };
385
+ }
386
+ var Hn = /* @__PURE__ */ x({ unique_: Vn });
387
+ // node_modules/@tensorflow/tfjs-core/dist/public/chained_ops/zeros_like.js
388
+ C().prototype.abs = function() {
389
+ return this.throwIfDisposed(), r(this);
390
+ }, C().prototype.acos = function() {
391
+ return this.throwIfDisposed(), kt(this);
392
+ }, C().prototype.acosh = function() {
393
+ return this.throwIfDisposed(), jt(this);
394
+ }, C().prototype.add = function(e) {
395
+ return this.throwIfDisposed(), oe(this, e);
396
+ }, C().prototype.all = function(e, t) {
397
+ return this.throwIfDisposed(), De(this, e, t);
398
+ }, C().prototype.any = function(e, t) {
399
+ return this.throwIfDisposed(), ve(this, e, t);
400
+ }, C().prototype.argMax = function(e) {
401
+ return this.throwIfDisposed(), Oe(this, e);
402
+ }, C().prototype.argMin = function(e) {
403
+ return this.throwIfDisposed(), Nt(this, e);
404
+ }, C().prototype.asScalar = function() {
405
+ return this.throwIfDisposed(), k(this.size === 1, () => "The array must have only 1 element."), B(this, []);
406
+ }, C().prototype.asType = function(e) {
407
+ return this.throwIfDisposed(), l(this, e);
408
+ }, C().prototype.as1D = function() {
409
+ return this.throwIfDisposed(), B(this, [this.size]);
410
+ }, C().prototype.as2D = function(e, t) {
411
+ return this.throwIfDisposed(), B(this, [e, t]);
412
+ }, C().prototype.as3D = function(e, t, n) {
413
+ return this.throwIfDisposed(), B(this, [
414
+ e,
415
+ t,
416
+ n
417
+ ]);
418
+ }, C().prototype.as4D = function(e, t, n, r) {
419
+ return this.throwIfDisposed(), B(this, [
420
+ e,
421
+ t,
422
+ n,
423
+ r
424
+ ]);
425
+ }, C().prototype.as5D = function(e, t, n, r, i) {
426
+ return this.throwIfDisposed(), B(this, [
427
+ e,
428
+ t,
429
+ n,
430
+ r,
431
+ i
432
+ ]);
433
+ }, C().prototype.asin = function() {
434
+ return this.throwIfDisposed(), Ft(this);
435
+ }, C().prototype.asinh = function() {
436
+ return this.throwIfDisposed(), Lt(this);
437
+ }, C().prototype.atan = function() {
438
+ return this.throwIfDisposed(), zt(this);
439
+ }, C().prototype.atan2 = function(e) {
440
+ return this.throwIfDisposed(), Vt(this, e);
441
+ }, C().prototype.atanh = function() {
442
+ return this.throwIfDisposed(), Ut(this);
443
+ }, C().prototype.avgPool = function(e, t, n, r) {
444
+ return this.throwIfDisposed(), j(this, e, t, n, r);
445
+ }, C().prototype.batchToSpaceND = function(e, t) {
446
+ return this.throwIfDisposed(), A(this, e, t);
447
+ }, C().prototype.batchNorm = function(e, t, n, r, i) {
448
+ return this.throwIfDisposed(), xe(this, e, t, n, r, i);
449
+ }, C().prototype.broadcastTo = function(e) {
450
+ return this.throwIfDisposed(), Re(this, e);
451
+ }, C().prototype.cast = function(e) {
452
+ return this.throwIfDisposed(), l(this, e);
453
+ }, C().prototype.ceil = function() {
454
+ return this.throwIfDisposed(), Gt(this);
455
+ }, C().prototype.clipByValue = function(e, t) {
456
+ return this.throwIfDisposed(), ze(this, e, t);
457
+ }, C().prototype.concat = function(e, t) {
458
+ return this.throwIfDisposed(), e instanceof D && (e = [e]), V([this, ...e], t);
459
+ }, C().prototype.conv1d = function(e, t, n, r, i, a) {
460
+ return this.throwIfDisposed(), ye(this, e, t, n, r, i, a);
461
+ }, C().prototype.conv2dTranspose = function(e, t, n, r, i) {
462
+ return this.throwIfDisposed(), Ie(this, e, t, n, r, i);
463
+ }, C().prototype.conv2d = function(e, t, n, r, i, a) {
464
+ return this.throwIfDisposed(), Fe(this, e, t, n, r, i, a);
465
+ }, C().prototype.cos = function() {
466
+ return this.throwIfDisposed(), M(this);
467
+ }, C().prototype.cosh = function() {
468
+ return this.throwIfDisposed(), Le(this);
469
+ }, C().prototype.cumprod = function(e, t, n) {
470
+ return this.throwIfDisposed(), Pe(this, e, t, n);
471
+ }, C().prototype.cumsum = function(e, t, n) {
472
+ return this.throwIfDisposed(), Se(this, e, t, n);
473
+ }, C().prototype.depthToSpace = function(e, t) {
474
+ return this.throwIfDisposed(), qt(this, e, t);
475
+ }, C().prototype.depthwiseConv2d = function(e, t, n, r, i, a) {
476
+ return this.throwIfDisposed(), Te(this, e, t, n, r, i, a);
477
+ }, C().prototype.dilation2d = function(e, t, n, r, i) {
478
+ return this.throwIfDisposed(), Yt(this, e, t, n, r, i);
479
+ }, C().prototype.divNoNan = function(e) {
480
+ return this.throwIfDisposed(), Zt(this, e);
481
+ }, C().prototype.div = function(e) {
482
+ return this.throwIfDisposed(), w(this, e);
483
+ }, C().prototype.dot = function(e) {
484
+ return this.throwIfDisposed(), $t(this, e);
485
+ }, C().prototype.elu = function() {
486
+ return this.throwIfDisposed(), Ke(this);
487
+ }, C().prototype.equal = function(e) {
488
+ return this.throwIfDisposed(), F(this, e);
489
+ }, C().prototype.erf = function() {
490
+ return this.throwIfDisposed(), Ae(this);
491
+ }, C().prototype.euclideanNorm = function(e, t) {
492
+ return this.throwIfDisposed(), tn(this, e, t);
493
+ }, C().prototype.exp = function() {
494
+ return this.throwIfDisposed(), Be(this);
495
+ }, C().prototype.expandDims = function(e) {
496
+ return this.throwIfDisposed(), dt(this, e);
497
+ }, C().prototype.expm1 = function() {
498
+ return this.throwIfDisposed(), rn(this);
499
+ }, C().prototype.fft = function() {
500
+ return this.throwIfDisposed(), jn(this);
501
+ }, C().prototype.flatten = function() {
502
+ return this.throwIfDisposed(), B(this, [this.size]);
503
+ }, C().prototype.floor = function() {
504
+ return this.throwIfDisposed(), ft(this);
505
+ }, C().prototype.floorDiv = function(t) {
506
+ return this.throwIfDisposed(), e(this, t);
507
+ }, C().prototype.gather = function(e, t, n) {
508
+ return this.throwIfDisposed(), pt(this, e, t, n);
509
+ }, C().prototype.greaterEqual = function(e) {
510
+ return this.throwIfDisposed(), tt(this, e);
511
+ }, C().prototype.greater = function(e) {
512
+ return this.throwIfDisposed(), nt(this, e);
513
+ }, C().prototype.ifft = function() {
514
+ return this.throwIfDisposed(), $(this);
515
+ }, C().prototype.irfft = function() {
516
+ return this.throwIfDisposed(), Pn(this);
517
+ }, C().prototype.isFinite = function() {
518
+ return this.throwIfDisposed(), on(this);
519
+ }, C().prototype.isInf = function() {
520
+ return this.throwIfDisposed(), cn(this);
521
+ }, C().prototype.isNaN = function() {
522
+ return this.throwIfDisposed(), un(this);
523
+ }, C().prototype.leakyRelu = function(e) {
524
+ return this.throwIfDisposed(), Ye(this, e);
525
+ }, C().prototype.lessEqual = function(e) {
526
+ return this.throwIfDisposed(), it(this, e);
527
+ }, C().prototype.less = function(e) {
528
+ return this.throwIfDisposed(), ut(this, e);
529
+ }, C().prototype.localResponseNormalization = function(e, t, n, r) {
530
+ return this.throwIfDisposed(), fn(this, e, t, n, r);
531
+ }, C().prototype.logSigmoid = function() {
532
+ return this.throwIfDisposed(), mn(this);
533
+ }, C().prototype.logSoftmax = function(e) {
534
+ return this.throwIfDisposed(), we(this, e);
535
+ }, C().prototype.logSumExp = function(e, t) {
536
+ return this.throwIfDisposed(), We(this, e, t);
537
+ }, C().prototype.log = function() {
538
+ return this.throwIfDisposed(), Ve(this);
539
+ }, C().prototype.log1p = function() {
540
+ return this.throwIfDisposed(), et(this);
541
+ }, C().prototype.logicalAnd = function(e) {
542
+ return this.throwIfDisposed(), K(this, e);
543
+ }, C().prototype.logicalNot = function() {
544
+ return this.throwIfDisposed(), P(this);
545
+ }, C().prototype.logicalOr = function(e) {
546
+ return this.throwIfDisposed(), Q(this, e);
547
+ }, C().prototype.logicalXor = function(e) {
548
+ return this.throwIfDisposed(), _n(this, e);
549
+ }, C().prototype.matMul = function(e, t, n) {
550
+ return this.throwIfDisposed(), U(this, e, t, n);
551
+ }, C().prototype.maxPool = function(e, t, n, r) {
552
+ return this.throwIfDisposed(), z(this, e, t, n, r);
553
+ }, C().prototype.max = function(e, t) {
554
+ return this.throwIfDisposed(), Ue(this, e, t);
555
+ }, C().prototype.maximum = function(e) {
556
+ return this.throwIfDisposed(), ne(this, e);
557
+ }, C().prototype.mean = function(e, t) {
558
+ return this.throwIfDisposed(), He(this, e, t);
559
+ }, C().prototype.min = function(e, t) {
560
+ return this.throwIfDisposed(), at(this, e, t);
561
+ }, C().prototype.minimum = function(e) {
562
+ return this.throwIfDisposed(), st(this, e);
563
+ }, C().prototype.mirrorPad = function(e, t) {
564
+ return this.throwIfDisposed(), yn(this, e, t);
565
+ }, C().prototype.mod = function(e) {
566
+ return this.throwIfDisposed(), gt(this, e);
567
+ }, C().prototype.mul = function(e) {
568
+ return this.throwIfDisposed(), p(this, e);
569
+ }, C().prototype.neg = function() {
570
+ return this.throwIfDisposed(), Y(this);
571
+ }, C().prototype.norm = function(e, t, n) {
572
+ return this.throwIfDisposed(), G(this, e, t, n);
573
+ }, C().prototype.notEqual = function(e) {
574
+ return this.throwIfDisposed(), Ge(this, e);
575
+ }, C().prototype.oneHot = function(e, t = 1, n = 0) {
576
+ return this.throwIfDisposed(), _t(this, e, t, n);
577
+ }, C().prototype.onesLike = function() {
578
+ return this.throwIfDisposed(), ke(this);
579
+ }, C().prototype.pad = function(e, t) {
580
+ return this.throwIfDisposed(), vt(this, e, t);
581
+ }, C().prototype.pool = function(e, t, n, r, i, a) {
582
+ return this.throwIfDisposed(), Cn(this, e, t, n, r, i, a);
583
+ }, C().prototype.pow = function(e) {
584
+ return this.throwIfDisposed(), O(this, e);
585
+ }, C().prototype.prelu = function(e) {
586
+ return this.throwIfDisposed(), Ze(this, e);
587
+ }, C().prototype.prod = function(e, t) {
588
+ return this.throwIfDisposed(), Tn(this, e, t);
589
+ }, C().prototype.reciprocal = function() {
590
+ return this.throwIfDisposed(), Dn(this);
591
+ }, C().prototype.relu = function() {
592
+ return this.throwIfDisposed(), yt(this);
593
+ }, C().prototype.relu6 = function() {
594
+ return this.throwIfDisposed(), Xe(this);
595
+ }, C().prototype.reshapeAs = function(e) {
596
+ return this.throwIfDisposed(), B(this, e.shape);
597
+ }, C().prototype.reshape = function(e) {
598
+ return this.throwIfDisposed(), B(this, e);
599
+ }, C().prototype.resizeBilinear = function(e, t, n) {
600
+ return this.throwIfDisposed(), ot(this, e, t, n);
601
+ }, C().prototype.resizeNearestNeighbor = function(e, t, n) {
602
+ return this.throwIfDisposed(), lt(this, e, t, n);
603
+ }, C().prototype.reverse = function(e) {
604
+ return this.throwIfDisposed(), R(this, e);
605
+ }, C().prototype.rfft = function() {
606
+ return this.throwIfDisposed(), In(this);
607
+ }, C().prototype.round = function() {
608
+ return this.throwIfDisposed(), $e(this);
609
+ }, C().prototype.rsqrt = function() {
610
+ return this.throwIfDisposed(), Me(this);
611
+ }, C().prototype.selu = function() {
612
+ return this.throwIfDisposed(), Ce(this);
613
+ }, C().prototype.separableConv2d = function(e, t, n, r, i, a) {
614
+ return this.throwIfDisposed(), Ee(this, e, t, n, r, i, a);
615
+ }, C().prototype.sigmoid = function() {
616
+ return this.throwIfDisposed(), W(this);
617
+ }, C().prototype.sign = function() {
618
+ return this.throwIfDisposed(), kn(this);
619
+ }, C().prototype.sin = function() {
620
+ return this.throwIfDisposed(), L(this);
621
+ }, C().prototype.sinh = function() {
622
+ return this.throwIfDisposed(), je(this);
623
+ }, C().prototype.slice = function(e, t) {
624
+ return this.throwIfDisposed(), X(this, e, t);
625
+ }, C().prototype.softmax = function(e) {
626
+ return this.throwIfDisposed(), St(this, e);
627
+ }, C().prototype.softplus = function() {
628
+ return this.throwIfDisposed(), I(this);
629
+ }, C().prototype.spaceToBatchND = function(e, t) {
630
+ return this.throwIfDisposed(), N(this, e, t);
631
+ }, C().prototype.split = function(e, t) {
632
+ return this.throwIfDisposed(), Z(this, e, t);
633
+ }, C().prototype.sqrt = function() {
634
+ return this.throwIfDisposed(), ge(this);
635
+ }, C().prototype.square = function() {
636
+ return this.throwIfDisposed(), me(this);
637
+ }, C().prototype.squaredDifference = function(e) {
638
+ return this.throwIfDisposed(), rt(this, e);
639
+ }, C().prototype.squeeze = function(e) {
640
+ return this.throwIfDisposed(), Ct(this, e);
641
+ }, C().prototype.stack = function(e, t) {
642
+ this.throwIfDisposed();
643
+ let n = e instanceof D ? [this, e] : [this, ...e];
644
+ return wt(n, t);
645
+ }, C().prototype.step = function(e) {
646
+ return this.throwIfDisposed(), Qe(this, e);
647
+ }, C().prototype.stridedSlice = function(e, t, n, r, i, a, o, s) {
648
+ return this.throwIfDisposed(), Rn(this, e, t, n, r, i, a, o, s);
649
+ }, C().prototype.sub = function(e) {
650
+ return this.throwIfDisposed(), de(this, e);
651
+ }, C().prototype.sum = function(e, t) {
652
+ return this.throwIfDisposed(), Tt(this, e, t);
653
+ }, C().prototype.tan = function() {
654
+ return this.throwIfDisposed(), Bn(this);
655
+ }, C().prototype.tanh = function() {
656
+ return this.throwIfDisposed(), be(this);
657
+ }, C().prototype.tile = function(e) {
658
+ return this.throwIfDisposed(), Et(this, e);
659
+ }, C().prototype.toBool = function() {
660
+ return this.throwIfDisposed(), l(this, "bool");
661
+ }, C().prototype.toFloat = function() {
662
+ return this.throwIfDisposed(), l(this, "float32");
663
+ }, C().prototype.toInt = function() {
664
+ return this.throwIfDisposed(), l(this, "int32");
665
+ }, C().prototype.topk = function(e, t) {
666
+ return this.throwIfDisposed(), Dt(this, e, t);
667
+ }, C().prototype.transpose = function(e) {
668
+ return this.throwIfDisposed(), ht(this, e);
669
+ }, C().prototype.unique = function(e) {
670
+ return this.throwIfDisposed(), Hn(this, e);
671
+ }, C().prototype.unsortedSegmentSum = function(e, t) {
672
+ return this.throwIfDisposed(), Ne(this, e, t);
673
+ }, C().prototype.unstack = function(e) {
674
+ return this.throwIfDisposed(), ct(this, e);
675
+ }, C().prototype.where = function(e, t) {
676
+ return this.throwIfDisposed(), H(e, this, t);
677
+ }, C().prototype.zerosLike = function() {
678
+ return this.throwIfDisposed(), g(this);
679
+ };
680
+ // lib/layers/RoPECache.ts
681
+ var Un = class {
682
+ config;
683
+ rotaryDim;
684
+ ropeBase;
685
+ ropeInvFreq;
686
+ ropeCos = null;
687
+ ropeSin = null;
688
+ ropeNegSin = null;
689
+ ropeCacheLen = 0;
690
+ constructor(e) {
691
+ this.config = e;
692
+ let t = this.config.nEmbed / this.config.nHead;
693
+ if (this.rotaryDim = t, this.rotaryDim % 2 != 0) throw Error("rotaryDim must be even");
694
+ let n = this.config.ropeTheta ?? 1e4;
695
+ this.ropeBase = n;
696
+ let r = xt(0, this.rotaryDim, 2, "float32"), i = w(r, S(this.rotaryDim, "float32")), a = O(S(this.ropeBase, "float32"), i);
697
+ this.ropeInvFreq = Dn(a), i.dispose(), a.dispose(), r.dispose(), (this.config.modelType === "GenAI_NanoGPT_v1" ? this.config.useRope ?? !0 : !0) === !1 ? (this.ropeCos = null, this.ropeSin = null, this.ropeNegSin = null, this.ropeCacheLen = 0) : b(() => {
698
+ this.ensureRopeCache(this.config.blockSize * 4);
699
+ });
700
+ }
701
+ ensureRopeCache(e) {
702
+ b(() => {
703
+ if (e <= this.ropeCacheLen) return;
704
+ this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose();
705
+ let t = Math.max(e, this.ropeCacheLen + this.config.blockSize * 4), n = xt(0, t, 1, "float32").expandDims(1).mul(this.ropeInvFreq.expandDims(0));
706
+ this.ropeCos = y(M(n).expandDims(-1)), this.ropeSin = y(L(n).expandDims(-1)), this.ropeNegSin = y(this.ropeSin.neg()), this.ropeCacheLen = t;
707
+ });
708
+ }
709
+ getCos() {
710
+ return this.ropeCos;
711
+ }
712
+ getSin() {
713
+ return this.ropeSin;
714
+ }
715
+ getNegSin() {
716
+ return this.ropeNegSin;
717
+ }
718
+ dispose() {
719
+ this.ropeCos && this.ropeCos.dispose(), this.ropeSin && this.ropeSin.dispose(), this.ropeInvFreq.dispose();
720
+ }
721
+ };
722
+ export { Un as t };