@genai-fi/nanogpt 0.20.0 → 0.20.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 (433) hide show
  1. package/dist/BaseTokeniser-DSg9zcYq.js +221 -0
  2. package/dist/DatasetBuilder-DgURD85T.js +712 -0
  3. package/dist/Generator.d.ts +82 -0
  4. package/dist/Generator.js +2 -0
  5. package/dist/RealDiv-DBu0FQqT.js +362 -0
  6. package/dist/Reshape-CABOPB9d.js +94 -0
  7. package/dist/Reshape-DqO3r8BC.js +17 -0
  8. package/dist/TeachableLLM.d.ts +70 -0
  9. package/dist/TeachableLLM.js +2 -0
  10. package/dist/Trainer.d.ts +43 -0
  11. package/dist/Trainer.js +2 -0
  12. package/dist/backend.d.ts +2 -0
  13. package/dist/backend.js +13 -0
  14. package/dist/backend_util-Cg-roD1p.js +399 -0
  15. package/dist/binary_op_util-CrYk9LXL.js +103 -0
  16. package/dist/checks/appendCache.d.ts +1 -0
  17. package/dist/checks/appendCache.js +55 -0
  18. package/dist/checks/attentionMask.d.ts +1 -0
  19. package/dist/checks/attentionMask.js +56 -0
  20. package/dist/checks/check.d.ts +9 -0
  21. package/dist/checks/check.js +32 -0
  22. package/dist/checks/gelu.d.ts +1 -0
  23. package/dist/checks/gelu.js +46 -0
  24. package/dist/checks/index.d.ts +26 -0
  25. package/dist/checks/index.js +28 -0
  26. package/dist/checks/matMulGelu.d.ts +1 -0
  27. package/dist/checks/matMulGelu.js +84 -0
  28. package/dist/checks/normRMS.d.ts +1 -0
  29. package/dist/checks/normRMS.js +28 -0
  30. package/dist/checks/normRMSGrad.d.ts +1 -0
  31. package/dist/checks/normRMSGrad.js +22 -0
  32. package/dist/checks/packUnpack.d.ts +1 -0
  33. package/dist/checks/packUnpack.js +46 -0
  34. package/dist/checks/qkv.d.ts +1 -0
  35. package/dist/checks/qkv.js +34 -0
  36. package/dist/checks/rope.d.ts +1 -0
  37. package/dist/checks/rope.js +30 -0
  38. package/dist/checks/weights.d.ts +14 -0
  39. package/dist/checks/weights.js +27 -0
  40. package/dist/chunk-BPntVaq0.js +23 -0
  41. package/dist/complex_util-CkazZsaH.js +60 -0
  42. package/dist/concat_util-CWDZCBlA.js +19 -0
  43. package/dist/data/docx.d.ts +2 -0
  44. package/dist/data/docx.js +3046 -0
  45. package/dist/data/pdf.d.ts +2 -0
  46. package/dist/data/pdf.js +17 -0
  47. package/dist/data/textLoader.d.ts +7 -0
  48. package/dist/data/textLoader.js +613 -0
  49. package/dist/dist-BewPQWjc.js +7572 -0
  50. package/dist/dist-DVmq73nz.js +8775 -0
  51. package/dist/dist-DXwIvKxl.js +896 -0
  52. package/dist/dist-VEU5mfO0.js +7545 -0
  53. package/dist/gelu-Bf1HW1RY.js +27 -0
  54. package/dist/gpgpu_math-DvLcCH6u.js +1612 -0
  55. package/dist/inference/types.d.ts +16 -0
  56. package/dist/inference/types.js +0 -0
  57. package/dist/kernel_funcs_utils-HiXOOx3f.js +229 -0
  58. package/dist/layers/BaseLayer.d.ts +44 -0
  59. package/dist/layers/BaseLayer.js +76 -0
  60. package/dist/layers/CausalSelfAttention.d.ts +39 -0
  61. package/dist/layers/CausalSelfAttention.js +99 -0
  62. package/dist/layers/LoRA.d.ts +14 -0
  63. package/dist/layers/LoRA.js +48 -0
  64. package/dist/layers/MLP.d.ts +17 -0
  65. package/dist/layers/MLP.js +34 -0
  66. package/dist/layers/PositionEmbedding.d.ts +8 -0
  67. package/dist/layers/PositionEmbedding.js +27 -0
  68. package/dist/layers/RMSNorm.d.ts +12 -0
  69. package/dist/layers/RMSNorm.js +20 -0
  70. package/dist/layers/RoPECache.d.ts +18 -0
  71. package/dist/layers/RoPECache.js +337 -0
  72. package/dist/layers/TiedEmbedding.d.ts +13 -0
  73. package/dist/layers/TiedEmbedding.js +32 -0
  74. package/dist/layers/TransformerBlock.d.ts +27 -0
  75. package/dist/layers/TransformerBlock.js +51 -0
  76. package/dist/layers/WeightStore.d.ts +20 -0
  77. package/dist/layers/WeightStore.js +69 -0
  78. package/dist/loader/load.d.ts +6 -0
  79. package/dist/loader/load.js +2 -0
  80. package/dist/loader/loadHF.d.ts +8 -0
  81. package/dist/loader/loadHF.js +2 -0
  82. package/dist/loader/loadTransformers.d.ts +4 -0
  83. package/dist/loader/loadTransformers.js +2 -0
  84. package/dist/loader/loadZipMeta.d.ts +3 -0
  85. package/dist/loader/loadZipMeta.js +16 -0
  86. package/dist/loader/newZipLoad.d.ts +3 -0
  87. package/dist/loader/newZipLoad.js +2 -0
  88. package/dist/loader/oldZipLoad.d.ts +9 -0
  89. package/dist/loader/oldZipLoad.js +2 -0
  90. package/dist/loader/save.d.ts +16 -0
  91. package/dist/loader/save.js +2 -0
  92. package/dist/loader/types.d.ts +68 -0
  93. package/dist/loader/types.js +0 -0
  94. package/dist/main-CPjeMv0G.js +13500 -0
  95. package/dist/main.d.ts +50 -0
  96. package/dist/main.js +16 -0
  97. package/dist/matMul16-BNfZSnNM.js +81 -0
  98. package/dist/matMulGelu-CPTntosE.js +162 -0
  99. package/dist/models/NanoGPTV1.d.ts +16 -0
  100. package/dist/models/NanoGPTV1.js +2 -0
  101. package/dist/models/NanoGPTV2.d.ts +16 -0
  102. package/dist/models/NanoGPTV2.js +2 -0
  103. package/dist/models/config.d.ts +27 -0
  104. package/dist/models/config.js +37 -0
  105. package/dist/models/factory.d.ts +3 -0
  106. package/dist/models/factory.js +2 -0
  107. package/dist/models/model.d.ts +44 -0
  108. package/dist/models/model.js +2 -0
  109. package/dist/ops/adamAdjust.d.ts +2 -0
  110. package/dist/ops/adamAdjust.js +18 -0
  111. package/dist/ops/adamMoments.d.ts +2 -0
  112. package/dist/ops/adamMoments.js +16 -0
  113. package/dist/ops/add16.d.ts +2 -0
  114. package/dist/ops/add16.js +12 -0
  115. package/dist/ops/appendCache.d.ts +2 -0
  116. package/dist/ops/appendCache.js +25 -0
  117. package/dist/ops/attentionMask.d.ts +2 -0
  118. package/dist/ops/attentionMask.js +16 -0
  119. package/dist/ops/concat16.d.ts +2 -0
  120. package/dist/ops/concat16.js +8 -0
  121. package/dist/ops/cpu/adamAdjust.d.ts +1 -0
  122. package/dist/ops/cpu/adamAdjust.js +16 -0
  123. package/dist/ops/cpu/adamMoments.d.ts +1 -0
  124. package/dist/ops/cpu/adamMoments.js +16 -0
  125. package/dist/ops/cpu/appendCache.d.ts +1 -0
  126. package/dist/ops/cpu/appendCache.js +65 -0
  127. package/dist/ops/cpu/attentionMask.d.ts +1 -0
  128. package/dist/ops/cpu/attentionMask.js +16 -0
  129. package/dist/ops/cpu/fusedSoftmax.d.ts +9 -0
  130. package/dist/ops/cpu/fusedSoftmax.js +22 -0
  131. package/dist/ops/cpu/gatherSub.d.ts +1 -0
  132. package/dist/ops/cpu/gatherSub.js +12 -0
  133. package/dist/ops/cpu/gelu.d.ts +1 -0
  134. package/dist/ops/cpu/gelu.js +36 -0
  135. package/dist/ops/cpu/matMul16.d.ts +1 -0
  136. package/dist/ops/cpu/matMul16.js +14 -0
  137. package/dist/ops/cpu/matMulGelu.d.ts +1 -0
  138. package/dist/ops/cpu/matMulGelu.js +41 -0
  139. package/dist/ops/cpu/matMulMul.d.ts +1 -0
  140. package/dist/ops/cpu/matMulMul.js +20 -0
  141. package/dist/ops/cpu/mulDropout.d.ts +1 -0
  142. package/dist/ops/cpu/mulDropout.js +20 -0
  143. package/dist/ops/cpu/normRMS.d.ts +1 -0
  144. package/dist/ops/cpu/normRMS.js +35 -0
  145. package/dist/ops/cpu/qkv.d.ts +5 -0
  146. package/dist/ops/cpu/qkv.js +73 -0
  147. package/dist/ops/cpu/rope.d.ts +6 -0
  148. package/dist/ops/cpu/rope.js +81 -0
  149. package/dist/ops/cpu/scatterSub.d.ts +1 -0
  150. package/dist/ops/cpu/scatterSub.js +12 -0
  151. package/dist/ops/dot16.d.ts +2 -0
  152. package/dist/ops/dot16.js +29 -0
  153. package/dist/ops/dropout.d.ts +2 -0
  154. package/dist/ops/dropout.js +11 -0
  155. package/dist/ops/dropout16.d.ts +2 -0
  156. package/dist/ops/dropout16.js +22 -0
  157. package/dist/ops/gatherSub.d.ts +2 -0
  158. package/dist/ops/gatherSub.js +13 -0
  159. package/dist/ops/gelu.d.ts +3 -0
  160. package/dist/ops/gelu.js +2 -0
  161. package/dist/ops/globalNorm.d.ts +2 -0
  162. package/dist/ops/globalNorm.js +19 -0
  163. package/dist/ops/grads/add16.d.ts +1 -0
  164. package/dist/ops/grads/add16.js +27 -0
  165. package/dist/ops/grads/attentionMask.d.ts +1 -0
  166. package/dist/ops/grads/attentionMask.js +26 -0
  167. package/dist/ops/grads/dropout16.d.ts +1 -0
  168. package/dist/ops/grads/dropout16.js +1 -0
  169. package/dist/ops/grads/gelu.d.ts +2 -0
  170. package/dist/ops/grads/gelu.js +2 -0
  171. package/dist/ops/grads/matMul16.d.ts +2 -0
  172. package/dist/ops/grads/matMul16.js +2 -0
  173. package/dist/ops/grads/matMulGelu.d.ts +1 -0
  174. package/dist/ops/grads/matMulGelu.js +22 -0
  175. package/dist/ops/grads/mul16.d.ts +1 -0
  176. package/dist/ops/grads/mul16.js +1 -0
  177. package/dist/ops/grads/normRMS.d.ts +3 -0
  178. package/dist/ops/grads/normRMS.js +37 -0
  179. package/dist/ops/grads/pack16.d.ts +2 -0
  180. package/dist/ops/grads/pack16.js +2 -0
  181. package/dist/ops/grads/qkv.d.ts +3 -0
  182. package/dist/ops/grads/qkv.js +46 -0
  183. package/dist/ops/grads/rope.d.ts +2 -0
  184. package/dist/ops/grads/rope.js +2 -0
  185. package/dist/ops/grads/softmax16.d.ts +2 -0
  186. package/dist/ops/grads/softmax16.js +23 -0
  187. package/dist/ops/grads/unpack16.d.ts +2 -0
  188. package/dist/ops/grads/unpack16.js +2 -0
  189. package/dist/ops/grads/utils.d.ts +4 -0
  190. package/dist/ops/grads/utils.js +12 -0
  191. package/dist/ops/log.d.ts +0 -0
  192. package/dist/ops/log.js +1 -0
  193. package/dist/ops/matMul16.d.ts +15 -0
  194. package/dist/ops/matMul16.js +2 -0
  195. package/dist/ops/matMulGelu.d.ts +3 -0
  196. package/dist/ops/matMulGelu.js +20 -0
  197. package/dist/ops/matMulMul.d.ts +2 -0
  198. package/dist/ops/matMulMul.js +16 -0
  199. package/dist/ops/mul16.d.ts +2 -0
  200. package/dist/ops/mul16.js +43 -0
  201. package/dist/ops/mulDrop.d.ts +2 -0
  202. package/dist/ops/mulDrop.js +15 -0
  203. package/dist/ops/normRMS.d.ts +2 -0
  204. package/dist/ops/normRMS.js +22 -0
  205. package/dist/ops/pack16.d.ts +2 -0
  206. package/dist/ops/pack16.js +2 -0
  207. package/dist/ops/qkv.d.ts +2 -0
  208. package/dist/ops/qkv.js +16 -0
  209. package/dist/ops/reshape16.d.ts +2 -0
  210. package/dist/ops/reshape16.js +33 -0
  211. package/dist/ops/rope.d.ts +3 -0
  212. package/dist/ops/rope.js +2 -0
  213. package/dist/ops/scatterSub.d.ts +2 -0
  214. package/dist/ops/scatterSub.js +13 -0
  215. package/dist/ops/slice16.d.ts +2 -0
  216. package/dist/ops/slice16.js +11 -0
  217. package/dist/ops/softmax16.d.ts +2 -0
  218. package/dist/ops/softmax16.js +9 -0
  219. package/dist/ops/sub16.d.ts +2 -0
  220. package/dist/ops/sub16.js +11 -0
  221. package/dist/ops/sum16.d.ts +2 -0
  222. package/dist/ops/sum16.js +13 -0
  223. package/dist/ops/transpose16.d.ts +3 -0
  224. package/dist/ops/transpose16.js +32 -0
  225. package/dist/ops/unpack16.d.ts +2 -0
  226. package/dist/ops/unpack16.js +2 -0
  227. package/dist/ops/webgl/adamAdjust.d.ts +1 -0
  228. package/dist/ops/webgl/adamAdjust.js +82 -0
  229. package/dist/ops/webgl/adamMoments.d.ts +1 -0
  230. package/dist/ops/webgl/adamMoments.js +44 -0
  231. package/dist/ops/webgl/appendCache.d.ts +1 -0
  232. package/dist/ops/webgl/appendCache.js +53 -0
  233. package/dist/ops/webgl/attentionMask.d.ts +1 -0
  234. package/dist/ops/webgl/attentionMask.js +64 -0
  235. package/dist/ops/webgl/dropout16.d.ts +1 -0
  236. package/dist/ops/webgl/dropout16.js +12 -0
  237. package/dist/ops/webgl/fusedSoftmax.d.ts +11 -0
  238. package/dist/ops/webgl/fusedSoftmax.js +70 -0
  239. package/dist/ops/webgl/gatherSub.d.ts +1 -0
  240. package/dist/ops/webgl/gatherSub.js +28 -0
  241. package/dist/ops/webgl/gelu.d.ts +2 -0
  242. package/dist/ops/webgl/gelu.js +48 -0
  243. package/dist/ops/webgl/log.d.ts +17 -0
  244. package/dist/ops/webgl/log.js +14 -0
  245. package/dist/ops/webgl/matMul16.d.ts +1 -0
  246. package/dist/ops/webgl/matMul16.js +37 -0
  247. package/dist/ops/webgl/matMulGelu.d.ts +21 -0
  248. package/dist/ops/webgl/matMulGelu.js +2 -0
  249. package/dist/ops/webgl/matMulMul.d.ts +14 -0
  250. package/dist/ops/webgl/matMulMul.js +24 -0
  251. package/dist/ops/webgl/mulDropout.d.ts +1 -0
  252. package/dist/ops/webgl/mulDropout.js +32 -0
  253. package/dist/ops/webgl/normRMS.d.ts +1 -0
  254. package/dist/ops/webgl/normRMS.js +114 -0
  255. package/dist/ops/webgl/qkv.d.ts +1 -0
  256. package/dist/ops/webgl/qkv.js +54 -0
  257. package/dist/ops/webgl/rope.d.ts +1 -0
  258. package/dist/ops/webgl/rope.js +72 -0
  259. package/dist/ops/webgl/scatterSub.d.ts +1 -0
  260. package/dist/ops/webgl/scatterSub.js +28 -0
  261. package/dist/ops/webgpu/adamAdjust.d.ts +1 -0
  262. package/dist/ops/webgpu/adamAdjust.js +77 -0
  263. package/dist/ops/webgpu/adamMoments.d.ts +1 -0
  264. package/dist/ops/webgpu/adamMoments.js +76 -0
  265. package/dist/ops/webgpu/add16.d.ts +1 -0
  266. package/dist/ops/webgpu/add16.js +14 -0
  267. package/dist/ops/webgpu/appendCache.d.ts +1 -0
  268. package/dist/ops/webgpu/appendCache.js +130 -0
  269. package/dist/ops/webgpu/attentionMask.d.ts +1 -0
  270. package/dist/ops/webgpu/attentionMask.js +42 -0
  271. package/dist/ops/webgpu/attentionMask32_program.d.ts +19 -0
  272. package/dist/ops/webgpu/attentionMask32_program.js +62 -0
  273. package/dist/ops/webgpu/clipScale.d.ts +1 -0
  274. package/dist/ops/webgpu/clipScale.js +45 -0
  275. package/dist/ops/webgpu/concat16.d.ts +19 -0
  276. package/dist/ops/webgpu/concat16.js +111 -0
  277. package/dist/ops/webgpu/dropout16.d.ts +1 -0
  278. package/dist/ops/webgpu/dropout16.js +59 -0
  279. package/dist/ops/webgpu/gatherSub.d.ts +1 -0
  280. package/dist/ops/webgpu/gatherSub.js +52 -0
  281. package/dist/ops/webgpu/gelu.d.ts +14 -0
  282. package/dist/ops/webgpu/gelu.js +147 -0
  283. package/dist/ops/webgpu/index.d.ts +0 -0
  284. package/dist/ops/webgpu/index.js +26 -0
  285. package/dist/ops/webgpu/matMul16.d.ts +1 -0
  286. package/dist/ops/webgpu/matMul16.js +70 -0
  287. package/dist/ops/webgpu/matMul16_program.d.ts +42 -0
  288. package/dist/ops/webgpu/matMul16_program.js +303 -0
  289. package/dist/ops/webgpu/mul16.d.ts +1 -0
  290. package/dist/ops/webgpu/mul16.js +14 -0
  291. package/dist/ops/webgpu/norm2.d.ts +1 -0
  292. package/dist/ops/webgpu/norm2.js +46 -0
  293. package/dist/ops/webgpu/normRMS.d.ts +1 -0
  294. package/dist/ops/webgpu/normRMS.js +26 -0
  295. package/dist/ops/webgpu/normRMS16_program.d.ts +10 -0
  296. package/dist/ops/webgpu/normRMS16_program.js +28 -0
  297. package/dist/ops/webgpu/normRMS32_program.d.ts +10 -0
  298. package/dist/ops/webgpu/normRMS32_program.js +28 -0
  299. package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
  300. package/dist/ops/webgpu/normRMSGrad.js +225 -0
  301. package/dist/ops/webgpu/pack16.d.ts +1 -0
  302. package/dist/ops/webgpu/pack16.js +21 -0
  303. package/dist/ops/webgpu/pack16_program.d.ts +19 -0
  304. package/dist/ops/webgpu/pack16_program.js +93 -0
  305. package/dist/ops/webgpu/qkv.d.ts +1 -0
  306. package/dist/ops/webgpu/qkv.js +64 -0
  307. package/dist/ops/webgpu/rope.d.ts +1 -0
  308. package/dist/ops/webgpu/rope.js +163 -0
  309. package/dist/ops/webgpu/scatterSub.d.ts +1 -0
  310. package/dist/ops/webgpu/scatterSub.js +53 -0
  311. package/dist/ops/webgpu/slice16.d.ts +7 -0
  312. package/dist/ops/webgpu/slice16.js +74 -0
  313. package/dist/ops/webgpu/softmax16.d.ts +17 -0
  314. package/dist/ops/webgpu/softmax16.js +18 -0
  315. package/dist/ops/webgpu/softmax16_program.d.ts +13 -0
  316. package/dist/ops/webgpu/softmax16_program.js +89 -0
  317. package/dist/ops/webgpu/softmax16_subgroup_program.d.ts +17 -0
  318. package/dist/ops/webgpu/softmax16_subgroup_program.js +70 -0
  319. package/dist/ops/webgpu/softmax16grad.d.ts +1 -0
  320. package/dist/ops/webgpu/softmax16grad.js +31 -0
  321. package/dist/ops/webgpu/sub16.d.ts +1 -0
  322. package/dist/ops/webgpu/sub16.js +14 -0
  323. package/dist/ops/webgpu/sum16.d.ts +1 -0
  324. package/dist/ops/webgpu/sum16.js +29 -0
  325. package/dist/ops/webgpu/transpose16.d.ts +1 -0
  326. package/dist/ops/webgpu/transpose16.js +37 -0
  327. package/dist/ops/webgpu/transpose16_program.d.ts +16 -0
  328. package/dist/ops/webgpu/transpose16_program.js +51 -0
  329. package/dist/ops/webgpu/transpose16_shared_program.d.ts +15 -0
  330. package/dist/ops/webgpu/transpose16_shared_program.js +79 -0
  331. package/dist/ops/webgpu/unpack16.d.ts +1 -0
  332. package/dist/ops/webgpu/unpack16.js +60 -0
  333. package/dist/ops/webgpu/utils/binary_op.d.ts +35 -0
  334. package/dist/ops/webgpu/utils/binary_op.js +141 -0
  335. package/dist/ops/webgpu/utils/deviceInfo.d.ts +7 -0
  336. package/dist/ops/webgpu/utils/deviceInfo.js +11 -0
  337. package/dist/ops/webgpu/utils/reductions.d.ts +43 -0
  338. package/dist/ops/webgpu/utils/reductions.js +263 -0
  339. package/dist/pack16-Ck-spx_F.js +39 -0
  340. package/dist/patches/webgpu_backend.d.ts +18 -0
  341. package/dist/patches/webgpu_backend.js +43 -0
  342. package/dist/patches/webgpu_base.d.ts +21 -0
  343. package/dist/patches/webgpu_base.js +22 -0
  344. package/dist/patches/webgpu_program.d.ts +36 -0
  345. package/dist/patches/webgpu_program.js +293 -0
  346. package/dist/pdf-UoDqCYzz.js +16726 -0
  347. package/dist/picomatch-3tUnMMbd.js +1063 -0
  348. package/dist/rope-CbeGlsV8.js +25 -0
  349. package/dist/selu_util-zkAx5doH.js +24 -0
  350. package/dist/shared-D1coEFea.js +1314 -0
  351. package/dist/shared-DOgWaqvL.js +5 -0
  352. package/dist/slice_util-Dgb3ANWI.js +208 -0
  353. package/dist/tfjs_backend-BjuQ5FqB.js +614 -0
  354. package/dist/tokeniser/BaseTokeniser.d.ts +33 -0
  355. package/dist/tokeniser/BaseTokeniser.js +2 -0
  356. package/dist/tokeniser/CharTokeniser.d.ts +24 -0
  357. package/dist/tokeniser/CharTokeniser.js +92 -0
  358. package/dist/tokeniser/bpe.d.ts +28 -0
  359. package/dist/tokeniser/bpe.js +170 -0
  360. package/dist/tokeniser/messages.d.ts +61 -0
  361. package/dist/tokeniser/messages.js +0 -0
  362. package/dist/tokeniser/type.d.ts +34 -0
  363. package/dist/tokeniser/type.js +0 -0
  364. package/dist/training/AdamW.d.ts +36 -0
  365. package/dist/training/AdamW.js +128 -0
  366. package/dist/training/BasicTrainer.d.ts +63 -0
  367. package/dist/training/BasicTrainer.js +265 -0
  368. package/dist/training/DatasetBuilder.d.ts +26 -0
  369. package/dist/training/DatasetBuilder.js +2 -0
  370. package/dist/training/Evaluator.d.ts +19 -0
  371. package/dist/training/Evaluator.js +48 -0
  372. package/dist/training/LRScheduler.d.ts +12 -0
  373. package/dist/training/LRScheduler.js +38 -0
  374. package/dist/training/PreTrainer.d.ts +11 -0
  375. package/dist/training/PreTrainer.js +22 -0
  376. package/dist/training/SFTTrainer.d.ts +12 -0
  377. package/dist/training/SFTTrainer.js +24 -0
  378. package/dist/training/loss.d.ts +3 -0
  379. package/dist/training/loss.js +19 -0
  380. package/dist/training/orthoGrad.d.ts +2 -0
  381. package/dist/training/orthoGrad.js +10 -0
  382. package/dist/training/sparseCrossEntropy.d.ts +7 -0
  383. package/dist/training/sparseCrossEntropy.js +47 -0
  384. package/dist/training/tasks/ConversationTask.d.ts +18 -0
  385. package/dist/training/tasks/ConversationTask.js +38 -0
  386. package/dist/training/tasks/PretrainingTask.d.ts +17 -0
  387. package/dist/training/tasks/PretrainingTask.js +42 -0
  388. package/dist/training/tasks/StartSentenceTask.d.ts +18 -0
  389. package/dist/training/tasks/StartSentenceTask.js +45 -0
  390. package/dist/training/tasks/Task.d.ts +22 -0
  391. package/dist/training/tasks/Task.js +55 -0
  392. package/dist/training/tasks/splitter.d.ts +5 -0
  393. package/dist/training/tasks/splitter.js +18 -0
  394. package/dist/training/types.d.ts +78 -0
  395. package/dist/training/types.js +0 -0
  396. package/dist/training/validation.d.ts +17 -0
  397. package/dist/training/validation.js +2 -0
  398. package/dist/utilities/arrayClose.d.ts +1 -0
  399. package/dist/utilities/arrayClose.js +16 -0
  400. package/dist/utilities/datasetID.d.ts +2 -0
  401. package/dist/utilities/datasetID.js +18 -0
  402. package/dist/utilities/dummy.d.ts +9 -0
  403. package/dist/utilities/dummy.js +36 -0
  404. package/dist/utilities/multinomialCPU.d.ts +2 -0
  405. package/dist/utilities/multinomialCPU.js +9 -0
  406. package/dist/utilities/naming.d.ts +4 -0
  407. package/dist/utilities/naming.js +0 -0
  408. package/dist/utilities/packed.d.ts +4 -0
  409. package/dist/utilities/packed.js +13 -0
  410. package/dist/utilities/parameters.d.ts +11 -0
  411. package/dist/utilities/parameters.js +38 -0
  412. package/dist/utilities/performance.d.ts +2 -0
  413. package/dist/utilities/performance.js +16 -0
  414. package/dist/utilities/profile.d.ts +17 -0
  415. package/dist/utilities/profile.js +33 -0
  416. package/dist/utilities/safetensors.d.ts +3 -0
  417. package/dist/utilities/safetensors.js +53 -0
  418. package/dist/utilities/sentences.d.ts +5 -0
  419. package/dist/utilities/sentences.js +32 -0
  420. package/dist/utilities/tokenParse.d.ts +1 -0
  421. package/dist/utilities/tokenParse.js +17 -0
  422. package/dist/utilities/topP.d.ts +1 -0
  423. package/dist/utilities/topP.js +12 -0
  424. package/dist/utilities/waitForModel.d.ts +2 -0
  425. package/dist/utilities/waitForModel.js +12 -0
  426. package/dist/utilities/weights.d.ts +12 -0
  427. package/dist/utilities/weights.js +40 -0
  428. package/dist/utilities/yielder.d.ts +1 -0
  429. package/dist/utilities/yielder.js +7 -0
  430. package/dist/webgpu-Dt7BMzWz.js +525 -0
  431. package/dist/webgpu_program-WOyIVMlZ.js +392 -0
  432. package/dist/webgpu_util-B_F3SShA.js +106 -0
  433. package/package.json +1 -1
@@ -0,0 +1,13 @@
1
+ import { ai as e, ci as t, ui as n } from "./dist-BewPQWjc.js";
2
+ //#region lib/backend.ts
3
+ async function r(r, i) {
4
+ if (e() !== r) {
5
+ if (r === "webgpu") {
6
+ let { registerWebGPUBackend: e } = await import("./patches/webgpu_base.js");
7
+ e(i), await import("./dist-DVmq73nz.js"), await import("./ops/webgpu/index.js");
8
+ }
9
+ await n(r), await t(), console.log(`Backend set to ${r}`);
10
+ }
11
+ }
12
+ //#endregion
13
+ export { r as selectBackend };
@@ -0,0 +1,399 @@
1
+ import { r as e } from "./chunk-BPntVaq0.js";
2
+ import { Ar as t, Ci as n, Cn as r, Cr as i, Dn as a, Dr as o, En as s, Er as c, In as l, Li as u, Ln as d, M as ee, N as te, Oi as ne, On as re, Or as ie, Ps as f, Ri as ae, Rn as oe, Rs as se, Sn as ce, Sr as le, Tn as ue, Tr as de, ec as p, j as fe, jr as pe, ki as me, kr as he, oc as m, wn as ge, wr as _e, xn as ve, xr as ye } from "./dist-BewPQWjc.js";
3
+ import { a as be, i as xe, n as Se, o as Ce, r as we, t as Te } from "./selu_util-zkAx5doH.js";
4
+ import { s as Ee } from "./slice_util-Dgb3ANWI.js";
5
+ import { n as De, t as Oe } from "./concat_util-CWDZCBlA.js";
6
+ import { a as ke, c as Ae, i as je, n as Me, o as Ne, r as Pe, s as Fe, t as Ie } from "./complex_util-CkazZsaH.js";
7
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/gather_nd_util.js
8
+ function h(e, t) {
9
+ let n = e.shape.length, r = t.shape.length;
10
+ if (n < 1) throw Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`);
11
+ if (r < 1) throw Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`);
12
+ if (t.dtype !== "int32") throw Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`);
13
+ if (t.shape[r - 1] > n) throw Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r - 1]} vs. ${n}`);
14
+ if (m(e.shape) === 0) throw Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`);
15
+ let i = t.shape, a = i[i.length - 1], o = 1;
16
+ for (let e = 0; e < i.length - 1; ++e) o *= i[e];
17
+ let s = e.shape, c = i.slice();
18
+ c.pop();
19
+ let l = 1;
20
+ for (let e = a; e < n; ++e) l *= s[e], c.push(s[e]);
21
+ let u = [...se(e.shape).map((e) => e / l), 1].slice(0, a);
22
+ return [
23
+ c,
24
+ o,
25
+ l,
26
+ u
27
+ ];
28
+ }
29
+ //#endregion
30
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/ragged_to_dense_util.js
31
+ var g;
32
+ (function(e) {
33
+ e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS";
34
+ })(g ||= {});
35
+ function _(e, t, n) {
36
+ let r = [];
37
+ if (n == null && t == null) return r;
38
+ if (t == null) for (; r.length < e + n.length;) r.push(-1);
39
+ else r = t.slice();
40
+ if (n == null) return r;
41
+ if (e + n.length !== r.length) throw Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e + n.length}, but shape.rank = ${r.length}`);
42
+ for (let i = 1; i < n.length; ++i) {
43
+ let a = n[i], o = r[r.length - n.length + i], s = r[o];
44
+ if (a >= 0) if (s >= 0) {
45
+ if (s !== a) throw Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${i + e}] = ${a} but shape[${i + e}] = ${s}`);
46
+ } else r[o] = a;
47
+ }
48
+ return r;
49
+ }
50
+ function v(e) {
51
+ let t = {
52
+ FIRST_DIM_SIZE: g.FIRST_DIM_SIZE,
53
+ VALUE_ROWIDS: g.VALUE_ROWIDS,
54
+ ROW_LENGTHS: g.ROW_LENGTHS,
55
+ ROW_SPLITS: g.ROW_SPLITS,
56
+ ROW_LIMITS: g.ROW_LIMITS,
57
+ ROW_STARTS: g.ROW_STARTS
58
+ }, n = [];
59
+ for (let r of e) if (r in t) n.push(t[r]);
60
+ else break;
61
+ return n;
62
+ }
63
+ function y(e) {
64
+ return e.length === 0 ? 0 : e[0] === g.FIRST_DIM_SIZE ? e.length - 1 : e.length;
65
+ }
66
+ function b(e, t) {
67
+ if (e == null || t == null) return;
68
+ let n = e.length, r = t.length;
69
+ if (n >= r) throw Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);
70
+ for (let i = 0; i < Math.min(n, r - 1); ++i) {
71
+ let n = e[i], r = t[i + 1];
72
+ if (n >= 0 && r >= 0 && n !== 1 && n !== r) throw Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${i - e.length}] = ${n} but ragged tensor input.flatValues.shape[${i - e.length}] = ${r}`);
73
+ }
74
+ }
75
+ function x(e) {
76
+ return e <= 30 ? e : p(e, Math.floor(Math.sqrt(e)));
77
+ }
78
+ //#endregion
79
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/rotate_util.js
80
+ function S(e, t, n) {
81
+ return [n * (typeof e == "number" ? e : e[0]), t * (typeof e == "number" ? e : e[1])];
82
+ }
83
+ //#endregion
84
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/array_ops_util.js
85
+ function C(e, t, n, r = !0) {
86
+ let i = [];
87
+ if (r) i = i.concat(t.slice(0)), i.push(e[0] / n), i = i.concat(e.slice(1));
88
+ else {
89
+ i = i.concat(e[0]);
90
+ let n = t.length;
91
+ for (let r = 0; r < n; ++r) i = i.concat([e[r + 1] / t[r], t[r]]);
92
+ i = i.concat(e.slice(n + 1));
93
+ }
94
+ return i;
95
+ }
96
+ function Le(e, t, n = !0) {
97
+ let r = [];
98
+ if (n) {
99
+ r.push(t);
100
+ for (let n = t + 1; n < e; ++n) n <= 2 * t ? (r.push(n), r.push(n - (t + 1))) : r.push(n);
101
+ } else {
102
+ let n = [], i = [];
103
+ for (let r = 1; r < e; ++r) r >= t * 2 + 1 || r % 2 == 1 ? i.push(r) : n.push(r);
104
+ r.push(...n), r.push(0), r.push(...i);
105
+ }
106
+ return r;
107
+ }
108
+ function w(e, t, n, r = !0) {
109
+ let i = [];
110
+ r ? i.push(e[0] / n) : i.push(e[0] * n);
111
+ for (let n = 1; n < e.length; ++n) n <= t.length ? r ? i.push(t[n - 1] * e[n]) : i.push(e[n] / t[n - 1]) : i.push(e[n]);
112
+ return i;
113
+ }
114
+ function T(e, t) {
115
+ let n = [0];
116
+ for (let r = 0; r < t; ++r) n.push(e[r][0]);
117
+ return n;
118
+ }
119
+ function E(e, t, n) {
120
+ let r = e.slice(0, 1);
121
+ for (let i = 0; i < n; ++i) r.push(e[i + 1] - t[i][0] - t[i][1]);
122
+ return r;
123
+ }
124
+ //#endregion
125
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/erf_util.js
126
+ var D = .3275911, O = .254829592, k = -.284496736, A = 1.421413741, j = -1.453152027, M = 1.061405429, N = "->", Re = /->/g, P = ",", F = "...";
127
+ function I(e, t) {
128
+ e = e.replace(/\s/g, "");
129
+ let n = (e.length - e.replace(Re, "").length) / 2;
130
+ if (n < 1) throw Error("Equations without an arrow are not supported.");
131
+ if (n > 1) throw Error(`Equation must contain exactly one arrow ("${N}").`);
132
+ let [r, i] = e.split(N);
133
+ f(r.indexOf(F) === -1, () => `The ellipsis notation ("${F}") is not supported yet.`);
134
+ let a = r.split(P), o = a.length;
135
+ if (t !== o) throw Error(`Expected ${o} input tensors, received ${t}`);
136
+ if (o > 2) throw Error("Support for more than 2 input tensors is not implemented yet.");
137
+ let s = [];
138
+ for (let e = 0; e < i.length; ++e) {
139
+ let t = i[e];
140
+ if (!a.some((e) => e.indexOf(t) !== -1)) throw Error(`Output subscripts contain the label ${t} not present in the input subscripts.`);
141
+ s.indexOf(t) === -1 && s.push(t);
142
+ }
143
+ for (let e = 0; e < r.length; ++e) {
144
+ let t = r[e];
145
+ s.indexOf(t) === -1 && t !== P && s.push(t);
146
+ }
147
+ let c = Array(a.length);
148
+ for (let e = 0; e < o; ++e) {
149
+ if (new Set(a[e].split("")).size !== a[e].length) throw Error(`Found duplicate axes in input component ${a[e]}. Support for duplicate axes in input is not implemented yet.`);
150
+ c[e] = [];
151
+ for (let t = 0; t < a[e].length; ++t) c[e].push(s.indexOf(a[e][t]));
152
+ }
153
+ let l = s.length, u = i.length, d = [];
154
+ for (let e = u; e < l; ++e) d.push(e);
155
+ return {
156
+ allDims: s,
157
+ summedDims: d,
158
+ idDims: c
159
+ };
160
+ }
161
+ function L(e, t) {
162
+ let n = Array(e);
163
+ n.fill(-1);
164
+ for (let e = 0; e < t.length; ++e) n[t[e]] = e;
165
+ let r = [];
166
+ for (let t = 0; t < e; ++t) n[t] === -1 && r.push(t);
167
+ return n = n.filter((e) => e !== -1), {
168
+ permutationIndices: n,
169
+ expandDims: r
170
+ };
171
+ }
172
+ function R(e, t, n) {
173
+ let r = Array(e);
174
+ for (let e = 0; e < n.length; ++e) {
175
+ let i = n[e].shape;
176
+ for (let n = 0; n < t[e].length; ++n) r[t[e][n]] === void 0 ? r[t[e][n]] = i[n] : f(r[t[e][n]] === i[n], () => `Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(i)}, but got dimension ${i[n]}`);
177
+ }
178
+ }
179
+ function z(e, t) {
180
+ let n = e, r = [], i = 0;
181
+ e.length === 0 && n.push(-1), i = e.length + 1;
182
+ for (let e = 0; e < i; ++e) r.push([]);
183
+ let a = [];
184
+ for (let e = 0; e < n.length; ++e) {
185
+ let i = n[e], o = ze(t, i);
186
+ for (let t of o) a.indexOf(t) === -1 && (r[e].push(t), a.push(t));
187
+ }
188
+ return {
189
+ path: n,
190
+ steps: r
191
+ };
192
+ }
193
+ function B(e) {
194
+ return e.every((e, t) => e === t);
195
+ }
196
+ function ze(e, t) {
197
+ let n = [];
198
+ for (let r = 0; r < e.length; ++r) (e[r].length === 0 || e[r].indexOf(t) !== -1 || t === -1) && n.push(r);
199
+ return n;
200
+ }
201
+ //#endregion
202
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/split_util.js
203
+ function V(e, t, n = 0) {
204
+ let r = [];
205
+ if (typeof t == "number") f(e.shape[n] % t === 0, () => "Number of splits must evenly divide the axis."), r = Array(t).fill(e.shape[n] / t);
206
+ else {
207
+ f(t.reduce((e, t) => (t === -1 && (e += 1), e), 0) <= 1, () => "There should be only one negative value in split array.");
208
+ let i = t.indexOf(-1);
209
+ if (i !== -1) {
210
+ let r = t.reduce((e, t) => t > 0 ? e + t : e);
211
+ t[i] = e.shape[n] - r;
212
+ }
213
+ f(e.shape[n] === t.reduce((e, t) => e + t), () => "The sum of sizes must match the size of the axis dimension."), r = t;
214
+ }
215
+ return r;
216
+ }
217
+ //#endregion
218
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/sparse/sparse_fill_empty_rows_util.js
219
+ function H(e) {
220
+ return `Received SparseTensor with denseShape[0] = 0 but
221
+ indices.shape[0] = ${e}`;
222
+ }
223
+ function U(e, t) {
224
+ return `indices(${e}, 0) is invalid: ${t} < 0`;
225
+ }
226
+ function W(e, t, n) {
227
+ return `indices(${e}, 0) is invalid: ${t} >= ${n}`;
228
+ }
229
+ //#endregion
230
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/sparse/sparse_reshape_util.js
231
+ function G(e, t) {
232
+ return `only one output dimension may be -1, not both ${e} and ${t}`;
233
+ }
234
+ function K(e, t) {
235
+ return `size ${e} must be non-negative, not ${t}`;
236
+ }
237
+ function q() {
238
+ return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
239
+ }
240
+ function J(e, t) {
241
+ return `Input to reshape is a SparseTensor with ${m(e)}
242
+ dense values, but the requested shape requires a multiple of ${m(t)}. inputShape=${e} outputShape= ${t}`;
243
+ }
244
+ function Y(e, t) {
245
+ return `Input to reshape is a tensor with ${m(e)} dense values, but the requested shape has ${m(t)}. inputShape=${e} outputShape=${t}`;
246
+ }
247
+ //#endregion
248
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/sparse/sparse_segment_reduction_util.js
249
+ function X() {
250
+ return "segment ids must be >= 0";
251
+ }
252
+ function Z() {
253
+ return "segment ids are not increasing";
254
+ }
255
+ function Q(e, t) {
256
+ return `Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`;
257
+ }
258
+ function Be(e, t, n) {
259
+ return `Bad: indices[${e}] == ${t} out of range [0, ${n})`;
260
+ }
261
+ //#endregion
262
+ //#region node_modules/@tensorflow/tfjs-core/dist/ops/segment_util.js
263
+ var Ve = /* @__PURE__ */ e({
264
+ collectGatherOpShapeInfo: () => We,
265
+ computeOutShape: () => Ue,
266
+ segOpComputeOptimalWindowSize: () => He
267
+ });
268
+ function He(e, t) {
269
+ let n = !1, r;
270
+ for (e <= 30 ? (r = e, n = !0) : r = p(e, Math.floor(Math.sqrt(e))); !n;) r > t || r === e ? n = !0 : r = p(e, r + 1);
271
+ return r;
272
+ }
273
+ function Ue(e, t, n) {
274
+ let r = [], i = e.length;
275
+ for (let a = 0; a < i; a++) a === t ? r.push(n) : r.push(e[a]);
276
+ return r;
277
+ }
278
+ function We(e, t, n, r) {
279
+ let i = t.shape.length, a = e.shape.length;
280
+ if (r !== 0 && (r < -i || r > i)) throw Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${r}`);
281
+ if (r < 0 && (r += i), r > a) throw Error(`batchDims (${r}) must be less than rank(x) (
282
+ ${a}).`);
283
+ if (n < r) throw Error(`batchDims (${r}) must be less than or equal to axis (${n}).`);
284
+ for (let n = 0; n < r; ++n) if (e.shape[n] !== t.shape[n]) throw Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`);
285
+ let o = e.shape[n], s = [], c = 1, l = 1, u = 1;
286
+ for (let t = 0; t < r; ++t) s.push(e.shape[t]), c *= e.shape[t];
287
+ for (let t = r; t < n; t++) s.push(e.shape[t]), l *= e.shape[t];
288
+ for (let e = r; e < i; e++) s.push(t.shape[e]);
289
+ for (let t = n + 1; t < a; t++) s.push(e.shape[t]), u *= e.shape[t];
290
+ return {
291
+ batchSize: c,
292
+ sliceSize: u,
293
+ outerSize: l,
294
+ dimSize: o,
295
+ outputShape: s
296
+ };
297
+ }
298
+ //#endregion
299
+ //#region node_modules/@tensorflow/tfjs-core/dist/backends/backend_util.js
300
+ var Ge = /* @__PURE__ */ e({
301
+ ERF_A1: () => O,
302
+ ERF_A2: () => k,
303
+ ERF_A3: () => A,
304
+ ERF_A4: () => j,
305
+ ERF_A5: () => M,
306
+ ERF_P: () => D,
307
+ PARALLELIZE_THRESHOLD: () => 30,
308
+ RowPartitionType: () => g,
309
+ SELU_SCALE: () => Te,
310
+ SELU_SCALEALPHA: () => Se,
311
+ applyActivation: () => we,
312
+ assertAndGetBroadcastShape: () => l,
313
+ assertAxesAreInnerMostDims: () => ve,
314
+ assertParamsConsistent: () => Oe,
315
+ assignToTypedArray: () => Ie,
316
+ axesAreInnerMostDims: () => ce,
317
+ calculateShapes: () => fe,
318
+ checkEinsumDimSizes: () => R,
319
+ checkPadOnDimRoundingMode: () => ye,
320
+ combineLocations: () => r,
321
+ combineRaggedTensorToTensorShapes: () => _,
322
+ complexWithEvenIndex: () => Me,
323
+ complexWithOddIndex: () => Pe,
324
+ computeConv2DInfo: () => le,
325
+ computeConv3DInfo: () => i,
326
+ computeDefaultPad: () => _e,
327
+ computeDilation2DInfo: () => de,
328
+ computeOptimalWindowSize: () => x,
329
+ computeOutAndReduceShapes: () => ge,
330
+ computeOutShape: () => De,
331
+ computePool2DInfo: () => c,
332
+ computePool3DInfo: () => o,
333
+ convertConv2DDataFormat: () => ie,
334
+ decodeEinsumEquation: () => I,
335
+ eitherStridesOrDilationsAreOne: () => he,
336
+ expandShapeToKeepDim: () => ue,
337
+ exponent: () => je,
338
+ exponents: () => ke,
339
+ fromStringArrayToUint8: () => $,
340
+ fromUint8ToStringArray: () => Ke,
341
+ getAxesPermutation: () => s,
342
+ getBroadcastDims: () => d,
343
+ getComplexWithIndex: () => Ne,
344
+ getEinsumComputePath: () => z,
345
+ getEinsumPermutation: () => L,
346
+ getFusedBiasGradient: () => xe,
347
+ getFusedDyActivation: () => be,
348
+ getImageCenter: () => S,
349
+ getInnerMostAxes: () => a,
350
+ getPermuted: () => Le,
351
+ getRaggedRank: () => y,
352
+ getReductionAxes: () => oe,
353
+ getReshaped: () => C,
354
+ getReshapedPermuted: () => w,
355
+ getRowPartitionTypesHelper: () => v,
356
+ getSliceBeginCoords: () => T,
357
+ getSliceSize: () => E,
358
+ getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => H,
359
+ getSparseFillEmptyRowsNegativeIndexErrorMessage: () => U,
360
+ getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => W,
361
+ getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => q,
362
+ getSparseReshapeInputOutputMismatchErrorMessage: () => Y,
363
+ getSparseReshapeInputOutputMultipleErrorMessage: () => J,
364
+ getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => G,
365
+ getSparseReshapeNegativeOutputDimErrorMessage: () => K,
366
+ getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => Be,
367
+ getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => X,
368
+ getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => Z,
369
+ getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => Q,
370
+ getUndoAxesPermutation: () => re,
371
+ isIdentityPermutation: () => B,
372
+ log: () => u,
373
+ mergeRealAndImagArrays: () => Fe,
374
+ prepareAndValidate: () => h,
375
+ prepareSplitSize: () => V,
376
+ segment_util: () => Ve,
377
+ shouldFuse: () => Ce,
378
+ slice_util: () => Ee,
379
+ splitRealAndImagArrays: () => Ae,
380
+ stridesOrDilationsArePositive: () => t,
381
+ tupleValuesAreOne: () => pe,
382
+ upcastType: () => n,
383
+ validateDefaultValueShape: () => b,
384
+ validateInput: () => ee,
385
+ validateUpdateShape: () => te,
386
+ warn: () => ae
387
+ });
388
+ function Ke(e) {
389
+ try {
390
+ return e.map((e) => ne(e));
391
+ } catch (e) {
392
+ throw Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`);
393
+ }
394
+ }
395
+ function $(e) {
396
+ return e.map((e) => me(e));
397
+ }
398
+ //#endregion
399
+ export { D as A, y as B, L as C, A as D, k as E, E as F, b as H, S as I, x as L, C as M, w as N, j as O, T as P, g as R, z as S, O as T, h as U, v as V, U as _, Ue as a, R as b, X as c, q as d, Y as f, H as g, K as h, We as i, Le as j, M as k, Z as l, G as m, $ as n, He as o, J as p, Ke as r, Be as s, Ge as t, Q as u, W as v, B as w, I as x, V as y, _ as z };
@@ -0,0 +1,103 @@
1
+ //#region node_modules/@tensorflow/tfjs-backend-webgpu/dist/binary_op_util.js
2
+ var e;
3
+ (function(e) {
4
+ 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";
5
+ })(e ||= {});
6
+ var t = "let resultTemp = a + b;", n = "let resultTemp = atan2(a, b);", r = "let resultTemp = areal * breal - aimag * bimag;", i = "let resultTemp = areal * bimag + aimag * breal;", a = "let resultTemp = a / b;", o = "let resultTemp = select(a * (b + 1.0), a, b >= b - b);", s = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a == b);\n", c = "\n let remainder =\n select(a % b, round(a % b), (round(a) == a) & (round(b) == b));\n let quotient = (a - remainder) / b;\n let resultTemp =\n round(select(quotient, quotient - 1, sign(remainder) == -sign(b)));\n", l = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a > b);\n", u = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a >= b);\n", d = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a < b);\n", f = "\n let zero = sign(a) * 0 + 0;\n let one = sign(b) * 0 + 1;\n let resultTemp = select(zero, one, a <= b);\n", p = "return f32(a >= 1.0 && b >= 1.0);", m = "return (vec4<f32>(a >= vec4<f32>(1.0)) *\n vec4<f32>(b >= vec4<f32>(1.0)));", h = "return f32(a >= 1.0 || b >= 1.0);", g = "return min(vec4<f32>(a >= vec4<f32>(1.0)) +\n vec4<f32>(b >= vec4<f32>(1.0)), vec4<f32>(1.0));", _ = "let resultTemp = max(a, b);", v = "let resultTemp = min(a, b);", y = "\n let isNaN = b == 0.;\n var resultTemp = a % b;\n resultTemp = select((resultTemp + b) % b, resultTemp,\n (a < 0. && b < 0.) || (a >= 0. && b > 0.));\n", b = "\n let isNaN = !vec4<bool>(b);\n var resultTemp = vec4<f32>(a % b);\n if (!((a[0] < 0. && b[0] < 0.) || (a[0] >= 0. && b[0] > 0.))) {\n resultTemp[0] = (resultTemp[0] + b[0]) % b[0];\n }\n if (!((a[1] < 0. && b[1] < 0.) || (a[1] >= 0. && b[1] > 0.))) {\n resultTemp[1] = (resultTemp[1] + b[1]) % b[1];\n }\n if (!((a[2] < 0. && b[2] < 0.) || (a[2] >= 0. && b[2] > 0.))) {\n resultTemp[2] = (resultTemp[2] + b[2]) % b[2];\n }\n if (!((a[3] < 0. && b[3] < 0.) || (a[3] >= 0. && b[3] > 0.))) {\n resultTemp[3] = (resultTemp[3] + b[3]) % b[3];\n }\n", x = "let resultTemp = a * b;", S = "\n var resultTemp = f32(a != b);\n let valueForNaN = 1.0;\n", C = "\n var resultTemp = vec4<f32>(a != b);\n let valueForNaN = 1.0;\n", w = "\n let isNaN = a < 0.0 && floor(b) < b;\n if (b == 0.0) {\n return 1.0;\n }\n var resultTemp = select(sign(a) * pow(abs(a), b), pow(abs(a), b),\n round(abs(b) % 2.0) != 1.0);\n", T = "\n let isModRound1Bool = vec4<i32>(round(abs(b) % vec4<f32>(2.0))) == vec4<i32>(1);\n let isModRound1 = vec4<f32>(isModRound1Bool);\n let multiplier = sign(a) * isModRound1 + (vec4<f32>(1.0) - isModRound1);\n var resultTemp = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n let isExpZero = b == vec4<f32>(0.0);\n if (isExpZero.r) {\n resultTemp.r = 1.0;\n }\n if (isExpZero.g) {\n resultTemp.g = 1.0;\n }\n if (isExpZero.b) {\n resultTemp.b = 1.0;\n }\n if (isExpZero.a) {\n resultTemp.a = 1.0;\n }\n let isNaN = (a < vec4<f32>(0.0)) & (floor(b) < b);\n", E = "if (a < 0.0) { return b * a; } return a;", D = "\n let aLessThanZero = vec4<f32>(a < vec4<f32>(0.0));\n return (aLessThanZero * (b * a)) + ((vec4<f32>(1.0) - aLessThanZero) * a);\n", O = "let resultTemp = (a - b) * (a - b);", k = "let resultTemp = a - b;";
7
+ function A(A, j) {
8
+ let M;
9
+ do {
10
+ switch (A) {
11
+ case e.ATAN2:
12
+ M = n;
13
+ break;
14
+ case e.MAX:
15
+ M = _;
16
+ break;
17
+ case e.MIN:
18
+ M = v;
19
+ break;
20
+ case e.MOD:
21
+ M = j ? b : y;
22
+ break;
23
+ case e.NOT_EQUAL:
24
+ M = j ? C : S;
25
+ break;
26
+ case e.POW:
27
+ M = j ? T : w;
28
+ break;
29
+ default: continue;
30
+ }
31
+ let t, r, i;
32
+ return j ? (t = "isnanVec4", r = "vec4<f32>", i = "vec4<bool>") : (t = "isnan", r = "f32", i = "bool"), `
33
+ let aIsNaN = ${t}(a);
34
+ let aPostLegalization = select(a, ${r}(42), aIsNaN);
35
+ let bIsNaN = ${t}(b);
36
+ let bPostLegalization = select(b, ${r}(42), bIsNaN);
37
+ let isNaN = false;
38
+ let valueForNaN = uniforms.NAN;
39
+ {
40
+ let a = aPostLegalization;
41
+ let b = bPostLegalization;
42
+ ${M}
43
+ return select(
44
+ resultTemp, ${r}(valueForNaN),
45
+ ${i}(isNaN) | aIsNaN | bIsNaN);
46
+ }
47
+ `;
48
+ } while (!1);
49
+ switch (A) {
50
+ case e.ADD:
51
+ M = t;
52
+ break;
53
+ case e.COMPLEX_MULTIPLY_IMAG:
54
+ M = i;
55
+ break;
56
+ case e.COMPLEX_MULTIPLY_REAL:
57
+ M = r;
58
+ break;
59
+ case e.DIV:
60
+ M = a;
61
+ break;
62
+ case e.ELU_DER:
63
+ M = o;
64
+ break;
65
+ case e.EQUAL:
66
+ M = s;
67
+ break;
68
+ case e.FLOOR_DIV:
69
+ M = c;
70
+ break;
71
+ case e.GREATER:
72
+ M = l;
73
+ break;
74
+ case e.GREATER_EQUAL:
75
+ M = u;
76
+ break;
77
+ case e.LESS:
78
+ M = d;
79
+ break;
80
+ case e.LESS_EQUAL:
81
+ M = f;
82
+ break;
83
+ case e.LOGICAL_AND: return j ? m : p;
84
+ case e.LOGICAL_OR: return j ? g : h;
85
+ case e.MUL:
86
+ M = x;
87
+ break;
88
+ case e.PRELU: return j ? D : E;
89
+ case e.SQUARED_DIFFERENCE:
90
+ M = O;
91
+ break;
92
+ case e.SUB:
93
+ M = k;
94
+ break;
95
+ default:
96
+ }
97
+ return `
98
+ ${M}
99
+ return resultTemp;
100
+ `;
101
+ }
102
+ //#endregion
103
+ export { A as n, e as t };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,55 @@
1
+ import { P as e, ii as t, ui as n } from "../dist-BewPQWjc.js";
2
+ //#region lib/checks/appendCache.ts
3
+ async function r(r) {
4
+ await n(r);
5
+ let i = e([[[
6
+ [
7
+ .1,
8
+ .2,
9
+ 0,
10
+ 0
11
+ ],
12
+ [
13
+ .1,
14
+ .2,
15
+ 0,
16
+ 0
17
+ ],
18
+ [
19
+ 0,
20
+ 0,
21
+ 0,
22
+ 0
23
+ ],
24
+ [
25
+ 0,
26
+ 0,
27
+ 0,
28
+ 0
29
+ ]
30
+ ]]], [
31
+ 1,
32
+ 1,
33
+ 4,
34
+ 4
35
+ ]), a = e([[[[
36
+ .1,
37
+ .2,
38
+ .3,
39
+ .4
40
+ ]]]], [
41
+ 1,
42
+ 1,
43
+ 1,
44
+ 4
45
+ ]);
46
+ return await t().runKernel("AppendCache", {
47
+ cache: i,
48
+ item: a
49
+ }, {
50
+ maxSize: 4,
51
+ pastLen: 2
52
+ }).array();
53
+ }
54
+ //#endregion
55
+ export { r as execute };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;
@@ -0,0 +1,56 @@
1
+ import { I as e, P as t, ii as n, ui as r } from "../dist-BewPQWjc.js";
2
+ //#region lib/checks/attentionMask.ts
3
+ async function i(i) {
4
+ await r(i);
5
+ let a = t([[[[
6
+ .1,
7
+ .2,
8
+ .3,
9
+ .4
10
+ ], [
11
+ .3,
12
+ .4,
13
+ .5,
14
+ .6
15
+ ]]]], [
16
+ 1,
17
+ 1,
18
+ 2,
19
+ 4
20
+ ]), o = t([[[[
21
+ .5,
22
+ .6,
23
+ .5,
24
+ .6
25
+ ], [
26
+ .7,
27
+ .8,
28
+ .7,
29
+ .8
30
+ ]]]], [
31
+ 1,
32
+ 1,
33
+ 2,
34
+ 4
35
+ ]), s = e([[
36
+ 0,
37
+ -Infinity,
38
+ -Infinity,
39
+ -Infinity
40
+ ], [
41
+ 0,
42
+ 0,
43
+ 0,
44
+ -Infinity
45
+ ]], [2, 4]);
46
+ return await n().runKernel("AttentionMask", {
47
+ q: a,
48
+ k: o,
49
+ mask: s
50
+ }, {
51
+ divisor: .5,
52
+ pastLen: 0
53
+ }).array();
54
+ }
55
+ //#endregion
56
+ export { i as execute };
@@ -0,0 +1,9 @@
1
+ interface Result {
2
+ backend: string;
3
+ result: unknown;
4
+ error?: string;
5
+ passed: boolean;
6
+ maxError?: number;
7
+ }
8
+ export default function runCheck(check: (backend: string) => Promise<unknown>, epsilon?: number, backends?: string[]): Promise<Result[]>;
9
+ export {};
@@ -0,0 +1,32 @@
1
+ import { arraysClose as e } from "../utilities/arrayClose.js";
2
+ //#region lib/checks/check.ts
3
+ async function t(t, n, r) {
4
+ let i = r ?? [
5
+ "cpu",
6
+ "webgl",
7
+ "webgpu"
8
+ ], a = [];
9
+ for (let e of i) try {
10
+ let n = await t(e);
11
+ a.push({
12
+ backend: e,
13
+ result: n,
14
+ passed: !0
15
+ });
16
+ } catch (t) {
17
+ a.push({
18
+ backend: e,
19
+ error: t.message,
20
+ result: [],
21
+ passed: !1
22
+ });
23
+ }
24
+ let o = await Promise.all(a), s = o[0].result;
25
+ for (let t = 1; t < o.length; t++) {
26
+ let r = o[t].result, i = e(s, r);
27
+ o[t].passed = i <= (n ?? 1e-6), o[t].maxError = i;
28
+ }
29
+ return o;
30
+ }
31
+ //#endregion
32
+ export { t as default };
@@ -0,0 +1 @@
1
+ export declare function execute(backend: string): Promise<number | number[] | number[][] | number[][][] | number[][][][] | number[][][][][] | number[][][][][][]>;