@genai-fi/nanogpt 0.9.0 → 0.10.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 (343) hide show
  1. package/README.md +352 -14
  2. package/dist/Generator.js +69 -78
  3. package/dist/{RealDiv-D4EzDsC0.js → RealDiv-DgA3z9oO.js} +32 -206
  4. package/dist/Reshape-CF6odzV4.js +16 -0
  5. package/dist/Reshape-_kILl6tK.js +81 -0
  6. package/dist/TeachableLLM.js +28 -22
  7. package/dist/Trainer.d.ts +2 -0
  8. package/dist/Trainer.js +3 -2
  9. package/dist/{axis_util-TbGYJ208.js → axis_util-BvHEw88j.js} +7 -23
  10. package/dist/backend.d.ts +2 -1
  11. package/dist/backend.js +10 -4
  12. package/dist/backend_util-D-rUb2ty.js +474 -0
  13. package/dist/backend_webgpu-B0u2ndUn.js +547 -0
  14. package/dist/binary_op_util-pKXltfxI.js +192 -0
  15. package/dist/broadcast_to-CwF7XIeu.js +30 -0
  16. package/dist/checks/appendCache.js +2 -2
  17. package/dist/checks/attentionMask.js +3 -3
  18. package/dist/checks/check.d.ts +1 -1
  19. package/dist/checks/check.js +8 -8
  20. package/dist/checks/gelu.js +2 -2
  21. package/dist/checks/index.d.ts +2 -0
  22. package/dist/checks/index.js +7 -5
  23. package/dist/checks/matMulGelu.js +6 -6
  24. package/dist/checks/normRMS.js +7 -7
  25. package/dist/checks/normRMSGrad.js +3 -3
  26. package/dist/checks/packUnpack.d.ts +1 -0
  27. package/dist/checks/packUnpack.js +18 -0
  28. package/dist/checks/qkv.js +12 -27
  29. package/dist/checks/rope.js +2 -2
  30. package/dist/checks/weights.js +18 -16
  31. package/dist/complex-CSlYz-2T.js +13 -0
  32. package/dist/complex_util-Yc1A_gV1.js +55 -0
  33. package/dist/concat-BHlIJeyT.js +19 -0
  34. package/dist/concat_util-DcJk7YHS.js +22 -0
  35. package/dist/data/docx.js +1 -1
  36. package/dist/data/parquet.js +2 -2
  37. package/dist/data/pdf.js +1 -1
  38. package/dist/data/textLoader.js +1 -1
  39. package/dist/{dataset-DlZtKmBq.js → dataset-0xP8GjwI.js} +136 -236
  40. package/dist/dropout-C1pM3f11.js +99 -0
  41. package/dist/expand_dims-BPG4fwBP.js +13 -0
  42. package/dist/exports_initializers-xuidcwI4.js +7 -0
  43. package/dist/gather-DykLGqmW.js +10 -0
  44. package/dist/{gelu-Bp_-935b.js → gelu-CNLFZWea.js} +11 -10
  45. package/dist/{gpgpu_math-CDaYiyE_.js → gpgpu_math-DDVJCn6-.js} +90 -265
  46. package/dist/{index-C4L8Cm77.js → index-CieiGp4Y.js} +14 -14
  47. package/dist/index-CjOj7j-u.js +7308 -0
  48. package/dist/{index-Tf7vU29b.js → index-Cp39cXWe.js} +3 -10
  49. package/dist/{index-Dwqa6Zy2.js → index-DvYrXKkX.js} +2 -2
  50. package/dist/index-ZyQhjEPo.js +2157 -0
  51. package/dist/{jszip.min-CjP2V1VV.js → jszip.min-Bz5-11Bk.js} +56 -57
  52. package/dist/kernel_funcs_utils-Dg_-E44D.js +308 -0
  53. package/dist/layers/BaseLayer.d.ts +1 -0
  54. package/dist/layers/BaseLayer.js +7 -6
  55. package/dist/layers/CausalSelfAttention.d.ts +0 -1
  56. package/dist/layers/CausalSelfAttention.js +56 -55
  57. package/dist/layers/MLP.js +15 -16
  58. package/dist/layers/PositionEmbedding.js +5 -14
  59. package/dist/layers/RMSNorm.js +3 -3
  60. package/dist/layers/RoPECache.d.ts +2 -0
  61. package/dist/layers/RoPECache.js +22 -17
  62. package/dist/layers/TiedEmbedding.js +22 -17
  63. package/dist/layers/TransformerBlock.js +21 -20
  64. package/dist/loader/load.js +1 -1
  65. package/dist/loader/loadTransformers.js +1 -1
  66. package/dist/loader/oldZipLoad.js +39 -33
  67. package/dist/loader/save.js +1 -1
  68. package/dist/log_sum_exp-DWI-76TI.js +41 -0
  69. package/dist/main.d.ts +8 -0
  70. package/dist/main.js +63 -52
  71. package/dist/matMul16--R5hOwDG.js +77 -0
  72. package/dist/mat_mul-DeAh4uTH.js +12 -0
  73. package/dist/mod-Gt1rMB4n.js +12 -0
  74. package/dist/models/NanoGPTV1.js +40 -31
  75. package/dist/models/model.d.ts +2 -0
  76. package/dist/models/model.js +37 -29
  77. package/dist/{mulmat_packed_gpu-BT60jmzP.js → mulmat_packed_gpu-BMFhLwta.js} +1 -17
  78. package/dist/{non_max_suppression_impl-CsEgBuMA.js → non_max_suppression_impl-B2W7YjZB.js} +0 -32
  79. package/dist/ones-CAMiP4I2.js +15 -0
  80. package/dist/ops/adamAdjust.js +1 -1
  81. package/dist/ops/adamMoments.d.ts +1 -1
  82. package/dist/ops/adamMoments.js +4 -4
  83. package/dist/ops/add16.d.ts +2 -0
  84. package/dist/ops/add16.js +9 -0
  85. package/dist/ops/appendCache.js +16 -9
  86. package/dist/ops/attentionMask.js +4 -4
  87. package/dist/ops/concat16.d.ts +2 -0
  88. package/dist/ops/concat16.js +9 -0
  89. package/dist/ops/cpu/adamAdjust.js +14 -13
  90. package/dist/ops/cpu/adamMoments.js +10 -9
  91. package/dist/ops/cpu/appendCache.js +9 -8
  92. package/dist/ops/cpu/attentionMask.js +15 -14
  93. package/dist/ops/cpu/fusedSoftmax.js +13 -12
  94. package/dist/ops/cpu/gatherSub.js +9 -24
  95. package/dist/ops/cpu/gelu.js +13 -12
  96. package/dist/ops/cpu/matMul16.d.ts +1 -0
  97. package/dist/ops/cpu/matMul16.js +16 -0
  98. package/dist/ops/cpu/matMulGelu.js +18 -16
  99. package/dist/ops/cpu/matMulMul.js +8 -7
  100. package/dist/ops/cpu/mulDropout.js +4 -3
  101. package/dist/ops/cpu/normRMS.js +11 -10
  102. package/dist/ops/cpu/qkv.js +17 -13
  103. package/dist/ops/cpu/rope.js +23 -22
  104. package/dist/ops/cpu/scatterSub.js +16 -30
  105. package/dist/ops/dot16.d.ts +2 -0
  106. package/dist/ops/dot16.js +42 -0
  107. package/dist/ops/gatherSub.js +1 -1
  108. package/dist/ops/gelu.js +2 -2
  109. package/dist/ops/grads/add16.d.ts +1 -0
  110. package/dist/ops/grads/add16.js +27 -0
  111. package/dist/ops/grads/attentionMask.js +12 -19
  112. package/dist/ops/grads/gelu.js +4 -3
  113. package/dist/ops/grads/matMul16.d.ts +2 -0
  114. package/dist/ops/grads/matMul16.js +9 -0
  115. package/dist/ops/grads/matMulGelu.js +8 -7
  116. package/dist/ops/grads/normRMS.js +8 -7
  117. package/dist/ops/grads/{fusedSoftmax.d.ts → pack16.d.ts} +1 -1
  118. package/dist/ops/grads/pack16.js +7 -0
  119. package/dist/ops/grads/qkv.d.ts +3 -1
  120. package/dist/ops/grads/qkv.js +28 -22
  121. package/dist/ops/grads/rope.d.ts +2 -1
  122. package/dist/ops/grads/rope.js +6 -13
  123. package/dist/ops/grads/softmax16.d.ts +2 -0
  124. package/dist/ops/grads/softmax16.js +26 -0
  125. package/dist/ops/grads/unpack16.d.ts +2 -0
  126. package/dist/ops/grads/unpack16.js +6 -0
  127. package/dist/ops/grads/utils.d.ts +3 -0
  128. package/dist/ops/grads/utils.js +10 -0
  129. package/dist/ops/matMul16.d.ts +15 -0
  130. package/dist/ops/matMul16.js +13 -0
  131. package/dist/ops/matMulGelu.js +1 -1
  132. package/dist/ops/matMulMul.js +1 -1
  133. package/dist/ops/mul16.d.ts +2 -0
  134. package/dist/ops/mul16.js +8 -0
  135. package/dist/ops/mulDrop.js +1 -1
  136. package/dist/ops/normRMS.js +1 -1
  137. package/dist/ops/pack16.d.ts +2 -0
  138. package/dist/ops/pack16.js +6 -0
  139. package/dist/ops/qkv.d.ts +1 -1
  140. package/dist/ops/qkv.js +8 -4
  141. package/dist/ops/reshape16.d.ts +2 -0
  142. package/dist/ops/reshape16.js +43 -0
  143. package/dist/ops/rope.d.ts +1 -1
  144. package/dist/ops/rope.js +8 -10
  145. package/dist/ops/scatterSub.js +1 -1
  146. package/dist/ops/slice16.d.ts +2 -0
  147. package/dist/ops/slice16.js +9 -0
  148. package/dist/ops/softmax16.d.ts +2 -0
  149. package/dist/ops/softmax16.js +12 -0
  150. package/dist/ops/sub16.d.ts +2 -0
  151. package/dist/ops/sub16.js +8 -0
  152. package/dist/ops/sum16.d.ts +2 -0
  153. package/dist/ops/sum16.js +13 -0
  154. package/dist/ops/transpose16.d.ts +3 -0
  155. package/dist/ops/transpose16.js +41 -0
  156. package/dist/ops/unpack16.d.ts +2 -0
  157. package/dist/ops/unpack16.js +6 -0
  158. package/dist/ops/webgl/adamAdjust.js +3 -2
  159. package/dist/ops/webgl/adamMoments.js +2 -1
  160. package/dist/ops/webgl/appendCache.js +2 -1
  161. package/dist/ops/webgl/attentionMask.js +5 -4
  162. package/dist/ops/webgl/fusedSoftmax.js +6 -4
  163. package/dist/ops/webgl/gatherSub.js +7 -6
  164. package/dist/ops/webgl/gelu.js +3 -2
  165. package/dist/ops/webgl/log.js +12 -27
  166. package/dist/ops/webgl/matMul16.d.ts +1 -0
  167. package/dist/ops/webgl/matMul16.js +37 -0
  168. package/dist/ops/webgl/matMulGelu.js +17 -15
  169. package/dist/ops/webgl/matMulMul.js +13 -12
  170. package/dist/ops/webgl/mulDropout.js +9 -8
  171. package/dist/ops/webgl/normRMS.js +8 -7
  172. package/dist/ops/webgl/qkv.js +6 -5
  173. package/dist/ops/webgl/rope.js +11 -10
  174. package/dist/ops/webgl/scatterSub.js +6 -5
  175. package/dist/ops/webgpu/adamAdjust.js +12 -10
  176. package/dist/ops/webgpu/adamMoments.js +27 -22
  177. package/dist/ops/webgpu/add16.d.ts +1 -0
  178. package/dist/ops/webgpu/add16.js +14 -0
  179. package/dist/ops/webgpu/appendCache.js +64 -17
  180. package/dist/ops/webgpu/attentionMask.js +19 -62
  181. package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
  182. package/dist/ops/webgpu/attentionMask32_program.js +54 -0
  183. package/dist/ops/webgpu/concat16.d.ts +19 -0
  184. package/dist/ops/webgpu/concat16.js +128 -0
  185. package/dist/ops/webgpu/gatherSub.js +9 -7
  186. package/dist/ops/webgpu/gelu.js +78 -31
  187. package/dist/ops/webgpu/index.js +12 -0
  188. package/dist/ops/webgpu/matMul16.d.ts +1 -0
  189. package/dist/ops/webgpu/matMul16.js +58 -0
  190. package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
  191. package/dist/ops/webgpu/matMul16_program.js +336 -0
  192. package/dist/ops/webgpu/mul16.d.ts +1 -0
  193. package/dist/ops/webgpu/mul16.js +14 -0
  194. package/dist/ops/webgpu/normRMS.js +21 -40
  195. package/dist/ops/webgpu/normRMS16_program.d.ts +9 -0
  196. package/dist/ops/webgpu/normRMS16_program.js +24 -0
  197. package/dist/ops/webgpu/normRMS32_program.d.ts +9 -0
  198. package/dist/ops/webgpu/normRMS32_program.js +24 -0
  199. package/dist/ops/webgpu/normRMSGrad.js +113 -64
  200. package/dist/ops/webgpu/pack16.d.ts +1 -0
  201. package/dist/ops/webgpu/pack16.js +19 -0
  202. package/dist/ops/webgpu/pack16_program.d.ts +19 -0
  203. package/dist/ops/webgpu/pack16_program.js +92 -0
  204. package/dist/ops/webgpu/qkv.js +20 -55
  205. package/dist/ops/webgpu/rope.js +77 -22
  206. package/dist/ops/webgpu/scatterSub.js +9 -7
  207. package/dist/ops/webgpu/slice16.d.ts +7 -0
  208. package/dist/ops/webgpu/slice16.js +71 -0
  209. package/dist/{variable-Bm2OFwGI.js → ops/webgpu/softmax16.d.ts} +2 -8
  210. package/dist/ops/webgpu/softmax16.js +23 -0
  211. package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
  212. package/dist/ops/webgpu/softmax16_program.js +73 -0
  213. package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
  214. package/dist/ops/webgpu/softmax16_subgroup_program.js +75 -0
  215. package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
  216. package/dist/ops/webgpu/softmax16grad.js +38 -0
  217. package/dist/ops/webgpu/sub16.d.ts +1 -0
  218. package/dist/ops/webgpu/sub16.js +14 -0
  219. package/dist/ops/webgpu/sum16.d.ts +1 -0
  220. package/dist/ops/webgpu/sum16.js +40 -0
  221. package/dist/ops/webgpu/transpose16.d.ts +1 -0
  222. package/dist/ops/webgpu/transpose16.js +35 -0
  223. package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
  224. package/dist/ops/webgpu/transpose16_program.js +50 -0
  225. package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
  226. package/dist/ops/webgpu/transpose16_shared_program.js +71 -0
  227. package/dist/ops/webgpu/unpack16.d.ts +1 -0
  228. package/dist/ops/webgpu/unpack16.js +49 -0
  229. package/dist/ops/webgpu/utils/binary_op.d.ts +19 -0
  230. package/dist/ops/webgpu/utils/binary_op.js +79 -0
  231. package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
  232. package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
  233. package/dist/ops/webgpu/utils/reductions.d.ts +32 -4
  234. package/dist/ops/webgpu/utils/reductions.js +236 -45
  235. package/dist/ops-CNI3TwqM.js +645 -0
  236. package/dist/pack16-CFUqumar.js +41 -0
  237. package/dist/{papaparse.min-C8l2Kvo1.js → papaparse.min-C0cScC2i.js} +2 -8
  238. package/dist/{parquet-C0Tlmv9c.js → parquet-BE8MU_ge.js} +201 -278
  239. package/dist/patches/PackedTensor.d.ts +12 -0
  240. package/dist/patches/PackedTensor.js +11 -0
  241. package/dist/patches/engine.d.ts +261 -0
  242. package/dist/patches/engine.js +10 -0
  243. package/dist/patches/tape.d.ts +12 -0
  244. package/dist/patches/tape.js +5 -0
  245. package/dist/patches/webgpu_backend.d.ts +18 -0
  246. package/dist/patches/webgpu_backend.js +57 -0
  247. package/dist/{tensor-CZr4dh61.js → patches/webgpu_base.d.ts} +5 -8
  248. package/dist/patches/webgpu_base.js +34 -0
  249. package/dist/patches/webgpu_program.d.ts +36 -0
  250. package/dist/patches/webgpu_program.js +401 -0
  251. package/dist/{pdf-kJD-f258.js → pdf-NIhmP3sq.js} +424 -428
  252. package/dist/random_width-DY6Kk2Dl.js +10051 -0
  253. package/dist/range-BMS52eQi.js +11 -0
  254. package/dist/reciprocal-CTmshQ9J.js +10 -0
  255. package/dist/{register_all_kernels-DIGpEwcf.js → register_all_kernels-Bwu1PTuU.js} +719 -9766
  256. package/dist/relu-yZ2-7WxU.js +10 -0
  257. package/dist/reshape-DevtBWtf.js +10 -0
  258. package/dist/rope-B5UUMsPi.js +32 -0
  259. package/dist/{scatter_nd_util-BQdz--Gn.js → scatter_nd_util-5EL-8VAQ.js} +1 -1
  260. package/dist/selu_util-D1w6yyTO.js +303 -0
  261. package/dist/{shared-DuP7ue-R.js → shared-BRksrJb3.js} +1 -17
  262. package/dist/shared-BuAXb4CI.js +2145 -0
  263. package/dist/sin-BGfy2HZo.js +16 -0
  264. package/dist/slice-D_gkkqZK.js +13 -0
  265. package/dist/slice_util-DtEldBfK.js +261 -0
  266. package/dist/softmax-ZHVebtR1.js +13 -0
  267. package/dist/split-DrfihRpZ.js +10 -0
  268. package/dist/squeeze-DZEpeblb.js +11 -0
  269. package/dist/stack-yOIAalTq.js +13 -0
  270. package/dist/sum-_fzj5ZTB.js +12 -0
  271. package/dist/tensor-DdQUJZlz.js +909 -0
  272. package/dist/tensor-f35l8Odg.js +8 -0
  273. package/dist/tensor1d-CeZuc-Rv.js +12 -0
  274. package/dist/tensor2d-G4Ys2GxX.js +15 -0
  275. package/dist/tensor4d-B8roDgtc.js +15 -0
  276. package/dist/tensor_util-DV-FP5Q3.js +523 -0
  277. package/dist/tfjs_backend-kNyO5L2d.js +653 -0
  278. package/dist/tile-BzyEiF-F.js +13 -0
  279. package/dist/tokeniser/CharTokeniser.js +1 -1
  280. package/dist/tokeniser/bpe.js +1 -1
  281. package/dist/training/Adam.d.ts +2 -1
  282. package/dist/training/Adam.js +12 -28
  283. package/dist/training/AdamExt.d.ts +1 -0
  284. package/dist/training/AdamExt.js +2 -2
  285. package/dist/training/DatasetBuilder.js +3 -20
  286. package/dist/training/FullTrainer.js +82 -64
  287. package/dist/training/Trainer.d.ts +11 -6
  288. package/dist/training/Trainer.js +51 -39
  289. package/dist/training/sparseCrossEntropy.js +3 -3
  290. package/dist/transpose-DKELTqhe.js +38 -0
  291. package/dist/utilities/arrayClose.js +7 -7
  292. package/dist/utilities/dummy.js +35 -27
  293. package/dist/utilities/multinomialCPU.js +2 -2
  294. package/dist/utilities/packed.d.ts +7 -0
  295. package/dist/utilities/packed.js +716 -0
  296. package/dist/utilities/performance.js +1 -1
  297. package/dist/utilities/profile.js +1 -1
  298. package/dist/utilities/safetensors.js +2 -2
  299. package/dist/utilities/sentences.d.ts +5 -0
  300. package/dist/utilities/sentences.js +41 -0
  301. package/dist/utilities/weights.js +2 -2
  302. package/dist/variable-Bhn5bHYv.js +7 -0
  303. package/dist/{webgpu_program-DkQJOJSd.js → webgpu_program-Cigz-7RF.js} +15 -44
  304. package/dist/webgpu_util-BBCnKm2X.js +65 -0
  305. package/dist/zeros-2gldETuK.js +14 -0
  306. package/package.json +4 -3
  307. package/dist/Reshape-Bowtk9BP.js +0 -127
  308. package/dist/Reshape-DUqYftGC.js +0 -30
  309. package/dist/backend_util-CJIiDoV1.js +0 -749
  310. package/dist/broadcast_to-DzlNweb8.js +0 -44
  311. package/dist/concat-B912vBbo.js +0 -33
  312. package/dist/dropout-C-csYCLj.js +0 -193
  313. package/dist/exports_initializers-B8iZMgQ0.js +0 -16
  314. package/dist/gather-Dnpgw-YQ.js +0 -25
  315. package/dist/index-BzFyqcy-.js +0 -4457
  316. package/dist/index-C1rx_Ajs.js +0 -12076
  317. package/dist/kernel_funcs_utils-DKLK0Mg3.js +0 -466
  318. package/dist/log_sum_exp-DO6z8tSE.js +0 -103
  319. package/dist/mat_mul-DzjTFx-u.js +0 -27
  320. package/dist/mod-Dobti4j4.js +0 -27
  321. package/dist/ones-tIJeHlq-.js +0 -29
  322. package/dist/ops/fusedSoftmax.d.ts +0 -2
  323. package/dist/ops/fusedSoftmax.js +0 -10
  324. package/dist/ops/grads/fusedSoftmax.js +0 -22
  325. package/dist/ops-LuCMAnmM.js +0 -1525
  326. package/dist/random_width-CXVRloNK.js +0 -13670
  327. package/dist/range-CWcz7xFA.js +0 -26
  328. package/dist/reciprocal-C4rNcM-S.js +0 -25
  329. package/dist/relu-BjCh_SYb.js +0 -25
  330. package/dist/reshape-CnIwVG1c.js +0 -25
  331. package/dist/selu_util-OtRzVwW5.js +0 -719
  332. package/dist/shared-DmRsFyaJ.js +0 -3134
  333. package/dist/sin-gpDNRxE0.js +0 -47
  334. package/dist/slice-d0Vo9XTN.js +0 -28
  335. package/dist/softmax-D7Jj3p_P.js +0 -28
  336. package/dist/split-DK2k5eHf.js +0 -25
  337. package/dist/stack-DFatutCx.js +0 -27
  338. package/dist/sum-CJ0ULhmt.js +0 -27
  339. package/dist/tensor1d-vML0r3q6.js +0 -27
  340. package/dist/tensor2d-D76QGjF3.js +0 -30
  341. package/dist/tensor4d-Df1WlVDY.js +0 -30
  342. package/dist/webgpu_util-pLEV9tks.js +0 -80
  343. package/dist/zeros-Bj5rMYA7.js +0 -52
@@ -0,0 +1,2145 @@
1
+ import { j as Lt, h as ht, J as H, t as Ce } from "./index-ZyQhjEPo.js";
2
+ import { a as Pt, s as V, i as K, g as et, W as dt, X as at, f as st, Y as De, O as We, Z as W, I as Ue, p as At, R as It, t as pt, _ as ot } from "./tensor-DdQUJZlz.js";
3
+ import { a9 as $e, h as ze, I as Be, F as je, x as Ge, A as qt, aF as _t, aG as Vt, aH as Ct, z as Dt, aI as Wt, Q as Ut, a6 as $t, ak as zt, al as Bt, am as jt, an as Gt, L as Zt, af as Ht, ar as Kt, a7 as Xt, N as Ze, as as Jt, H as He, aJ as Ke, u as Xe, aK as Qt, U as Yt, f as Je, ad as te, au as ee, aL as ne, ae as se } from "./tensor_util-DV-FP5Q3.js";
4
+ import { f as it, g as Qe, a as Ye, R as tn, v as en, d as nn, e as sn, h as on, i as rn, j as an, k as ln, l as cn, m as un, n as hn, o as fn, p as kt, q as dn, r as gn, s as mn } from "./backend_util-D-rUb2ty.js";
5
+ import { m as Nt } from "./complex_util-Yc1A_gV1.js";
6
+ import { a as pn, b as wn, e as In, c as xn } from "./axis_util-BvHEw88j.js";
7
+ import { b as En } from "./broadcast_to-CwF7XIeu.js";
8
+ import { r as Fn } from "./reshape-DevtBWtf.js";
9
+ import { p as bn, a as yn, i as kn, c as Nn } from "./slice_util-DtEldBfK.js";
10
+ import { g as vn } from "./_commonjsHelpers-ByX85dGu.js";
11
+ function Sn(e, t) {
12
+ for (var n = 0; n < t.length; n++) {
13
+ const s = t[n];
14
+ if (typeof s != "string" && !Array.isArray(s)) {
15
+ for (const o in s)
16
+ if (o !== "default" && !(o in e)) {
17
+ const a = Object.getOwnPropertyDescriptor(s, o);
18
+ a && Object.defineProperty(e, o, a.get ? a : {
19
+ enumerable: !0,
20
+ get: () => s[o]
21
+ });
22
+ }
23
+ }
24
+ }
25
+ return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
26
+ }
27
+ var wt, vt;
28
+ function Tn() {
29
+ if (vt) return wt;
30
+ vt = 1, wt = t;
31
+ var e = null;
32
+ try {
33
+ e = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
34
+ 0,
35
+ 97,
36
+ 115,
37
+ 109,
38
+ 1,
39
+ 0,
40
+ 0,
41
+ 0,
42
+ 1,
43
+ 13,
44
+ 2,
45
+ 96,
46
+ 0,
47
+ 1,
48
+ 127,
49
+ 96,
50
+ 4,
51
+ 127,
52
+ 127,
53
+ 127,
54
+ 127,
55
+ 1,
56
+ 127,
57
+ 3,
58
+ 7,
59
+ 6,
60
+ 0,
61
+ 1,
62
+ 1,
63
+ 1,
64
+ 1,
65
+ 1,
66
+ 6,
67
+ 6,
68
+ 1,
69
+ 127,
70
+ 1,
71
+ 65,
72
+ 0,
73
+ 11,
74
+ 7,
75
+ 50,
76
+ 6,
77
+ 3,
78
+ 109,
79
+ 117,
80
+ 108,
81
+ 0,
82
+ 1,
83
+ 5,
84
+ 100,
85
+ 105,
86
+ 118,
87
+ 95,
88
+ 115,
89
+ 0,
90
+ 2,
91
+ 5,
92
+ 100,
93
+ 105,
94
+ 118,
95
+ 95,
96
+ 117,
97
+ 0,
98
+ 3,
99
+ 5,
100
+ 114,
101
+ 101,
102
+ 109,
103
+ 95,
104
+ 115,
105
+ 0,
106
+ 4,
107
+ 5,
108
+ 114,
109
+ 101,
110
+ 109,
111
+ 95,
112
+ 117,
113
+ 0,
114
+ 5,
115
+ 8,
116
+ 103,
117
+ 101,
118
+ 116,
119
+ 95,
120
+ 104,
121
+ 105,
122
+ 103,
123
+ 104,
124
+ 0,
125
+ 0,
126
+ 10,
127
+ 191,
128
+ 1,
129
+ 6,
130
+ 4,
131
+ 0,
132
+ 35,
133
+ 0,
134
+ 11,
135
+ 36,
136
+ 1,
137
+ 1,
138
+ 126,
139
+ 32,
140
+ 0,
141
+ 173,
142
+ 32,
143
+ 1,
144
+ 173,
145
+ 66,
146
+ 32,
147
+ 134,
148
+ 132,
149
+ 32,
150
+ 2,
151
+ 173,
152
+ 32,
153
+ 3,
154
+ 173,
155
+ 66,
156
+ 32,
157
+ 134,
158
+ 132,
159
+ 126,
160
+ 34,
161
+ 4,
162
+ 66,
163
+ 32,
164
+ 135,
165
+ 167,
166
+ 36,
167
+ 0,
168
+ 32,
169
+ 4,
170
+ 167,
171
+ 11,
172
+ 36,
173
+ 1,
174
+ 1,
175
+ 126,
176
+ 32,
177
+ 0,
178
+ 173,
179
+ 32,
180
+ 1,
181
+ 173,
182
+ 66,
183
+ 32,
184
+ 134,
185
+ 132,
186
+ 32,
187
+ 2,
188
+ 173,
189
+ 32,
190
+ 3,
191
+ 173,
192
+ 66,
193
+ 32,
194
+ 134,
195
+ 132,
196
+ 127,
197
+ 34,
198
+ 4,
199
+ 66,
200
+ 32,
201
+ 135,
202
+ 167,
203
+ 36,
204
+ 0,
205
+ 32,
206
+ 4,
207
+ 167,
208
+ 11,
209
+ 36,
210
+ 1,
211
+ 1,
212
+ 126,
213
+ 32,
214
+ 0,
215
+ 173,
216
+ 32,
217
+ 1,
218
+ 173,
219
+ 66,
220
+ 32,
221
+ 134,
222
+ 132,
223
+ 32,
224
+ 2,
225
+ 173,
226
+ 32,
227
+ 3,
228
+ 173,
229
+ 66,
230
+ 32,
231
+ 134,
232
+ 132,
233
+ 128,
234
+ 34,
235
+ 4,
236
+ 66,
237
+ 32,
238
+ 135,
239
+ 167,
240
+ 36,
241
+ 0,
242
+ 32,
243
+ 4,
244
+ 167,
245
+ 11,
246
+ 36,
247
+ 1,
248
+ 1,
249
+ 126,
250
+ 32,
251
+ 0,
252
+ 173,
253
+ 32,
254
+ 1,
255
+ 173,
256
+ 66,
257
+ 32,
258
+ 134,
259
+ 132,
260
+ 32,
261
+ 2,
262
+ 173,
263
+ 32,
264
+ 3,
265
+ 173,
266
+ 66,
267
+ 32,
268
+ 134,
269
+ 132,
270
+ 129,
271
+ 34,
272
+ 4,
273
+ 66,
274
+ 32,
275
+ 135,
276
+ 167,
277
+ 36,
278
+ 0,
279
+ 32,
280
+ 4,
281
+ 167,
282
+ 11,
283
+ 36,
284
+ 1,
285
+ 1,
286
+ 126,
287
+ 32,
288
+ 0,
289
+ 173,
290
+ 32,
291
+ 1,
292
+ 173,
293
+ 66,
294
+ 32,
295
+ 134,
296
+ 132,
297
+ 32,
298
+ 2,
299
+ 173,
300
+ 32,
301
+ 3,
302
+ 173,
303
+ 66,
304
+ 32,
305
+ 134,
306
+ 132,
307
+ 130,
308
+ 34,
309
+ 4,
310
+ 66,
311
+ 32,
312
+ 135,
313
+ 167,
314
+ 36,
315
+ 0,
316
+ 32,
317
+ 4,
318
+ 167,
319
+ 11
320
+ ])), {}).exports;
321
+ } catch {
322
+ }
323
+ function t(I, c, F) {
324
+ this.low = I | 0, this.high = c | 0, this.unsigned = !!F;
325
+ }
326
+ t.prototype.__isLong__, Object.defineProperty(t.prototype, "__isLong__", { value: !0 });
327
+ function n(I) {
328
+ return (I && I.__isLong__) === !0;
329
+ }
330
+ t.isLong = n;
331
+ var s = {}, o = {};
332
+ function a(I, c) {
333
+ var F, N, L;
334
+ return c ? (I >>>= 0, (L = 0 <= I && I < 256) && (N = o[I], N) ? N : (F = i(I, (I | 0) < 0 ? -1 : 0, !0), L && (o[I] = F), F)) : (I |= 0, (L = -128 <= I && I < 128) && (N = s[I], N) ? N : (F = i(I, I < 0 ? -1 : 0, !1), L && (s[I] = F), F));
335
+ }
336
+ t.fromInt = a;
337
+ function r(I, c) {
338
+ if (isNaN(I))
339
+ return c ? x : g;
340
+ if (c) {
341
+ if (I < 0)
342
+ return x;
343
+ if (I >= m)
344
+ return O;
345
+ } else {
346
+ if (I <= -b)
347
+ return S;
348
+ if (I + 1 >= b)
349
+ return M;
350
+ }
351
+ return I < 0 ? r(-I, c).neg() : i(I % w | 0, I / w | 0, c);
352
+ }
353
+ t.fromNumber = r;
354
+ function i(I, c, F) {
355
+ return new t(I, c, F);
356
+ }
357
+ t.fromBits = i;
358
+ var l = Math.pow;
359
+ function u(I, c, F) {
360
+ if (I.length === 0)
361
+ throw Error("empty string");
362
+ if (I === "NaN" || I === "Infinity" || I === "+Infinity" || I === "-Infinity")
363
+ return g;
364
+ if (typeof c == "number" ? (F = c, c = !1) : c = !!c, F = F || 10, F < 2 || 36 < F)
365
+ throw RangeError("radix");
366
+ var N;
367
+ if ((N = I.indexOf("-")) > 0)
368
+ throw Error("interior hyphen");
369
+ if (N === 0)
370
+ return u(I.substring(1), c, F).neg();
371
+ for (var L = r(l(F, 8)), R = g, A = 0; A < I.length; A += 8) {
372
+ var $ = Math.min(8, I.length - A), j = parseInt(I.substring(A, A + $), F);
373
+ if ($ < 8) {
374
+ var C = r(l(F, $));
375
+ R = R.mul(C).add(r(j));
376
+ } else
377
+ R = R.mul(L), R = R.add(r(j));
378
+ }
379
+ return R.unsigned = c, R;
380
+ }
381
+ t.fromString = u;
382
+ function h(I, c) {
383
+ return typeof I == "number" ? r(I, c) : typeof I == "string" ? u(I, c) : i(I.low, I.high, typeof c == "boolean" ? c : I.unsigned);
384
+ }
385
+ t.fromValue = h;
386
+ var f = 65536, p = 1 << 24, w = f * f, m = w * w, b = m / 2, d = a(p), g = a(0);
387
+ t.ZERO = g;
388
+ var x = a(0, !0);
389
+ t.UZERO = x;
390
+ var k = a(1);
391
+ t.ONE = k;
392
+ var y = a(1, !0);
393
+ t.UONE = y;
394
+ var v = a(-1);
395
+ t.NEG_ONE = v;
396
+ var M = i(-1, 2147483647, !1);
397
+ t.MAX_VALUE = M;
398
+ var O = i(-1, -1, !0);
399
+ t.MAX_UNSIGNED_VALUE = O;
400
+ var S = i(0, -2147483648, !1);
401
+ t.MIN_VALUE = S;
402
+ var E = t.prototype;
403
+ return E.toInt = function() {
404
+ return this.unsigned ? this.low >>> 0 : this.low;
405
+ }, E.toNumber = function() {
406
+ return this.unsigned ? (this.high >>> 0) * w + (this.low >>> 0) : this.high * w + (this.low >>> 0);
407
+ }, E.toString = function(c) {
408
+ if (c = c || 10, c < 2 || 36 < c)
409
+ throw RangeError("radix");
410
+ if (this.isZero())
411
+ return "0";
412
+ if (this.isNegative())
413
+ if (this.eq(S)) {
414
+ var F = r(c), N = this.div(F), L = N.mul(F).sub(this);
415
+ return N.toString(c) + L.toInt().toString(c);
416
+ } else
417
+ return "-" + this.neg().toString(c);
418
+ for (var R = r(l(c, 6), this.unsigned), A = this, $ = ""; ; ) {
419
+ var j = A.div(R), C = A.sub(j.mul(R)).toInt() >>> 0, P = C.toString(c);
420
+ if (A = j, A.isZero())
421
+ return P + $;
422
+ for (; P.length < 6; )
423
+ P = "0" + P;
424
+ $ = "" + P + $;
425
+ }
426
+ }, E.getHighBits = function() {
427
+ return this.high;
428
+ }, E.getHighBitsUnsigned = function() {
429
+ return this.high >>> 0;
430
+ }, E.getLowBits = function() {
431
+ return this.low;
432
+ }, E.getLowBitsUnsigned = function() {
433
+ return this.low >>> 0;
434
+ }, E.getNumBitsAbs = function() {
435
+ if (this.isNegative())
436
+ return this.eq(S) ? 64 : this.neg().getNumBitsAbs();
437
+ for (var c = this.high != 0 ? this.high : this.low, F = 31; F > 0 && (c & 1 << F) == 0; F--)
438
+ ;
439
+ return this.high != 0 ? F + 33 : F + 1;
440
+ }, E.isZero = function() {
441
+ return this.high === 0 && this.low === 0;
442
+ }, E.eqz = E.isZero, E.isNegative = function() {
443
+ return !this.unsigned && this.high < 0;
444
+ }, E.isPositive = function() {
445
+ return this.unsigned || this.high >= 0;
446
+ }, E.isOdd = function() {
447
+ return (this.low & 1) === 1;
448
+ }, E.isEven = function() {
449
+ return (this.low & 1) === 0;
450
+ }, E.equals = function(c) {
451
+ return n(c) || (c = h(c)), this.unsigned !== c.unsigned && this.high >>> 31 === 1 && c.high >>> 31 === 1 ? !1 : this.high === c.high && this.low === c.low;
452
+ }, E.eq = E.equals, E.notEquals = function(c) {
453
+ return !this.eq(
454
+ /* validates */
455
+ c
456
+ );
457
+ }, E.neq = E.notEquals, E.ne = E.notEquals, E.lessThan = function(c) {
458
+ return this.comp(
459
+ /* validates */
460
+ c
461
+ ) < 0;
462
+ }, E.lt = E.lessThan, E.lessThanOrEqual = function(c) {
463
+ return this.comp(
464
+ /* validates */
465
+ c
466
+ ) <= 0;
467
+ }, E.lte = E.lessThanOrEqual, E.le = E.lessThanOrEqual, E.greaterThan = function(c) {
468
+ return this.comp(
469
+ /* validates */
470
+ c
471
+ ) > 0;
472
+ }, E.gt = E.greaterThan, E.greaterThanOrEqual = function(c) {
473
+ return this.comp(
474
+ /* validates */
475
+ c
476
+ ) >= 0;
477
+ }, E.gte = E.greaterThanOrEqual, E.ge = E.greaterThanOrEqual, E.compare = function(c) {
478
+ if (n(c) || (c = h(c)), this.eq(c))
479
+ return 0;
480
+ var F = this.isNegative(), N = c.isNegative();
481
+ return F && !N ? -1 : !F && N ? 1 : this.unsigned ? c.high >>> 0 > this.high >>> 0 || c.high === this.high && c.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(c).isNegative() ? -1 : 1;
482
+ }, E.comp = E.compare, E.negate = function() {
483
+ return !this.unsigned && this.eq(S) ? S : this.not().add(k);
484
+ }, E.neg = E.negate, E.add = function(c) {
485
+ n(c) || (c = h(c));
486
+ var F = this.high >>> 16, N = this.high & 65535, L = this.low >>> 16, R = this.low & 65535, A = c.high >>> 16, $ = c.high & 65535, j = c.low >>> 16, C = c.low & 65535, P = 0, G = 0, _ = 0, B = 0;
487
+ return B += R + C, _ += B >>> 16, B &= 65535, _ += L + j, G += _ >>> 16, _ &= 65535, G += N + $, P += G >>> 16, G &= 65535, P += F + A, P &= 65535, i(_ << 16 | B, P << 16 | G, this.unsigned);
488
+ }, E.subtract = function(c) {
489
+ return n(c) || (c = h(c)), this.add(c.neg());
490
+ }, E.sub = E.subtract, E.multiply = function(c) {
491
+ if (this.isZero())
492
+ return g;
493
+ if (n(c) || (c = h(c)), e) {
494
+ var F = e.mul(
495
+ this.low,
496
+ this.high,
497
+ c.low,
498
+ c.high
499
+ );
500
+ return i(F, e.get_high(), this.unsigned);
501
+ }
502
+ if (c.isZero())
503
+ return g;
504
+ if (this.eq(S))
505
+ return c.isOdd() ? S : g;
506
+ if (c.eq(S))
507
+ return this.isOdd() ? S : g;
508
+ if (this.isNegative())
509
+ return c.isNegative() ? this.neg().mul(c.neg()) : this.neg().mul(c).neg();
510
+ if (c.isNegative())
511
+ return this.mul(c.neg()).neg();
512
+ if (this.lt(d) && c.lt(d))
513
+ return r(this.toNumber() * c.toNumber(), this.unsigned);
514
+ var N = this.high >>> 16, L = this.high & 65535, R = this.low >>> 16, A = this.low & 65535, $ = c.high >>> 16, j = c.high & 65535, C = c.low >>> 16, P = c.low & 65535, G = 0, _ = 0, B = 0, ct = 0;
515
+ return ct += A * P, B += ct >>> 16, ct &= 65535, B += R * P, _ += B >>> 16, B &= 65535, B += A * C, _ += B >>> 16, B &= 65535, _ += L * P, G += _ >>> 16, _ &= 65535, _ += R * C, G += _ >>> 16, _ &= 65535, _ += A * j, G += _ >>> 16, _ &= 65535, G += N * P + L * C + R * j + A * $, G &= 65535, i(B << 16 | ct, G << 16 | _, this.unsigned);
516
+ }, E.mul = E.multiply, E.divide = function(c) {
517
+ if (n(c) || (c = h(c)), c.isZero())
518
+ throw Error("division by zero");
519
+ if (e) {
520
+ if (!this.unsigned && this.high === -2147483648 && c.low === -1 && c.high === -1)
521
+ return this;
522
+ var F = (this.unsigned ? e.div_u : e.div_s)(
523
+ this.low,
524
+ this.high,
525
+ c.low,
526
+ c.high
527
+ );
528
+ return i(F, e.get_high(), this.unsigned);
529
+ }
530
+ if (this.isZero())
531
+ return this.unsigned ? x : g;
532
+ var N, L, R;
533
+ if (this.unsigned) {
534
+ if (c.unsigned || (c = c.toUnsigned()), c.gt(this))
535
+ return x;
536
+ if (c.gt(this.shru(1)))
537
+ return y;
538
+ R = x;
539
+ } else {
540
+ if (this.eq(S)) {
541
+ if (c.eq(k) || c.eq(v))
542
+ return S;
543
+ if (c.eq(S))
544
+ return k;
545
+ var A = this.shr(1);
546
+ return N = A.div(c).shl(1), N.eq(g) ? c.isNegative() ? k : v : (L = this.sub(c.mul(N)), R = N.add(L.div(c)), R);
547
+ } else if (c.eq(S))
548
+ return this.unsigned ? x : g;
549
+ if (this.isNegative())
550
+ return c.isNegative() ? this.neg().div(c.neg()) : this.neg().div(c).neg();
551
+ if (c.isNegative())
552
+ return this.div(c.neg()).neg();
553
+ R = g;
554
+ }
555
+ for (L = this; L.gte(c); ) {
556
+ N = Math.max(1, Math.floor(L.toNumber() / c.toNumber()));
557
+ for (var $ = Math.ceil(Math.log(N) / Math.LN2), j = $ <= 48 ? 1 : l(2, $ - 48), C = r(N), P = C.mul(c); P.isNegative() || P.gt(L); )
558
+ N -= j, C = r(N, this.unsigned), P = C.mul(c);
559
+ C.isZero() && (C = k), R = R.add(C), L = L.sub(P);
560
+ }
561
+ return R;
562
+ }, E.div = E.divide, E.modulo = function(c) {
563
+ if (n(c) || (c = h(c)), e) {
564
+ var F = (this.unsigned ? e.rem_u : e.rem_s)(
565
+ this.low,
566
+ this.high,
567
+ c.low,
568
+ c.high
569
+ );
570
+ return i(F, e.get_high(), this.unsigned);
571
+ }
572
+ return this.sub(this.div(c).mul(c));
573
+ }, E.mod = E.modulo, E.rem = E.modulo, E.not = function() {
574
+ return i(~this.low, ~this.high, this.unsigned);
575
+ }, E.and = function(c) {
576
+ return n(c) || (c = h(c)), i(this.low & c.low, this.high & c.high, this.unsigned);
577
+ }, E.or = function(c) {
578
+ return n(c) || (c = h(c)), i(this.low | c.low, this.high | c.high, this.unsigned);
579
+ }, E.xor = function(c) {
580
+ return n(c) || (c = h(c)), i(this.low ^ c.low, this.high ^ c.high, this.unsigned);
581
+ }, E.shiftLeft = function(c) {
582
+ return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low << c, this.high << c | this.low >>> 32 - c, this.unsigned) : i(0, this.low << c - 32, this.unsigned);
583
+ }, E.shl = E.shiftLeft, E.shiftRight = function(c) {
584
+ return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low >>> c | this.high << 32 - c, this.high >> c, this.unsigned) : i(this.high >> c - 32, this.high >= 0 ? 0 : -1, this.unsigned);
585
+ }, E.shr = E.shiftRight, E.shiftRightUnsigned = function(c) {
586
+ if (n(c) && (c = c.toInt()), c &= 63, c === 0)
587
+ return this;
588
+ var F = this.high;
589
+ if (c < 32) {
590
+ var N = this.low;
591
+ return i(N >>> c | F << 32 - c, F >>> c, this.unsigned);
592
+ } else return c === 32 ? i(F, 0, this.unsigned) : i(F >>> c - 32, 0, this.unsigned);
593
+ }, E.shru = E.shiftRightUnsigned, E.shr_u = E.shiftRightUnsigned, E.toSigned = function() {
594
+ return this.unsigned ? i(this.low, this.high, !1) : this;
595
+ }, E.toUnsigned = function() {
596
+ return this.unsigned ? this : i(this.low, this.high, !0);
597
+ }, E.toBytes = function(c) {
598
+ return c ? this.toBytesLE() : this.toBytesBE();
599
+ }, E.toBytesLE = function() {
600
+ var c = this.high, F = this.low;
601
+ return [
602
+ F & 255,
603
+ F >>> 8 & 255,
604
+ F >>> 16 & 255,
605
+ F >>> 24,
606
+ c & 255,
607
+ c >>> 8 & 255,
608
+ c >>> 16 & 255,
609
+ c >>> 24
610
+ ];
611
+ }, E.toBytesBE = function() {
612
+ var c = this.high, F = this.low;
613
+ return [
614
+ c >>> 24,
615
+ c >>> 16 & 255,
616
+ c >>> 8 & 255,
617
+ c & 255,
618
+ F >>> 24,
619
+ F >>> 16 & 255,
620
+ F >>> 8 & 255,
621
+ F & 255
622
+ ];
623
+ }, t.fromBytes = function(c, F, N) {
624
+ return N ? t.fromBytesLE(c, F) : t.fromBytesBE(c, F);
625
+ }, t.fromBytesLE = function(c, F) {
626
+ return new t(
627
+ c[0] | c[1] << 8 | c[2] << 16 | c[3] << 24,
628
+ c[4] | c[5] << 8 | c[6] << 16 | c[7] << 24,
629
+ F
630
+ );
631
+ }, t.fromBytesBE = function(c, F) {
632
+ return new t(
633
+ c[4] << 24 | c[5] << 16 | c[6] << 8 | c[7],
634
+ c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3],
635
+ F
636
+ );
637
+ }, wt;
638
+ }
639
+ var oe = Tn();
640
+ const re = /* @__PURE__ */ vn(oe), Rn = /* @__PURE__ */ Sn({
641
+ __proto__: null,
642
+ default: re
643
+ }, [oe]);
644
+ const tt = (
645
+ // tslint:disable-next-line
646
+ re || Rn
647
+ );
648
+ function gt(e) {
649
+ return tt.fromString(e, !0, 16);
650
+ }
651
+ const ae = gt("c3a5c85c97cb3127"), Y = gt("b492b66fbe98f273"), D = gt("9ae16a3b2f90404f");
652
+ function xt(e) {
653
+ return e.xor(e.shru(47));
654
+ }
655
+ function ie(e, t, n) {
656
+ const s = e.slice(t, t + n);
657
+ return tt.fromBytes(Array.from(s), !0, !0);
658
+ }
659
+ function T(e, t) {
660
+ return ie(e, t, 8);
661
+ }
662
+ function St(e, t) {
663
+ return ie(e, t, 4);
664
+ }
665
+ function q(e, t) {
666
+ return t === 0 ? e : e.shru(t).or(e.shl(64 - t));
667
+ }
668
+ function J(e, t, n = gt("9ddfea08eb382d69")) {
669
+ let s = e.xor(t).mul(n);
670
+ s = s.xor(s.shru(47));
671
+ let o = t.xor(s).mul(n);
672
+ return o = o.xor(o.shru(47)), o = o.mul(n), o;
673
+ }
674
+ function Mn(e, t, n, s, o, a) {
675
+ o = o.add(e), a = q(a.add(o).add(s), 21);
676
+ const r = o;
677
+ return o = o.add(t), o = o.add(n), a = a.add(q(o, 44)), [o.add(s), a.add(r)];
678
+ }
679
+ function ut(e, t, n, s) {
680
+ return Mn(T(e, t), T(e, t + 8), T(e, t + 16), T(e, t + 24), n, s);
681
+ }
682
+ function On(e, t = e.length) {
683
+ if (t >= 8) {
684
+ const n = D.add(t * 2), s = T(e, 0).add(D), o = T(e, t - 8), a = q(o, 37).mul(n).add(s), r = q(s, 25).add(o).mul(n);
685
+ return J(a, r, n);
686
+ }
687
+ if (t >= 4) {
688
+ const n = D.add(t * 2), s = St(e, 0);
689
+ return J(s.shl(3).add(t), St(e, t - 4), n);
690
+ }
691
+ if (t > 0) {
692
+ const n = e[0], s = e[t >> 1], o = e[t - 1], a = n + (s << 8), r = t + (o << 2);
693
+ return xt(D.mul(a).xor(ae.mul(r))).mul(D);
694
+ }
695
+ return D;
696
+ }
697
+ function Ln(e, t = e.length) {
698
+ const n = D.add(t * 2), s = T(e, 0).mul(Y), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(D);
699
+ return J(q(s.add(o), 43).add(q(a, 30)).add(r), s.add(q(o.add(D), 18)).add(a), n);
700
+ }
701
+ function Pn(e, t = e.length) {
702
+ const n = D.add(t * 2), s = T(e, 0).mul(D), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(D), i = q(s.add(o), 43).add(q(a, 30)).add(r), l = J(i, s.add(q(o.add(D), 18)).add(a), n), u = T(e, 16).mul(n), h = T(e, 24), f = i.add(T(e, t - 32)).mul(n), p = l.add(T(e, t - 24)).mul(n);
703
+ return J(q(u.add(h), 43).add(q(f, 30)).add(p), u.add(q(h.add(s), 18)).add(f), n);
704
+ }
705
+ function An(e, t = e.length) {
706
+ const n = tt.fromNumber(81, !0);
707
+ if (t <= 32)
708
+ return t <= 16 ? On(e, t) : Ln(e, t);
709
+ if (t <= 64)
710
+ return Pn(e, t);
711
+ let s = n, o = n.mul(Y).add(113), a = xt(o.mul(D).add(113)).mul(D), r = [tt.UZERO, tt.UZERO], i = [tt.UZERO, tt.UZERO];
712
+ s = s.mul(D).add(T(e, 0));
713
+ let l = 0;
714
+ const u = (t - 1 >> 6) * 64, h = u + (t - 1 & 63) - 63;
715
+ do
716
+ s = q(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(Y), o = q(o.add(r[1]).add(T(e, l + 48)), 42).mul(Y), s = s.xor(i[1]), o = o.add(r[0]).add(T(e, l + 40)), a = q(a.add(i[0]), 33).mul(Y), r = ut(e, l, r[1].mul(Y), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], l += 64;
717
+ while (l !== u);
718
+ const f = Y.add(a.and(255).shl(1));
719
+ return l = h, i[0] = i[0].add(t - 1 & 63), r[0] = r[0].add(i[0]), i[0] = i[0].add(r[0]), s = q(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(f), o = q(o.add(r[1]).add(T(e, l + 48)), 42).mul(f), s = s.xor(i[1].mul(9)), o = o.add(r[0].mul(9).add(T(e, l + 40))), a = q(a.add(i[0]), 33).mul(f), r = ut(e, l, r[1].mul(f), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], J(J(r[0], i[0], f).add(xt(o).mul(ae)).add(a), J(r[1], i[1], f).add(s), f);
720
+ }
721
+ function nt(e, t) {
722
+ Array.isArray(e) || (e = [e]), e.forEach((n) => {
723
+ n != null && Pt(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the CPU backend.`);
724
+ });
725
+ }
726
+ function le(e) {
727
+ const t = new Float32Array(e.length);
728
+ for (let n = 0; n < e.length; ++n)
729
+ t[n] = Math.abs(e[n]);
730
+ return t;
731
+ }
732
+ const qn = (e) => {
733
+ const { x: t } = e.inputs, n = e.backend;
734
+ nt(t, "abs");
735
+ let s = new Float32Array(V(t.shape));
736
+ const o = n.data.get(t.dataId).values;
737
+ return s = le(o), n.makeOutput(s, t.shape, t.dtype);
738
+ }, Ys = {
739
+ kernelName: $e,
740
+ backendName: "cpu",
741
+ kernelFunc: qn
742
+ };
743
+ function U(e) {
744
+ return (t, n, s, o, a) => {
745
+ const r = Lt(t, n), i = r.length, l = K(r), u = V(r), h = et(a, u), f = t.length, p = n.length, w = K(t), m = K(n), b = ht(t, r), d = ht(n, r);
746
+ if (b.length + d.length === 0)
747
+ for (let g = 0; g < h.length; ++g)
748
+ h[g] = e(s[g % s.length], o[g % o.length]);
749
+ else
750
+ for (let g = 0; g < h.length; ++g) {
751
+ const x = dt(g, i, l), k = x.slice(-f);
752
+ b.forEach((O) => k[O] = 0);
753
+ const y = at(k, f, w), v = x.slice(-p);
754
+ d.forEach((O) => v[O] = 0);
755
+ const M = at(v, p, m);
756
+ h[g] = e(s[y], o[M]);
757
+ }
758
+ return [h, r];
759
+ };
760
+ }
761
+ function mt(e) {
762
+ const { inputs: t, backend: n } = e, { real: s, imag: o } = t, a = n.data.get(s.dataId).values, r = n.data.get(o.dataId).values, i = n.makeTensorInfo(s.shape, "complex64"), l = n.data.get(i.dataId);
763
+ return l.complexTensorInfos = {
764
+ real: n.makeTensorInfo(s.shape, "float32", a),
765
+ imag: n.makeTensorInfo(o.shape, "float32", r)
766
+ }, i;
767
+ }
768
+ const to = {
769
+ kernelName: ze,
770
+ backendName: "cpu",
771
+ kernelFunc: mt
772
+ };
773
+ function Et(e, t, n = "float32") {
774
+ if (n === "complex64") {
775
+ const o = Et(e, t, "float32"), a = Et(e, t, "float32");
776
+ return mt({ inputs: { real: o, imag: a }, backend: e });
777
+ }
778
+ const s = st(V(t), n);
779
+ return e.makeTensorInfo(t, n, s);
780
+ }
781
+ function Ft(e) {
782
+ const { inputs: t, backend: n } = e, { x: s } = t;
783
+ return n.incRef(s.dataId), { dataId: s.dataId, shape: s.shape, dtype: s.dtype };
784
+ }
785
+ const eo = {
786
+ kernelName: Be,
787
+ backendName: "cpu",
788
+ kernelFunc: Ft
789
+ };
790
+ function ce(e) {
791
+ const { inputs: t, backend: n } = e, { input: s } = t, o = n.data.get(s.dataId).complexTensorInfos.real, a = n.data.get(o.dataId).values;
792
+ return n.makeTensorInfo(o.shape, o.dtype, a);
793
+ }
794
+ const no = {
795
+ kernelName: je,
796
+ backendName: "cpu",
797
+ kernelFunc: ce
798
+ };
799
+ function ue(e, t, n, s) {
800
+ if (s === "int32") {
801
+ const o = Int32Array.from(e);
802
+ return [t, "int32", o];
803
+ }
804
+ if (s === "bool") {
805
+ const o = We([0], n), [a, r] = U((i, l) => i !== l ? 1 : 0)(t, [], e, o, "bool");
806
+ return [r, "bool", a];
807
+ }
808
+ throw new Error(`Error in Cast: failed to cast ${n} to ${s}`);
809
+ }
810
+ function lt(e) {
811
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { dtype: a } = s;
812
+ if (a === "complex64") {
813
+ if (o.dtype === "complex64")
814
+ return Ft({ inputs: { x: o }, backend: n });
815
+ const h = Et(n, o.shape, o.dtype), f = lt({ inputs: { x: o }, backend: n, attrs: { dtype: "float32" } }), p = mt({ inputs: { real: f, imag: h }, backend: n });
816
+ return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(f), p;
817
+ }
818
+ if (o.dtype === "complex64") {
819
+ const h = ce({ inputs: { input: o }, backend: n }), f = lt({ inputs: { x: h }, backend: n, attrs: { dtype: a } });
820
+ return n.disposeIntermediateTensorInfo(h), f;
821
+ }
822
+ if (!De(o.dtype, a)) {
823
+ const h = Ft({ inputs: { x: o }, backend: n });
824
+ return { dataId: h.dataId, shape: h.shape, dtype: a };
825
+ }
826
+ const r = n.data.get(o.dataId).values, [i, l, u] = ue(r, o.shape, o.dtype, a);
827
+ return n.makeTensorInfo(i, l, u);
828
+ }
829
+ const so = {
830
+ kernelName: Ge,
831
+ backendName: "cpu",
832
+ kernelFunc: lt
833
+ };
834
+ function z(e, t, n, s) {
835
+ return n == null ? ({ inputs: o, backend: a }) => {
836
+ const { a: r, b: i } = o, l = a;
837
+ nt([r, i], e);
838
+ const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = r.dtype === "string" ? (
839
+ // tslint:disable-next-line: no-any
840
+ it(u)
841
+ ) : u, p = r.dtype === "string" ? (
842
+ // tslint:disable-next-line: no-any
843
+ it(h)
844
+ ) : h, w = s || r.dtype, [m, b] = t(r.shape, i.shape, f, p, w);
845
+ return l.makeTensorInfo(b, w, m);
846
+ } : ({ inputs: o, backend: a }) => {
847
+ const { a: r, b: i } = o, l = a;
848
+ if (r.dtype === "complex64" || i.dtype === "complex64") {
849
+ const u = lt({ inputs: { x: r }, backend: l, attrs: { dtype: "complex64" } }), h = l.data.get(u.dataId), f = h.complexTensorInfos.real, p = h.complexTensorInfos.imag, w = l.data.get(f.dataId).values, m = l.data.get(p.dataId).values, b = lt({ inputs: { x: i }, backend: l, attrs: { dtype: "complex64" } }), d = l.data.get(b.dataId), g = d.complexTensorInfos.real, x = d.complexTensorInfos.imag, k = l.data.get(g.dataId).values, y = l.data.get(x.dataId).values, [v, M, O] = n(r.shape, i.shape, w, m, k, y), S = l.makeTensorInfo(O, "float32", v), E = l.makeTensorInfo(O, "float32", M), I = mt({ inputs: { real: S, imag: E }, backend: l });
850
+ return l.disposeIntermediateTensorInfo(u), l.disposeIntermediateTensorInfo(b), l.disposeIntermediateTensorInfo(S), l.disposeIntermediateTensorInfo(E), I;
851
+ } else {
852
+ const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = s || r.dtype, [p, w] = t(r.shape, i.shape, u, h, f);
853
+ return l.makeTensorInfo(w, f, p);
854
+ }
855
+ };
856
+ }
857
+ function bt(e) {
858
+ return (t, n, s, o, a, r) => {
859
+ const i = Lt(t, n), l = V(i), u = i.length, h = K(i), f = et("float32", l), p = et("float32", l), w = ht(t, i), m = ht(n, i), b = Nt(s, o), d = Nt(a, r), g = t.length, x = K(t), k = n.length, y = K(n);
860
+ if (w.length + m.length === 0)
861
+ for (let v = 0; v < f.length; v++) {
862
+ const M = v % b.length, O = v % d.length, S = e(b[M * 2], b[M * 2 + 1], d[O * 2], d[O * 2 + 1]);
863
+ f[v] = S.real, p[v] = S.imag;
864
+ }
865
+ else
866
+ for (let v = 0; v < f.length; v++) {
867
+ const M = dt(v, u, h), O = M.slice(-g);
868
+ w.forEach((F) => O[F] = 0);
869
+ const S = at(O, g, x), E = M.slice(-k);
870
+ m.forEach((F) => E[F] = 0);
871
+ const I = at(E, k, y), c = e(b[S * 2], b[S * 2 + 1], d[I * 2], d[I * 2 + 1]);
872
+ f[v] = c.real, p[v] = c.imag;
873
+ }
874
+ return [f, p, i];
875
+ };
876
+ }
877
+ const he = U(((e, t) => e + t)), _n = bt(((e, t, n, s) => ({ real: e + n, imag: t + s }))), Vn = z(qt, he, _n), oo = {
878
+ kernelName: qt,
879
+ backendName: "cpu",
880
+ kernelFunc: Vn
881
+ };
882
+ function Cn(e, t, n, s, o) {
883
+ const a = V(s), r = st(o, n);
884
+ for (let i = 0; i < e.length; i++) {
885
+ const l = e[i];
886
+ if (l < 0)
887
+ throw new Error("Input x must be non-negative!");
888
+ l >= o || (a > 0 ? r[l] += t[i] : r[l] += 1);
889
+ }
890
+ return r;
891
+ }
892
+ function Dn(e, t, n, s = !1) {
893
+ const o = e.shape[0], a = e.shape[1], r = H([o, n], t.dtype);
894
+ for (let i = 0; i < o; i++)
895
+ for (let l = 0; l < a; l++) {
896
+ const u = e.get(i, l);
897
+ if (u < 0)
898
+ throw new Error("Input x must be non-negative!");
899
+ u >= n || (s ? r.set(1, i, u) : t.size > 0 ? r.set(r.get(i, u) + t.get(i, l), i, u) : r.set(r.get(i, u) + 1, i, u));
900
+ }
901
+ return r;
902
+ }
903
+ const fe = U(((e, t) => e & t)), Wn = z(_t, fe), ro = {
904
+ kernelName: _t,
905
+ backendName: "cpu",
906
+ kernelFunc: Wn
907
+ };
908
+ function X(e) {
909
+ return (t, n, s) => {
910
+ const o = W(n, t.length);
911
+ for (let a = 0; a < t.length; ++a)
912
+ o[a] = e(t[a], s);
913
+ return o;
914
+ };
915
+ }
916
+ function de(e, t, n) {
917
+ const s = X(t);
918
+ return Q(e, s, n);
919
+ }
920
+ function Q(e, t, n) {
921
+ return ({ inputs: s, attrs: o, backend: a }) => {
922
+ const { x: r } = s;
923
+ nt(r, e);
924
+ const i = a, l = i.data.get(r.dataId).values;
925
+ let u;
926
+ if (r.dtype === "string") {
927
+ if (!Array.isArray(l))
928
+ throw new Error("String tensor's value was not an instance of Array");
929
+ u = it(l);
930
+ } else
931
+ u = l;
932
+ const h = n || r.dtype, f = t(u, h, o);
933
+ return i.makeTensorInfo(r.shape, h, f);
934
+ };
935
+ }
936
+ const ge = X((e) => Math.ceil(e)), Un = Q(Vt, ge), ao = {
937
+ kernelName: Vt,
938
+ backendName: "cpu",
939
+ kernelFunc: Un
940
+ };
941
+ function $n(e, t, n, s) {
942
+ const o = W(n, V(t));
943
+ if (s && n !== "string") {
944
+ let a = 0;
945
+ e.forEach((r) => {
946
+ const i = V(r.shape);
947
+ o.set(r.vals, a), a += i;
948
+ });
949
+ } else {
950
+ let a = 0;
951
+ e.forEach((r) => {
952
+ const i = n === "string" ? it(r.vals) : r.vals;
953
+ let l = 0;
954
+ for (let u = 0; u < r.shape[0]; ++u) {
955
+ const h = u * t[1] + a;
956
+ for (let f = 0; f < r.shape[1]; ++f)
957
+ o[h + f] = i[l++];
958
+ }
959
+ a += r.shape[1];
960
+ });
961
+ }
962
+ return o;
963
+ }
964
+ const me = U((e, t) => e === t ? 1 : 0), zn = z(Ct, me, null, "bool"), io = {
965
+ kernelName: Ct,
966
+ backendName: "cpu",
967
+ kernelFunc: zn
968
+ };
969
+ const pe = X((e) => Math.exp(e)), Bn = Q(Dt, pe, "float32"), lo = {
970
+ kernelName: Dt,
971
+ backendName: "cpu",
972
+ kernelFunc: Bn
973
+ };
974
+ const we = X((e) => Math.expm1(e)), jn = Q(Wt, we), co = {
975
+ kernelName: Wt,
976
+ backendName: "cpu",
977
+ kernelFunc: jn
978
+ };
979
+ const Ie = X((e) => Math.floor(e)), Gn = Q(Ut, Ie), uo = {
980
+ kernelName: Ut,
981
+ backendName: "cpu",
982
+ kernelFunc: Gn
983
+ };
984
+ const xe = U((e, t) => Math.floor(e / t)), Zn = z($t, xe, null, "int32"), ho = {
985
+ kernelName: $t,
986
+ backendName: "cpu",
987
+ kernelFunc: Zn
988
+ };
989
+ function Hn(e, t, n, s, o, a, r, i, l) {
990
+ const u = H([s, a], n);
991
+ for (let h = 0; h < s; h++) {
992
+ const f = [];
993
+ let p = 0;
994
+ for (let w = 0; w < o; w++) {
995
+ const m = e[h * o + w];
996
+ p += m * r[w], f.push(m);
997
+ }
998
+ if (p < 0 || p >= l / a)
999
+ throw new Error(`Invalid indices: ${f} does not index into ${i}`);
1000
+ for (let w = 0; w < a; w++)
1001
+ u.values[h * a + w] = t.get(...t.indexToLoc(p * a + w));
1002
+ }
1003
+ return u;
1004
+ }
1005
+ function Kn(e, t, n) {
1006
+ const s = H(n, e.dtype);
1007
+ for (let o = 0; o < s.size; ++o) {
1008
+ const r = s.indexToLoc(o).slice(), i = r[0], l = r[2], u = t.locToIndex([i, l]);
1009
+ r[2] = t.values[u];
1010
+ const h = e.locToIndex(r);
1011
+ 0 <= h && h < e.values.length && (s.values[o] = e.values[h]);
1012
+ }
1013
+ return s;
1014
+ }
1015
+ const Ee = U((e, t) => e > t ? 1 : 0), Xn = z(zt, Ee, null, "bool"), fo = {
1016
+ kernelName: zt,
1017
+ backendName: "cpu",
1018
+ kernelFunc: Xn
1019
+ };
1020
+ const Fe = U((e, t) => e >= t ? 1 : 0), Jn = z(Bt, Fe, null, "bool"), go = {
1021
+ kernelName: Bt,
1022
+ backendName: "cpu",
1023
+ kernelFunc: Jn
1024
+ };
1025
+ const be = U((e, t) => e < t ? 1 : 0), Qn = z(jt, be, null, "bool"), mo = {
1026
+ kernelName: jt,
1027
+ backendName: "cpu",
1028
+ kernelFunc: Qn
1029
+ };
1030
+ const ye = U((e, t) => e <= t ? 1 : 0), Yn = z(Gt, ye, null, "bool"), po = {
1031
+ kernelName: Gt,
1032
+ backendName: "cpu",
1033
+ kernelFunc: Yn
1034
+ };
1035
+ function ts(e, t, n) {
1036
+ const s = (t - e) / (n - 1), o = st(n, "float32");
1037
+ o[0] = e;
1038
+ for (let a = 1; a < o.length; a++)
1039
+ o[a] = o[a - 1] + s;
1040
+ return o;
1041
+ }
1042
+ const ke = X((e) => Math.log(e)), es = Q(Zt, ke), wo = {
1043
+ kernelName: Zt,
1044
+ backendName: "cpu",
1045
+ kernelFunc: es
1046
+ };
1047
+ function ns(e, t, n, s) {
1048
+ const o = et(s, V(n));
1049
+ for (let a = 0; a < o.length; ++a) {
1050
+ const r = a * t;
1051
+ let i = e[r];
1052
+ for (let l = 0; l < t; ++l) {
1053
+ const u = e[r + l];
1054
+ (Number.isNaN(u) || u > i) && (i = u);
1055
+ }
1056
+ o[a] = i;
1057
+ }
1058
+ return o;
1059
+ }
1060
+ const Ne = U(((e, t) => Math.max(e, t))), ss = z(Ht, Ne), Io = {
1061
+ kernelName: Ht,
1062
+ backendName: "cpu",
1063
+ kernelFunc: ss
1064
+ };
1065
+ const ve = U(((e, t) => Math.min(e, t))), os = z(Kt, ve), xo = {
1066
+ kernelName: Kt,
1067
+ backendName: "cpu",
1068
+ kernelFunc: os
1069
+ };
1070
+ const yt = U(((e, t) => e * t)), rs = bt(((e, t, n, s) => ({
1071
+ real: e * n - t * s,
1072
+ imag: e * s + t * n
1073
+ }))), as = z(Xt, yt, rs), Eo = {
1074
+ kernelName: Xt,
1075
+ backendName: "cpu",
1076
+ kernelFunc: as
1077
+ };
1078
+ function Se(e, t, n) {
1079
+ const s = Ue(-1, n);
1080
+ return yt([], t, s, e, n);
1081
+ }
1082
+ function is(e) {
1083
+ const { inputs: t, backend: n } = e, { x: s } = t;
1084
+ nt(s, "neg");
1085
+ const o = n.data.get(s.dataId).values, [a, r] = Se(o, s.shape, s.dtype);
1086
+ return n.makeTensorInfo(r, s.dtype, a);
1087
+ }
1088
+ const Fo = {
1089
+ kernelName: Ze,
1090
+ backendName: "cpu",
1091
+ kernelFunc: is
1092
+ };
1093
+ const Te = U(((e, t) => e !== t ? 1 : 0)), ls = z(Jt, Te, null, "bool"), bo = {
1094
+ kernelName: Jt,
1095
+ backendName: "cpu",
1096
+ kernelFunc: ls
1097
+ };
1098
+ function Re(e, t, n, s, o) {
1099
+ const a = t.length, r = V(t), i = K(t), l = K(o), u = et(n, V(o));
1100
+ for (let h = 0; h < r; ++h) {
1101
+ const f = dt(h, a, i), p = new Array(f.length);
1102
+ for (let m = 0; m < p.length; m++)
1103
+ p[m] = f[s[m]];
1104
+ const w = at(p, a, l);
1105
+ u[w] = e[h];
1106
+ }
1107
+ return u;
1108
+ }
1109
+ function Me(e) {
1110
+ const { inputs: t, attrs: n, backend: s } = e, { x: o } = t, { perm: a } = n;
1111
+ nt(o, "transpose");
1112
+ const r = o.shape.length, i = new Array(r);
1113
+ for (let f = 0; f < i.length; f++)
1114
+ i[f] = o.shape[a[f]];
1115
+ const l = s.data.get(o.dataId).values, u = Re(l, o.shape, o.dtype, a, i);
1116
+ return { dataId: s.write(u, i, o.dtype), shape: i, dtype: o.dtype };
1117
+ }
1118
+ const yo = {
1119
+ kernelName: He,
1120
+ backendName: "cpu",
1121
+ kernelFunc: Me
1122
+ };
1123
+ function Oe(e, t, n, s) {
1124
+ const [o, a] = xn(e, s), r = Xe(t, "int32"), i = st(V(o), r), l = V(a);
1125
+ for (let u = 0; u < i.length; ++u) {
1126
+ const h = u * l;
1127
+ let f = 1;
1128
+ for (let p = 0; p < l; ++p)
1129
+ f *= n[h + p];
1130
+ i[u] = f;
1131
+ }
1132
+ return { outVals: i, outShape: o, outDtype: r };
1133
+ }
1134
+ function cs(e) {
1135
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { axis: a, keepDims: r } = s;
1136
+ nt(o, "prod");
1137
+ const i = o.shape.length, l = At(a, o.shape), u = pn(l, i);
1138
+ let h = l, f = o;
1139
+ const p = [];
1140
+ u != null && (f = Me({ inputs: { x: o }, backend: n, attrs: { perm: u } }), p.push(f), h = wn(h.length, i));
1141
+ const w = n.data.get(f.dataId).values, { outVals: m, outShape: b, outDtype: d } = Oe(f.shape, f.dtype, w, h);
1142
+ let g = b;
1143
+ return r && (g = In(b, l)), p.forEach((x) => n.disposeIntermediateTensorInfo(x)), n.makeTensorInfo(g, d, m);
1144
+ }
1145
+ const ko = {
1146
+ kernelName: Ke,
1147
+ backendName: "cpu",
1148
+ kernelFunc: cs
1149
+ };
1150
+ function us(e, t, n) {
1151
+ e.forEach((s, o) => {
1152
+ if (s < 0 || s >= n) {
1153
+ const a = dt(o, t.length, K(t)).join(",");
1154
+ throw new Error(`indices[${a}] = ${s} is not in [0, ${n})`);
1155
+ }
1156
+ });
1157
+ }
1158
+ function hs(e, t) {
1159
+ for (let n = 0; n < e.length; ++n) {
1160
+ const s = e[n], o = n === e.length - 1 ? t : e[n + 1].length;
1161
+ if (s.length === 0)
1162
+ throw new Error("Ragged splits may not be empty");
1163
+ if (s[0] < 0)
1164
+ throw new Error("Ragged splits must be non-negative");
1165
+ if (s[s.length - 1] > o)
1166
+ throw new Error("Ragged splits must not point past values");
1167
+ for (let a = 1; a < s.length; ++a)
1168
+ if (s[a - 1] > s[a])
1169
+ throw new Error("Ragged splits must be sorted in ascending order");
1170
+ }
1171
+ }
1172
+ function fs(e, t, n, s) {
1173
+ const o = [];
1174
+ let a = 0;
1175
+ const r = t.length - 1 + n.length, i = new Array(r).fill(null).map(() => [0]);
1176
+ hs(n, s);
1177
+ let l = 1;
1178
+ for (let u = 0; u < t.length - 1; ++u) {
1179
+ l *= t[u];
1180
+ const h = t[u + 1];
1181
+ for (let f = 1; f < l + 1; ++f)
1182
+ i[u].push(f * h);
1183
+ }
1184
+ for (let u = 0; u < e.length; ++u) {
1185
+ let h = e[u], f = e[u] + 1;
1186
+ for (let p = 0; p < n.length; ++p) {
1187
+ const w = n[p], m = p + t.length - 1;
1188
+ if (m >= 0) {
1189
+ const b = i[m], d = b[b.length - 1] - w[h];
1190
+ for (let g = h; g < f; ++g)
1191
+ i[m].push(w[g + 1] + d);
1192
+ }
1193
+ h = w[h], f = w[f];
1194
+ }
1195
+ f !== h && (o.push([h, f]), a += f - h);
1196
+ }
1197
+ return { outSplits: i, valueSlices: o, numValues: a };
1198
+ }
1199
+ function ds(e) {
1200
+ const t = [];
1201
+ for (let n = 0; n < e.length; ++n) {
1202
+ const s = e[n].length, o = W("int32", s);
1203
+ t.push(o), e[n].forEach((a, r) => o[r] = a);
1204
+ }
1205
+ return t;
1206
+ }
1207
+ function Tt(e, t) {
1208
+ const n = e.slice(0, t);
1209
+ for (; n.length < t; )
1210
+ n.push(1);
1211
+ for (let s = t; s < e.length; s++)
1212
+ n[t - 1] *= e[s];
1213
+ return n;
1214
+ }
1215
+ function gs(e, t, n, s, o, a) {
1216
+ const r = Tt(t, 2)[1], i = Tt(a, 2)[1];
1217
+ let l = 0;
1218
+ for (const u of n)
1219
+ for (let h = u[0]; h < u[1]; ++h) {
1220
+ for (let f = 0; f < s; ++f)
1221
+ o[l * i + f] = e[h * r + f];
1222
+ ++l;
1223
+ }
1224
+ }
1225
+ function ms(e, t, n, s, o) {
1226
+ const a = t.slice();
1227
+ a[0] = o;
1228
+ const r = W(n, V(a)), i = e.length, l = i === 0 ? 0 : i / t[0];
1229
+ return gs(e, t, s, l, r, a), [r, a];
1230
+ }
1231
+ function ps(e, t, n, s, o, a, r, i) {
1232
+ if (e.length === 0)
1233
+ throw new Error("paramsNestedSplits must be non empty");
1234
+ if (t[0].length === 0)
1235
+ throw new Error("Split tensors must not be scalars");
1236
+ const l = t[0][0] - 1;
1237
+ if (us(a, r, l), s.length === 0)
1238
+ throw new Error("params.rank must be nonzero");
1239
+ const u = s[0], { outSplits: h, valueSlices: f, numValues: p } = fs(a, r, e, u), w = ds(h), m = ms(n, s, o, f, p);
1240
+ return [w, m[0], m[1]];
1241
+ }
1242
+ const Rt = 2147483647;
1243
+ function ws(e, t, n, s, o, a, r) {
1244
+ if (t.length > 1)
1245
+ throw new Error("starts must be a scalar or vector");
1246
+ if (o.length > 1)
1247
+ throw new Error("limits must be a scalar or vector");
1248
+ if (r.length > 1)
1249
+ throw new Error("deltas must be a scalar or vector");
1250
+ const i = t.length === 0, l = o.length === 0, u = r.length === 0, h = [];
1251
+ i || h.push(t[0]), l || h.push(o[0]), u || h.push(r[0]);
1252
+ for (let d = 1; d < h.length; ++d)
1253
+ if (h[d] !== h[d - 1])
1254
+ throw new Error("starts, limits, and deltas must have the same shape");
1255
+ const f = h.length === 0 ? 1 : h[0], p = W("int32", f + 1);
1256
+ p[0] = 0;
1257
+ for (let d = 0; d < f; ++d) {
1258
+ const g = i ? e[0] : e[d], x = l ? s[0] : s[d], k = u ? a[0] : a[d];
1259
+ if (k === 0)
1260
+ throw new Error("Requires delta != 0");
1261
+ let y;
1262
+ if (k > 0 && x < g || k < 0 && x > g)
1263
+ y = 0;
1264
+ else if (y = Math.ceil(Math.abs((x - g) / k)), y > Rt)
1265
+ throw new Error(`Requires ((limit - start) / delta) <= ${Rt}`);
1266
+ p[d + 1] = p[d] + y;
1267
+ }
1268
+ const w = p[f], m = W(n, w);
1269
+ let b = 0;
1270
+ for (let d = 0; d < f; ++d) {
1271
+ const g = p[d + 1] - p[d];
1272
+ let x = i ? e[0] : e[d];
1273
+ const k = u ? a[0] : a[d];
1274
+ for (let y = 0; y < g; ++y)
1275
+ m[b++] = x, x += k;
1276
+ }
1277
+ return [p, m];
1278
+ }
1279
+ var Z = tn;
1280
+ class ft {
1281
+ constructor(t, n, s, o, a, r, i, l, u, h) {
1282
+ this.shape = t, this.shapeShape = n, this.values = s, this.valuesShape = o, this.valuesDType = a, this.defaultValue = r, this.defaultValueShape = i, this.rowPartitionValues = l, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = Qe(h), this.raggedRank = Ye(this.rowPartitionTypes);
1283
+ }
1284
+ getRowPartitionTypeByDimension(t) {
1285
+ return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionTypes[t + 1] : this.rowPartitionTypes[t];
1286
+ }
1287
+ // Returns the relationship between dimension and dimension + 1.
1288
+ getRowPartitionTensor(t) {
1289
+ return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionValues[t + 1] : this.rowPartitionValues[t];
1290
+ }
1291
+ getMaxWidth(t) {
1292
+ const n = this.getRowPartitionTensor(t - 1);
1293
+ switch (this.getRowPartitionTypeByDimension(t - 1)) {
1294
+ case Z.VALUE_ROWIDS:
1295
+ return ft.getMaxWidthValueRowID(n);
1296
+ case Z.ROW_SPLITS:
1297
+ return ft.getMaxWidthRowSplit(n);
1298
+ default:
1299
+ throw new Error(`Cannot handle partition type ${Z[this.getRowPartitionTypeByDimension(t - 1)]}`);
1300
+ }
1301
+ }
1302
+ static getMaxWidthRowSplit(t) {
1303
+ const n = t.length;
1304
+ if (n === 0 || n === 1)
1305
+ return 0;
1306
+ let s = 0;
1307
+ for (let o = 0; o < n - 1; ++o) {
1308
+ const a = t[o + 1] - t[o];
1309
+ a > s && (s = a);
1310
+ }
1311
+ return s;
1312
+ }
1313
+ static getMaxWidthValueRowID(t) {
1314
+ const n = t.length;
1315
+ if (n === 0)
1316
+ return 0;
1317
+ let s = 0, o = t[0], a = 0;
1318
+ for (let r = 1; r < n; ++r) {
1319
+ const i = t[r];
1320
+ i !== o && (o = i, a = Math.max(r - s, a), s = r);
1321
+ }
1322
+ return Math.max(n - s, a);
1323
+ }
1324
+ tensorShapeFromTensor(t, n, s = !0) {
1325
+ if (n.length === 0) {
1326
+ if (t[0] === -1)
1327
+ return [];
1328
+ throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
1329
+ }
1330
+ return Ot(t, s);
1331
+ }
1332
+ calculateOutputSize(t) {
1333
+ const n = this.valuesShape, s = this.defaultValueShape;
1334
+ en(s, n);
1335
+ const o = this.tensorShapeFromTensor(this.shape, this.shapeShape), r = nn(this.raggedRank, o, n);
1336
+ r[0] < 0 && (r[0] = t);
1337
+ for (let i = 1; i <= this.raggedRank; ++i)
1338
+ r[i] < 0 && (r[i] = this.getMaxWidth(i));
1339
+ return r;
1340
+ }
1341
+ /**
1342
+ * The outputIndex represents the index in the output tensor
1343
+ * where the first element of a particular dimension would be written.
1344
+ * If it is -1, it indicates that the index is out of scope.
1345
+ * Example, given firstDimension = 10, firstDimensionOutput = 6,
1346
+ * and outputIndexMultiplier = 100:
1347
+ * result = [0 100 200 300 400 500 -1 -1 -1 -1]
1348
+ * If firstDimensionOutput = 11 instead, then:
1349
+ * result = [0 100 200 300 400 500 600 700 800 900]
1350
+ */
1351
+ calculateFirstParentOutputIndex(t, n, s) {
1352
+ const o = Math.min(t, s), a = [];
1353
+ let r = 0;
1354
+ for (let i = 0; i < o; ++i, r += n)
1355
+ a.push(r);
1356
+ for (let i = o; i < t; ++i)
1357
+ a.push(-1);
1358
+ return Pt(a.length === t, () => "Final length of result must be equal to firstDimension."), a;
1359
+ }
1360
+ calculateOutputIndexRowSplit(t, n, s, o) {
1361
+ const a = t.length, r = [];
1362
+ for (let i = 0; i < a - 1; ++i) {
1363
+ const l = t[i + 1] - t[i];
1364
+ let u = Math.min(o, l), h = n[i];
1365
+ h === -1 && (u = 0);
1366
+ for (let f = 0; f < u; ++f)
1367
+ r.push(h), h += s;
1368
+ for (let f = 0; f < l - u; ++f)
1369
+ r.push(-1);
1370
+ }
1371
+ if (a > 0 && r.length !== t[a - 1])
1372
+ throw new Error("Invalid row split size.");
1373
+ return r;
1374
+ }
1375
+ // Calculate the output index of the first element of a list.
1376
+ // The parentOutputIndex is the same computation for the previous list.
1377
+ // -1 indicates an element or list that is out of range.
1378
+ // The outputIndexMultiplier is the number of output indices one moves
1379
+ // forward for each column.
1380
+ // E.g., given:
1381
+ // valueRowIds:[0 1 2 2 2 3 5 5 6]
1382
+ // parentOutputIndex:[1000 1100 2000 2100 -1 3000 4000]
1383
+ // outputIndexMultiplier: 10
1384
+ // outputSize: 2
1385
+ // You get:
1386
+ // result = [1000 1100 2000 2010 -1 2100 -1 -1 3000]
1387
+ // result[0] = parentOutputIndex[valueRowIds[0]]
1388
+ // result[1] = parentOutputIndex[valueRowIds[1]]
1389
+ // result[2] = parentOutputIndex[valueRowIds[2]]
1390
+ // result[3] = parentOutputIndex[valueRowIds[2] + 10]
1391
+ // result[4] = -1 because it is the third element the size is 2.
1392
+ // result[5] = parentOutputIndex[valueRowIds[3]]
1393
+ // result[6] = -1 because parentOutputIndex[valueRowIds[6]] == -1
1394
+ // result[7] = -1 because parentOutputIndex[valueRowIds[6]] == -1
1395
+ // result[8] = parentOutputIndex[valueRowIds[7]]
1396
+ calculateOutputIndexValueRowID(t, n, s, o) {
1397
+ const a = t.length, r = [];
1398
+ if (a === 0)
1399
+ return [];
1400
+ let i = 0, l = t[0];
1401
+ if (l >= n.length)
1402
+ throw new Error(`Got currentValueRowId=${l}, which is not less than ${n.length}`);
1403
+ let u = n[l];
1404
+ r.push(u);
1405
+ for (let h = 1; h < a; ++h) {
1406
+ const f = t[h];
1407
+ if (f === l)
1408
+ u >= 0 && (++i, i < o ? u += s : u = -1);
1409
+ else {
1410
+ if (i = 0, l = f, f >= n.length)
1411
+ throw new Error(`Got nextValueRowId=${f} which is not less than ${n.length}`);
1412
+ u = n[f];
1413
+ }
1414
+ r.push(u);
1415
+ }
1416
+ if (r.length !== t.length)
1417
+ throw new Error("Invalid row ids.");
1418
+ return r;
1419
+ }
1420
+ calculateOutputIndex(t, n, s, o) {
1421
+ const a = this.getRowPartitionTensor(t), r = this.getRowPartitionTypeByDimension(t);
1422
+ switch (r) {
1423
+ case Z.VALUE_ROWIDS:
1424
+ return this.calculateOutputIndexValueRowID(a, n, s, o);
1425
+ case Z.ROW_SPLITS:
1426
+ if (a.length - 1 > n.length)
1427
+ throw new Error(`Row partition size is greater than output size: ${a.length - 1} > ${n.length}`);
1428
+ return this.calculateOutputIndexRowSplit(a, n, s, o);
1429
+ default:
1430
+ throw new Error(`Unsupported partition type: ${Z[r]}`);
1431
+ }
1432
+ }
1433
+ getFirstDimensionSize() {
1434
+ const t = this.rowPartitionValues[0];
1435
+ if (this.rowPartitionTypes.length === 0)
1436
+ throw new Error("No row_partition_types given.");
1437
+ const n = this.rowPartitionTypes[0];
1438
+ switch (n) {
1439
+ case Z.FIRST_DIM_SIZE:
1440
+ return t[0];
1441
+ case Z.VALUE_ROWIDS:
1442
+ throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
1443
+ case Z.ROW_SPLITS:
1444
+ return this.rowPartitionValuesShapes[0][0] - 1;
1445
+ default:
1446
+ throw new Error(`Cannot handle type ${Z[n]}`);
1447
+ }
1448
+ }
1449
+ compute() {
1450
+ if (this.rowPartitionValues[0].length <= 0)
1451
+ throw new Error("Invalid first partition input. Tensor requires at least one element.");
1452
+ const n = this.getFirstDimensionSize(), s = this.calculateOutputSize(n), o = new Array(this.raggedRank + 1);
1453
+ o[o.length - 1] = 1;
1454
+ for (let l = o.length - 2; l >= 0; --l)
1455
+ o[l] = o[l + 1] * s[l + 1];
1456
+ const a = Ot(s, !1), r = W(this.valuesDType, V(a));
1457
+ if (o[0] * s[0] > 0) {
1458
+ let l = this.calculateFirstParentOutputIndex(n, o[0], s[0]);
1459
+ for (let u = 1; u <= this.raggedRank; ++u)
1460
+ l = this.calculateOutputIndex(u - 1, l, o[u], s[u]);
1461
+ this.setOutput(this.raggedRank, l, r, a);
1462
+ }
1463
+ return [a, r];
1464
+ }
1465
+ setOutput(t, n, s, o) {
1466
+ if (s.length === 0)
1467
+ return;
1468
+ const a = this.values, r = s;
1469
+ let i = o.slice();
1470
+ i = i.slice(t + 1);
1471
+ const l = V(i), u = n.length;
1472
+ let h = this.defaultValue;
1473
+ if (h.length !== l && h.length !== 1) {
1474
+ const m = this.defaultValueShape;
1475
+ Ce(() => {
1476
+ const b = Fn(h, m);
1477
+ h = En(b, i).dataSync();
1478
+ });
1479
+ }
1480
+ let f = 0, p = 0, w = 0;
1481
+ for (let m = 0; m <= u; ++m) {
1482
+ let b = m < u ? n[m] : -1;
1483
+ if (b === w) {
1484
+ ++w;
1485
+ continue;
1486
+ }
1487
+ if (p < w) {
1488
+ const d = a.subarray(f * l), g = r.subarray(p * l), x = (w - p) * l;
1489
+ Mt(g, d, x);
1490
+ }
1491
+ if (m >= u) {
1492
+ const d = s.length;
1493
+ b = Math.floor(d / l);
1494
+ }
1495
+ if (b > w)
1496
+ if (this.defaultValue.length === 1)
1497
+ r.subarray(w * l, b * l).fill(this.defaultValue[0]), w = b;
1498
+ else
1499
+ for (; b > w; ) {
1500
+ const d = r.slice(w * l);
1501
+ Mt(d, h, l), ++w;
1502
+ }
1503
+ b < 0 ? (f = m + 1, p = w) : (f = m, p = w, w = p + 1);
1504
+ }
1505
+ }
1506
+ }
1507
+ function Mt(e, t, n) {
1508
+ for (let s = 0; s < n; s++)
1509
+ e[s] = t[s];
1510
+ }
1511
+ function Ot(e, t) {
1512
+ const n = [];
1513
+ for (let s of e) {
1514
+ if (s < 0) {
1515
+ if (!t)
1516
+ throw new Error(`Dimension ${s} must be >= 0`);
1517
+ if (s < -1)
1518
+ throw new Error(`Dimension ${s} must be >= -1`);
1519
+ s = -1;
1520
+ }
1521
+ n.push(s);
1522
+ }
1523
+ return n;
1524
+ }
1525
+ function Is(e, t, n, s, o, a, r, i, l, u) {
1526
+ return new ft(e, t, n, s, o, a, r, i, l, u).compute();
1527
+ }
1528
+ function xs(e, t, n, s) {
1529
+ const o = e === t, a = e < t && n < 0, r = t < e && n > 1;
1530
+ if (o || a || r)
1531
+ return st(0, s);
1532
+ const i = Math.abs(Math.ceil((t - e) / n)), l = st(i, s);
1533
+ t < e && n === 1 && (n = -1), l[0] = e;
1534
+ for (let u = 1; u < l.length; u++)
1535
+ l[u] = l[u - 1] + n;
1536
+ return l;
1537
+ }
1538
+ const Le = X((e) => 1 / Math.sqrt(e)), Es = Q(Qt, Le), No = {
1539
+ kernelName: Qt,
1540
+ backendName: "cpu",
1541
+ kernelFunc: Es
1542
+ };
1543
+ function Fs(e, t, n, s, o, a, r, i, l, u) {
1544
+ const h = [s / o, o], f = e.values, p = t.values;
1545
+ if (s === 0)
1546
+ return H(n, t.dtype);
1547
+ const w = l instanceof It ? l : H(h, t.dtype);
1548
+ typeof l == "string" || typeof l == "number" ? w.values.fill(l) : typeof l == "boolean" && w.values.fill(+l);
1549
+ for (let m = 0; m < a; m++) {
1550
+ const b = [];
1551
+ let d = 0;
1552
+ for (let g = 0; g < r; g++) {
1553
+ const x = f[m * r + g];
1554
+ b.push(x), d += x * i[g];
1555
+ }
1556
+ if (d < 0 || d >= s / o)
1557
+ throw new Error(`Invalid indices: ${b} does not index into ${n}`);
1558
+ for (let g = 0; g < o; g++)
1559
+ u ? w.values[d * o + g] += p[m * o + g] : w.values[d * o + g] = t.rank === 0 ? p[0] : p[m * o + g];
1560
+ }
1561
+ return w;
1562
+ }
1563
+ const bs = X((e) => 1 / (1 + Math.exp(-e))), ys = de(Yt, (e) => 1 / (1 + Math.exp(-e))), vo = {
1564
+ kernelName: Yt,
1565
+ backendName: "cpu",
1566
+ kernelFunc: ys
1567
+ };
1568
+ function Pe(e, t, n, s, o) {
1569
+ const a = kn(s, t, n), r = V(n), i = K(s);
1570
+ if (a) {
1571
+ const f = Nn(t, i);
1572
+ return o === "string" ? e.slice(f, f + r) : e.subarray(f, f + r);
1573
+ }
1574
+ const l = o === "string" ? it(e) : e, u = H(s, o, l), h = H(n, o);
1575
+ for (let f = 0; f < h.size; ++f) {
1576
+ const p = h.indexToLoc(f), w = p.map((m, b) => m + t[b]);
1577
+ h.set(u.get(...w), ...p);
1578
+ }
1579
+ return o === "string" ? sn(h.values) : h.values;
1580
+ }
1581
+ function ks(e) {
1582
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { begin: a, size: r } = s;
1583
+ nt(o, "slice");
1584
+ const [i, l] = bn(o, a, r);
1585
+ yn(o, i, l);
1586
+ const u = n.data.get(o.dataId).values, h = Pe(u, i, l, o.shape, o.dtype);
1587
+ return n.makeTensorInfo(l, o.dtype, h);
1588
+ }
1589
+ const So = {
1590
+ kernelName: Je,
1591
+ backendName: "cpu",
1592
+ kernelFunc: ks
1593
+ };
1594
+ function Ns(e, t, n, s, o, a, r) {
1595
+ const i = t[0], l = a[0], u = new Array(l), h = new Array(i), f = t[1];
1596
+ if (l === 0) {
1597
+ if (i !== 0)
1598
+ throw new Error(on(i));
1599
+ const d = W(n, 0), g = W(o, 0);
1600
+ return [
1601
+ d,
1602
+ [0, f],
1603
+ g,
1604
+ u,
1605
+ h
1606
+ ];
1607
+ }
1608
+ let p = !0, w = 0;
1609
+ const m = new Array(l).fill(0);
1610
+ for (let d = 0; d < i; ++d) {
1611
+ const g = e[d * f];
1612
+ if (g < 0)
1613
+ throw new Error(rn(d, g));
1614
+ if (g >= l)
1615
+ throw new Error(an(d, g, l));
1616
+ ++m[g], p = p && g >= w, w = g;
1617
+ }
1618
+ let b = !0;
1619
+ for (let d = 0; d < l; ++d) {
1620
+ const g = m[d] === 0;
1621
+ u[d] = g, b = b && !g, m[d] = Math.max(m[d], 1), d > 0 && (m[d] += m[d - 1]);
1622
+ }
1623
+ if (b && p) {
1624
+ const d = e, g = s;
1625
+ for (let x = 0; x < i; ++x)
1626
+ h[x] = x;
1627
+ return [
1628
+ d,
1629
+ [i, f],
1630
+ g,
1631
+ u,
1632
+ h
1633
+ ];
1634
+ } else {
1635
+ const d = m[l - 1], g = W(n, d * f), x = W(o, d), k = new Array(l).fill(0);
1636
+ for (let y = 0; y < i; ++y) {
1637
+ const v = e[y * f], M = k[v], O = (v === 0 ? 0 : m[v - 1]) + M;
1638
+ k[v]++;
1639
+ for (let S = 0; S < f; ++S)
1640
+ g[O * f + S] = e[y * f + S];
1641
+ x[O] = s[y], h[y] = O;
1642
+ }
1643
+ for (let y = 0; y < l; ++y)
1644
+ if (k[y] === 0) {
1645
+ const M = y === 0 ? 0 : m[y - 1];
1646
+ g[M * f + 0] = y;
1647
+ for (let O = 1; O < f; ++O)
1648
+ g[M * f + O] = 0;
1649
+ x[M] = r;
1650
+ }
1651
+ return [
1652
+ g,
1653
+ [d, f],
1654
+ x,
1655
+ u,
1656
+ h
1657
+ ];
1658
+ }
1659
+ }
1660
+ function vs(e, t, n, s, o) {
1661
+ const a = V(s), r = t[0], i = o.length, l = [];
1662
+ let u = 1, h = -1;
1663
+ for (let d = 0; d < i; ++d) {
1664
+ const g = o[d];
1665
+ if (g === -1) {
1666
+ if (h !== -1)
1667
+ throw new Error(ln(h, d));
1668
+ h = d, l.push(1);
1669
+ } else {
1670
+ if (g < 0)
1671
+ throw new Error(cn(d, g));
1672
+ u *= g, l.push(g);
1673
+ }
1674
+ }
1675
+ if (h !== -1) {
1676
+ if (u <= 0)
1677
+ throw new Error(un());
1678
+ const d = Math.trunc(a / u);
1679
+ if (u * d !== a)
1680
+ throw new Error(hn(s, l));
1681
+ l[h] = d;
1682
+ }
1683
+ if (V(l) !== a)
1684
+ throw new Error(fn(s, l));
1685
+ const p = s.length, w = [];
1686
+ if (p > 0) {
1687
+ w[p - 1] = 1;
1688
+ for (let d = p - 2; d >= 0; --d)
1689
+ w[d] = w[d + 1] * s[d + 1];
1690
+ }
1691
+ const m = [];
1692
+ if (i > 0) {
1693
+ m[i - 1] = 1;
1694
+ for (let d = i - 2; d >= 0; --d)
1695
+ m[d] = m[d + 1] * l[d + 1];
1696
+ }
1697
+ const b = W(n, r * i);
1698
+ for (let d = 0; d < r; ++d) {
1699
+ let g = 0;
1700
+ for (let x = 0; x < p; ++x)
1701
+ g += e[d * p + x] * w[x];
1702
+ for (let x = 0; x < i; ++x)
1703
+ b[d * i + x] = Math.trunc(g / m[x]), g %= m[x];
1704
+ }
1705
+ return [b, [r, i], l];
1706
+ }
1707
+ function Ss(e, t, n, s, o, a = !1, r = 0) {
1708
+ const i = s.length, l = [t[0], e.length / t[0]], u = l[1], f = i > 0 ? o[i - 1] + 1 : 0;
1709
+ if (f < 0)
1710
+ throw new Error(kt());
1711
+ const p = t.slice();
1712
+ p[0] = f;
1713
+ const w = p.reduce((k, y) => k * y, 1), m = W(n, w);
1714
+ if (i === 0)
1715
+ return f > 0 && m.fill(r), [m, p];
1716
+ if (f <= 0)
1717
+ throw new Error(kt());
1718
+ let b = 0, d = 1, g = 0, x = o[b];
1719
+ for (; ; ) {
1720
+ let k = 0;
1721
+ if (d < i) {
1722
+ if (k = o[d], x === k) {
1723
+ ++d;
1724
+ continue;
1725
+ }
1726
+ if (x >= k)
1727
+ throw new Error(dn());
1728
+ }
1729
+ if (x < 0 || x >= f)
1730
+ throw new Error(gn(x, f));
1731
+ x > g && m.fill(r, g * u, x * u);
1732
+ for (let y = b; y < d; ++y) {
1733
+ const v = s[y];
1734
+ if (v < 0 || v >= l[0])
1735
+ throw new Error(mn(y, s[y], l[0]));
1736
+ for (let M = 0; M < u; M++)
1737
+ m[x * u + M] += e[v * u + M];
1738
+ }
1739
+ if (a)
1740
+ for (let y = 0; y < u; y++)
1741
+ m[x * u + y] /= d - b;
1742
+ if (b = d, ++d, g = x + 1, x = k, d > i)
1743
+ break;
1744
+ }
1745
+ return g < f && m.fill(r, g * u, f * u), [m, p];
1746
+ }
1747
+ const Ts = X((e) => Math.sqrt(e)), Rs = de(te, (e) => Math.sqrt(e)), To = {
1748
+ kernelName: te,
1749
+ backendName: "cpu",
1750
+ kernelFunc: Rs
1751
+ };
1752
+ const Ae = U(((e, t) => {
1753
+ const n = e - t;
1754
+ return n * n;
1755
+ })), Ms = z(ee, Ae), Ro = {
1756
+ kernelName: ee,
1757
+ backendName: "cpu",
1758
+ kernelFunc: Ms
1759
+ };
1760
+ const qe = X((e, t) => {
1761
+ const { pattern: n, replaceGlobal: s, rewrite: o } = t;
1762
+ return e.replace(new RegExp(n, s ? "g" : ""), o);
1763
+ }), Os = Q(ne, qe), Mo = {
1764
+ kernelName: ne,
1765
+ backendName: "cpu",
1766
+ kernelFunc: Os
1767
+ };
1768
+ function Ls(e, t, n, s) {
1769
+ const o = H(e, t.dtype);
1770
+ for (let a = 0; a < o.size; a++) {
1771
+ const r = o.indexToLoc(a), i = new Array(r.length);
1772
+ for (let l = 0; l < i.length; l++)
1773
+ i[l] = r[l] * n[l] + s[l];
1774
+ o.set(t.get(...i), ...r);
1775
+ }
1776
+ return o;
1777
+ }
1778
+ class Ps {
1779
+ constructor(t, n, s, o, a, r) {
1780
+ this.separator = pt(t), this.nGramWidths = n, this.leftPad = pt(s), this.rightPad = pt(o), this.padWidth = a, this.preserveShort = r;
1781
+ }
1782
+ getPadWidth(t) {
1783
+ return Math.min(this.padWidth < 0 ? t - 1 : this.padWidth, t - 1);
1784
+ }
1785
+ getNumNGrams(t, n) {
1786
+ const s = this.getPadWidth(n);
1787
+ return Math.max(0, t + 2 * s - n + 1);
1788
+ }
1789
+ createNGrams(t, n, s, o, a, r) {
1790
+ for (let i = 0; i < a; ++i) {
1791
+ const l = this.getPadWidth(r), u = Math.max(0, l - i), h = Math.max(0, l - (a - (i + 1))), f = r - (u + h), p = n + (u > 0 ? 0 : i - l);
1792
+ let w = 0;
1793
+ w += u * this.leftPad.length;
1794
+ for (let x = 0; x < f; ++x)
1795
+ w += t[p + x].length;
1796
+ w += h * this.rightPad.length;
1797
+ const m = u + h + f - 1;
1798
+ w += m * this.separator.length, s[o + i] = new Uint8Array(w);
1799
+ const b = s[o + i];
1800
+ let d = 0;
1801
+ const g = (x) => x.forEach((k) => b[d++] = k);
1802
+ for (let x = 0; x < u; ++x)
1803
+ g(this.leftPad), g(this.separator);
1804
+ for (let x = 0; x < f - 1; ++x)
1805
+ g(t[p + x]), g(this.separator);
1806
+ if (f > 0) {
1807
+ g(t[p + f - 1]);
1808
+ for (let x = 0; x < h; ++x)
1809
+ g(this.separator), g(this.rightPad);
1810
+ } else {
1811
+ for (let x = 0; x < h - 1; ++x)
1812
+ g(this.rightPad), g(this.separator);
1813
+ g(this.rightPad);
1814
+ }
1815
+ }
1816
+ }
1817
+ // Data and splits together form the definition of the ragged tensor,
1818
+ // where data is 1 dimensional and contains the values of the tensor
1819
+ // and splits denotes the indices at which each row starts.
1820
+ compute(t, n) {
1821
+ const s = t.length, o = n.length;
1822
+ if (o > 0) {
1823
+ let l = n[0];
1824
+ if (l !== 0)
1825
+ throw new Error(`First split value must be 0, got ${l}`);
1826
+ for (let u = 1; u < o; ++u) {
1827
+ let h = n[u] >= l;
1828
+ if (h = h && n[u] <= s, !h)
1829
+ throw new Error(`Invalid split value ${n[u]}, must be in [${l}, ${s}]`);
1830
+ l = n[u];
1831
+ }
1832
+ if (l !== s)
1833
+ throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`);
1834
+ }
1835
+ const a = o - 1, r = W("int32", o);
1836
+ if (s === 0 || o === 0) {
1837
+ const l = new Array(s);
1838
+ for (let u = 0; u <= a; ++u)
1839
+ r[u] = 0;
1840
+ return [l, r];
1841
+ }
1842
+ r[0] = 0;
1843
+ for (let l = 1; l <= a; ++l) {
1844
+ const u = n[l] - n[l - 1];
1845
+ let h = 0;
1846
+ this.nGramWidths.forEach((f) => {
1847
+ h += this.getNumNGrams(u, f);
1848
+ }), this.preserveShort && u > 0 && h === 0 && (h = 1), r[l] = r[l - 1] + h;
1849
+ }
1850
+ const i = new Array(r[a]);
1851
+ for (let l = 0; l < a; ++l) {
1852
+ const u = n[l];
1853
+ let h = r[l];
1854
+ if (this.nGramWidths.forEach((f) => {
1855
+ const p = n[l + 1] - n[l], w = this.getNumNGrams(p, f);
1856
+ this.createNGrams(t, u, i, h, w, f), h += w;
1857
+ }), this.preserveShort && h === r[l]) {
1858
+ const f = n[l + 1] - n[l];
1859
+ if (f === 0)
1860
+ continue;
1861
+ const p = f + 2 * this.padWidth;
1862
+ this.createNGrams(t, u, i, h, 1, p);
1863
+ }
1864
+ }
1865
+ return [i, r];
1866
+ }
1867
+ }
1868
+ function As(e, t, n, s, o, a, r, i) {
1869
+ return new Ps(n, s, o, a, r, i).compute(e, t);
1870
+ }
1871
+ function qs(e, t, n, s) {
1872
+ if (!e.length)
1873
+ return;
1874
+ if (t.length === 0) {
1875
+ for (let a = 0; a < e.length; ++a)
1876
+ s.push(e.subarray(a, a + 1));
1877
+ return;
1878
+ }
1879
+ if (t.length === 1) {
1880
+ const a = t[0];
1881
+ let r = e.indexOf(a);
1882
+ for (; r !== -1; ) {
1883
+ const i = e.subarray(0, r);
1884
+ (!n || i.length !== 0) && s.push(i), e = e.subarray(r + 1), r = e.indexOf(a);
1885
+ }
1886
+ (!n || e.length !== 0) && s.push(e);
1887
+ return;
1888
+ }
1889
+ let o = 0;
1890
+ for (let a = 0; a < e.length + 1; a++)
1891
+ if (a === e.length || t.indexOf(e[a]) !== -1) {
1892
+ const r = e.subarray(o, a);
1893
+ (!n || r.length !== 0) && s.push(r), o = a + 1;
1894
+ }
1895
+ }
1896
+ function _s(e, t, n) {
1897
+ const s = e.length, o = [];
1898
+ let a = 0, r = 0;
1899
+ const i = new Array(s);
1900
+ for (let p = 0; p < s; ++p) {
1901
+ const w = o.length;
1902
+ qs(e[p], t, n, o);
1903
+ const m = o.length - w;
1904
+ i[p] = m, a += m, r = Math.max(r, m);
1905
+ }
1906
+ const l = W("int32", a * 2), u = new Array(a), h = [s, r];
1907
+ let f = 0;
1908
+ for (let p = 0; p < s; ++p)
1909
+ for (let w = 0; w < i[p]; ++w)
1910
+ l[f * 2] = p, l[f * 2 + 1] = w, u[f] = o[f], ++f;
1911
+ return [l, u, h];
1912
+ }
1913
+ function Vs(e, t) {
1914
+ const n = W("int32", e.length);
1915
+ for (let s = 0; s < e.length; ++s)
1916
+ n[s] = An(e[s]).modulo(t).getLowBitsUnsigned();
1917
+ return n;
1918
+ }
1919
+ const _e = U(((e, t) => e - t)), Cs = bt(((e, t, n, s) => ({ real: e - n, imag: t - s }))), Ds = z(se, _e, Cs), Oo = {
1920
+ kernelName: se,
1921
+ backendName: "cpu",
1922
+ kernelFunc: Ds
1923
+ };
1924
+ function Ws(e, t) {
1925
+ const n = new Array(e.rank);
1926
+ for (let o = 0; o < n.length; o++)
1927
+ n[o] = e.shape[o] * t[o];
1928
+ const s = H(n, e.dtype);
1929
+ for (let o = 0; o < s.values.length; ++o) {
1930
+ const a = s.indexToLoc(o), r = new Array(e.rank);
1931
+ for (let l = 0; l < r.length; l++)
1932
+ r[l] = a[l] % e.shape[l];
1933
+ const i = e.locToIndex(r);
1934
+ s.values[o] = e.values[i];
1935
+ }
1936
+ return s;
1937
+ }
1938
+ const rt = (e, t) => {
1939
+ const n = t.value - e.value;
1940
+ return n === 0 ? e.index - t.index : n;
1941
+ };
1942
+ function Ve(e, t, n = 0, s = e.length - 1) {
1943
+ for (; s > n; ) {
1944
+ if (s - n > 600) {
1945
+ const i = s - n + 1, l = t - n + 1, u = Math.log(i), h = 0.5 * Math.exp(2 * u / 3), f = 0.5 * Math.sqrt(u * h * (i - h) / i) * Math.sign(l - i / 2), p = Math.max(n, Math.floor(t - l * h / i + f)), w = Math.min(s, Math.floor(t + (i - l) * h / i + f));
1946
+ Ve(e, t, p, w);
1947
+ }
1948
+ const o = e[t];
1949
+ let a = n, r = s;
1950
+ for (ot(e, n, t), rt(e[s], o) > 0 && ot(e, n, s); a < r; ) {
1951
+ for (ot(e, a, r), a++, r--; rt(e[a], o) < 0; )
1952
+ a = a + 1;
1953
+ for (; rt(e[r], o) > 0; )
1954
+ r = r - 1;
1955
+ }
1956
+ rt(e[n], o) === 0 ? ot(e, n, r) : (r = r + 1, ot(e, r, s)), r <= t && (n = r + 1), t <= r && (s = r - 1);
1957
+ }
1958
+ }
1959
+ function Us(e, t, n, s, o) {
1960
+ const a = t[t.length - 1], [r, i] = [e.length / a, a], l = et(n, r * s), u = et("int32", r * s);
1961
+ for (let f = 0; f < r; f++) {
1962
+ const p = f * i, w = e.subarray(p, p + i);
1963
+ let m = new Array(w.length);
1964
+ w.forEach((x, k) => m[k] = { value: x, index: k }), s < m.length && (Ve(m, s), m = m.slice(0, s)), o && m.sort(rt);
1965
+ const b = f * s, d = l.subarray(b, b + s), g = u.subarray(b, b + s);
1966
+ for (let x = 0; x < s; x++)
1967
+ d[x] = m[x].value, g[x] = m[x].index;
1968
+ }
1969
+ const h = t.slice();
1970
+ return h[h.length - 1] = s, [
1971
+ H(h, n, l),
1972
+ H(h, "int32", u)
1973
+ ];
1974
+ }
1975
+ function $s(e, t, n, s) {
1976
+ const o = At(t, n)[0], a = [1, n[0], 1];
1977
+ for (let m = 0; m < o; m++)
1978
+ a[0] *= n[m];
1979
+ a[1] = n[o];
1980
+ for (let m = o + 1; m < n.length; m++)
1981
+ a[2] *= n[m];
1982
+ const r = /* @__PURE__ */ new Map(), i = new Int32Array(n[o]), l = new It(a, s, e), u = [], h = a[0] === 1 && a[2] === 1;
1983
+ for (let m = 0; m < n[o]; m++) {
1984
+ let b;
1985
+ if (h)
1986
+ b = e[m].toString();
1987
+ else {
1988
+ const g = [];
1989
+ for (let x = 0; x < a[0]; x++)
1990
+ for (let k = 0; k < a[2]; k++)
1991
+ g.push(l.get(x, m, k));
1992
+ b = g.join(",");
1993
+ }
1994
+ const d = r.get(b);
1995
+ if (d != null)
1996
+ i[m] = d;
1997
+ else {
1998
+ const g = r.size;
1999
+ r.set(b, g), i[m] = g, u.push(m);
2000
+ }
2001
+ }
2002
+ const f = a.slice();
2003
+ f[1] = r.size;
2004
+ const p = new It(f, s);
2005
+ u.forEach((m, b) => {
2006
+ for (let d = 0; d < a[0]; d++)
2007
+ for (let g = 0; g < a[2]; g++)
2008
+ p.set(l.get(d, m, g), d, b, g);
2009
+ });
2010
+ const w = n.slice();
2011
+ return w[o] = f[1], {
2012
+ outputValues: p.values,
2013
+ outputShape: w,
2014
+ indices: i
2015
+ };
2016
+ }
2017
+ const Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2018
+ __proto__: null,
2019
+ addImpl: he,
2020
+ bincountImpl: Cn,
2021
+ bincountReduceImpl: Dn,
2022
+ bitwiseAndImpl: fe,
2023
+ castImpl: ue,
2024
+ ceilImpl: ge,
2025
+ concatImpl: $n,
2026
+ equalImpl: me,
2027
+ expImpl: pe,
2028
+ expm1Impl: we,
2029
+ floorDivImpl: xe,
2030
+ floorImpl: Ie,
2031
+ gatherNdImpl: Hn,
2032
+ gatherV2Impl: Kn,
2033
+ greaterEqualImpl: Fe,
2034
+ greaterImpl: Ee,
2035
+ lessEqualImpl: ye,
2036
+ lessImpl: be,
2037
+ linSpaceImpl: ts,
2038
+ logImpl: ke,
2039
+ maxImpl: ns,
2040
+ maximumImpl: Ne,
2041
+ minimumImpl: ve,
2042
+ multiplyImpl: yt,
2043
+ negImpl: Se,
2044
+ notEqualImpl: Te,
2045
+ prodImpl: Oe,
2046
+ raggedGatherImpl: ps,
2047
+ raggedRangeImpl: ws,
2048
+ raggedTensorToTensorImpl: Is,
2049
+ rangeImpl: xs,
2050
+ rsqrtImpl: Le,
2051
+ scatterImpl: Fs,
2052
+ sigmoidImpl: bs,
2053
+ simpleAbsImpl: le,
2054
+ sliceImpl: Pe,
2055
+ sparseFillEmptyRowsImpl: Ns,
2056
+ sparseReshapeImpl: vs,
2057
+ sparseSegmentReductionImpl: Ss,
2058
+ sqrtImpl: Ts,
2059
+ squaredDifferenceImpl: Ae,
2060
+ staticRegexReplaceImpl: qe,
2061
+ stridedSliceImpl: Ls,
2062
+ stringNGramsImpl: As,
2063
+ stringSplitImpl: _s,
2064
+ stringToHashBucketFastImpl: Vs,
2065
+ subImpl: _e,
2066
+ tileImpl: Ws,
2067
+ topKImpl: Us,
2068
+ transposeImpl: Re,
2069
+ uniqueImpl: $s
2070
+ }, Symbol.toStringTag, { value: "Module" }));
2071
+ export {
2072
+ go as $,
2073
+ ws as A,
2074
+ Is as B,
2075
+ xs as C,
2076
+ Fs as D,
2077
+ Ns as E,
2078
+ vs as F,
2079
+ Ss as G,
2080
+ Ls as H,
2081
+ As as I,
2082
+ _s as J,
2083
+ Vs as K,
2084
+ Ws as L,
2085
+ Us as M,
2086
+ $s as N,
2087
+ zn as O,
2088
+ Ys as P,
2089
+ oo as Q,
2090
+ ro as R,
2091
+ so as S,
2092
+ ao as T,
2093
+ to as U,
2094
+ io as V,
2095
+ lo as W,
2096
+ co as X,
2097
+ uo as Y,
2098
+ ho as Z,
2099
+ fo as _,
2100
+ nt as a,
2101
+ eo as a0,
2102
+ mo as a1,
2103
+ po as a2,
2104
+ wo as a3,
2105
+ Io as a4,
2106
+ xo as a5,
2107
+ Eo as a6,
2108
+ Fo as a7,
2109
+ bo as a8,
2110
+ ko as a9,
2111
+ no as aa,
2112
+ No as ab,
2113
+ vo as ac,
2114
+ So as ad,
2115
+ To as ae,
2116
+ Ro as af,
2117
+ Mo as ag,
2118
+ Oo as ah,
2119
+ yo as ai,
2120
+ ys as b,
2121
+ U as c,
2122
+ Vn as d,
2123
+ z as e,
2124
+ ks as f,
2125
+ Cn as g,
2126
+ mt as h,
2127
+ Ft as i,
2128
+ $n as j,
2129
+ Dn as k,
2130
+ lt as l,
2131
+ as as m,
2132
+ Ds as n,
2133
+ Hn as o,
2134
+ Kn as p,
2135
+ ts as q,
2136
+ ce as r,
2137
+ Lo as s,
2138
+ Me as t,
2139
+ de as u,
2140
+ Re as v,
2141
+ ns as w,
2142
+ Bn as x,
2143
+ ps as y,
2144
+ Et as z
2145
+ };