@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,525 +0,0 @@
1
- import { ad as z, ac as F, ab as E, a9 as j, x as A } from "./index-CUXkjxiT.js";
2
- function L(t, s) {
3
- if (Math.max(...t) > 5)
4
- throw new Error("Cannot symbolically compute strides for rank > 6 tensor.");
5
- const e = t.length, o = "xyzwuv", i = t.map((n) => `${s}.${o[n]}`), u = new Array(e - 1);
6
- u[e - 2] = i[e - 1];
7
- for (let n = e - 3; n >= 0; --n)
8
- u[n] = `(${u[n + 1]} * ${i[n + 1]})`;
9
- return u;
10
- }
11
- const X = (t, s, e) => e === "int32" ? `atomicAdd(${t}, bitcast<i32>(${s}));` : `
12
- {
13
- var oldValue = 0;
14
- loop {
15
- let newValueF32 = bitcast<f32>(oldValue) + (${s});
16
- let newValue = bitcast<i32>(newValueF32);
17
- let res = atomicCompareExchangeWeak(${t}, oldValue, newValue);
18
- if res.exchanged {
19
- break;
20
- }
21
- oldValue = res.old_value;
22
- }
23
- }`;
24
- var w;
25
- (function(t) {
26
- t[t.FROM_PIXELS = 0] = "FROM_PIXELS", t[t.DRAW = 1] = "DRAW";
27
- })(w || (w = {}));
28
- const H = (t, s, e, o, i) => {
29
- const u = { dtype: o.dtype, shape: o.shape }, n = D(e, u, s), r = t.createShaderModule({ code: n, label: s.constructor.name });
30
- let d = E().get("WEBGPU_PRINT_SHADER");
31
- if (d !== "") {
32
- d = d.toLowerCase();
33
- const p = d.split(",");
34
- (d === "all" || p.some((a) => s.shaderKey.toLowerCase().includes(a))) && (console.group(s.shaderKey), console.debug(n), console.groupEnd());
35
- }
36
- return i ? t.createComputePipelineAsync({
37
- compute: { module: r, entryPoint: "_start" },
38
- label: s.constructor.name,
39
- layout: "auto"
40
- }) : t.createComputePipeline({
41
- compute: { module: r, entryPoint: "_start" },
42
- label: s.constructor.name,
43
- layout: "auto"
44
- });
45
- }, h = (t, s = "f32") => {
46
- switch (t) {
47
- case 1:
48
- return `${s}`;
49
- case 2:
50
- return `vec2<${s}>`;
51
- case 3:
52
- return `vec3<${s}>`;
53
- case 4:
54
- return `vec4<${s}>`;
55
- default:
56
- throw new Error(`${t}-component ${s} is not supported.`);
57
- }
58
- };
59
- function g(t) {
60
- if (t <= 1)
61
- return "i32";
62
- if (t === 2)
63
- return "vec2<i32>";
64
- if (t === 3)
65
- return "vec3<i32>";
66
- if (t === 4)
67
- return "vec4<i32>";
68
- if (t === 5)
69
- return "vec5";
70
- if (t === 6)
71
- return "vec6";
72
- throw Error(`GPU for rank ${t} is not yet supported`);
73
- }
74
- function I(t) {
75
- if (t === 0)
76
- return "x";
77
- if (t === 1)
78
- return "y";
79
- if (t === 2)
80
- return "z";
81
- if (t === 3)
82
- return "w";
83
- if (t === 4)
84
- return "u";
85
- if (t === 5)
86
- return "v";
87
- throw Error(`Index ${t} is not yet supported`);
88
- }
89
- function Y(...t) {
90
- let s;
91
- switch (t.length) {
92
- case 0:
93
- s = `
94
- fn main()
95
- `;
96
- break;
97
- case 1:
98
- s = `
99
- fn main(${t[0]} : i32)
100
- `;
101
- break;
102
- default:
103
- throw Error("Unreachable");
104
- }
105
- return s;
106
- }
107
- function C(t, s) {
108
- let e;
109
- return e = `
110
- ${N(s)}
111
- fn _start(@builtin(local_invocation_id) LocalId : vec3<u32>,
112
- @builtin(global_invocation_id) GlobalId : vec3<u32>,
113
- @builtin(local_invocation_index) LocalIndex: u32,
114
- @builtin(workgroup_id) WorkgroupId : vec3<u32>,
115
- ${s.subgroupBuiltins ? "@builtin(subgroup_invocation_id) SubgroupInvocationId : u32," : ""}
116
- ${s.subgroupBuiltins ? "@builtin(subgroup_size) SubgroupSize : u32," : ""}
117
- @builtin(num_workgroups) NumWorkgroups : vec3<u32>) {
118
- localId = LocalId;
119
- localIndex = LocalIndex;
120
- globalId = GlobalId;
121
- numWorkgroups = NumWorkgroups;
122
- workgroupId = WorkgroupId;
123
- ${s.subgroupBuiltins ? "subgroupInvocationId = SubgroupInvocationId" : ""};
124
- ${s.subgroupBuiltins ? "subgroupSize = SubgroupSize" : ""};
125
- ${t ? "main(getGlobalIndex());" : "main();"};
126
- }
127
- `, e;
128
- }
129
- function N(t) {
130
- return `
131
- @compute @workgroup_size(${t.workgroupSize[0]}, ${t.workgroupSize[1]}, ${t.workgroupSize[2]})
132
- `;
133
- }
134
- function D(t, s, e) {
135
- const o = [], i = e.workgroupSize[0] * e.workgroupSize[1] * e.workgroupSize[2];
136
- if (e.outputComponent = e.outputComponent ? e.outputComponent : 1, o.push(`
137
-
138
- var<private> localId: vec3<u32>;
139
- var<private> localIndex: u32;
140
- var<private> globalId: vec3<u32>;
141
- var<private> numWorkgroups: vec3<u32>;
142
- var<private> workgroupId: vec3<u32>;
143
- ${e.subgroupBuiltins ? "var<private> subgroupInvocationId: u32;" : ""}
144
- ${e.subgroupBuiltins ? "var<private> subgroupSize: u32;" : ""}
145
-
146
- // Only used when the y/z dimension of workgroup size is 1.
147
- fn getGlobalIndex() -> i32 {
148
- ${_(e) ? " return i32(globalId.x);" : ` return i32((workgroupId.z * numWorkgroups.x * numWorkgroups.y +
149
- workgroupId.y * numWorkgroups.x + workgroupId.x) * ${i}u +
150
- localIndex);
151
- `}
152
- }
153
- `), e.pixelsOpType != null) {
154
- const c = e.pixelsOpType === w.FROM_PIXELS ? `@group(0) @binding(0) var<storage, read_write> result: array<${b(s.dtype, e.outputComponent)}>;` : `@group(0) @binding(1) var<storage, read> inBuf : array<${b(t[0].dtype, e.outputComponent)}>;`, $ = s.shape.length === 3 ? "vec2<i32>" : "i32";
155
- o.push(`
156
- struct Uniform {
157
- outShapeStrides : ${$},
158
- size : i32,
159
- numChannels : i32,
160
- alpha : f32,
161
- };
162
-
163
- ${c}
164
- @group(0) @binding(2) var<uniform> uniforms: Uniform;
165
- `);
166
- const x = k(e);
167
- return [
168
- m,
169
- o.join(`
170
- `),
171
- y(s.shape),
172
- e.getUserCode(),
173
- C(x, e)
174
- ].join(`
175
- `);
176
- }
177
- let u, n, r = "struct Uniforms { NAN : f32, INFINITY : f32, ";
178
- e.variableNames.forEach((c, $) => {
179
- const x = g(t[$].shape.length);
180
- r += `${c.charAt(0).toLowerCase() + c.slice(1)}Shape : ${x}, `, u = t[$].shape.length - 1, n = g(u), r += `${c.charAt(0).toLowerCase() + c.slice(1)}ShapeStrides: ${n}, `;
181
- });
182
- const d = g(s.shape.length);
183
- r += `outShape : ${d}, `, u = s.shape.length - 1, n = g(u), r += `
184
- outShapeStrides: ${n}, `, e.size && (r += "size : i32, "), e.uniforms && (r += e.uniforms), r += "};", r = V(r), o.push(r), e.atomic ? o.push(`
185
- @group(0) @binding(0) var<storage, read_write> result: array<atomic<i32>>;
186
- `) : o.push(`
187
- @group(0) @binding(0) var<storage, read_write> result: array<${b(s.dtype, e.outputComponent)}>;
188
- `), e.variableNames.forEach((c, $) => {
189
- o.push(`
190
- @group(0) @binding(${1 + $}) var<storage, read> ${c}: array<${e.variableComponents ? b(t[$].dtype, e.variableComponents[$]) : b(t[$].dtype, e.outputComponent)}>;
191
- `);
192
- }), r !== "" && o.push(`
193
- @group(0) @binding(${1 + e.variableNames.length}) var<uniform> uniforms: Uniforms;
194
- `);
195
- const p = P(s.shape, e.dispatchLayout), v = [
196
- e.subgroups ? "enable subgroups;" : "",
197
- m,
198
- o.join(`
199
- `) + T,
200
- y(s.shape),
201
- p,
202
- R(s.shape.length)
203
- ];
204
- e.atomic || v.push(G(s.shape, s.dtype, e.outputComponent)), e.variableNames.forEach((c, $) => {
205
- v.push(`${y(t[$].shape, c)}`);
206
- });
207
- const l = t.map((c, $) => B(c, s.shape, e.variableComponents ? e.variableComponents[$] : e.outputComponent, e.dispatchLayout.x.length === s.shape.length)).join(`
208
- `);
209
- v.push(l), v.push(e.getUserCode());
210
- const f = k(e);
211
- return v.push(C(f, e)), v.join(`
212
- `);
213
- }
214
- function q(t, s, e) {
215
- let o = t.shaderKey;
216
- if (t.pixelsOpType != null)
217
- return o;
218
- const i = [], u = [];
219
- s.forEach((a) => {
220
- i.push(a.shape), u.push(a.dtype);
221
- }), i.push(e.shape), u.push(e.dtype);
222
- const n = s.map((a) => z(a.shape, e.shape)), r = s.map((a) => F(a.shape, e.shape)).join("_"), d = n.map((a) => a.join("_")).join(";"), p = _(t) ? "flatDispatch" : "";
223
- return o += "_" + (t.workgroupSize ? t.workgroupSize.join(",") : "") + i.map((a) => a.length).join(",") + u.join(",") + t.variableNames.join(",") + d + r + p, o;
224
- }
225
- const m = `
226
- struct vec5 {x: i32, y: i32, z: i32, w: i32, u: i32};
227
- struct vec6 {x: i32, y: i32, z: i32, w: i32, u: i32, v: i32};
228
-
229
- // Checks whether coordinates lie within the bounds of the shape.
230
- fn coordsInBounds2D(coord : vec2<i32>, shape : vec2<i32>) -> bool {
231
- return all(coord >= vec2<i32>(0)) && all(coord < shape);
232
- }
233
- fn coordsInBounds3D(coord : vec3<i32>, shape : vec3<i32>) -> bool {
234
- return all(coord >= vec3<i32>(0)) && all(coord < shape);
235
- }
236
- fn coordsInBounds4D(coord : vec4<i32>, shape : vec4<i32>) -> bool {
237
- return all(coord >= vec4<i32>(0)) && all(coord < shape);
238
- }
239
-
240
- fn getIndexFromCoords1D(coord : i32, shape : i32) -> i32 {
241
- return coord;
242
- }
243
- fn getIndexFromCoords2D(coords : vec2<i32>, shape : vec2<i32>) -> i32 {
244
- return dot(coords, vec2<i32>(shape.y, 1));
245
- }
246
- fn getIndexFromCoords3D(coords : vec3<i32>, shape : vec3<i32>) -> i32 {
247
- return dot(coords, vec3<i32>(shape.y * shape.z, shape.z, 1));
248
- }
249
- fn getIndexFromCoords4D(coords : vec4<i32>, shape : vec4<i32>) -> i32 {
250
- return dot(coords, vec4<i32>(
251
- shape.y * shape.z * shape.w, shape.z * shape.w, shape.w, 1));
252
- }
253
- fn getIndexFromCoords5D(coords : vec5, shape : vec5) -> i32 {
254
- let shapeStrides: vec5 = vec5(shape.y * shape.z * shape.w * shape.u, shape.z * shape.w * shape.u, shape.w * shape.u, shape.u, 1);
255
- return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u;
256
- }
257
- fn getIndexFromCoords6D(coords : vec6, shape : vec6) -> i32 {
258
- let shapeStrides: vec6 = vec6(shape.y * shape.z * shape.w * shape.u * shape.v, shape.z * shape.w * shape.u * shape.v, shape.w * shape.u * shape.v, shape.u * shape.v, shape.v, 1);
259
- return coords.x*shapeStrides.x + coords.y*shapeStrides.y + coords.z*shapeStrides.z + coords.w*shapeStrides.w + coords.u*shapeStrides.u + coords.v*shapeStrides.v;
260
- }
261
-
262
- // NaN defination in IEEE 754-1985 is :
263
- // - sign = either 0 or 1.
264
- // - biased exponent = all 1 bits.
265
- // - fraction = anything except all 0 bits (since all 0 bits represents infinity).
266
- // https://en.wikipedia.org/wiki/IEEE_754-1985#Representation_of_non-numbers
267
- fn isnan(val: f32) -> bool {
268
- let floatToUint: u32 = bitcast<u32>(val);
269
- return (floatToUint & 0x7fffffffu) > 0x7f800000u;
270
- }
271
- fn isnanVec4(val : vec4<f32>) -> vec4<bool> {
272
- let floatToUint: vec4<u32> = bitcast<vec4<u32>>(val);
273
- return (floatToUint & vec4<u32>(0x7fffffffu)) > vec4<u32>(0x7f800000u);
274
- }
275
- `, T = `
276
- fn isinf(val: f32) -> bool {
277
- return abs(val) == uniforms.INFINITY;
278
- }
279
- `;
280
- function y(t, s = "") {
281
- const e = t.length, o = s !== "" ? `get${s.charAt(0).toUpperCase() + s.slice(1)}CoordsFromIndex` : "getCoordsFromIndex", i = s !== "" ? `${s.charAt(0).toLowerCase() + s.slice(1)}ShapeStrides` : "outShapeStrides";
282
- if (e <= 1)
283
- return `fn ${o}(index : i32) -> i32 { return index; }`;
284
- const u = j(t), n = g(e), r = [];
285
- for (let p = 0; p < e; p++)
286
- r.push(`d${p}`);
287
- if (u.length === 1)
288
- return ` fn ${o}(index : i32) -> vec2<i32> {
289
- let d0 = index / uniforms.${i}; let d1 = index - d0 * uniforms.${i};
290
- return vec2<i32>(d0, d1);
291
- }`;
292
- let d;
293
- return d = "var index2 = index;" + u.map((p, a) => {
294
- const v = `let ${r[a]} = index2 / uniforms.${i}.${I(a)}`, l = a === u.length - 1 ? `let ${r[a + 1]} = index2 - ${r[a]} * uniforms.${i}.${I(a)}` : `index2 = index2 - ${r[a]} * uniforms.${i}.${I(a)}`;
295
- return `${v}; ${l};`;
296
- }).join(""), `
297
- fn ${o}(index : i32) -> ${n} {
298
- ${d}
299
- return ${n}(${r.join(",")});
300
- }
301
- `;
302
- }
303
- function U(t, s) {
304
- const e = t.name, o = t.shape.length, i = g(o), u = "get" + e.charAt(0).toUpperCase() + e.slice(1), n = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), r = n.map((a) => `${a} : i32`).join(", ");
305
- if (o < 1)
306
- return `
307
- fn ${u}() -> ${h(s)} {
308
- return ${h(s)}(${e}[0]);
309
- }
310
- `;
311
- const d = `uniforms.${e.charAt(0).toLowerCase() + e.slice(1)}Shape`;
312
- let p = `${o}D`;
313
- return o === 0 && (p = "1D"), `
314
- fn ${u}(${r}) -> ${h(s)} {
315
- return ${h(s)}(${e}[getIndexFromCoords${p}(${i}(${n.join(",")}),
316
- ${d})${s === 1 ? "" : ` / ${s}`}]);
317
- }
318
- `;
319
- }
320
- function W(t, s, e, o) {
321
- const i = t.name, u = i.charAt(0).toUpperCase() + i.slice(1), n = "get" + u + "ByOutput", r = t.shape.length, d = s.length, p = g(d);
322
- if (F(t.shape, s) && o)
323
- return `
324
- fn ${n}Index(globalIndex : i32) -> ${h(e)} {
325
- return ${h(e)}(${i}[globalIndex]);
326
- }
327
-
328
- fn ${n}Coords(coords : ${p}) -> ${h(e)} {
329
- return ${h(e)}(${i}[${d > 1 ? "getOutputIndexFromCoords(coords)" : "coords"}${e === 1 ? "" : ` / ${e}`}]);
330
- }
331
- `;
332
- const a = z(t.shape, s), v = d - r;
333
- let l = "";
334
- if (r === 0)
335
- return `
336
- fn ${n}Index(globalIndex : i32) -> ${h(e)}{
337
- return get${u}();
338
- }
339
-
340
- fn ${n}Coords(coords : ${p}) -> ${h(e)}{
341
- return get${u}();
342
- }
343
- `;
344
- d < 2 && a.length >= 1 ? l = "coords = 0;" : l = a.map(($) => `coords.${I($ + v)} = 0;`).join(`
345
- `);
346
- let f = "";
347
- if (d < 2 && r > 0)
348
- f = "coords";
349
- else if (d > 1) {
350
- const $ = g(r), x = t.shape.map((M, O) => `coords.${I(O + v)}`).join(", ");
351
- f = `${$}(${x})`;
352
- } else
353
- f = "coords";
354
- const S = `uniforms.${i.charAt(0).toLowerCase() + i.slice(1)}Shape`, c = `${r}D`;
355
- return `
356
- fn ${n}Index(globalIndex : i32) -> ${h(e)} {
357
- var coords = getCoordsFromIndex(globalIndex);
358
- ${l}
359
- return ${h(e)}(${i}[getIndexFromCoords${c}(${f}, ${S})${e === 1 ? "" : ` / ${e}`}]);
360
- }
361
-
362
- fn ${n}Coords(coordsIn : ${p}) -> ${h(e)} {
363
- var coords = coordsIn;
364
- ${l}
365
- return ${h(e)}(${i}[getIndexFromCoords${c}(${f}, ${S})${e === 1 ? "" : ` / ${e}`}]);
366
- }
367
- `;
368
- }
369
- function B(t, s, e, o) {
370
- let i = U(t, e);
371
- return t.shape.length <= s.length && (i += W(t, s, e, o)), i;
372
- }
373
- function P(t, s) {
374
- const { x: e, y: o = [], z: i = [] } = s, u = t.length, n = e.length + o.length + i.length;
375
- if (n !== u)
376
- return "";
377
- if (e.length === u)
378
- return `fn getOutputCoords() -> ${g(u)}{
379
- let globalIndex = getGlobalIndex();
380
- return getCoordsFromIndex(globalIndex);
381
- }
382
- `;
383
- let r = "";
384
- const d = [e, o, i];
385
- for (let l = 0; l < d.length; l++) {
386
- const f = d[l];
387
- if (f.length !== 0)
388
- if (f.length === 1)
389
- r += `let d${f[0]} = i32(globalId[${l}]);`;
390
- else {
391
- const S = L(f, "uniforms.outShape");
392
- r += `var index${l} = i32(globalId[${l}]);`;
393
- for (let c = 0; c < S.length; c++)
394
- r += `let d${f[c]} = index${l} / ${S[c]};`, c === S.length - 1 ? r += `let d${f[c + 1]} = index${l} - d${f[c]} * ${S[c]};` : r += `index${l} = index${l} - d${f[c]} * ${S[c]};`;
395
- }
396
- }
397
- const p = [];
398
- for (let l = 0; l < n; l++)
399
- p.push(`d${l}`);
400
- const a = g(n);
401
- let v = `fn getOutputCoords() -> ${a} {
402
- ${r}
403
- `;
404
- return p.length === 0 ? v += `return ${a}(0); }` : v += `return ${a}(${p.join(",")}); }`, v;
405
- }
406
- function R(t) {
407
- let s = "";
408
- switch (t) {
409
- case 0:
410
- case 1:
411
- s += `
412
- fn getOutputIndexFromCoords(coords : i32) -> i32 {
413
- return coords;
414
- }
415
- `;
416
- break;
417
- case 2:
418
- s += `
419
- fn getOutputIndexFromCoords(coords : vec2<i32>) -> i32 {
420
- return dot(coords, vec2<i32>(uniforms.outShapeStrides, 1));
421
- }
422
- `;
423
- break;
424
- case 3:
425
- s += `
426
- fn getOutputIndexFromCoords(coords : vec3<i32>) -> i32 {
427
- return dot(coords, vec3<i32>(uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, 1));
428
- }
429
- `;
430
- break;
431
- case 4:
432
- s += `
433
- fn getOutputIndexFromCoords(coords : vec4<i32>) -> i32 {
434
- return dot(coords, vec4<i32>(
435
- uniforms.outShapeStrides.x, uniforms.outShapeStrides.y, uniforms.outShapeStrides.z, 1));
436
- }
437
- `;
438
- break;
439
- case 5:
440
- s += `
441
- fn getOutputIndexFromCoords(coords : vec5) -> i32 {
442
- return coords.x * uniforms.outShapeStrides.x +
443
- coords.y * uniforms.outShapeStrides.y +
444
- coords.z * uniforms.outShapeStrides.z +
445
- coords.w * uniforms.outShapeStrides.w +
446
- coords.u;
447
- }
448
- `;
449
- break;
450
- case 6:
451
- s += `
452
- fn getOutputIndexFromCoords(coords : vec6) -> i32 {
453
- return coords.x * uniforms.outShapeStrides.x +
454
- coords.y * uniforms.outShapeStrides.y +
455
- coords.z * uniforms.outShapeStrides.z +
456
- coords.w * uniforms.outShapeStrides.w +
457
- coords.u * uniforms.outShapeStrides.u +
458
- coords.v;
459
- }
460
- `;
461
- break;
462
- default:
463
- A(!1, () => `Unsupported ${t}D shape`);
464
- break;
465
- }
466
- return s;
467
- }
468
- function _(t) {
469
- return t.dispatch[1] === 1 && t.dispatch[2] === 1;
470
- }
471
- function b(t, s = 1) {
472
- if (t === "float32")
473
- return h(s, "f32");
474
- if (t === "int32" || t === "bool" || t === "packedF16")
475
- return h(s, "i32");
476
- throw new Error(`type ${t} is not supported.`);
477
- }
478
- function G(t, s, e) {
479
- const o = t.length, i = b(s, e);
480
- let u = `fn setOutputAtIndex(flatIndex : i32, value : ${h(e)}) {
481
- result[flatIndex] = ${i}(value);
482
- }
483
-
484
- fn setOutputAtIndexI32(flatIndex : i32, value : ${h(e, "i32")}) {
485
- result[flatIndex] = ${i}(value);
486
- }
487
- `;
488
- if (o >= 2) {
489
- const n = ["d0", "d1", "d2", "d3", "d4", "d5"].slice(0, o), r = g(o);
490
- u += `
491
- fn setOutputAtCoords(${n.map((d) => `${d} : i32`).join(", ")}, value : ${h(e)}) {
492
- let flatIndex = getOutputIndexFromCoords(${r}(${n.join(", ")}));
493
- setOutputAtIndex(flatIndex${e === 1 ? "" : ` / ${e}`}, value);
494
- }
495
- fn setOutputAtCoordsI32(${n.map((d) => `${d} : i32`).join(", ")}, value : ${h(e, "i32")}) {
496
- let flatIndex = getOutputIndexFromCoords(${r}(${n.join(", ")}));
497
- setOutputAtIndexI32(flatIndex${e === 1 ? "" : ` / ${e}`}, value);
498
- }
499
- `;
500
- }
501
- return u;
502
- }
503
- function V(t) {
504
- const s = /(\w+)\s*:\s*vec(5|6)/g;
505
- t = t.replace(s, (o) => "@align(16) " + o);
506
- const e = /vec(5|6)\s*,\s*(\w+)/g;
507
- return t = t.replace(e, (o, i, u) => `vec${i}, @align(16) ${u}`), t;
508
- }
509
- function k(t) {
510
- return !(t.dispatchLayout.hasOwnProperty("y") && t.dispatchLayout.y.length !== 0 || t.dispatchLayout.hasOwnProperty("z") && t.dispatchLayout.z.length !== 0);
511
- }
512
- export {
513
- w as P,
514
- y as a,
515
- g as b,
516
- I as c,
517
- b as d,
518
- Y as e,
519
- H as f,
520
- N as g,
521
- X as h,
522
- q as m,
523
- L as s,
524
- h as t
525
- };
@@ -1,64 +0,0 @@
1
- import { x as u } from "./index-CUXkjxiT.js";
2
- const c = (r) => {
3
- let t = 1;
4
- for (let n = 0; n < r.length; n++)
5
- t *= r[n];
6
- return t;
7
- };
8
- function m(r, t, n = [1, 1, 1], a = [1, 1, 1]) {
9
- const [o, i, f] = [
10
- Math.ceil(c(r.x.map((e) => t[e])) / (n[0] * a[0])),
11
- r.y ? Math.ceil(c(r.y.map((e) => t[e])) / (n[1] * a[1])) : 1,
12
- r.z ? Math.ceil(c(r.z.map((e) => t[e])) / (n[2] * a[2])) : 1
13
- ];
14
- return [o, i, f];
15
- }
16
- function d(r, t, n, a = !1) {
17
- const o = [8, 8, 1], i = [4, 4, 1];
18
- return a || (r <= 8 && (i[1] = 1), t <= 16 && n <= 16 && (o[0] = 4)), { workgroupSize: o, elementsPerThread: i };
19
- }
20
- function p(r, t, n = !1) {
21
- if (n)
22
- return [8, 8, 1];
23
- const a = c(r.x.map((i) => t[i])), o = c(r.y.map((i) => t[i]));
24
- return a <= 4 ? [4, 16, 1] : o <= 4 ? [16, 4, 1] : [16, 16, 1];
25
- }
26
- function x(r, t, n = !1) {
27
- if (n)
28
- return [4, 4, 1];
29
- const a = c(r.x.map((i) => t[i])), o = c(r.y.map((i) => t[i]));
30
- return a <= 4 ? [1, 2, 1] : o <= 4 ? [2, 1, 1] : [2, 2, 1];
31
- }
32
- function M(r) {
33
- return { x: r.map((t, n) => n) };
34
- }
35
- function h(r) {
36
- if (r === "float32" || r === "int32" || r === "bool" || r === "string" || r === "packedF16")
37
- return 4;
38
- if (r === "complex64")
39
- return 8;
40
- throw new Error(`Unknown dtype ${r}`);
41
- }
42
- function g() {
43
- return !!(typeof globalThis < "u" && globalThis.navigator && globalThis.navigator.gpu);
44
- }
45
- function b(r, t) {
46
- Array.isArray(r) || (r = [r]), r.forEach((n) => {
47
- n != null && u(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGPU backend.`);
48
- });
49
- }
50
- var s;
51
- (function(r) {
52
- r[r.MatMulReduceProgram = 0] = "MatMulReduceProgram", r[r.MatMulSplitKProgram = 1] = "MatMulSplitKProgram", r[r.MatMulSmallOutputSizeProgram = 2] = "MatMulSmallOutputSizeProgram", r[r.MatMulPackedProgram = 3] = "MatMulPackedProgram", r[r.MatMulMax = 4] = "MatMulMax";
53
- })(s || (s = {}));
54
- export {
55
- h as G,
56
- s as M,
57
- d as a,
58
- b,
59
- m as c,
60
- p as d,
61
- x as e,
62
- M as f,
63
- g as i
64
- };
@@ -1,13 +0,0 @@
1
- import { u as n, Q as m, U as i, E as c } from "./index-CUXkjxiT.js";
2
- import { c as f } from "./complex-DI35Q-gW.js";
3
- function e(o, r = "float32") {
4
- if (n(o), r === "complex64") {
5
- const s = e(o, "float32"), t = e(o, "float32");
6
- return f(s, t);
7
- }
8
- const a = m(i(o), r);
9
- return c.makeTensor(a, o, r);
10
- }
11
- export {
12
- e as z
13
- };