@genai-fi/nanogpt 0.19.1 → 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 (347) hide show
  1. package/dist/BaseTokeniser-DSg9zcYq.js +221 -0
  2. package/dist/DatasetBuilder-DgURD85T.js +712 -0
  3. package/dist/Generator.js +2 -11941
  4. package/dist/RealDiv-DBu0FQqT.js +362 -0
  5. package/dist/Reshape-CABOPB9d.js +94 -0
  6. package/dist/Reshape-DqO3r8BC.js +17 -0
  7. package/dist/TeachableLLM.d.ts +5 -5
  8. package/dist/TeachableLLM.js +2 -273
  9. package/dist/Trainer.js +2 -244
  10. package/dist/backend.js +12 -12
  11. package/dist/backend_util-Cg-roD1p.js +399 -0
  12. package/dist/binary_op_util-CrYk9LXL.js +103 -0
  13. package/dist/checks/appendCache.js +54 -21
  14. package/dist/checks/attentionMask.js +55 -36
  15. package/dist/checks/check.js +31 -19
  16. package/dist/checks/gelu.js +45 -17
  17. package/dist/checks/index.js +25 -25
  18. package/dist/checks/matMulGelu.js +83 -27
  19. package/dist/checks/normRMS.js +27 -15
  20. package/dist/checks/normRMSGrad.js +21 -11
  21. package/dist/checks/packUnpack.js +45 -17
  22. package/dist/checks/qkv.js +33 -33
  23. package/dist/checks/rope.js +29 -35
  24. package/dist/checks/weights.d.ts +1 -1
  25. package/dist/checks/weights.js +25 -29
  26. package/dist/chunk-BPntVaq0.js +23 -0
  27. package/dist/complex_util-CkazZsaH.js +60 -0
  28. package/dist/concat_util-CWDZCBlA.js +19 -0
  29. package/dist/data/docx.js +3044 -13
  30. package/dist/data/pdf.js +16 -13
  31. package/dist/data/textLoader.js +607 -112
  32. package/dist/dist-BewPQWjc.js +7572 -0
  33. package/dist/dist-DVmq73nz.js +8775 -0
  34. package/dist/dist-DXwIvKxl.js +896 -0
  35. package/dist/dist-VEU5mfO0.js +7545 -0
  36. package/dist/gelu-Bf1HW1RY.js +27 -0
  37. package/dist/gpgpu_math-DvLcCH6u.js +1612 -0
  38. package/dist/inference/types.js +0 -1
  39. package/dist/kernel_funcs_utils-HiXOOx3f.js +229 -0
  40. package/dist/layers/BaseLayer.d.ts +2 -2
  41. package/dist/layers/BaseLayer.js +75 -73
  42. package/dist/layers/CausalSelfAttention.d.ts +1 -1
  43. package/dist/layers/CausalSelfAttention.js +98 -85
  44. package/dist/layers/LoRA.js +47 -57
  45. package/dist/layers/MLP.d.ts +1 -1
  46. package/dist/layers/MLP.js +33 -43
  47. package/dist/layers/PositionEmbedding.d.ts +1 -1
  48. package/dist/layers/PositionEmbedding.js +26 -30
  49. package/dist/layers/RMSNorm.d.ts +1 -1
  50. package/dist/layers/RMSNorm.js +19 -21
  51. package/dist/layers/RoPECache.js +336 -49
  52. package/dist/layers/TiedEmbedding.d.ts +1 -1
  53. package/dist/layers/TiedEmbedding.js +30 -34
  54. package/dist/layers/TransformerBlock.d.ts +1 -1
  55. package/dist/layers/TransformerBlock.js +50 -39
  56. package/dist/layers/WeightStore.js +68 -75
  57. package/dist/loader/load.js +2 -68
  58. package/dist/loader/loadHF.d.ts +2 -2
  59. package/dist/loader/loadHF.js +2 -22
  60. package/dist/loader/loadTransformers.d.ts +1 -1
  61. package/dist/loader/loadTransformers.js +2 -44
  62. package/dist/loader/loadZipMeta.js +15 -15
  63. package/dist/loader/newZipLoad.js +2 -31
  64. package/dist/loader/oldZipLoad.d.ts +2 -2
  65. package/dist/loader/oldZipLoad.js +2 -80
  66. package/dist/loader/save.d.ts +5 -5
  67. package/dist/loader/save.js +2 -90
  68. package/dist/loader/types.d.ts +9 -8
  69. package/dist/loader/types.js +0 -1
  70. package/dist/main-CPjeMv0G.js +13500 -0
  71. package/dist/main.d.ts +1 -1
  72. package/dist/main.js +16 -109
  73. package/dist/matMul16-BNfZSnNM.js +81 -0
  74. package/dist/matMulGelu-CPTntosE.js +162 -0
  75. package/dist/models/NanoGPTV1.js +2 -99
  76. package/dist/models/NanoGPTV2.js +2 -90
  77. package/dist/models/config.js +34 -47
  78. package/dist/models/factory.d.ts +1 -1
  79. package/dist/models/factory.js +2 -16
  80. package/dist/models/model.d.ts +2 -2
  81. package/dist/models/model.js +2 -134
  82. package/dist/ops/adamAdjust.js +15 -6
  83. package/dist/ops/adamMoments.js +13 -6
  84. package/dist/ops/add16.js +9 -6
  85. package/dist/ops/appendCache.js +22 -19
  86. package/dist/ops/attentionMask.js +12 -6
  87. package/dist/ops/concat16.js +7 -8
  88. package/dist/ops/cpu/adamAdjust.js +15 -17
  89. package/dist/ops/cpu/adamMoments.js +15 -15
  90. package/dist/ops/cpu/appendCache.js +64 -22
  91. package/dist/ops/cpu/attentionMask.js +15 -21
  92. package/dist/ops/cpu/fusedSoftmax.js +21 -28
  93. package/dist/ops/cpu/gatherSub.js +11 -17
  94. package/dist/ops/cpu/gelu.js +34 -38
  95. package/dist/ops/cpu/matMul16.js +13 -14
  96. package/dist/ops/cpu/matMulGelu.js +39 -51
  97. package/dist/ops/cpu/matMulMul.js +19 -22
  98. package/dist/ops/cpu/mulDropout.js +19 -22
  99. package/dist/ops/cpu/normRMS.js +33 -37
  100. package/dist/ops/cpu/qkv.js +72 -40
  101. package/dist/ops/cpu/rope.js +79 -36
  102. package/dist/ops/cpu/scatterSub.js +11 -22
  103. package/dist/ops/dot16.js +28 -41
  104. package/dist/ops/dropout.js +10 -13
  105. package/dist/ops/dropout16.js +20 -23
  106. package/dist/ops/gatherSub.js +10 -6
  107. package/dist/ops/gelu.js +2 -8
  108. package/dist/ops/globalNorm.js +18 -12
  109. package/dist/ops/grads/add16.js +27 -26
  110. package/dist/ops/grads/attentionMask.js +26 -21
  111. package/dist/ops/grads/dropout16.js +0 -1
  112. package/dist/ops/grads/gelu.js +2 -5
  113. package/dist/ops/grads/matMul16.js +2 -9
  114. package/dist/ops/grads/matMulGelu.js +21 -16
  115. package/dist/ops/grads/mul16.js +0 -3
  116. package/dist/ops/grads/normRMS.js +34 -30
  117. package/dist/ops/grads/pack16.js +2 -6
  118. package/dist/ops/grads/qkv.js +44 -32
  119. package/dist/ops/grads/rope.js +2 -5
  120. package/dist/ops/grads/softmax16.js +21 -23
  121. package/dist/ops/grads/unpack16.js +2 -5
  122. package/dist/ops/grads/utils.js +9 -11
  123. package/dist/ops/matMul16.js +2 -13
  124. package/dist/ops/matMulGelu.js +16 -10
  125. package/dist/ops/matMulMul.js +13 -6
  126. package/dist/ops/mul16.js +42 -38
  127. package/dist/ops/mulDrop.js +12 -6
  128. package/dist/ops/normRMS.js +18 -15
  129. package/dist/ops/pack16.js +2 -5
  130. package/dist/ops/qkv.js +12 -6
  131. package/dist/ops/reshape16.js +31 -39
  132. package/dist/ops/rope.d.ts +1 -1
  133. package/dist/ops/rope.js +2 -7
  134. package/dist/ops/scatterSub.js +10 -6
  135. package/dist/ops/slice16.js +9 -7
  136. package/dist/ops/softmax16.js +7 -7
  137. package/dist/ops/sub16.js +9 -6
  138. package/dist/ops/sum16.js +12 -12
  139. package/dist/ops/transpose16.js +29 -37
  140. package/dist/ops/unpack16.js +2 -6
  141. package/dist/ops/webgl/adamAdjust.js +62 -29
  142. package/dist/ops/webgl/adamMoments.js +30 -26
  143. package/dist/ops/webgl/appendCache.js +30 -21
  144. package/dist/ops/webgl/attentionMask.js +43 -24
  145. package/dist/ops/webgl/dropout16.js +11 -10
  146. package/dist/ops/webgl/fusedSoftmax.js +69 -79
  147. package/dist/ops/webgl/gatherSub.js +27 -26
  148. package/dist/ops/webgl/gelu.js +32 -34
  149. package/dist/ops/webgl/log.js +14 -23
  150. package/dist/ops/webgl/matMul16.js +36 -44
  151. package/dist/ops/webgl/matMulGelu.js +2 -9
  152. package/dist/ops/webgl/matMulMul.js +23 -27
  153. package/dist/ops/webgl/mulDropout.js +31 -40
  154. package/dist/ops/webgl/normRMS.js +92 -71
  155. package/dist/ops/webgl/qkv.js +35 -27
  156. package/dist/ops/webgl/rope.js +37 -21
  157. package/dist/ops/webgl/scatterSub.js +27 -26
  158. package/dist/ops/webgpu/adamAdjust.js +59 -39
  159. package/dist/ops/webgpu/adamMoments.js +62 -46
  160. package/dist/ops/webgpu/add16.js +13 -12
  161. package/dist/ops/webgpu/appendCache.js +79 -54
  162. package/dist/ops/webgpu/attentionMask.js +41 -25
  163. package/dist/ops/webgpu/attentionMask32_program.js +34 -26
  164. package/dist/ops/webgpu/clipScale.js +44 -57
  165. package/dist/ops/webgpu/concat16.js +96 -111
  166. package/dist/ops/webgpu/dropout16.js +40 -32
  167. package/dist/ops/webgpu/gatherSub.js +43 -30
  168. package/dist/ops/webgpu/gelu.js +88 -82
  169. package/dist/ops/webgpu/index.js +16 -16
  170. package/dist/ops/webgpu/matMul16.js +69 -64
  171. package/dist/ops/webgpu/matMul16_program.js +152 -192
  172. package/dist/ops/webgpu/mul16.js +13 -12
  173. package/dist/ops/webgpu/norm2.js +45 -75
  174. package/dist/ops/webgpu/normRMS.js +25 -33
  175. package/dist/ops/webgpu/normRMS16_program.js +21 -18
  176. package/dist/ops/webgpu/normRMS32_program.js +21 -18
  177. package/dist/ops/webgpu/normRMSGrad.js +125 -184
  178. package/dist/ops/webgpu/pack16.js +20 -17
  179. package/dist/ops/webgpu/pack16_program.js +48 -47
  180. package/dist/ops/webgpu/qkv.js +63 -23
  181. package/dist/ops/webgpu/rope.js +85 -57
  182. package/dist/ops/webgpu/scatterSub.js +43 -30
  183. package/dist/ops/webgpu/slice16.js +66 -61
  184. package/dist/ops/webgpu/softmax16.js +17 -20
  185. package/dist/ops/webgpu/softmax16_program.js +34 -18
  186. package/dist/ops/webgpu/softmax16_subgroup_program.js +40 -45
  187. package/dist/ops/webgpu/softmax16grad.js +30 -36
  188. package/dist/ops/webgpu/sub16.js +13 -12
  189. package/dist/ops/webgpu/sum16.js +28 -37
  190. package/dist/ops/webgpu/transpose16.js +36 -33
  191. package/dist/ops/webgpu/transpose16_program.js +40 -39
  192. package/dist/ops/webgpu/transpose16_shared_program.js +53 -44
  193. package/dist/ops/webgpu/unpack16.js +49 -37
  194. package/dist/ops/webgpu/utils/binary_op.js +70 -68
  195. package/dist/ops/webgpu/utils/deviceInfo.d.ts +1 -1
  196. package/dist/ops/webgpu/utils/deviceInfo.js +10 -10
  197. package/dist/ops/webgpu/utils/reductions.js +136 -148
  198. package/dist/pack16-Ck-spx_F.js +39 -0
  199. package/dist/patches/webgpu_backend.d.ts +2 -2
  200. package/dist/patches/webgpu_backend.js +42 -55
  201. package/dist/patches/webgpu_base.js +21 -33
  202. package/dist/patches/webgpu_program.js +213 -320
  203. package/dist/pdf-UoDqCYzz.js +16726 -0
  204. package/dist/picomatch-3tUnMMbd.js +1063 -0
  205. package/dist/rope-CbeGlsV8.js +25 -0
  206. package/dist/selu_util-zkAx5doH.js +24 -0
  207. package/dist/shared-D1coEFea.js +1314 -0
  208. package/dist/shared-DOgWaqvL.js +5 -0
  209. package/dist/slice_util-Dgb3ANWI.js +208 -0
  210. package/dist/tfjs_backend-BjuQ5FqB.js +614 -0
  211. package/dist/tokeniser/BaseTokeniser.js +2 -124
  212. package/dist/tokeniser/CharTokeniser.js +91 -106
  213. package/dist/tokeniser/bpe.js +163 -166
  214. package/dist/tokeniser/messages.js +0 -1
  215. package/dist/tokeniser/type.js +0 -1
  216. package/dist/training/AdamW.js +127 -137
  217. package/dist/training/BasicTrainer.d.ts +1 -1
  218. package/dist/training/BasicTrainer.js +264 -264
  219. package/dist/training/DatasetBuilder.js +2 -86
  220. package/dist/training/Evaluator.d.ts +1 -1
  221. package/dist/training/Evaluator.js +47 -38
  222. package/dist/training/LRScheduler.js +37 -33
  223. package/dist/training/PreTrainer.d.ts +2 -2
  224. package/dist/training/PreTrainer.js +21 -19
  225. package/dist/training/SFTTrainer.d.ts +2 -2
  226. package/dist/training/SFTTrainer.js +23 -21
  227. package/dist/training/loss.js +17 -22
  228. package/dist/training/orthoGrad.js +9 -9
  229. package/dist/training/sparseCrossEntropy.js +45 -67
  230. package/dist/training/tasks/ConversationTask.d.ts +1 -1
  231. package/dist/training/tasks/ConversationTask.js +36 -38
  232. package/dist/training/tasks/PretrainingTask.d.ts +1 -1
  233. package/dist/training/tasks/PretrainingTask.js +41 -46
  234. package/dist/training/tasks/StartSentenceTask.d.ts +1 -1
  235. package/dist/training/tasks/StartSentenceTask.js +44 -48
  236. package/dist/training/tasks/Task.d.ts +1 -1
  237. package/dist/training/tasks/Task.js +53 -66
  238. package/dist/training/tasks/splitter.js +17 -20
  239. package/dist/training/types.d.ts +2 -2
  240. package/dist/training/types.js +0 -1
  241. package/dist/training/validation.d.ts +1 -1
  242. package/dist/training/validation.js +2 -84
  243. package/dist/utilities/arrayClose.js +15 -19
  244. package/dist/utilities/datasetID.js +17 -20
  245. package/dist/utilities/dummy.d.ts +1 -1
  246. package/dist/utilities/dummy.js +33 -40
  247. package/dist/utilities/multinomialCPU.js +8 -12
  248. package/dist/utilities/naming.js +0 -1
  249. package/dist/utilities/packed.js +10 -12
  250. package/dist/utilities/parameters.d.ts +1 -1
  251. package/dist/utilities/parameters.js +32 -51
  252. package/dist/utilities/performance.js +15 -15
  253. package/dist/utilities/profile.js +32 -37
  254. package/dist/utilities/safetensors.js +49 -79
  255. package/dist/utilities/sentences.d.ts +1 -1
  256. package/dist/utilities/sentences.js +29 -38
  257. package/dist/utilities/tokenParse.js +16 -20
  258. package/dist/utilities/topP.js +11 -12
  259. package/dist/utilities/waitForModel.d.ts +1 -1
  260. package/dist/utilities/waitForModel.js +11 -11
  261. package/dist/utilities/weights.js +37 -42
  262. package/dist/utilities/yielder.js +6 -6
  263. package/dist/webgpu-Dt7BMzWz.js +525 -0
  264. package/dist/webgpu_program-WOyIVMlZ.js +392 -0
  265. package/dist/webgpu_util-B_F3SShA.js +106 -0
  266. package/package.json +9 -10
  267. package/dist/RealDiv-CGwv0liw.js +0 -365
  268. package/dist/Reshape-BW__R4mZ.js +0 -79
  269. package/dist/Reshape-CPBkTIH2.js +0 -14
  270. package/dist/_commonjsHelpers-ByX85dGu.js +0 -33
  271. package/dist/axis_util-GTVlo58H.js +0 -55
  272. package/dist/backend_util-GaFarB78.js +0 -425
  273. package/dist/backend_webgpu-BqASlsbV.js +0 -545
  274. package/dist/binary_op_util-pKXltfxI.js +0 -192
  275. package/dist/broadcast_to-eS93CCN_.js +0 -28
  276. package/dist/clip_by_value-DDA7rrcT.js +0 -12
  277. package/dist/complex-DI35Q-gW.js +0 -11
  278. package/dist/complex_util-Yc1A_gV1.js +0 -55
  279. package/dist/concat-CAQpCret.js +0 -17
  280. package/dist/concat_util-D18dJ4fD.js +0 -22
  281. package/dist/data/parquet.d.ts +0 -2
  282. package/dist/data/parquet.js +0 -17
  283. package/dist/dataset-CGGp1z9P.js +0 -1124
  284. package/dist/dropout_util--NxWuYg2.js +0 -27
  285. package/dist/expand_dims-Bkd1YD5x.js +0 -11
  286. package/dist/exports_initializers-CYzKLjN7.js +0 -7
  287. package/dist/floor-BQtb-Azg.js +0 -9
  288. package/dist/gather-qIqEqaGn.js +0 -9
  289. package/dist/gelu-B220X1Go.js +0 -26
  290. package/dist/gpgpu_math-BwvV12df.js +0 -2022
  291. package/dist/index-CUXkjxiT.js +0 -3516
  292. package/dist/index-CieiGp4Y.js +0 -349
  293. package/dist/index-CjOWnMXP.js +0 -7308
  294. package/dist/index-Cp39cXWe.js +0 -1016
  295. package/dist/index-D5v913EJ.js +0 -4
  296. package/dist/index-DmeWGGmS.js +0 -1074
  297. package/dist/index-DvYrXKkX.js +0 -113
  298. package/dist/index-Ksja3su6.js +0 -151
  299. package/dist/index-xuotMAFm.js +0 -118
  300. package/dist/jszip.min-BZhlzntC.js +0 -2313
  301. package/dist/kernel_funcs_utils-pq0CK9co.js +0 -306
  302. package/dist/matMul16-BcVC_E62.js +0 -80
  303. package/dist/matMulGelu-JNLZqKQp.js +0 -163
  304. package/dist/mat_mul-DhG0Newp.js +0 -11
  305. package/dist/mod-CSdCpRjf.js +0 -11
  306. package/dist/non_max_suppression_impl-B2W7YjZB.js +0 -102
  307. package/dist/not_equal-hurPF26l.js +0 -64
  308. package/dist/ones-BytntneX.js +0 -14
  309. package/dist/ops-CsXeTq1P.js +0 -476
  310. package/dist/pack16-bqltoUlR.js +0 -39
  311. package/dist/papaparse.min-C0cScC2i.js +0 -418
  312. package/dist/parquet-Bqjmp2vo.js +0 -44231
  313. package/dist/pdf-NIhmP3sq.js +0 -19477
  314. package/dist/rand_util-CZ7yLoUm.js +0 -50
  315. package/dist/random_normal-IBRrha8a.js +0 -14
  316. package/dist/random_width-DN5ZtQkM.js +0 -9796
  317. package/dist/range-C-CjF-LI.js +0 -10
  318. package/dist/relu-J_X6MUzx.js +0 -9
  319. package/dist/reshape-BDOuCSNW.js +0 -9
  320. package/dist/resize_nearest_neighbor-BojqlfRe.js +0 -150
  321. package/dist/rope-DcrZM_e6.js +0 -24
  322. package/dist/scatter_nd_util-ByNJaL6I.js +0 -46
  323. package/dist/segment_util-Dasb2Zaf.js +0 -43
  324. package/dist/selu_util-BLhIqRkw.js +0 -44
  325. package/dist/shared-3agzAqQ_.js +0 -53
  326. package/dist/shared-CagdqkLh.js +0 -2143
  327. package/dist/slice-BzS11Qh0.js +0 -12
  328. package/dist/slice_util-CC35pLmT.js +0 -153
  329. package/dist/softmax-D4q1LJN7.js +0 -12
  330. package/dist/split-C2Sj255c.js +0 -9
  331. package/dist/squeeze-ho4wLUek.js +0 -10
  332. package/dist/stack-DudVrtmG.js +0 -11
  333. package/dist/step-BTxPtq1r.js +0 -261
  334. package/dist/sum-BpiwSWvg.js +0 -11
  335. package/dist/tensor-BWFldCso.js +0 -8
  336. package/dist/tensor1d-LMGMIUlr.js +0 -11
  337. package/dist/tensor2d-BnXMKScO.js +0 -14
  338. package/dist/tensor4d-C6UCG_u8.js +0 -14
  339. package/dist/tfjs_backend-BGnG-ppu.js +0 -654
  340. package/dist/tile-CFy-xTO6.js +0 -11
  341. package/dist/transpose-9kRxIXWR.js +0 -36
  342. package/dist/unsorted_segment_sum-DJvk5xnh.js +0 -277
  343. package/dist/variable-Ck482e3n.js +0 -7
  344. package/dist/webgpu_program-B4HmApL1.js +0 -525
  345. package/dist/webgpu_util-DYlGSwOJ.js +0 -64
  346. package/dist/zeros-DvZpK8s6.js +0 -13
  347. package/dist/zeros_like-CWjDdwr-.js +0 -721
@@ -1,12 +0,0 @@
1
- import { o as c, q as e, E as a, S as l } from "./index-CUXkjxiT.js";
2
- function p(r, n, o) {
3
- const s = e(r, "x", "slice", "string_or_numeric");
4
- if (s.rank === 0)
5
- throw new Error("Slicing scalar is not possible");
6
- const t = { x: s }, i = { begin: n, size: o };
7
- return a.runKernel(l, t, i);
8
- }
9
- const x = /* @__PURE__ */ c({ slice_: p });
10
- export {
11
- x as s
12
- };
@@ -1,153 +0,0 @@
1
- import { x as b } from "./index-CUXkjxiT.js";
2
- const y = -2, N = -1;
3
- function L(r, e, n) {
4
- const t = r.shape.length;
5
- b(t === e.length, () => `Error in slice${t}D: Length of begin ${e} must match the rank of the array (${t}).`), b(t === n.length, () => `Error in slice${t}D: Length of size ${n} must match the rank of the array (${t}).`);
6
- for (let l = 0; l < t; ++l)
7
- b(e[l] + n[l] <= r.shape[l], () => `Error in slice${t}D: begin[${l}] + size[${l}] (${e[l] + n[l]}) would overflow input.shape[${l}] (${r.shape[l]})`);
8
- }
9
- function v(r, e, n) {
10
- const t = [];
11
- for (let l = 0; l < r.length; l++)
12
- t[l] = Math.ceil((e[l] - r[l]) / n[l]);
13
- return t;
14
- }
15
- function P(r, e, n) {
16
- let t = n.length;
17
- for (let l = 0; l < n.length; l++)
18
- if (n[l] > 1) {
19
- t = l;
20
- break;
21
- }
22
- for (let l = t + 1; l < n.length; l++)
23
- if (e[l] > 0 || n[l] !== r[l])
24
- return !1;
25
- return !0;
26
- }
27
- function X(r, e) {
28
- let n = r.length > 0 ? r[r.length - 1] : 1;
29
- for (let t = 0; t < r.length - 1; t++)
30
- n += r[t] * e[t];
31
- return n;
32
- }
33
- function C(r, e, n) {
34
- let t;
35
- const l = r.shape.length;
36
- typeof e == "number" ? t = [e, ...new Array(l - 1).fill(0)] : e.length < l ? t = e.concat(new Array(l - e.length).fill(0)) : t = e.slice(), t.forEach((f) => {
37
- b(f !== -1, () => "slice() does not support negative begin indexing.");
38
- });
39
- let a;
40
- return n == null ? a = new Array(l).fill(-1) : typeof n == "number" ? a = [n, ...new Array(l - 1).fill(-1)] : n.length < l ? a = n.concat(new Array(l - n.length).fill(-1)) : a = n, a = a.map((f, u) => f >= 0 ? f : (b(f === -1, () => `Negative size values should be exactly -1 but got ${f} for the slice() size at index ${u}.`), r.shape[u] - t[u])), [t, a];
41
- }
42
- function H(r, e, n, t, l, a, f, u, D) {
43
- let g;
44
- if (t == null ? (g = new Array(e.length), g.fill(1)) : g = t, f != null && (f & f - 1) !== 0)
45
- throw new Error("Multiple ellipses in slice is not allowed.");
46
- let w = !1;
47
- const d = {
48
- dims: g.length,
49
- numAddAxisAfterEllipsis: 0,
50
- begin: e.slice(),
51
- end: n.slice(),
52
- strides: g.slice(),
53
- beginMask: l,
54
- endMask: a,
55
- ellipsisMask: f,
56
- newAxisMask: u,
57
- shrinkAxisMask: D
58
- };
59
- for (let i = 0; i < d.dims; i++)
60
- w && (1 << i & u) !== 0 && d.numAddAxisAfterEllipsis++, 1 << i & f && (w = !0);
61
- w || (d.ellipsisMask |= 1 << d.dims, d.dims++);
62
- const s = {
63
- dims: r.length,
64
- beginMask: 0,
65
- endMask: 0,
66
- beginValid: !1,
67
- endValid: !1
68
- };
69
- O(d, s);
70
- let m = !0, S = !0, M = !0;
71
- const k = [], I = [];
72
- for (let i = 0; i < r.length; ++i) {
73
- if (s.strides[i] === 0)
74
- throw Error(`strides[${i}] must be non-zero`);
75
- const o = !!(s.shrinkAxisMask & 1 << i), h = r[i];
76
- if (h === -1) {
77
- k.push(o ? 1 : -1);
78
- continue;
79
- }
80
- const G = [s.beginMask & 1 << i, s.endMask & 1 << i], E = [
81
- s.strides[i] > 0 ? 0 : -1,
82
- s.strides[i] > 0 ? h : h - 1
83
- ];
84
- if (o && s.strides[i] <= 0)
85
- throw Error("only stride 1 allowed on non-range indexing.");
86
- M = M && s.strides[i] === 1;
87
- const $ = !!(s.beginMask & 1 << i && s.endMask & 1 << i);
88
- if (s.beginValid && s.endValid) {
89
- if (o) {
90
- const x = s.begin[i] < 0 ? h + s.begin[i] : s.begin[i];
91
- if (s.begin[i] = x, s.end[i] = s.begin[i] + 1, x < 0 || x >= h)
92
- throw Error(`slice index ${s.begin[i]} of dimension ${i} out of bounds.`);
93
- } else
94
- s.begin[i] = V(s.begin[i], 0, s.strides[i], h, G, E), s.end[i] = V(s.end[i], 1, s.strides[i], h, G, E);
95
- const p = s.strides[i] === 1 && s.begin[i] === 0 && s.end[i] === h;
96
- m = m && p, S = S && (i === 0 && s.strides[i] === 1 || p);
97
- } else
98
- m = m && s.strides[i] === 1 && $, S = S && (i === 0 && s.strides[i] === 1 || $);
99
- let c, A = !1;
100
- if (s.beginValid && s.endValid ? (c = s.end[i] - s.begin[i], A = !0) : o ? (c = 1, A = !0) : $ && h >= 0 && (s.strides[i] < 0 ? c = -h : c = h, A = !0), A) {
101
- let p;
102
- c === 0 || c < 0 != s.strides[i] < 0 ? p = 0 : p = Math.trunc(c / s.strides[i]) + (c % s.strides[i] !== 0 ? 1 : 0), k.push(p);
103
- } else
104
- k.push(-1);
105
- }
106
- for (let i = 0; i < s.finalShapeGatherIndices.length; ++i) {
107
- const o = s.finalShapeGatherIndices[i];
108
- o >= 0 ? I.push(k[o]) : o === y && I.push(1);
109
- }
110
- return {
111
- finalShapeSparse: I.filter((i, o) => s.finalShapeGatherIndices[o] !== y),
112
- finalShape: I,
113
- isIdentity: m,
114
- sliceDim0: S,
115
- isSimpleSlice: M,
116
- begin: s.begin,
117
- end: s.end,
118
- strides: s.strides
119
- };
120
- }
121
- function O(r, e) {
122
- e.beginMask = 0, e.endMask = 0, e.shrinkAxisMask = 0;
123
- let n = 0;
124
- e.beginValid = r.begin != null, e.endValid = r.end != null, e.begin = new Array(e.dims), e.end = new Array(e.dims), e.strides = new Array(e.dims), e.finalShapeGatherIndices = [], e.finalShapeGatherIndicesSparse = [], e.inputShapeGatherIndicesSparse = new Array(e.dims);
125
- for (let t = 0; t < r.dims; t++)
126
- if (1 << t & r.ellipsisMask) {
127
- const l = Math.min(e.dims - (r.dims - t) + 1 + r.numAddAxisAfterEllipsis, e.dims);
128
- for (; n < l; n++)
129
- e.begin[n] = 0, e.end[n] = 0, e.strides[n] = 1, e.beginMask |= 1 << n, e.endMask |= 1 << n, e.finalShapeGatherIndices.push(n), e.finalShapeGatherIndicesSparse.push(-1), e.inputShapeGatherIndicesSparse[n] = t;
130
- } else if (1 << t & r.newAxisMask)
131
- e.finalShapeGatherIndices.push(y), e.finalShapeGatherIndicesSparse.push(-1);
132
- else {
133
- if (n === e.begin.length)
134
- throw Error(`Index out of range using input dim ${n}; input has only ${e.dims} dims, ${e.begin.length}.`);
135
- r.begin != null && (e.begin[n] = r.begin[t]), r.end != null && (e.end[n] = r.end[t]), e.strides[n] = r.strides[t], r.beginMask & 1 << t && (e.beginMask |= 1 << n), r.endMask & 1 << t && (e.endMask |= 1 << n), r.shrinkAxisMask & 1 << t ? (e.finalShapeGatherIndices.push(N), e.finalShapeGatherIndicesSparse.push(-1), e.shrinkAxisMask |= 1 << n) : (e.finalShapeGatherIndices.push(n), e.finalShapeGatherIndicesSparse.push(t)), e.inputShapeGatherIndicesSparse[n] = t, n++;
136
- }
137
- }
138
- function V(r, e, n, t, l, a) {
139
- if (l[e])
140
- return n > 0 ? a[e] : a[e + 1 & 1];
141
- {
142
- const f = r < 0 ? t + r : r;
143
- return f < a[0] ? a[0] : f > a[1] ? a[1] : f;
144
- }
145
- }
146
- export {
147
- L as a,
148
- v as b,
149
- X as c,
150
- P as i,
151
- C as p,
152
- H as s
153
- };
@@ -1,12 +0,0 @@
1
- import { o as r, q as f, E as e, I as i } from "./index-CUXkjxiT.js";
2
- function l(s, o = -1) {
3
- const t = f(s, "logits", "softmax", "float32");
4
- if (o === -1 && (o = t.rank - 1), o !== t.rank - 1)
5
- throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${t.rank} and dim was ${o}`);
6
- const n = { logits: t }, a = { dim: o };
7
- return e.runKernel(i, n, a);
8
- }
9
- const p = /* @__PURE__ */ r({ softmax_: l });
10
- export {
11
- p as s
12
- };
@@ -1,9 +0,0 @@
1
- import { o as p, q as i, E as a, J as c } from "./index-CUXkjxiT.js";
2
- function e(t, s, o = 0) {
3
- const n = { x: i(t, "x", "split") }, r = { numOrSizeSplits: s, axis: o };
4
- return a.runKernel(c, n, r);
5
- }
6
- const u = /* @__PURE__ */ p({ split_: e });
7
- export {
8
- u as s
9
- };
@@ -1,10 +0,0 @@
1
- import { o as r, q as n, K as a } from "./index-CUXkjxiT.js";
2
- import { r as t } from "./reshape-BDOuCSNW.js";
3
- function p(s, o) {
4
- const e = n(s, "x", "squeeze", "string_or_numeric");
5
- return t(e, a(e.shape, o).newShape);
6
- }
7
- const i = /* @__PURE__ */ r({ squeeze_: p });
8
- export {
9
- i as s
10
- };
@@ -1,11 +0,0 @@
1
- import { o as e, y as c, x as n, E as k, P as i } from "./index-CUXkjxiT.js";
2
- function u(r, t = 0) {
3
- const s = c(r, "tensors", "stack", "string_or_numeric");
4
- n(s.length >= 1, () => "Pass at least one tensor to tf.stack"), s.length > 0 && n(t <= s[0].rank, () => "Axis must be <= rank of the tensor");
5
- const o = s, a = { axis: t };
6
- return k.runKernel(i, o, a);
7
- }
8
- const l = /* @__PURE__ */ e({ stack_: u });
9
- export {
10
- l as s
11
- };
@@ -1,261 +0,0 @@
1
- import { x as _, aE as P, o as A, q as I, E as v, aF as G, aG as q, aH as J, aI as X, aJ as Q, aK as Y } from "./index-CUXkjxiT.js";
2
- function it(t, n, e, o, s = "NHWC", f) {
3
- const l = t[3], r = [...n, l], c = nt(s);
4
- return j(t, r, e, f, o, null, null, c);
5
- }
6
- function ft(t, n, e, o, s, f, l = "channelsLast") {
7
- const [r, c] = T(n);
8
- let u;
9
- if (l === "channelsLast")
10
- u = [r, c, t[3], t[3]];
11
- else if (l === "channelsFirst")
12
- u = [r, c, t[1], t[1]];
13
- else
14
- throw new Error(`Unknown dataFormat ${l}`);
15
- return j(t, u, e, o, s, f, !1, l);
16
- }
17
- function ht(t, n, e, o, s, f, l = "NDHWC") {
18
- const [r, c, u] = K(n);
19
- let h, i;
20
- if (l === "NDHWC")
21
- i = "channelsLast", h = [r, c, u, t[4], t[4]];
22
- else if (l === "NCDHW")
23
- i = "channelsFirst", h = [r, c, u, t[1], t[1]];
24
- else
25
- throw new Error(`Unknown dataFormat ${l}`);
26
- return Z(t, h, e, o, s, !1, i, f);
27
- }
28
- function j(t, n, e, o, s, f, l = !1, r = "channelsLast") {
29
- let [c, u, h, i] = [-1, -1, -1, -1];
30
- if (r === "channelsLast")
31
- [c, u, h, i] = t;
32
- else if (r === "channelsFirst")
33
- [c, i, u, h] = t;
34
- else
35
- throw new Error(`Unknown dataFormat ${r}`);
36
- const [a, p, , $] = n, [w, g] = T(e), [x, y] = T(o), C = k(a, x), b = k(p, y), { padInfo: L, outHeight: E, outWidth: D } = d(s, u, h, w, g, C, b, f, r), M = l ? $ * i : $;
37
- let m;
38
- return r === "channelsFirst" ? m = [c, M, E, D] : r === "channelsLast" && (m = [c, E, D, M]), {
39
- batchSize: c,
40
- dataFormat: r,
41
- inHeight: u,
42
- inWidth: h,
43
- inChannels: i,
44
- outHeight: E,
45
- outWidth: D,
46
- outChannels: M,
47
- padInfo: L,
48
- strideHeight: w,
49
- strideWidth: g,
50
- filterHeight: a,
51
- filterWidth: p,
52
- effectiveFilterHeight: C,
53
- effectiveFilterWidth: b,
54
- dilationHeight: x,
55
- dilationWidth: y,
56
- inShape: t,
57
- outShape: m,
58
- filterShape: n
59
- };
60
- }
61
- function Z(t, n, e, o, s, f = !1, l = "channelsLast", r) {
62
- let [c, u, h, i, a] = [-1, -1, -1, -1, -1];
63
- if (l === "channelsLast")
64
- [c, u, h, i, a] = t;
65
- else if (l === "channelsFirst")
66
- [c, a, u, h, i] = t;
67
- else
68
- throw new Error(`Unknown dataFormat ${l}`);
69
- const [p, $, w, , g] = n, [x, y, C] = K(e), [b, L, E] = K(o), D = k(p, b), M = k($, L), m = k(w, E), { padInfo: F, outDepth: N, outHeight: R, outWidth: W } = tt(s, u, h, i, x, y, C, D, M, m, r), H = f ? g * a : g;
70
- let O;
71
- return l === "channelsFirst" ? O = [c, H, N, R, W] : l === "channelsLast" && (O = [c, N, R, W, H]), {
72
- batchSize: c,
73
- dataFormat: l,
74
- inDepth: u,
75
- inHeight: h,
76
- inWidth: i,
77
- inChannels: a,
78
- outDepth: N,
79
- outHeight: R,
80
- outWidth: W,
81
- outChannels: H,
82
- padInfo: F,
83
- strideDepth: x,
84
- strideHeight: y,
85
- strideWidth: C,
86
- filterDepth: p,
87
- filterHeight: $,
88
- filterWidth: w,
89
- effectiveFilterDepth: D,
90
- effectiveFilterHeight: M,
91
- effectiveFilterWidth: m,
92
- dilationDepth: b,
93
- dilationHeight: L,
94
- dilationWidth: E,
95
- inShape: t,
96
- outShape: O,
97
- filterShape: n
98
- };
99
- }
100
- function z(t, n, e, o, s) {
101
- o == null && (o = B(t, n, e));
102
- const f = t[0], l = t[1], r = U((f - n + 2 * o) / e + 1, s), c = U((l - n + 2 * o) / e + 1, s);
103
- return [r, c];
104
- }
105
- function S(t, n, e, o, s, f) {
106
- s == null && (s = B(t, n[0], o[0]));
107
- const l = [0, 0, 0, e];
108
- for (let r = 0; r < 3; r++)
109
- t[r] + 2 * s >= n[r] && (l[r] = U((t[r] - n[r] + 2 * s) / o[r] + 1, f));
110
- return l;
111
- }
112
- function B(t, n, e, o = 1) {
113
- const s = k(n, o);
114
- return Math.floor((t[0] * (e - 1) - e + s) / 2);
115
- }
116
- function T(t) {
117
- return typeof t == "number" ? [t, t, t] : t.length === 2 ? [t[0], t[1], 1] : t;
118
- }
119
- function K(t) {
120
- return typeof t == "number" ? [t, t, t] : t;
121
- }
122
- function k(t, n) {
123
- return n <= 1 ? t : t + (t - 1) * (n - 1);
124
- }
125
- function d(t, n, e, o, s, f, l, r, c) {
126
- let u, h, i;
127
- if (typeof t == "number") {
128
- u = { top: t, bottom: t, left: t, right: t, type: t === 0 ? "VALID" : "NUMBER" };
129
- const p = z([n, e], f, o, t, r);
130
- h = p[0], i = p[1];
131
- } else if (t === "same") {
132
- h = Math.ceil(n / o), i = Math.ceil(e / s);
133
- const a = Math.max(0, (h - 1) * o + f - n), p = Math.max(0, (i - 1) * s + l - e), $ = Math.floor(a / 2), w = a - $, g = Math.floor(p / 2), x = p - g;
134
- u = { top: $, bottom: w, left: g, right: x, type: "SAME" };
135
- } else if (t === "valid")
136
- u = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, h = Math.ceil((n - f + 1) / o), i = Math.ceil((e - l + 1) / s);
137
- else if (typeof t == "object") {
138
- const a = c === "channelsLast" ? t[1][0] : t[2][0], p = c === "channelsLast" ? t[1][1] : t[2][1], $ = c === "channelsLast" ? t[2][0] : t[3][0], w = c === "channelsLast" ? t[2][1] : t[3][1];
139
- u = { top: a, bottom: p, left: $, right: w, type: a === 0 && p === 0 && $ === 0 && w === 0 ? "VALID" : "EXPLICIT" }, h = U((n - f + a + p) / o + 1, r), i = U((e - l + $ + w) / s + 1, r);
140
- } else
141
- throw Error(`Unknown padding parameter: ${t}`);
142
- return { padInfo: u, outHeight: h, outWidth: i };
143
- }
144
- function tt(t, n, e, o, s, f, l, r, c, u, h) {
145
- let i, a, p, $;
146
- if (t === "valid" && (t = 0), typeof t == "number") {
147
- i = {
148
- top: t,
149
- bottom: t,
150
- left: t,
151
- right: t,
152
- front: t,
153
- back: t,
154
- type: t === 0 ? "VALID" : "NUMBER"
155
- };
156
- const g = S([n, e, o, 1], [r, c, u], 1, [s, f, l], t, h);
157
- a = g[0], p = g[1], $ = g[2];
158
- } else if (t === "same") {
159
- a = Math.ceil(n / s), p = Math.ceil(e / f), $ = Math.ceil(o / l);
160
- const w = (a - 1) * s + r - n, g = (p - 1) * f + c - e, x = ($ - 1) * l + u - o, y = Math.floor(w / 2), C = w - y, b = Math.floor(g / 2), L = g - b, E = Math.floor(x / 2), D = x - E;
161
- i = { top: b, bottom: L, left: E, right: D, front: y, back: C, type: "SAME" };
162
- } else
163
- throw Error(`Unknown padding parameter: ${t}`);
164
- return { padInfo: i, outDepth: a, outHeight: p, outWidth: $ };
165
- }
166
- function U(t, n) {
167
- if (!n)
168
- return Math.trunc(t);
169
- switch (n) {
170
- case "round":
171
- return Math.round(t);
172
- case "ceil":
173
- return Math.ceil(t);
174
- case "floor":
175
- return Math.floor(t);
176
- default:
177
- throw new Error(`Unknown roundingMode ${n}`);
178
- }
179
- }
180
- function V(t) {
181
- const [n, e, o] = T(t);
182
- return n === 1 && e === 1 && o === 1;
183
- }
184
- function at(t, n) {
185
- return V(t) || V(n);
186
- }
187
- function pt(t) {
188
- return T(t).every((n) => n > 0);
189
- }
190
- function nt(t) {
191
- if (t === "NHWC")
192
- return "channelsLast";
193
- if (t === "NCHW")
194
- return "channelsFirst";
195
- throw new Error(`Unknown dataFormat ${t}`);
196
- }
197
- function $t(t, n, e) {
198
- if (e != null) {
199
- if (typeof n == "string")
200
- throw Error(`Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
201
- if (typeof n == "number")
202
- _(P(n), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${n}.`);
203
- else if (typeof n == "object")
204
- n.forEach((o) => {
205
- o.forEach((s) => {
206
- _(P(s), () => `Error in ${t}: pad must be an integer when using dimRoundingMode ${e} but got pad ${s}.`);
207
- });
208
- });
209
- else
210
- throw Error(`Error in ${t}: Unknown padding parameter: ${n}`);
211
- }
212
- }
213
- function et(t) {
214
- const e = { x: I(t, "x", "sigmoid", "float32") };
215
- return v.runKernel(G, e);
216
- }
217
- const gt = /* @__PURE__ */ A({ sigmoid_: et });
218
- function ot(t) {
219
- const e = { x: I(t, "x", "elu", "float32") };
220
- return v.runKernel(q, e);
221
- }
222
- const wt = /* @__PURE__ */ A({ elu_: ot });
223
- function st(t, n = 0.2) {
224
- const o = { x: I(t, "x", "leakyRelu") }, s = { alpha: n };
225
- return v.runKernel(J, o, s);
226
- }
227
- const xt = /* @__PURE__ */ A({ leakyRelu_: st });
228
- function rt(t, n) {
229
- const e = I(t, "x", "prelu"), o = I(n, "alpha", "prelu"), s = { x: e, alpha: o };
230
- return v.runKernel(X, s);
231
- }
232
- const Et = /* @__PURE__ */ A({ prelu_: rt });
233
- function lt(t) {
234
- const e = { x: I(t, "x", "relu6") };
235
- return v.runKernel(Q, e);
236
- }
237
- const yt = /* @__PURE__ */ A({ relu6_: lt });
238
- function ct(t, n = 0) {
239
- const o = { x: I(t, "x", "step") }, s = { alpha: n };
240
- return v.runKernel(Y, o, s);
241
- }
242
- const bt = /* @__PURE__ */ A({ step_: ct });
243
- export {
244
- bt as a,
245
- j as b,
246
- $t as c,
247
- Z as d,
248
- wt as e,
249
- B as f,
250
- it as g,
251
- ft as h,
252
- ht as i,
253
- nt as j,
254
- at as k,
255
- xt as l,
256
- pt as m,
257
- Et as p,
258
- yt as r,
259
- gt as s,
260
- V as t
261
- };
@@ -1,11 +0,0 @@
1
- import { o as e, q as u, L as c, E as l, N as m } from "./index-CUXkjxiT.js";
2
- function i(t, o = null, n = !1) {
3
- let s = u(t, "x", "sum");
4
- s.dtype === "bool" && (s = c(s, "int32"));
5
- const r = { x: s }, a = { axis: o, keepDims: n };
6
- return l.runKernel(m, r, a);
7
- }
8
- const f = /* @__PURE__ */ e({ sum_: i });
9
- export {
10
- f as s
11
- };
@@ -1,8 +0,0 @@
1
- import { X as t, Y as a } from "./index-CUXkjxiT.js";
2
- function f(r, n, e) {
3
- const o = t(r, e);
4
- return a(r, n, o, e);
5
- }
6
- export {
7
- f as t
8
- };
@@ -1,11 +0,0 @@
1
- import { W as o, X as s, Y as t } from "./index-CUXkjxiT.js";
2
- function h(r, e) {
3
- o(r);
4
- const n = s(r, e);
5
- if (n.length !== 1)
6
- throw new Error("tensor1d() requires values to be a flat/TypedArray");
7
- return t(r, null, n, e);
8
- }
9
- export {
10
- h as t
11
- };
@@ -1,14 +0,0 @@
1
- import { W as t, X as s, Y as a } from "./index-CUXkjxiT.js";
2
- function i(n, r, o) {
3
- if (t(n), r != null && r.length !== 2)
4
- throw new Error("tensor2d() requires shape to have two numbers");
5
- const e = s(n, o);
6
- if (e.length !== 2 && e.length !== 1)
7
- throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray");
8
- if (e.length === 1 && r == null)
9
- throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray");
10
- return a(n, r, e, o);
11
- }
12
- export {
13
- i as t
14
- };
@@ -1,14 +0,0 @@
1
- import { W as t, X as a, Y as s } from "./index-CUXkjxiT.js";
2
- function i(n, r, o) {
3
- if (t(n), r != null && r.length !== 4)
4
- throw new Error("tensor4d() requires shape to have four numbers");
5
- const e = a(n, o);
6
- if (e.length !== 4 && e.length !== 1)
7
- throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray");
8
- if (e.length === 1 && r == null)
9
- throw new Error("tensor4d() requires shape to be provided when `values` are a flat array");
10
- return s(n, r, e, o);
11
- }
12
- export {
13
- i as t
14
- };