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