@genai-fi/nanogpt 0.9.1 → 0.10.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +55 -48
  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,192 @@
1
+ var t;
2
+ (function(e) {
3
+ e[e.ADD = 0] = "ADD", e[e.ATAN2 = 1] = "ATAN2", e[e.COMPLEX_MULTIPLY_IMAG = 2] = "COMPLEX_MULTIPLY_IMAG", e[e.COMPLEX_MULTIPLY_REAL = 3] = "COMPLEX_MULTIPLY_REAL", e[e.DIV = 4] = "DIV", e[e.ELU_DER = 5] = "ELU_DER", e[e.EQUAL = 6] = "EQUAL", e[e.FLOOR_DIV = 7] = "FLOOR_DIV", e[e.GREATER = 8] = "GREATER", e[e.GREATER_EQUAL = 9] = "GREATER_EQUAL", e[e.LESS = 10] = "LESS", e[e.LESS_EQUAL = 11] = "LESS_EQUAL", e[e.LOGICAL_AND = 12] = "LOGICAL_AND", e[e.LOGICAL_OR = 13] = "LOGICAL_OR", e[e.MAX = 14] = "MAX", e[e.MIN = 15] = "MIN", e[e.MOD = 16] = "MOD", e[e.MUL = 17] = "MUL", e[e.NOT_EQUAL = 18] = "NOT_EQUAL", e[e.POW = 19] = "POW", e[e.PRELU = 20] = "PRELU", e[e.SQUARED_DIFFERENCE = 21] = "SQUARED_DIFFERENCE", e[e.SUB = 22] = "SUB";
4
+ })(t || (t = {}));
5
+ const r = "let resultTemp = a + b;", L = "let resultTemp = atan2(a, b);", E = "let resultTemp = areal * breal - aimag * bimag;", c = "let resultTemp = areal * bimag + aimag * breal;", u = "let resultTemp = a / b;", n = "let resultTemp = select(a * (b + 1.0), a, b >= b - b);", A = `
6
+ let zero = sign(a) * 0 + 0;
7
+ let one = sign(b) * 0 + 1;
8
+ let resultTemp = select(zero, one, a == b);
9
+ `, N = `
10
+ let remainder =
11
+ select(a % b, round(a % b), (round(a) == a) & (round(b) == b));
12
+ let quotient = (a - remainder) / b;
13
+ let resultTemp =
14
+ round(select(quotient, quotient - 1, sign(remainder) == -sign(b)));
15
+ `, _ = `
16
+ let zero = sign(a) * 0 + 0;
17
+ let one = sign(b) * 0 + 1;
18
+ let resultTemp = select(zero, one, a > b);
19
+ `, m = `
20
+ let zero = sign(a) * 0 + 0;
21
+ let one = sign(b) * 0 + 1;
22
+ let resultTemp = select(zero, one, a >= b);
23
+ `, R = `
24
+ let zero = sign(a) * 0 + 0;
25
+ let one = sign(b) * 0 + 1;
26
+ let resultTemp = select(zero, one, a < b);
27
+ `, U = `
28
+ let zero = sign(a) * 0 + 0;
29
+ let one = sign(b) * 0 + 1;
30
+ let resultTemp = select(zero, one, a <= b);
31
+ `, I = "return f32(a >= 1.0 && b >= 1.0);", f = `return (vec4<f32>(a >= vec4<f32>(1.0)) *
32
+ vec4<f32>(b >= vec4<f32>(1.0)));`, M = "return f32(a >= 1.0 || b >= 1.0);", i = `return min(vec4<f32>(a >= vec4<f32>(1.0)) +
33
+ vec4<f32>(b >= vec4<f32>(1.0)), vec4<f32>(1.0));`, D = "let resultTemp = max(a, b);", v = "let resultTemp = min(a, b);", P = `
34
+ let isNaN = b == 0.;
35
+ var resultTemp = a % b;
36
+ resultTemp = select((resultTemp + b) % b, resultTemp,
37
+ (a < 0. && b < 0.) || (a >= 0. && b > 0.));
38
+ `, g = `
39
+ let isNaN = !vec4<bool>(b);
40
+ var resultTemp = vec4<f32>(a % b);
41
+ if (!((a[0] < 0. && b[0] < 0.) || (a[0] >= 0. && b[0] > 0.))) {
42
+ resultTemp[0] = (resultTemp[0] + b[0]) % b[0];
43
+ }
44
+ if (!((a[1] < 0. && b[1] < 0.) || (a[1] >= 0. && b[1] > 0.))) {
45
+ resultTemp[1] = (resultTemp[1] + b[1]) % b[1];
46
+ }
47
+ if (!((a[2] < 0. && b[2] < 0.) || (a[2] >= 0. && b[2] > 0.))) {
48
+ resultTemp[2] = (resultTemp[2] + b[2]) % b[2];
49
+ }
50
+ if (!((a[3] < 0. && b[3] < 0.) || (a[3] >= 0. && b[3] > 0.))) {
51
+ resultTemp[3] = (resultTemp[3] + b[3]) % b[3];
52
+ }
53
+ `, C = "let resultTemp = a * b;", S = `
54
+ var resultTemp = f32(a != b);
55
+ let valueForNaN = 1.0;
56
+ `, d = `
57
+ var resultTemp = vec4<f32>(a != b);
58
+ let valueForNaN = 1.0;
59
+ `, T = `
60
+ let isNaN = a < 0.0 && floor(b) < b;
61
+ if (b == 0.0) {
62
+ return 1.0;
63
+ }
64
+ var resultTemp = select(sign(a) * pow(abs(a), b), pow(abs(a), b),
65
+ round(abs(b) % 2.0) != 1.0);
66
+ `, G = `
67
+ let isModRound1Bool = vec4<i32>(round(abs(b) % vec4<f32>(2.0))) == vec4<i32>(1);
68
+ let isModRound1 = vec4<f32>(isModRound1Bool);
69
+ let multiplier = sign(a) * isModRound1 + (vec4<f32>(1.0) - isModRound1);
70
+ var resultTemp = multiplier * pow(abs(a), b);
71
+
72
+ // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS
73
+ let isExpZero = b == vec4<f32>(0.0);
74
+ if (isExpZero.r) {
75
+ resultTemp.r = 1.0;
76
+ }
77
+ if (isExpZero.g) {
78
+ resultTemp.g = 1.0;
79
+ }
80
+ if (isExpZero.b) {
81
+ resultTemp.b = 1.0;
82
+ }
83
+ if (isExpZero.a) {
84
+ resultTemp.a = 1.0;
85
+ }
86
+ let isNaN = (a < vec4<f32>(0.0)) & (floor(b) < b);
87
+ `, Q = "if (a < 0.0) { return b * a; } return a;", k = `
88
+ let aLessThanZero = vec4<f32>(a < vec4<f32>(0.0));
89
+ return (aLessThanZero * (b * a)) + ((vec4<f32>(1.0) - aLessThanZero) * a);
90
+ `, F = "let resultTemp = (a - b) * (a - b);", z = "let resultTemp = a - b;";
91
+ function X(e, a) {
92
+ let s;
93
+ do {
94
+ switch (e) {
95
+ case t.ATAN2:
96
+ s = L;
97
+ break;
98
+ case t.MAX:
99
+ s = D;
100
+ break;
101
+ case t.MIN:
102
+ s = v;
103
+ break;
104
+ case t.MOD:
105
+ s = a ? g : P;
106
+ break;
107
+ case t.NOT_EQUAL:
108
+ s = a ? d : S;
109
+ break;
110
+ case t.POW:
111
+ s = a ? G : T;
112
+ break;
113
+ default:
114
+ continue;
115
+ }
116
+ let o, l, b;
117
+ return a ? (o = "isnanVec4", l = "vec4<f32>", b = "vec4<bool>") : (o = "isnan", l = "f32", b = "bool"), `
118
+ let aIsNaN = ${o}(a);
119
+ let aPostLegalization = select(a, ${l}(42), aIsNaN);
120
+ let bIsNaN = ${o}(b);
121
+ let bPostLegalization = select(b, ${l}(42), bIsNaN);
122
+ let isNaN = false;
123
+ let valueForNaN = uniforms.NAN;
124
+ {
125
+ let a = aPostLegalization;
126
+ let b = bPostLegalization;
127
+ ${s}
128
+ return select(
129
+ resultTemp, ${l}(valueForNaN),
130
+ ${b}(isNaN) | aIsNaN | bIsNaN);
131
+ }
132
+ `;
133
+ } while (!1);
134
+ switch (e) {
135
+ case t.ADD:
136
+ s = r;
137
+ break;
138
+ case t.COMPLEX_MULTIPLY_IMAG:
139
+ s = c;
140
+ break;
141
+ case t.COMPLEX_MULTIPLY_REAL:
142
+ s = E;
143
+ break;
144
+ case t.DIV:
145
+ s = u;
146
+ break;
147
+ case t.ELU_DER:
148
+ s = n;
149
+ break;
150
+ case t.EQUAL:
151
+ s = A;
152
+ break;
153
+ case t.FLOOR_DIV:
154
+ s = N;
155
+ break;
156
+ case t.GREATER:
157
+ s = _;
158
+ break;
159
+ case t.GREATER_EQUAL:
160
+ s = m;
161
+ break;
162
+ case t.LESS:
163
+ s = R;
164
+ break;
165
+ case t.LESS_EQUAL:
166
+ s = U;
167
+ break;
168
+ case t.LOGICAL_AND:
169
+ return a ? f : I;
170
+ case t.LOGICAL_OR:
171
+ return a ? i : M;
172
+ case t.MUL:
173
+ s = C;
174
+ break;
175
+ case t.PRELU:
176
+ return a ? k : Q;
177
+ case t.SQUARED_DIFFERENCE:
178
+ s = F;
179
+ break;
180
+ case t.SUB:
181
+ s = z;
182
+ break;
183
+ }
184
+ return `
185
+ ${s}
186
+ return resultTemp;
187
+ `;
188
+ }
189
+ export {
190
+ t as B,
191
+ X as g
192
+ };
@@ -0,0 +1,30 @@
1
+ import { A as f, B as h, D as p, E as m } from "./index-ZyQhjEPo.js";
2
+ import { T as g } from "./tensor_util-DV-FP5Q3.js";
3
+ import { d as u } from "./tensor-DdQUJZlz.js";
4
+ import { r as T } from "./reshape-DevtBWtf.js";
5
+ function b(e, o) {
6
+ let r = h(e, "broadcastTo", "x");
7
+ const a = r.shape;
8
+ if (u(o), o.length < r.rank)
9
+ throw new Error(`broadcastTo(): shape.length=${o.length} < input.rank=${r.rank}.`);
10
+ if (o.length > r.rank) {
11
+ const t = r.shape.slice();
12
+ for (; t.length < o.length; )
13
+ t.unshift(1);
14
+ r = T(r, t);
15
+ }
16
+ const s = r.shape, n = Array.from(o);
17
+ for (let t = o.length - 1; t >= 0; t--)
18
+ if (s[t] === o[t])
19
+ n[t] = 1;
20
+ else if (r.shape[t] !== 1)
21
+ throw new Error(`broadcastTo(): [${a}] cannot be broadcast to [${o}].`);
22
+ if (n.map((t, l) => t > 1 ? l : -1).filter((t) => t >= 0).length === 0)
23
+ return p(r);
24
+ const i = { x: r }, c = { reps: n };
25
+ return m.runKernel(g, i, c);
26
+ }
27
+ const N = /* @__PURE__ */ f({ broadcastTo_: b });
28
+ export {
29
+ N as b
30
+ };
@@ -1,5 +1,5 @@
1
- import { s, e as a } from "../index-BzFyqcy-.js";
2
- import { t } from "../tensor4d-Df1WlVDY.js";
1
+ import { s, e as a } from "../index-ZyQhjEPo.js";
2
+ import { t } from "../tensor4d-B8roDgtc.js";
3
3
  async function u(e) {
4
4
  await s(e);
5
5
  const n = t(
@@ -1,6 +1,6 @@
1
- import { s as i, e } from "../index-BzFyqcy-.js";
2
- import { t } from "../tensor4d-Df1WlVDY.js";
3
- import { t as a } from "../tensor2d-D76QGjF3.js";
1
+ import { s as i, e } from "../index-ZyQhjEPo.js";
2
+ import { t } from "../tensor4d-B8roDgtc.js";
3
+ import { t as a } from "../tensor2d-G4Ys2GxX.js";
4
4
  async function k(n) {
5
5
  await i(n);
6
6
  const s = t(
@@ -5,5 +5,5 @@ interface Result {
5
5
  passed: boolean;
6
6
  maxError?: number;
7
7
  }
8
- export default function runCheck(check: (backend: string) => Promise<unknown>, epsilon?: number): Promise<Result[]>;
8
+ export default function runCheck(check: (backend: string) => Promise<unknown>, epsilon?: number, backends?: string[]): Promise<Result[]>;
9
9
  export {};
@@ -1,20 +1,20 @@
1
- import { arraysClose as l } from "../utilities/arrayClose.js";
2
- async function f(c, a) {
3
- const n = ["cpu", "webgl", "webgpu"], t = [];
4
- for (const e of n)
1
+ import { arraysClose as p } from "../utilities/arrayClose.js";
2
+ async function d(c, o, n) {
3
+ const u = n ?? ["cpu", "webgl", "webgpu"], t = [];
4
+ for (const e of u)
5
5
  try {
6
6
  const r = await c(e);
7
7
  t.push({ backend: e, result: r, passed: !0 });
8
8
  } catch (r) {
9
9
  t.push({ backend: e, error: r.message, result: [], passed: !1 });
10
10
  }
11
- const s = await Promise.all(t), u = s[0].result;
11
+ const s = await Promise.all(t), l = s[0].result;
12
12
  for (let e = 1; e < s.length; e++) {
13
- const r = s[e].result, o = l(u, r);
14
- s[e].passed = o <= (a ?? 1e-6), s[e].maxError = o;
13
+ const r = s[e].result, a = p(l, r);
14
+ s[e].passed = a <= (o ?? 1e-6), s[e].maxError = a;
15
15
  }
16
16
  return s;
17
17
  }
18
18
  export {
19
- f as default
19
+ d as default
20
20
  };
@@ -1,5 +1,5 @@
1
- import { s as e, e as o } from "../index-BzFyqcy-.js";
2
- import { t as s } from "../tensor2d-D76QGjF3.js";
1
+ import { s as e, e as o } from "../index-ZyQhjEPo.js";
2
+ import { t as s } from "../tensor2d-G4Ys2GxX.js";
3
3
  async function m(t) {
4
4
  await e(t);
5
5
  const r = s(
@@ -6,6 +6,7 @@ import { execute as normRMSGrad } from './normRMSGrad';
6
6
  import { execute as appendCache } from './appendCache';
7
7
  import { execute as attentionMask } from './attentionMask';
8
8
  import { execute as matMulGelu } from './matMulGelu';
9
+ import { execute as packUnpack } from './packUnpack';
9
10
  import { default as runCheck } from './check';
10
11
  import { createWeightStatistics, createTensorStatistics } from './weights';
11
12
  declare const checks: {
@@ -17,6 +18,7 @@ declare const checks: {
17
18
  appendCache: typeof appendCache;
18
19
  attentionMask: typeof attentionMask;
19
20
  matMulGelu: typeof matMulGelu;
21
+ packUnpack: typeof packUnpack;
20
22
  runCheck: typeof runCheck;
21
23
  createLayerWeightStatistics: typeof createWeightStatistics;
22
24
  createWeightStatistics: typeof createTensorStatistics;
@@ -6,9 +6,10 @@ import { execute as o } from "./normRMSGrad.js";
6
6
  import { execute as a } from "./appendCache.js";
7
7
  import { execute as m } from "./attentionMask.js";
8
8
  import { execute as i } from "./matMulGelu.js";
9
+ import { execute as u } from "./packUnpack.js";
9
10
  import s from "./check.js";
10
- import { createTensorStatistics as u, createWeightStatistics as x } from "./weights.js";
11
- const d = {
11
+ import { createTensorStatistics as x, createWeightStatistics as p } from "./weights.js";
12
+ const C = {
12
13
  rope: e,
13
14
  qkv: r,
14
15
  gelu: c,
@@ -17,10 +18,11 @@ const d = {
17
18
  appendCache: a,
18
19
  attentionMask: m,
19
20
  matMulGelu: i,
21
+ packUnpack: u,
20
22
  runCheck: s,
21
- createLayerWeightStatistics: x,
22
- createWeightStatistics: u
23
+ createLayerWeightStatistics: p,
24
+ createWeightStatistics: x
23
25
  };
24
26
  export {
25
- d as default
27
+ C as default
26
28
  };
@@ -1,9 +1,9 @@
1
- import { s as n, e as s } from "../index-BzFyqcy-.js";
2
- import "../random_width-CXVRloNK.js";
3
- import "../register_all_kernels-DIGpEwcf.js";
4
- import "../index-Tf7vU29b.js";
5
- import "../dataset-DlZtKmBq.js";
6
- import { t as e } from "../tensor2d-D76QGjF3.js";
1
+ import { s as n, e as s } from "../index-ZyQhjEPo.js";
2
+ import "../random_width-DY6Kk2Dl.js";
3
+ import "../register_all_kernels-Bwu1PTuU.js";
4
+ import "../index-Cp39cXWe.js";
5
+ import "../dataset-0xP8GjwI.js";
6
+ import { t as e } from "../tensor2d-G4Ys2GxX.js";
7
7
  async function f(t) {
8
8
  await n(t);
9
9
  const r = e(
@@ -1,13 +1,13 @@
1
- import { s as u, y as A, e as y } from "../index-BzFyqcy-.js";
2
- import { a as h } from "../ops-LuCMAnmM.js";
3
- import { t as p } from "../tensor1d-vML0r3q6.js";
4
- import { t as a } from "../tensor-CZr4dh61.js";
1
+ import { s as i, u as A, e as y } from "../index-ZyQhjEPo.js";
2
+ import { a as h } from "../ops-CNI3TwqM.js";
3
+ import { t as p } from "../tensor1d-CeZuc-Rv.js";
4
+ import { t as a } from "../tensor-f35l8Odg.js";
5
5
  const w = Array.from({ length: 2048 * 192 }, () => Math.random()), x = Array.from({ length: 192 }, () => Math.random()), M = Array.from({ length: 2048 * 192 }, () => Math.random());
6
6
  async function k(t) {
7
- await u(t);
7
+ await i(t);
8
8
  const o = p(x, "float32"), n = a(w, [16, 128, 192], "float32"), s = a(M, [16, 128, 192], "float32"), e = (d, g) => {
9
- const i = y().runKernel("RMSNorm", { x: d, gamma: g });
10
- return h.meanSquaredError(i, s);
9
+ const u = y().runKernel("RMSNorm", { x: d, gamma: g });
10
+ return h.meanSquaredError(u, s);
11
11
  }, { value: m, grads: r } = A(e)([n, o]), c = await m.array(), f = await r[0].array(), l = await r[1].array();
12
12
  return [c, f, l];
13
13
  }
@@ -1,6 +1,6 @@
1
- import { s as c, e as d } from "../index-BzFyqcy-.js";
2
- import { t as f } from "../tensor1d-vML0r3q6.js";
3
- import { t as r } from "../tensor-CZr4dh61.js";
1
+ import { s as c, e as d } from "../index-ZyQhjEPo.js";
2
+ import { t as f } from "../tensor1d-CeZuc-Rv.js";
3
+ import { t as r } from "../tensor-f35l8Odg.js";
4
4
  const y = Array.from({ length: 2048 * 192 }, () => Math.random()), i = Array.from({ length: 192 }, () => Math.random()), l = Array.from({ length: 2048 * 192 }, () => Math.random());
5
5
  async function x(t) {
6
6
  await c(t);
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,18 @@
1
+ import { s as a, e } from "../index-ZyQhjEPo.js";
2
+ import { t as c } from "../tensor2d-G4Ys2GxX.js";
3
+ async function i(n) {
4
+ await a(n);
5
+ const r = c(
6
+ [
7
+ [0.1, 0.2, 0, 0, 1230, 1232331234, -12234234],
8
+ [0.1, 0.2, 0, 0, -1230, -1232331234, 12234234],
9
+ [0, 0, 0, 0, -1, 0, 0],
10
+ [0, 0, 0, 0, -0.1, 1e-3, 0]
11
+ ],
12
+ [4, 7]
13
+ ), t = e().runKernel("Pack16", { x: r });
14
+ return await e().runKernel("Unpack16", { x: t }).array();
15
+ }
16
+ export {
17
+ i as execute
18
+ };
@@ -1,34 +1,19 @@
1
- import { B as i, C as u, D as c, s as l, e as h } from "../index-BzFyqcy-.js";
2
- import { t as f } from "../tensor2d-D76QGjF3.js";
3
- /**
4
- * @license
5
- * Copyright 2018 Google LLC. All Rights Reserved.
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- * =============================================================================
18
- */
19
- function m(t, e, n) {
20
- if (i(t), e != null && e.length !== 3)
1
+ import { x as i, y as u, s as c, e as l } from "../index-ZyQhjEPo.js";
2
+ import { c as m } from "../tensor-DdQUJZlz.js";
3
+ import { t as f } from "../tensor2d-G4Ys2GxX.js";
4
+ function h(t, e, n) {
5
+ if (m(t), e != null && e.length !== 3)
21
6
  throw new Error("tensor3d() requires shape to have three numbers");
22
- const r = u(t, n);
7
+ const r = i(t, n);
23
8
  if (r.length !== 3 && r.length !== 1)
24
9
  throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray");
25
10
  if (r.length === 1 && e == null)
26
11
  throw new Error("tensor3d() requires shape to be provided when `values` are a flat array");
27
- return c(t, e, r, n);
12
+ return u(t, e, r, n);
28
13
  }
29
- async function y(t) {
30
- await l(t);
31
- const e = m(
14
+ async function p(t) {
15
+ await c(t);
16
+ const e = h(
32
17
  [
33
18
  [
34
19
  [0.1, 0.2],
@@ -42,9 +27,9 @@ async function y(t) {
42
27
  [0.7, 0.8, 1.1, 1.2, 1.5, 1.6]
43
28
  ],
44
29
  [2, 6]
45
- ), r = h().runKernel("QKV", { x: e, kernel: n }, { heads: 1 }), o = await r[0].array(), a = await r[1].array(), s = await r[2].array();
30
+ ), r = l().runKernel("QKV", { x: e, kernel: n }, { heads: 1 }), o = await r[0].array(), a = await r[1].array(), s = await r[2].array();
46
31
  return [o, a, s];
47
32
  }
48
33
  export {
49
- y as execute
34
+ p as execute
50
35
  };
@@ -1,6 +1,6 @@
1
1
  import t from "../layers/RoPECache.js";
2
- import { s as c, e as i } from "../index-BzFyqcy-.js";
3
- import { t as p } from "../tensor4d-Df1WlVDY.js";
2
+ import { s as c, e as i } from "../index-ZyQhjEPo.js";
3
+ import { t as p } from "../tensor4d-B8roDgtc.js";
4
4
  async function y(a) {
5
5
  await c(a);
6
6
  const o = p(
@@ -1,29 +1,31 @@
1
- async function d(s) {
1
+ async function b(s) {
2
+ if (!Array.isArray(s) && s.dtype !== "float32")
3
+ throw new Error(`Unsupported dtype ${s.dtype} for weight statistics.`);
2
4
  const e = Array.isArray(s) ? s : await s.data(), a = e.length;
3
- let n = 0, l = 0, i = e[0], r = e[0], u = 0, h = !0, f = !1, m = 0;
5
+ let r = 0, l = 0, n = e[0], i = e[0], f = 0, d = !0, u = !1, y = 0;
4
6
  for (let c = 0; c < a; c++) {
5
7
  const t = e[c];
6
- n += t, l += t * t, t < i && (i = t), t > r && (r = t), t === 0 && u++, Math.abs(t) < 1e-8 && m++, Number.isNaN(t) && (f = !0);
8
+ r += t, l += t * t, t < n && (n = t), t > i && (i = t), t === 0 && f++, Math.abs(t) < 1e-8 && y++, Number.isNaN(t) && (u = !0);
7
9
  }
8
- const o = n / a, y = l / a - o * o, N = Math.sqrt(y), b = u / a;
10
+ const o = r / a, m = l / a - o * o, p = Math.sqrt(m), N = f / a;
9
11
  return {
10
12
  mean: o,
11
- std: N,
12
- min: i,
13
- max: r,
14
- sparsity: b,
15
- isFinite: h,
16
- hasNaN: f,
17
- closeToZeroCount: m
13
+ std: p,
14
+ min: n,
15
+ max: i,
16
+ sparsity: N,
17
+ isFinite: d,
18
+ hasNaN: u,
19
+ closeToZeroCount: y
18
20
  };
19
21
  }
20
- async function S(s) {
22
+ async function h(s) {
21
23
  const e = s.trainableVariables, a = {};
22
- for (const n of e)
23
- a[n.name] = await d(n);
24
+ for (const r of e)
25
+ a[r.name] = await b(r);
24
26
  return a;
25
27
  }
26
28
  export {
27
- d as createTensorStatistics,
28
- S as createWeightStatistics
29
+ b as createTensorStatistics,
30
+ h as createWeightStatistics
29
31
  };
@@ -0,0 +1,13 @@
1
+ import { A as r, B as o, E as t } from "./index-ZyQhjEPo.js";
2
+ import { h as c } from "./tensor_util-DV-FP5Q3.js";
3
+ import { j as n } from "./tensor-DdQUJZlz.js";
4
+ function l(s, m) {
5
+ const a = o(s, "real", "complex"), e = o(m, "imag", "complex");
6
+ n(a.shape, e.shape, `real and imag shapes, ${a.shape} and ${e.shape}, must match in call to tf.complex().`);
7
+ const p = { real: a, imag: e };
8
+ return t.runKernel(c, p);
9
+ }
10
+ const f = /* @__PURE__ */ r({ complex_: l });
11
+ export {
12
+ f as c
13
+ };
@@ -0,0 +1,55 @@
1
+ function s(t, a) {
2
+ if (t.length !== a.length)
3
+ throw new Error(`Cannot merge real and imag arrays of different lengths. real:${t.length}, imag: ${a.length}.`);
4
+ const r = new Float32Array(t.length * 2);
5
+ for (let n = 0; n < r.length; n += 2)
6
+ r[n] = t[n / 2], r[n + 1] = a[n / 2];
7
+ return r;
8
+ }
9
+ function l(t) {
10
+ const a = new Float32Array(t.length / 2), r = new Float32Array(t.length / 2);
11
+ for (let n = 0; n < t.length; n += 2)
12
+ a[n / 2] = t[n], r[n / 2] = t[n + 1];
13
+ return { real: a, imag: r };
14
+ }
15
+ function h(t) {
16
+ const a = Math.ceil(t.length / 4), r = new Float32Array(a), n = new Float32Array(a);
17
+ for (let e = 0; e < t.length; e += 4)
18
+ r[Math.floor(e / 4)] = t[e], n[Math.floor(e / 4)] = t[e + 1];
19
+ return { real: r, imag: n };
20
+ }
21
+ function i(t) {
22
+ const a = Math.floor(t.length / 4), r = new Float32Array(a), n = new Float32Array(a);
23
+ for (let e = 2; e < t.length; e += 4)
24
+ r[Math.floor(e / 4)] = t[e], n[Math.floor(e / 4)] = t[e + 1];
25
+ return { real: r, imag: n };
26
+ }
27
+ function g(t, a) {
28
+ const r = t[a * 2], n = t[a * 2 + 1];
29
+ return { real: r, imag: n };
30
+ }
31
+ function f(t, a, r, n) {
32
+ t[n * 2] = a, t[n * 2 + 1] = r;
33
+ }
34
+ function c(t, a) {
35
+ const r = new Float32Array(t / 2), n = new Float32Array(t / 2);
36
+ for (let e = 0; e < Math.ceil(t / 2); e++) {
37
+ const o = (a ? 2 : -2) * Math.PI * (e / t);
38
+ r[e] = Math.cos(o), n[e] = Math.sin(o);
39
+ }
40
+ return { real: r, imag: n };
41
+ }
42
+ function u(t, a, r) {
43
+ const n = (r ? 2 : -2) * Math.PI * (t / a), e = Math.cos(n), o = Math.sin(n);
44
+ return { real: e, imag: o };
45
+ }
46
+ export {
47
+ f as a,
48
+ i as b,
49
+ h as c,
50
+ c as d,
51
+ u as e,
52
+ g,
53
+ s as m,
54
+ l as s
55
+ };
@@ -0,0 +1,19 @@
1
+ import { A as c, C as s, D as p, E as i } from "./index-ZyQhjEPo.js";
2
+ import { C as m } from "./tensor_util-DV-FP5Q3.js";
3
+ import { a as f } from "./tensor-DdQUJZlz.js";
4
+ function l(o, r = 0) {
5
+ f(o.length >= 1, () => "Pass at least one tensor to concat");
6
+ const t = s(o, "tensors", "concat", "string_or_numeric");
7
+ if (t[0].dtype === "complex64" && t.forEach((n) => {
8
+ if (n.dtype !== "complex64")
9
+ throw new Error(`Cannot concatenate complex64 tensors with a tensor
10
+ with dtype ${n.dtype}. `);
11
+ }), t.length === 1)
12
+ return p(t[0]);
13
+ const e = t, a = { axis: r };
14
+ return i.runKernel(m, e, a);
15
+ }
16
+ const E = /* @__PURE__ */ c({ concat_: l });
17
+ export {
18
+ E as c
19
+ };
@@ -0,0 +1,22 @@
1
+ import { a as s } from "./tensor-DdQUJZlz.js";
2
+ function h(n, o) {
3
+ const t = n[0].length;
4
+ n.forEach((a, c) => {
5
+ s(a.length === t, () => `Error in concat${t}D: rank of tensors[${c}] must be the same as the rank of the rest (${t})`);
6
+ }), s(o >= 0 && o < t, () => `Error in concat${t}D: axis must be between 0 and ${t - 1}.`);
7
+ const e = n[0];
8
+ n.forEach((a, c) => {
9
+ for (let r = 0; r < t; r++)
10
+ s(r === o || a[r] === e[r], () => `Error in concat${t}D: Shape of tensors[${c}] (${a}) does not match the shape of the rest (${e}) along the non-concatenated axis ${c}.`);
11
+ });
12
+ }
13
+ function $(n, o) {
14
+ const t = n[0].slice();
15
+ for (let e = 1; e < n.length; e++)
16
+ t[o] += n[e][o];
17
+ return t;
18
+ }
19
+ export {
20
+ h as a,
21
+ $ as c
22
+ };
package/dist/data/docx.js CHANGED
@@ -1,4 +1,4 @@
1
- import { j as a } from "../jszip.min-CjP2V1VV.js";
1
+ import { j as a } from "../jszip.min-Bz5-11Bk.js";
2
2
  async function c(n) {
3
3
  const t = await (await a.loadAsync(n)).file("word/document.xml")?.async("string");
4
4
  if (!t) throw new Error("Failed to load document.xml");
@@ -1,7 +1,7 @@
1
- import { B as n } from "../index-Tf7vU29b.js";
1
+ import { B as n } from "../index-Cp39cXWe.js";
2
2
  const p = 100 * 1024 * 1024;
3
3
  async function d(i, s = p, e = "text") {
4
- const r = await (await import("../parquet-C0Tlmv9c.js").then((t) => t.p)).ParquetReader.openBuffer(n.from(await i.arrayBuffer())), a = [], f = r.getCursor([[e]]);
4
+ const r = await (await import("../parquet-BE8MU_ge.js").then((t) => t.p)).ParquetReader.openBuffer(n.from(await i.arrayBuffer())), a = [], f = r.getCursor([[e]]);
5
5
  let o = 0;
6
6
  for (; ; ) {
7
7
  const t = await f.next();