@genai-fi/nanogpt 1.4.1 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/dist/{DatasetBuilder-DU1G1OKX.js → DatasetBuilder-DRDW8tcM.js} +85 -86
  2. package/dist/Generator-BcR_14Cj.js +316 -0
  3. package/dist/{RealDiv-CSnvtN2E.js → RealDiv-Cl8k3YTx.js} +54 -62
  4. package/dist/{Reshape-BlylqwWy.js → Reshape-CKxKPKqi.js} +9 -12
  5. package/dist/Reshape-H5zZRgr9.js +16 -0
  6. package/dist/RoPECache-dYscFINl.js +722 -0
  7. package/dist/TeachableLLM.js +29 -34
  8. package/dist/api/beamer.d.ts +1 -0
  9. package/dist/api/beamer.js +19 -10
  10. package/dist/api/responses.js +11 -12
  11. package/dist/api/training.js +12 -14
  12. package/dist/axis_util-rF9RnwKE.js +37 -0
  13. package/dist/backend.js +5 -6
  14. package/dist/{backend_util-DAV0I34P.js → backend_util-Cpp0Gwlp.js} +180 -185
  15. package/dist/{binary_op_util-CrYk9LXL.js → binary_op_util-WY9YIl0q.js} +3 -7
  16. package/dist/broadcast_to-CGvLNiQ0.js +20 -0
  17. package/dist/checks/appendCache.js +7 -7
  18. package/dist/checks/attentionMask.js +9 -8
  19. package/dist/checks/check.js +1 -2
  20. package/dist/checks/gelu.js +6 -6
  21. package/dist/checks/index.js +24 -25
  22. package/dist/checks/matMulGelu.js +7 -7
  23. package/dist/checks/normRMS.js +14 -12
  24. package/dist/checks/normRMSGrad.js +9 -8
  25. package/dist/checks/packUnpack.js +7 -7
  26. package/dist/checks/qkv.js +1 -34
  27. package/dist/checks/rope.js +6 -6
  28. package/dist/checks/weights.js +1 -2
  29. package/dist/clip_by_value-D-UX9am5.js +13 -0
  30. package/dist/complex-Cl904TqN.js +13 -0
  31. package/dist/{complex_util-CkazZsaH.js → complex_util-BBlPAm-s.js} +1 -2
  32. package/dist/concat-Oip5acVY.js +14 -0
  33. package/dist/{concat_util-CWzvQQlK.js → concat_util-CY45Hf4F.js} +2 -3
  34. package/dist/data/docx.js +3 -4
  35. package/dist/data/pdf.js +11 -14
  36. package/dist/data/stream.js +1 -2
  37. package/dist/data/textLoader.js +16 -15
  38. package/dist/data-CV_i_H6B.js +11 -0
  39. package/dist/data.js +5 -12
  40. package/dist/dist-CMMLi-qO.js +2675 -0
  41. package/dist/{dist-BGVm64AY.js → dist-DeVH1nGn.js} +1465 -1573
  42. package/dist/{dist-CwK5S7Ls.js → dist-DyL7qSLJ.js} +2664 -2400
  43. package/dist/dropout16-CA31Ud5a.js +20 -0
  44. package/dist/dropout_util-SiFMbFXz.js +22 -0
  45. package/dist/{eventemitter3-D_qV3Lof.js → eventemitter3-wmfmOP_f.js} +2 -3
  46. package/dist/expand_dims-Dh3Fulyn.js +10 -0
  47. package/dist/floor-BwjmUb7X.js +8 -0
  48. package/dist/gather-B5Z1RFt5.js +14 -0
  49. package/dist/gatherSub-CRUfUzBa.js +22 -0
  50. package/dist/gelu-Xx9-ohH9.js +25 -0
  51. package/dist/{gpgpu_math-20tPK8LM.js → gpgpu_math-48m8q3jI.js} +265 -286
  52. package/dist/inference/Beamer.d.ts +14 -2
  53. package/dist/inference/Beamer.js +170 -105
  54. package/dist/inference/Generator.js +1 -259
  55. package/dist/inference/tokenisePrompt.d.ts +2 -1
  56. package/dist/inference/tokenisePrompt.js +15 -11
  57. package/dist/inference/types.d.ts +7 -0
  58. package/dist/inference/utilities.js +1 -2
  59. package/dist/{jszip.min-DKa1Rjyn.js → jszip.min-Btv48m44.js} +68 -64
  60. package/dist/{kernel_funcs_utils-ql8Y8qPn.js → kernel_funcs_utils-BYRpSfV_.js} +39 -42
  61. package/dist/layers/BaseLayer.js +9 -10
  62. package/dist/layers/{CausalSelfAttention.d.ts → GQA.d.ts} +8 -3
  63. package/dist/layers/GQA.js +102 -0
  64. package/dist/layers/HeadLayer.d.ts +12 -0
  65. package/dist/layers/HeadLayer.js +28 -0
  66. package/dist/layers/LoRA.js +17 -20
  67. package/dist/layers/MHA.d.ts +43 -0
  68. package/dist/layers/MHA.js +102 -0
  69. package/dist/layers/MLP.d.ts +5 -1
  70. package/dist/layers/MLP.js +33 -20
  71. package/dist/layers/PositionEmbedding.js +14 -13
  72. package/dist/layers/RMSNorm.d.ts +2 -0
  73. package/dist/layers/RMSNorm.js +16 -11
  74. package/dist/layers/RoPECache.js +1 -337
  75. package/dist/layers/TiedEmbedding.js +15 -14
  76. package/dist/layers/TransformerBlock.d.ts +4 -10
  77. package/dist/layers/TransformerBlock.js +29 -30
  78. package/dist/layers/WeightStore.js +4 -5
  79. package/dist/layers-CFqEip3s.js +13 -0
  80. package/dist/layers.d.ts +1 -1
  81. package/dist/layers.js +4 -12
  82. package/dist/loader/load.js +27 -24
  83. package/dist/loader/loadHF.js +3 -3
  84. package/dist/loader/loadTransformers.js +22 -7
  85. package/dist/loader/loadZipMeta.js +1 -2
  86. package/dist/loader/newZipLoad.js +1 -2
  87. package/dist/loader/oldZipLoad.js +8 -9
  88. package/dist/loader/save.js +31 -17
  89. package/dist/loader/types.d.ts +8 -2
  90. package/dist/main.js +3281 -3463
  91. package/dist/matMul16-tE26fnhf.js +87 -0
  92. package/dist/{matMulGelu-CBoqTZM7.js → matMulGelu-ASUWlKqu.js} +33 -33
  93. package/dist/mat_mul-R9_DWmIT.js +16 -0
  94. package/dist/models/Llama.d.ts +16 -0
  95. package/dist/models/Llama.js +88 -0
  96. package/dist/models/NanoGPTV1.js +53 -54
  97. package/dist/models/NanoGPTV2.js +48 -49
  98. package/dist/models/Qwen3.d.ts +16 -0
  99. package/dist/models/Qwen3.js +88 -0
  100. package/dist/models/config.d.ts +18 -1
  101. package/dist/models/config.js +3 -8
  102. package/dist/models/factory.js +14 -11
  103. package/dist/models/model.d.ts +5 -7
  104. package/dist/models/model.js +1 -2
  105. package/dist/models-DyBpJJwM.js +13 -0
  106. package/dist/models.js +6 -14
  107. package/dist/mul16-C7sqgqik.js +41 -0
  108. package/dist/non_max_suppression_impl-B0H318rb.js +72 -0
  109. package/dist/not_equal-Bu3O8rh_.js +67 -0
  110. package/dist/one_hot-TEMPumJj.js +14 -0
  111. package/dist/ones-DpPXWa6A.js +13 -0
  112. package/dist/ops/adamAdjust.js +2 -3
  113. package/dist/ops/adamMoments.js +2 -3
  114. package/dist/ops/add16.js +2 -3
  115. package/dist/ops/appendCache.js +9 -8
  116. package/dist/ops/attentionMask.d.ts +1 -1
  117. package/dist/ops/attentionMask.js +8 -5
  118. package/dist/ops/concat16.js +5 -5
  119. package/dist/ops/cpu/adamAdjust.js +7 -8
  120. package/dist/ops/cpu/adamMoments.js +5 -5
  121. package/dist/ops/cpu/appendCache.js +3 -3
  122. package/dist/ops/cpu/attentionMask.js +12 -8
  123. package/dist/ops/cpu/fusedSoftmax.js +3 -3
  124. package/dist/ops/cpu/gatherSub.js +1 -12
  125. package/dist/ops/cpu/gelu.js +12 -13
  126. package/dist/ops/cpu/matMul16.js +7 -7
  127. package/dist/ops/cpu/matMulGelu.js +21 -18
  128. package/dist/ops/cpu/matMulMul.js +8 -9
  129. package/dist/ops/cpu/mulDropout.js +8 -9
  130. package/dist/ops/cpu/normRMS.js +12 -13
  131. package/dist/ops/cpu/qkv.js +14 -13
  132. package/dist/ops/cpu/rope.js +11 -8
  133. package/dist/ops/cpu/scatterSub.js +1 -12
  134. package/dist/ops/dot16.js +16 -17
  135. package/dist/ops/dropout.js +9 -8
  136. package/dist/ops/dropout16.js +1 -22
  137. package/dist/ops/gatherSub.js +3 -4
  138. package/dist/ops/gelu.js +1 -2
  139. package/dist/ops/globalNorm.js +14 -14
  140. package/dist/ops/grads/add16.js +16 -17
  141. package/dist/ops/grads/attentionMask.js +6 -7
  142. package/dist/ops/grads/dropout16.js +1 -1
  143. package/dist/ops/grads/gelu.js +1 -2
  144. package/dist/ops/grads/matMul16.js +1 -2
  145. package/dist/ops/grads/matMulGelu.js +6 -7
  146. package/dist/ops/grads/mul16.js +1 -1
  147. package/dist/ops/grads/normRMS.js +8 -9
  148. package/dist/ops/grads/pack16.js +1 -2
  149. package/dist/ops/grads/qkv.js +10 -10
  150. package/dist/ops/grads/rope.js +1 -2
  151. package/dist/ops/grads/silu.d.ts +2 -0
  152. package/dist/ops/grads/silu.js +1 -0
  153. package/dist/ops/grads/softmax16.js +6 -7
  154. package/dist/ops/grads/unpack16.js +1 -2
  155. package/dist/ops/grads/utils.js +1 -2
  156. package/dist/ops/matMul16.d.ts +2 -2
  157. package/dist/ops/matMul16.js +1 -2
  158. package/dist/ops/matMulGelu.js +3 -4
  159. package/dist/ops/matMulMul.js +2 -3
  160. package/dist/ops/mul16.js +1 -43
  161. package/dist/ops/mulDrop.js +2 -3
  162. package/dist/ops/normRMS.d.ts +1 -1
  163. package/dist/ops/normRMS.js +10 -11
  164. package/dist/ops/pack16.js +1 -2
  165. package/dist/ops/qkv.js +2 -3
  166. package/dist/ops/reshape16.js +11 -11
  167. package/dist/ops/rope.d.ts +1 -1
  168. package/dist/ops/rope.js +1 -2
  169. package/dist/ops/scatterSub.js +3 -4
  170. package/dist/ops/silu.d.ts +3 -0
  171. package/dist/ops/silu.js +1 -0
  172. package/dist/ops/slice16.js +5 -5
  173. package/dist/ops/softmax16.js +3 -4
  174. package/dist/ops/sub16.js +3 -4
  175. package/dist/ops/sum16.js +3 -3
  176. package/dist/ops/transpose16.js +16 -15
  177. package/dist/ops/unpack16.js +1 -2
  178. package/dist/ops/webgl/adamAdjust.js +8 -9
  179. package/dist/ops/webgl/adamMoments.js +2 -3
  180. package/dist/ops/webgl/appendCache.js +2 -3
  181. package/dist/ops/webgl/attentionMask.js +2 -3
  182. package/dist/ops/webgl/dropout16.js +2 -3
  183. package/dist/ops/webgl/fusedSoftmax.js +13 -13
  184. package/dist/ops/webgl/gatherSub.js +2 -3
  185. package/dist/ops/webgl/gelu.js +11 -12
  186. package/dist/ops/webgl/log.js +10 -10
  187. package/dist/ops/webgl/matMul16.js +31 -24
  188. package/dist/ops/webgl/matMulGelu.js +1 -2
  189. package/dist/ops/webgl/matMulMul.js +3 -4
  190. package/dist/ops/webgl/mulDropout.js +2 -3
  191. package/dist/ops/webgl/normRMS.js +11 -10
  192. package/dist/ops/webgl/qkv.js +2 -3
  193. package/dist/ops/webgl/rope.js +10 -9
  194. package/dist/ops/webgl/scatterSub.js +2 -3
  195. package/dist/ops/webgpu/adamAdjust.js +13 -14
  196. package/dist/ops/webgpu/adamMoments.js +13 -14
  197. package/dist/ops/webgpu/add16.js +3 -4
  198. package/dist/ops/webgpu/appendCache.js +20 -21
  199. package/dist/ops/webgpu/attentionMask.js +18 -19
  200. package/dist/ops/webgpu/attentionMask32_program.js +7 -8
  201. package/dist/ops/webgpu/clipScale.js +11 -12
  202. package/dist/ops/webgpu/concat16.js +17 -18
  203. package/dist/ops/webgpu/dropout16.js +6 -7
  204. package/dist/ops/webgpu/gatherSub.js +11 -12
  205. package/dist/ops/webgpu/gelu.js +10 -11
  206. package/dist/ops/webgpu/index.js +17 -16
  207. package/dist/ops/webgpu/matMul16.js +74 -57
  208. package/dist/ops/webgpu/matMul16_program.d.ts +4 -3
  209. package/dist/ops/webgpu/matMul16_program.js +30 -22
  210. package/dist/ops/webgpu/mul16.js +3 -4
  211. package/dist/ops/webgpu/norm2.js +9 -10
  212. package/dist/ops/webgpu/normRMS.js +13 -14
  213. package/dist/ops/webgpu/normRMS16_program.d.ts +2 -1
  214. package/dist/ops/webgpu/normRMS16_program.js +5 -5
  215. package/dist/ops/webgpu/normRMS32_program.d.ts +2 -1
  216. package/dist/ops/webgpu/normRMS32_program.js +5 -5
  217. package/dist/ops/webgpu/normRMSGrad.js +30 -30
  218. package/dist/ops/webgpu/pack16.js +2 -3
  219. package/dist/ops/webgpu/pack16_program.js +3 -4
  220. package/dist/ops/webgpu/qkv.js +10 -11
  221. package/dist/ops/webgpu/rope.js +113 -49
  222. package/dist/ops/webgpu/scatterSub.js +12 -13
  223. package/dist/ops/webgpu/silu.d.ts +14 -0
  224. package/dist/ops/webgpu/silu.js +117 -0
  225. package/dist/ops/webgpu/slice16.js +17 -18
  226. package/dist/ops/webgpu/softmax16.js +9 -9
  227. package/dist/ops/webgpu/softmax16_program.js +9 -10
  228. package/dist/ops/webgpu/softmax16_subgroup_program.js +11 -12
  229. package/dist/ops/webgpu/softmax16grad.js +8 -9
  230. package/dist/ops/webgpu/sub16.js +3 -4
  231. package/dist/ops/webgpu/sum16.js +16 -15
  232. package/dist/ops/webgpu/transpose16.js +13 -12
  233. package/dist/ops/webgpu/transpose16_program.js +3 -4
  234. package/dist/ops/webgpu/transpose16_shared_program.js +17 -18
  235. package/dist/ops/webgpu/unpack16.js +8 -9
  236. package/dist/ops/webgpu/utils/binary_op.js +20 -21
  237. package/dist/ops/webgpu/utils/deviceInfo.js +1 -2
  238. package/dist/ops/webgpu/utils/reductions.js +21 -20
  239. package/dist/ops-Be5ACU5R.js +13 -0
  240. package/dist/ops-C1UpdEYM.js +509 -0
  241. package/dist/{pack16-BhuXNUS7.js → pack16-BHO4t1-M.js} +14 -17
  242. package/dist/pad-Dy-1IP3A.js +13 -0
  243. package/dist/patches/webgpu_backend.js +18 -19
  244. package/dist/patches/webgpu_base.js +2 -3
  245. package/dist/patches/webgpu_program.js +21 -22
  246. package/dist/{pdf-Bzuk68Vy.js → pdf-CbnQ75VG.js} +380 -701
  247. package/dist/{picomatch-BO4HbNfo.js → picomatch--TW6gyBJ.js} +229 -291
  248. package/dist/qkv-BQfNPucX.js +42 -0
  249. package/dist/rand_util-_vCY93Uw.js +44 -0
  250. package/dist/random_normal-DUIT8kyC.js +11 -0
  251. package/dist/range-CYvQC3fW.js +13 -0
  252. package/dist/relu-C4XULT8A.js +8 -0
  253. package/dist/reshape-DJb1jgMt.js +8 -0
  254. package/dist/resize_nearest_neighbor-DAqcTYUe.js +188 -0
  255. package/dist/{chunk-CWhphoD1.js → rolldown-runtime-CwxnZyOB.js} +4 -5
  256. package/dist/rope-JjBVufF_.js +24 -0
  257. package/dist/scatterSub-BOnqk-uY.js +27 -0
  258. package/dist/scatter_nd_util-BepMCpLY.js +34 -0
  259. package/dist/seedrandom-SHEGFK6H.js +282 -0
  260. package/dist/selu_util-DeOTf-sc.js +27 -0
  261. package/dist/shared-BIDMUBCs.js +1864 -0
  262. package/dist/{shared-CfTzpULd.js → shared-CX_iPI5K.js} +2 -3
  263. package/dist/silu-DsAE2cJ5.js +23 -0
  264. package/dist/slice-Dlb1FlzG.js +13 -0
  265. package/dist/{slice_util-Dve4TkDn.js → slice_util-BVgPRoij.js} +3 -4
  266. package/dist/softmax-Dpav_dWw.js +10 -0
  267. package/dist/split-DYnT8chz.js +11 -0
  268. package/dist/squeeze-B3XYGAlg.js +9 -0
  269. package/dist/stack-Dbbt9mIk.js +10 -0
  270. package/dist/step-DA-5DNu9.js +348 -0
  271. package/dist/{stream-BpAwcvHz.js → stream-BBe2apn4.js} +68 -88
  272. package/dist/sum-C8qNbFNp.js +13 -0
  273. package/dist/tensor-ALxWZfmz.js +7 -0
  274. package/dist/tensor1d-BHgkkhTE.js +9 -0
  275. package/dist/tensor2d-ARItvqVn.js +10 -0
  276. package/dist/tensor4d-D1zRBipJ.js +10 -0
  277. package/dist/tfjs_backend-CsXOum0h.js +685 -0
  278. package/dist/tile-DfyQ0KX-.js +10 -0
  279. package/dist/tokenise-DbS2Ea-T.js +14 -0
  280. package/dist/tokenise.js +6 -15
  281. package/dist/tokeniser/BaseTokeniser.js +5 -9
  282. package/dist/tokeniser/CharTokeniser.js +1 -2
  283. package/dist/tokeniser/bpe.js +19 -20
  284. package/dist/topk-BrU2pkrR.js +19 -0
  285. package/dist/training/AdamW.js +35 -31
  286. package/dist/training/BasicTrainer.js +56 -56
  287. package/dist/training/DatasetBuilder.js +1 -2
  288. package/dist/training/Evaluator.js +8 -5
  289. package/dist/training/LRScheduler.js +1 -2
  290. package/dist/training/PreTrainer.js +7 -8
  291. package/dist/training/SFTTrainer.js +7 -8
  292. package/dist/training/configure.js +16 -15
  293. package/dist/training/factory.js +1 -2
  294. package/dist/training/loss.js +1 -2
  295. package/dist/training/orthoGrad.js +2 -3
  296. package/dist/training/prepareData.js +18 -17
  297. package/dist/training/sparseCrossEntropy.js +38 -32
  298. package/dist/training/tasks/TokenStore.js +21 -22
  299. package/dist/training/tasks/tokenStream.js +1 -2
  300. package/dist/training/validateOptions.js +1 -2
  301. package/dist/training/validation.js +1 -2
  302. package/dist/transpose-BC-M_OoT.js +34 -0
  303. package/dist/unsorted_segment_sum-BelC7R-q.js +408 -0
  304. package/dist/utilities/arrayClose.js +5 -4
  305. package/dist/utilities/arrayShape.js +1 -2
  306. package/dist/utilities/datasetID.js +1 -2
  307. package/dist/utilities/dummy.js +15 -15
  308. package/dist/utilities/float16.js +10 -10
  309. package/dist/utilities/maxHeap.d.ts +16 -0
  310. package/dist/utilities/maxHeap.js +54 -0
  311. package/dist/utilities/multinomialCPU.d.ts +1 -2
  312. package/dist/utilities/multinomialCPU.js +6 -8
  313. package/dist/utilities/packed.js +2 -3
  314. package/dist/utilities/parameters.js +34 -19
  315. package/dist/utilities/performance.js +2 -3
  316. package/dist/utilities/profile.js +3 -4
  317. package/dist/utilities/random.js +1 -2
  318. package/dist/utilities/safetensors.js +14 -14
  319. package/dist/utilities/sentences.js +16 -13
  320. package/dist/utilities/tokenParse.js +1 -2
  321. package/dist/utilities/tokens.js +5 -6
  322. package/dist/utilities/topP.d.ts +1 -0
  323. package/dist/utilities/topP.js +20 -13
  324. package/dist/utilities/waitForModel.js +1 -2
  325. package/dist/utilities/weights.js +4 -4
  326. package/dist/utilities/yielder.js +1 -2
  327. package/dist/{v4-BK7K-jy_.js → v4-YCkfo8OR.js} +4 -7
  328. package/dist/{webgpu-IAn9VotJ.js → webgpu-BHX-uBym.js} +156 -163
  329. package/dist/{webgpu_program-B0PokuRJ.js → webgpu_program-DvkFqRlR.js} +28 -29
  330. package/dist/{webgpu_util-DfODg6XI.js → webgpu_util-5QTyovaf.js} +2 -3
  331. package/dist/zeros-hxKGkRfl.js +12 -0
  332. package/package.json +3 -3
  333. package/dist/Reshape-CwxdaU8n.js +0 -17
  334. package/dist/dist-Da20xy8E.js +0 -6375
  335. package/dist/gelu-B6637MKa.js +0 -27
  336. package/dist/layers/CausalSelfAttention.js +0 -99
  337. package/dist/matMul16-DGtlziMn.js +0 -81
  338. package/dist/rope-C8EAiSGY.js +0 -25
  339. package/dist/selu_util-B_AFEfoz.js +0 -24
  340. package/dist/shared-24EoeHJl.js +0 -1314
  341. package/dist/tfjs_backend-h5weiy1O.js +0 -614
@@ -1,14 +1,14 @@
1
- import { Ln as e, Ms as t, Ns as n, Ps as r, Rs as i, cc as a, ic as o, oc as s, sc as c, tc as l } from "./dist-Da20xy8E.js";
2
- import { t as u } from "./backend_util-DAV0I34P.js";
3
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/glsl_version.js
1
+ import { Gi as e, Hi as t, Ji as n, Ti as r, Yi as i, _i as a, qi as o, vi as s, w as c, yi as l } from "./dist-CMMLi-qO.js";
2
+ import { t as u } from "./backend_util-Cpp0Gwlp.js";
3
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/glsl_version.js
4
4
  function d() {
5
- let e, n, r, i, a, o, s, c, l, u;
6
- return t().getNumber("WEBGL_VERSION") === 2 ? (e = "#version 300 es", n = "in", r = "out", i = "in", a = "texture", o = "outputColor", s = "out vec4 outputColor;", c = t().getBool("WEBGL2_ISNAN_CUSTOM") ? "\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n " : "", l = "", u = "\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n ") : (e = "", n = "attribute", r = "varying", i = "varying", a = "texture2D", o = "gl_FragColor", s = "", c = "\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ", l = "\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ", u = "\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "), {
5
+ let e, t, n, r, i, o, s, c, l, u;
6
+ return a().getNumber("WEBGL_VERSION") === 2 ? (e = "#version 300 es", t = "in", n = "out", r = "in", i = "texture", o = "outputColor", s = "out vec4 outputColor;", c = a().getBool("WEBGL2_ISNAN_CUSTOM") ? "\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n " : "", l = "", u = "\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n ") : (e = "", t = "attribute", n = "varying", r = "varying", i = "texture2D", o = "gl_FragColor", s = "", c = "\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ", l = "\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ", u = "\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "), {
7
7
  version: e,
8
- attribute: n,
9
- varyingVs: r,
10
- varyingFs: i,
11
- texture2D: a,
8
+ attribute: t,
9
+ varyingVs: n,
10
+ varyingFs: r,
11
+ texture2D: i,
12
12
  output: o,
13
13
  defineOutput: s,
14
14
  defineSpecialNaN: c,
@@ -16,15 +16,14 @@ function d() {
16
16
  defineRound: u
17
17
  };
18
18
  }
19
- //#endregion
20
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/shader_compiler_util.js
19
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/shader_compiler_util.js
21
20
  function f(e, t, n = "index") {
22
- let r = i(t);
23
- return r.map((t, i) => `${`int ${e[i]} = ${n} / ${t}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${t}` : `index -= ${e[i]} * ${t}`};`).join("");
21
+ let i = r(t);
22
+ return i.map((t, r) => `${`int ${e[r]} = ${n} / ${t}`}; ${r === i.length - 1 ? `int ${e[r + 1]} = ${n} - ${e[r]} * ${t}` : `index -= ${e[r]} * ${t}`};`).join("");
24
23
  }
25
24
  function p(e, t, n = "index") {
26
- let r = i(t);
27
- return r.map((t, i) => `${`int ${e[i]} = ${n} / outShapeStrides[${i}]`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * outShapeStrides[${i}]` : `index -= ${e[i]} * outShapeStrides[${i}]`};`).join("");
25
+ let i = r(t);
26
+ return i.map((t, r) => `${`int ${e[r]} = ${n} / outShapeStrides[${r}]`}; ${r === i.length - 1 ? `int ${e[r + 1]} = ${n} - ${e[r]} * outShapeStrides[${r}]` : `index -= ${e[r]} * outShapeStrides[${r}]`};`).join("");
28
27
  }
29
28
  function m(e, t) {
30
29
  let n = e.length, r = e.map((e) => `${t}[${e}]`), i = Array(n - 1);
@@ -37,7 +36,7 @@ function h(e, t, n = "index") {
37
36
  return r.map((t, i) => `${`int ${e[i]} = ${n} / ${r[i]}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${r[i]}` : `index -= ${e[i]} * ${r[i]}`};`).join("");
38
37
  }
39
38
  function g(e) {
40
- let t = i(e).map((e) => e.toString());
39
+ let t = r(e).map((e) => e.toString());
41
40
  return `
42
41
  int getFlatIndex(ivec3 coords) {
43
42
  return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;
@@ -51,7 +50,7 @@ var v = "\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1
51
50
  function b(e, t, n) {
52
51
  let r = [];
53
52
  if (e.forEach((e) => {
54
- let t = s(e.shapeInfo.logicalShape);
53
+ let t = o(e.shapeInfo.logicalShape);
55
54
  if (e.shapeInfo.isUniform ? r.push(`uniform float ${e.name}${t > 1 ? `[${t}]` : ""};`) : (r.push(`uniform sampler2D ${e.name};`), r.push(`uniform int offset${e.name};`)), n.enableShapeUniforms) {
56
55
  let { uniformShape: t } = A(n.packedInputs, e.shapeInfo.logicalShape, e.shapeInfo.texShape);
57
56
  switch (t.length) {
@@ -64,10 +63,7 @@ function b(e, t, n) {
64
63
  case 3:
65
64
  r.push(`uniform ivec3 ${e.name}Shape;`);
66
65
  break;
67
- case 4:
68
- r.push(`uniform ivec4 ${e.name}Shape;`);
69
- break;
70
- default: break;
66
+ case 4: r.push(`uniform ivec4 ${e.name}Shape;`);
71
67
  }
72
68
  r.push(`uniform ivec2 ${e.name}TexShape;`);
73
69
  }
@@ -82,18 +78,15 @@ function b(e, t, n) {
82
78
  case 3:
83
79
  r.push("uniform ivec3 outShape;"), r.push("uniform ivec2 outShapeStrides;");
84
80
  break;
85
- case 4:
86
- r.push("uniform ivec4 outShape;"), r.push("uniform ivec3 outShapeStrides;");
87
- break;
88
- default: break;
81
+ case 4: r.push("uniform ivec4 outShape;"), r.push("uniform ivec3 outShapeStrides;");
89
82
  }
90
83
  r.push("uniform ivec2 outTexShape;");
91
84
  }
92
85
  n.customUniforms && n.customUniforms.forEach((e) => {
93
86
  r.push(`uniform ${e.type} ${e.name}${e.arrayIndex ? `[${e.arrayIndex}]` : ""};`);
94
87
  });
95
- let i = r.join("\n"), a = e.map((e) => ee(e, t, n.packedInputs, n.enableShapeUniforms)).join("\n"), o = t.texShape, c = d(), l = re(c), u, f, p = oe(c);
96
- return t.isPacked ? (u = te(t.logicalShape, o, n.enableShapeUniforms), f = ae(c)) : (u = ne(t.logicalShape, o, n.enableShapeUniforms), f = ie(c)), n.packedInputs && (p += ue), [
88
+ let i = r.join("\n"), a = e.map((e) => ee(e, t, n.packedInputs, n.enableShapeUniforms)).join("\n"), s = t.texShape, c = d(), l = re(c), u, f, p = oe(c);
89
+ return t.isPacked ? (u = te(t.logicalShape, s, n.enableShapeUniforms), f = ae(c)) : (u = ne(t.logicalShape, s, n.enableShapeUniforms), f = ie(c)), n.packedInputs && (p += ue), [
97
90
  p,
98
91
  l,
99
92
  f,
@@ -127,9 +120,9 @@ function S(e, t) {
127
120
  }
128
121
  function ee(e, t, n = !1, r) {
129
122
  let i = "";
130
- n ? i += S(e, r) : i += x(e, r);
123
+ i += n ? S(e, r) : x(e, r);
131
124
  let a = e.shapeInfo.logicalShape, o = t.logicalShape;
132
- return a.length <= o.length && (n ? i += Ae(e, t) : i += je(e, t)), i;
125
+ return a.length <= o.length && (i += n ? Ae(e, t) : je(e, t)), i;
133
126
  }
134
127
  function te(e, t, n) {
135
128
  switch (e.length) {
@@ -421,47 +414,47 @@ function ve(e, t) {
421
414
  }
422
415
  `;
423
416
  }
424
- function ye(e, t, r) {
425
- let i = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
426
- if (n(e, t)) return r ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n " : `
417
+ function ye(e, t, n) {
418
+ let r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)];
419
+ if (s(e, t)) return n ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n " : `
427
420
  ivec2 getOutputCoords() {
428
- return 2 * ivec2(resultUV.yx * vec2(${i[0]}, ${i[1]}));
421
+ return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));
429
422
  }
430
423
  `;
431
- let a = Math.ceil(e[1] / 2);
432
- return r ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n " : `
424
+ let i = Math.ceil(e[1] / 2);
425
+ return n ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n " : `
433
426
  ivec2 getOutputCoords() {
434
427
  ivec2 resTexRC = ivec2(resultUV.yx *
435
- vec2(${i[0]}, ${i[1]}));
428
+ vec2(${r[0]}, ${r[1]}));
436
429
 
437
- int index = resTexRC.x * ${i[1]} + resTexRC.y;
438
- int r = 2 * (index / ${a});
439
- int c = imod(index, ${a}) * 2;
430
+ int index = resTexRC.x * ${r[1]} + resTexRC.y;
431
+ int r = 2 * (index / ${i});
432
+ int c = imod(index, ${i}) * 2;
440
433
 
441
434
  return ivec2(r, c);
442
435
  }
443
436
  `;
444
437
  }
445
- function be(e, t, r) {
446
- return n(e, t) ? r ? "\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n " : `
438
+ function be(e, t, n) {
439
+ return s(e, t) ? n ? "\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n " : `
447
440
  ivec2 getOutputCoords() {
448
441
  return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));
449
442
  }
450
- ` : e[1] === 1 ? r ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n " : `
443
+ ` : e[1] === 1 ? n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n " : `
451
444
  ivec2 getOutputCoords() {
452
445
  ivec2 resTexRC = ivec2(resultUV.yx *
453
446
  vec2(${t[0]}, ${t[1]}));
454
447
  int index = resTexRC.x * ${t[1]} + resTexRC.y;
455
448
  return ivec2(index, 0);
456
449
  }
457
- ` : e[0] === 1 ? r ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n " : `
450
+ ` : e[0] === 1 ? n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n " : `
458
451
  ivec2 getOutputCoords() {
459
452
  ivec2 resTexRC = ivec2(resultUV.yx *
460
453
  vec2(${t[0]}, ${t[1]}));
461
454
  int index = resTexRC.x * ${t[1]} + resTexRC.y;
462
455
  return ivec2(0, index);
463
456
  }
464
- ` : r ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n " : `
457
+ ` : n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n " : `
465
458
  ivec2 getOutputCoords() {
466
459
  ivec2 resTexRC = ivec2(resultUV.yx *
467
460
  vec2(${t[0]}, ${t[1]}));
@@ -573,104 +566,104 @@ function we(e, t) {
573
566
  `;
574
567
  }
575
568
  function Te(e, t) {
576
- let r = e.shapeInfo.logicalShape, i = e.name, a = "get" + i.charAt(0).toUpperCase() + i.slice(1), o = e.shapeInfo.texShape, s = o[0], c = o[1], l = d();
577
- if (o != null && n(r, o)) return t ? `
578
- vec4 ${a}(int row, int col) {
579
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);
569
+ let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = a[0], c = a[1], l = d();
570
+ if (a != null && s(n, a)) return t ? `
571
+ vec4 ${i}(int row, int col) {
572
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
580
573
 
581
- return ${l.texture2D}(${i}, uv);
574
+ return ${l.texture2D}(${r}, uv);
582
575
  }
583
576
  ` : `
584
- vec4 ${a}(int row, int col) {
585
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${s}.0);
577
+ vec4 ${i}(int row, int col) {
578
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${c}.0, ${o}.0);
586
579
 
587
- return ${l.texture2D}(${i}, uv);
580
+ return ${l.texture2D}(${r}, uv);
588
581
  }
589
582
  `;
590
583
  if (t) return `
591
- vec4 ${a}(int row, int col) {
592
- ivec2 packedTexShape = ivec2(ceil(float(${i}TexShape[0]) / 2.0), ceil(float(${i}TexShape[1]) / 2.0));
593
- int valuesPerRow = int(ceil(float(${i}Shape[1]) / 2.0));
584
+ vec4 ${i}(int row, int col) {
585
+ ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));
586
+ int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));
594
587
  vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);
595
- return ${l.texture2D}(${i}, uv);
588
+ return ${l.texture2D}(${r}, uv);
596
589
  }
597
590
  `;
598
- let u = [Math.ceil(o[0] / 2), Math.ceil(o[1] / 2)];
591
+ let u = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)];
599
592
  return `
600
- vec4 ${a}(int row, int col) {
601
- vec2 uv = packedUVfrom2D(${Math.ceil(r[1] / 2)}, ${u[0]}, ${u[1]}, row, col);
602
- return ${l.texture2D}(${i}, uv);
593
+ vec4 ${i}(int row, int col) {
594
+ vec2 uv = packedUVfrom2D(${Math.ceil(n[1] / 2)}, ${u[0]}, ${u[1]}, row, col);
595
+ return ${l.texture2D}(${r}, uv);
603
596
  }
604
597
  `;
605
598
  }
606
599
  function Ee(e, t) {
607
- let r = e.shapeInfo.logicalShape, i = e.name, o = "get" + i.charAt(0).toUpperCase() + i.slice(1), s = e.shapeInfo.texShape;
608
- if (s != null && n(r, s)) {
600
+ let n = e.shapeInfo.logicalShape, r = e.name, a = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = e.shapeInfo.texShape;
601
+ if (o != null && s(n, o)) {
609
602
  if (t) return `
610
- float ${o}(int row, int col) {
611
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${i}TexShape[1], ${i}TexShape[0]);
612
- return sampleTexture(${i}, uv);
603
+ float ${a}(int row, int col) {
604
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
605
+ return sampleTexture(${r}, uv);
613
606
  }
614
607
  `;
615
- let e = s[0];
608
+ let e = o[0];
616
609
  return `
617
- float ${o}(int row, int col) {
618
- vec2 uv = (vec2(col, row) + halfCR) / vec2(${s[1]}.0, ${e}.0);
619
- return sampleTexture(${i}, uv);
610
+ float ${a}(int row, int col) {
611
+ vec2 uv = (vec2(col, row) + halfCR) / vec2(${o[1]}.0, ${e}.0);
612
+ return sampleTexture(${r}, uv);
620
613
  }
621
614
  `;
622
615
  }
623
- let { newShape: c, keptDims: l } = a(r), u = c;
624
- if (u.length < r.length) return `
616
+ let { newShape: c, keptDims: l } = i(n), u = c;
617
+ if (u.length < n.length) return `
625
618
  ${x(j(e, u), t)}
626
- float ${o}(int row, int col) {
627
- return ${o}(${M(["row", "col"], l)});
619
+ float ${a}(int row, int col) {
620
+ return ${a}(${M(["row", "col"], l)});
628
621
  }
629
622
  `;
630
623
  if (e.shapeInfo.isUniform) return `
631
- float ${o}(int row, int col) {
632
- int index = round(dot(vec2(row, col), vec2(${r[1]}, 1)));
624
+ float ${a}(int row, int col) {
625
+ int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));
633
626
  ${O(e)}
634
627
  }
635
628
  `;
636
- let d = s[0], f = s[1], p = w(i);
629
+ let d = o[0], f = o[1], p = w(r);
637
630
  return f === 1 ? t ? `
638
- float ${o}(int row, int col) {
639
- float index = dot(vec3(row, col, ${p}), vec3(${i}Shape[1], 1, 1));
640
- vec2 uv = vec2(0.5, (index + 0.5) / float(${i}TexShape[0]));
641
- return sampleTexture(${i}, uv);
631
+ float ${a}(int row, int col) {
632
+ float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));
633
+ vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));
634
+ return sampleTexture(${r}, uv);
642
635
  }
643
636
  ` : `
644
- float ${o}(int row, int col) {
645
- float index = dot(vec3(row, col, ${p}), vec3(${r[1]}, 1, 1));
637
+ float ${a}(int row, int col) {
638
+ float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));
646
639
  vec2 uv = vec2(0.5, (index + 0.5) / ${d}.0);
647
- return sampleTexture(${i}, uv);
640
+ return sampleTexture(${r}, uv);
648
641
  }
649
642
  ` : d === 1 ? t ? `
650
- float ${o}(int row, int col) {
651
- float index = dot(vec3(row, col, ${p}), vec3(${i}Shape[1], 1, 1));
652
- vec2 uv = vec2((index + 0.5) / float(${i}TexShape[1]), 0.5);
653
- return sampleTexture(${i}, uv);
643
+ float ${a}(int row, int col) {
644
+ float index = dot(vec3(row, col, ${p}), vec3(${r}Shape[1], 1, 1));
645
+ vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);
646
+ return sampleTexture(${r}, uv);
654
647
  }
655
648
  ` : `
656
- float ${o}(int row, int col) {
657
- float index = dot(vec3(row, col, ${p}), vec3(${r[1]}, 1, 1));
649
+ float ${a}(int row, int col) {
650
+ float index = dot(vec3(row, col, ${p}), vec3(${n[1]}, 1, 1));
658
651
  vec2 uv = vec2((index + 0.5) / ${f}.0, 0.5);
659
- return sampleTexture(${i}, uv);
652
+ return sampleTexture(${r}, uv);
660
653
  }
661
654
  ` : t ? `
662
- float ${o}(int row, int col) {
655
+ float ${a}(int row, int col) {
663
656
  // Explicitly use integer operations as dot() only works on floats.
664
- int index = row * ${i}Shape[1] + col + ${p};
665
- vec2 uv = uvFromFlat(${i}TexShape[0], ${i}TexShape[1], index);
666
- return sampleTexture(${i}, uv);
657
+ int index = row * ${r}Shape[1] + col + ${p};
658
+ vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);
659
+ return sampleTexture(${r}, uv);
667
660
  }
668
661
  ` : `
669
- float ${o}(int row, int col) {
662
+ float ${a}(int row, int col) {
670
663
  // Explicitly use integer operations as dot() only works on floats.
671
- int index = row * ${r[1]} + col + ${p};
664
+ int index = row * ${n[1]} + col + ${p};
672
665
  vec2 uv = uvFromFlat(${d}, ${f}, index);
673
- return sampleTexture(${i}, uv);
666
+ return sampleTexture(${r}, uv);
674
667
  }
675
668
  `;
676
669
  }
@@ -707,11 +700,11 @@ function T(e, t) {
707
700
  `;
708
701
  }
709
702
  function E(e, t) {
710
- let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[1] * n[2], s = n[2], { newShape: c, keptDims: l } = a(n), u = c;
703
+ let n = e.shapeInfo.logicalShape, r = e.name, a = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[1] * n[2], s = n[2], { newShape: c, keptDims: l } = i(n), u = c;
711
704
  if (u.length < n.length) return `
712
705
  ${x(j(e, u), t)}
713
- float ${i}(int row, int col, int depth) {
714
- return ${i}(${M([
706
+ float ${a}(int row, int col, int depth) {
707
+ return ${a}(${M([
715
708
  "row",
716
709
  "col",
717
710
  "depth"
@@ -719,7 +712,7 @@ function E(e, t) {
719
712
  }
720
713
  `;
721
714
  if (e.shapeInfo.isUniform) return `
722
- float ${i}(int row, int col, int depth) {
715
+ float ${a}(int row, int col, int depth) {
723
716
  int index = round(dot(vec3(row, col, depth),
724
717
  vec3(${o}, ${s}, 1)));
725
718
  ${O(e)}
@@ -727,7 +720,7 @@ function E(e, t) {
727
720
  `;
728
721
  let d = e.shapeInfo.texShape, f = d[0], p = d[1], m = e.shapeInfo.flatOffset;
729
722
  if (p === o && m == null) return t ? `
730
- float ${i}(int row, int col, int depth) {
723
+ float ${a}(int row, int col, int depth) {
731
724
  int stride1 = ${r}Shape[2];
732
725
  float texR = float(row);
733
726
  float texC = dot(vec2(col, depth), vec2(stride1, 1));
@@ -736,7 +729,7 @@ function E(e, t) {
736
729
  return sampleTexture(${r}, uv);
737
730
  }
738
731
  ` : `
739
- float ${i}(int row, int col, int depth) {
732
+ float ${a}(int row, int col, int depth) {
740
733
  float texR = float(row);
741
734
  float texC = dot(vec2(col, depth), vec2(${s}, 1));
742
735
  vec2 uv = (vec2(texC, texR) + halfCR) /
@@ -745,14 +738,14 @@ function E(e, t) {
745
738
  }
746
739
  `;
747
740
  if (p === s && m == null) return t ? `
748
- float ${i}(int row, int col, int depth) {
741
+ float ${a}(int row, int col, int depth) {
749
742
  float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));
750
743
  float texC = float(depth);
751
744
  vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);
752
745
  return sampleTexture(${r}, uv);
753
746
  }
754
747
  ` : `
755
- float ${i}(int row, int col, int depth) {
748
+ float ${a}(int row, int col, int depth) {
756
749
  float texR = dot(vec2(row, col), vec2(${n[1]}, 1));
757
750
  float texC = float(depth);
758
751
  vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${p}.0, ${f}.0);
@@ -761,7 +754,7 @@ function E(e, t) {
761
754
  `;
762
755
  let h = w(r);
763
756
  return t ? `
764
- float ${i}(int row, int col, int depth) {
757
+ float ${a}(int row, int col, int depth) {
765
758
  // Explicitly use integer operations as dot() only works on floats.
766
759
  int stride0 = ${r}Shape[1] * ${r}Shape[2];
767
760
  int stride1 = ${r}Shape[2];
@@ -770,7 +763,7 @@ function E(e, t) {
770
763
  return sampleTexture(${r}, uv);
771
764
  }
772
765
  ` : `
773
- float ${i}(int row, int col, int depth) {
766
+ float ${a}(int row, int col, int depth) {
774
767
  // Explicitly use integer operations as dot() only works on floats.
775
768
  int index = row * ${o} + col * ${s} + depth + ${h};
776
769
  vec2 uv = uvFromFlat(${f}, ${p}, index);
@@ -806,11 +799,11 @@ function D(e, t) {
806
799
  `;
807
800
  }
808
801
  function De(e, t) {
809
- let n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[3], s = n[2] * o, c = n[1] * s, { newShape: l, keptDims: u } = a(n);
802
+ let n = e.shapeInfo.logicalShape, r = e.name, a = "get" + r.charAt(0).toUpperCase() + r.slice(1), o = n[3], s = n[2] * o, c = n[1] * s, { newShape: l, keptDims: u } = i(n);
810
803
  if (l.length < n.length) return `
811
804
  ${x(j(e, l), t)}
812
- float ${i}(int row, int col, int depth, int depth2) {
813
- return ${i}(${M([
805
+ float ${a}(int row, int col, int depth, int depth2) {
806
+ return ${a}(${M([
814
807
  "row",
815
808
  "col",
816
809
  "depth",
@@ -819,7 +812,7 @@ function De(e, t) {
819
812
  }
820
813
  `;
821
814
  if (e.shapeInfo.isUniform) return `
822
- float ${i}(int row, int col, int depth, int depth2) {
815
+ float ${a}(int row, int col, int depth, int depth2) {
823
816
  int index = round(dot(vec4(row, col, depth, depth2),
824
817
  vec4(${c}, ${s}, ${o}, 1)));
825
818
  ${O(e)}
@@ -827,7 +820,7 @@ function De(e, t) {
827
820
  `;
828
821
  let d = e.shapeInfo.flatOffset, f = e.shapeInfo.texShape, p = f[0], m = f[1], h = `int stride2 = ${r}Shape[3];`, g = `int stride1 = ${r}Shape[2] * stride2;`, _ = `int stride0 = ${r}Shape[1] * stride1;`;
829
822
  if (m === c && d == null) return t ? `
830
- float ${i}(int row, int col, int depth, int depth2) {
823
+ float ${a}(int row, int col, int depth, int depth2) {
831
824
  ${h}
832
825
  ${g}
833
826
  float texR = float(row);
@@ -839,7 +832,7 @@ function De(e, t) {
839
832
  return sampleTexture(${r}, uv);
840
833
  }
841
834
  ` : `
842
- float ${i}(int row, int col, int depth, int depth2) {
835
+ float ${a}(int row, int col, int depth, int depth2) {
843
836
  float texR = float(row);
844
837
  float texC =
845
838
  dot(vec3(col, depth, depth2),
@@ -850,7 +843,7 @@ function De(e, t) {
850
843
  }
851
844
  `;
852
845
  if (m === o && d == null) return t ? `
853
- float ${i}(int row, int col, int depth, int depth2) {
846
+ float ${a}(int row, int col, int depth, int depth2) {
854
847
  float texR = dot(vec3(row, col, depth),
855
848
  vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));
856
849
  float texC = float(depth2);
@@ -859,7 +852,7 @@ function De(e, t) {
859
852
  return sampleTexture(${r}, uv);
860
853
  }
861
854
  ` : `
862
- float ${i}(int row, int col, int depth, int depth2) {
855
+ float ${a}(int row, int col, int depth, int depth2) {
863
856
  float texR = dot(vec3(row, col, depth),
864
857
  vec3(${n[1] * n[2]}, ${n[2]}, 1));
865
858
  float texC = float(depth2);
@@ -870,7 +863,7 @@ function De(e, t) {
870
863
  `;
871
864
  let v = w(r);
872
865
  return t ? `
873
- float ${i}(int row, int col, int depth, int depth2) {
866
+ float ${a}(int row, int col, int depth, int depth2) {
874
867
  // Explicitly use integer operations as dot() only works on floats.
875
868
  ${h}
876
869
  ${g}
@@ -881,7 +874,7 @@ function De(e, t) {
881
874
  return sampleTexture(${r}, uv);
882
875
  }
883
876
  ` : `
884
- float ${i}(int row, int col, int depth, int depth2) {
877
+ float ${a}(int row, int col, int depth, int depth2) {
885
878
  // Explicitly use integer operations as dot() only works on floats.
886
879
  int index = row * ${c} + col * ${s} +
887
880
  depth * ${o} + depth2;
@@ -891,7 +884,7 @@ function De(e, t) {
891
884
  `;
892
885
  }
893
886
  function Oe(e) {
894
- let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = t[4], o = t[3] * i, s = t[2] * o, c = t[1] * s, { newShape: l, keptDims: u } = a(t);
887
+ let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), a = t[4], o = t[3] * a, s = t[2] * o, c = t[1] * s, { newShape: l, keptDims: u } = i(t);
895
888
  if (l.length < t.length) return `
896
889
  ${x(j(e, l))}
897
890
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
@@ -908,7 +901,7 @@ function Oe(e) {
908
901
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
909
902
  float index = dot(
910
903
  vec4(row, col, depth, depth2),
911
- vec4(${c}, ${s}, ${o}, ${i})) +
904
+ vec4(${c}, ${s}, ${o}, ${a})) +
912
905
  depth3;
913
906
  ${O(e)}
914
907
  }
@@ -918,12 +911,12 @@ function Oe(e) {
918
911
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
919
912
  int texR = row;
920
913
  float texC = dot(vec4(col, depth, depth2, depth3),
921
- vec4(${s}, ${o}, ${i}, 1));
914
+ vec4(${s}, ${o}, ${a}, 1));
922
915
  vec2 uv = (vec2(texC, texR) + halfCR) /
923
916
  vec2(${m}.0, ${p}.0);
924
917
  return sampleTexture(${n}, uv);
925
918
  }
926
- ` : m === i && d == null ? `
919
+ ` : m === a && d == null ? `
927
920
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
928
921
  float texR = dot(
929
922
  vec4(row, col, depth, depth2),
@@ -938,16 +931,16 @@ function Oe(e) {
938
931
  float ${r}(int row, int col, int depth, int depth2, int depth3) {
939
932
  // Explicitly use integer operations as dot() only works on floats.
940
933
  int index = row * ${c} + col * ${s} + depth * ${o} +
941
- depth2 * ${i} + depth3 + ${w(n)};
934
+ depth2 * ${a} + depth3 + ${w(n)};
942
935
  vec2 uv = uvFromFlat(${p}, ${m}, index);
943
936
  return sampleTexture(${n}, uv);
944
937
  }
945
938
  `;
946
939
  }
947
940
  function ke(e) {
948
- let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: i, keptDims: o } = a(t);
949
- if (i.length < t.length) return `
950
- ${x(j(e, i))}
941
+ let t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: a, keptDims: o } = i(t);
942
+ if (a.length < t.length) return `
943
+ ${x(j(e, a))}
951
944
  float ${r}(int row, int col, int depth,
952
945
  int depth2, int depth3, int depth4) {
953
946
  return ${r}(${M([
@@ -1010,7 +1003,7 @@ function ke(e) {
1010
1003
  `;
1011
1004
  }
1012
1005
  function O(e) {
1013
- let t = e.name, n = s(e.shapeInfo.logicalShape);
1006
+ let t = e.name, n = o(e.shapeInfo.logicalShape);
1014
1007
  return n < 2 ? `return ${t};` : `
1015
1008
  for (int i = 0; i < ${n}; i++) {
1016
1009
  if (i == index) {
@@ -1020,7 +1013,7 @@ function O(e) {
1020
1013
  `;
1021
1014
  }
1022
1015
  function Ae(e, t) {
1023
- let n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, o = t.logicalShape.length, c = y(e.shapeInfo.logicalShape, t.logicalShape), l = k(o), u = o - a, d, f = [
1016
+ let n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, s = t.logicalShape.length, c = y(e.shapeInfo.logicalShape, t.logicalShape), l = k(s), u = s - a, d, f = [
1024
1017
  "x",
1025
1018
  "y",
1026
1019
  "z",
@@ -1028,12 +1021,12 @@ function Ae(e, t) {
1028
1021
  "u",
1029
1022
  "v"
1030
1023
  ];
1031
- d = a === 0 ? "" : o < 2 && c.length >= 1 ? "coords = 0;" : c.map((e) => `coords.${f[e + u]} = 0;`).join("\n");
1024
+ d = a === 0 ? "" : s < 2 && c.length >= 1 ? "coords = 0;" : c.map((e) => `coords.${f[e + u]} = 0;`).join("\n");
1032
1025
  let p = "";
1033
- p = o < 2 && a > 0 ? "coords" : e.shapeInfo.logicalShape.map((e, t) => `coords.${f[t + u]}`).join(", ");
1034
- let m = "return outputValue;", h = s(e.shapeInfo.logicalShape) === 1, g = s(t.logicalShape) === 1;
1026
+ p = s < 2 && a > 0 ? "coords" : e.shapeInfo.logicalShape.map((e, t) => `coords.${f[t + u]}`).join(", ");
1027
+ let m = "return outputValue;", h = o(e.shapeInfo.logicalShape) === 1, g = o(t.logicalShape) === 1;
1035
1028
  if (a === 1 && !h && !g) m = "\n return vec4(outputValue.xy, outputValue.xy);\n ";
1036
- else if (h && !g) m = o === 1 ? "\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n " : "\n return vec4(outputValue.x);\n ";
1029
+ else if (h && !g) m = s === 1 ? "\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n " : "\n return vec4(outputValue.x);\n ";
1037
1030
  else if (c.length) {
1038
1031
  let e = a - 2, t = a - 1;
1039
1032
  c.indexOf(e) > -1 && c.indexOf(t) > -1 ? m = "return vec4(outputValue.x);" : c.indexOf(e) > -1 ? m = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : c.indexOf(t) > -1 && (m = "return vec4(outputValue.xx, outputValue.zz);");
@@ -1048,10 +1041,10 @@ function Ae(e, t) {
1048
1041
  `;
1049
1042
  }
1050
1043
  function je(e, t) {
1051
- let r = e.name, i = r.charAt(0).toUpperCase() + r.slice(1), a = "get" + i + "AtOutCoords", o = t.texShape, s = e.shapeInfo.texShape, c = e.shapeInfo.logicalShape.length, l = t.logicalShape.length;
1052
- if (!e.shapeInfo.isUniform && c === l && e.shapeInfo.flatOffset == null && n(s, o)) return `
1053
- float ${a}() {
1054
- return sampleTexture(${r}, resultUV);
1044
+ let n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = t.texShape, o = e.shapeInfo.texShape, c = e.shapeInfo.logicalShape.length, l = t.logicalShape.length;
1045
+ if (!e.shapeInfo.isUniform && c === l && e.shapeInfo.flatOffset == null && s(o, a)) return `
1046
+ float ${i}() {
1047
+ return sampleTexture(${n}, resultUV);
1055
1048
  }
1056
1049
  `;
1057
1050
  let u = k(l), d = y(e.shapeInfo.logicalShape, t.logicalShape), f = l - c, p, m = [
@@ -1065,10 +1058,10 @@ function je(e, t) {
1065
1058
  p = c === 0 ? "" : l < 2 && d.length >= 1 ? "coords = 0;" : d.map((e) => `coords.${m[e + f]} = 0;`).join("\n");
1066
1059
  let h = "";
1067
1060
  return h = l < 2 && c > 0 ? "coords" : e.shapeInfo.logicalShape.map((e, t) => `coords.${m[t + f]}`).join(", "), `
1068
- float ${a}() {
1061
+ float ${i}() {
1069
1062
  ${u} coords = getOutputCoords();
1070
1063
  ${p}
1071
- return get${i}(${h});
1064
+ return get${r}(${h});
1072
1065
  }
1073
1066
  `;
1074
1067
  }
@@ -1081,12 +1074,12 @@ function k(e) {
1081
1074
  if (e === 6) return "ivec6";
1082
1075
  throw Error(`GPU for rank ${e} is not yet supported`);
1083
1076
  }
1084
- function A(e, t, r) {
1085
- let { newShape: i, keptDims: o } = a(t), s = t.length, c = e && s === 3 && t[0] === 1, l = c ? t.slice(1) : i, u = !e && s > 1 && !n(t, r) && i.length < s || c;
1077
+ function A(e, t, n) {
1078
+ let { newShape: r, keptDims: a } = i(t), o = t.length, c = e && o === 3 && t[0] === 1, l = c ? t.slice(1) : r, u = !e && o > 1 && !s(t, n) && r.length < o || c;
1086
1079
  return {
1087
1080
  useSqueezeShape: u,
1088
1081
  uniformShape: u ? l : t,
1089
- keptDims: o
1082
+ keptDims: a
1090
1083
  };
1091
1084
  }
1092
1085
  function j(e, t) {
@@ -1096,8 +1089,7 @@ function j(e, t) {
1096
1089
  function M(e, t) {
1097
1090
  return t.map((t) => e[t]).join(", ");
1098
1091
  }
1099
- //#endregion
1100
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/canvas_util.js
1092
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/canvas_util.js
1101
1093
  var N = {}, P = {
1102
1094
  alpha: !1,
1103
1095
  antialias: !1,
@@ -1120,19 +1112,18 @@ function F(e, t) {
1120
1112
  return n == null || n.isContextLost() ? (delete N[e], F(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), N[e]);
1121
1113
  }
1122
1114
  function Ne(e) {
1123
- if (!t().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2) return new OffscreenCanvas(300, 150);
1115
+ if (!a().getBool("IS_SAFARI") && typeof OffscreenCanvas < "u" && e === 2) return new OffscreenCanvas(300, 150);
1124
1116
  if (typeof document < "u") return document.createElement("canvas");
1125
1117
  throw Error("Cannot create a canvas in this context");
1126
1118
  }
1127
- function Pe(e, n) {
1119
+ function Pe(e, t) {
1128
1120
  if (e !== 1 && e !== 2) throw Error("Cannot get WebGL rendering context, WebGL is disabled.");
1129
- let r = n ?? Ne(e);
1130
- return r.addEventListener("webglcontextlost", (t) => {
1121
+ let n = t ?? Ne(e);
1122
+ return n.addEventListener("webglcontextlost", (t) => {
1131
1123
  t.preventDefault(), delete N[e];
1132
- }, !1), t().getBool("SOFTWARE_WEBGL_ENABLED") && (P.failIfMajorPerformanceCaveat = !1), e === 1 ? r.getContext("webgl", P) || r.getContext("experimental-webgl", P) : r.getContext("webgl2", P);
1124
+ }, !1), a().getBool("SOFTWARE_WEBGL_ENABLED") && (P.failIfMajorPerformanceCaveat = !1), e === 1 ? n.getContext("webgl", P) || n.getContext("experimental-webgl", P) : n.getContext("webgl2", P);
1133
1125
  }
1134
- //#endregion
1135
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/tex_util.js
1126
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/tex_util.js
1136
1127
  var I;
1137
1128
  (function(e) {
1138
1129
  e[e.DENSE = 0] = "DENSE", e[e.SHARED_BATCH = 1] = "SHARED_BATCH";
@@ -1152,8 +1143,8 @@ function Ie(e, t) {
1152
1143
  return e * t;
1153
1144
  }
1154
1145
  function Le(e) {
1155
- let t = s(e);
1156
- return c(Math.ceil(t / 4));
1146
+ let t = o(e), r = Math.ceil(t / 4);
1147
+ return n(r);
1157
1148
  }
1158
1149
  function z(e, t) {
1159
1150
  return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))];
@@ -1162,11 +1153,11 @@ function Re(e, t) {
1162
1153
  let [n, r] = z(e, t);
1163
1154
  return n * r * 4;
1164
1155
  }
1165
- function B(e, n) {
1166
- let r = e, i, a, o, s, c, l, u, d, f, p;
1167
- return t().getNumber("WEBGL_VERSION") === 2 ? (i = r.R32F, a = r.R16F, o = r.RGBA16F, s = r.RGBA32F, c = r.RED, u = 4, d = 1, f = r.HALF_FLOAT, p = r.FLOAT, l = r.RGBA8) : (i = e.RGBA, a = e.RGBA, o = e.RGBA, s = r.RGBA, c = e.RGBA, u = 4, d = 4, f = n == null ? null : n.HALF_FLOAT_OES, p = e.FLOAT, l = e.RGBA), {
1168
- internalFormatFloat: i,
1169
- internalFormatHalfFloat: a,
1156
+ function B(e, t) {
1157
+ let n = e, r, i, o, s, c, l, u, d, f, p;
1158
+ return a().getNumber("WEBGL_VERSION") === 2 ? (r = n.R32F, i = n.R16F, o = n.RGBA16F, s = n.RGBA32F, c = n.RED, u = 4, d = 1, f = n.HALF_FLOAT, p = n.FLOAT, l = n.RGBA8) : (r = e.RGBA, i = e.RGBA, o = e.RGBA, s = n.RGBA, c = e.RGBA, u = 4, d = 4, f = t == null ? null : t.HALF_FLOAT_OES, p = e.FLOAT, l = e.RGBA), {
1159
+ internalFormatFloat: r,
1160
+ internalFormatHalfFloat: i,
1170
1161
  internalFormatPackedHalfFloat: o,
1171
1162
  internalFormatPackedFloat: s,
1172
1163
  textureFormatFloat: c,
@@ -1177,11 +1168,10 @@ function B(e, n) {
1177
1168
  textureTypeFloat: p
1178
1169
  };
1179
1170
  }
1180
- //#endregion
1181
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/webgl_util.js
1182
- function V(e, n) {
1183
- let r = n();
1184
- return t().getBool("DEBUG") && ze(e), r;
1171
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/webgl_util.js
1172
+ function V(e, t) {
1173
+ let n = t();
1174
+ return a().getBool("DEBUG") && ze(e), n;
1185
1175
  }
1186
1176
  function ze(e) {
1187
1177
  let t = e.getError();
@@ -1189,7 +1179,7 @@ function ze(e) {
1189
1179
  }
1190
1180
  var Be = 5.96e-8, Ve = 65504;
1191
1181
  function He(e) {
1192
- return !!(t().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || Be < Math.abs(e) && Math.abs(e) < Ve);
1182
+ return !!(a().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || e === 0 || Be < Math.abs(e) && Math.abs(e) < Ve);
1193
1183
  }
1194
1184
  function Ue(e, t) {
1195
1185
  switch (t) {
@@ -1211,29 +1201,29 @@ function Ge(e, t) {
1211
1201
  if (V(e, () => e.shaderSource(n, t)), V(e, () => e.compileShader(n)), e.getShaderParameter(n, e.COMPILE_STATUS) === !1) throw console.log(e.getShaderInfoLog(n)), Error("Failed to compile vertex shader.");
1212
1202
  return n;
1213
1203
  }
1214
- function Ke(e, n) {
1215
- let r = W(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
1216
- if (V(e, () => e.shaderSource(r, n)), V(e, () => e.compileShader(r)), t().get("ENGINE_COMPILE_ONLY")) return r;
1217
- if (e.getShaderParameter(r, e.COMPILE_STATUS) === !1) throw U(n, e.getShaderInfoLog(r)), Error("Failed to compile fragment shader.");
1218
- return r;
1204
+ function Ke(e, t) {
1205
+ let n = W(e, () => e.createShader(e.FRAGMENT_SHADER), "Unable to create fragment WebGLShader.");
1206
+ if (V(e, () => e.shaderSource(n, t)), V(e, () => e.compileShader(n)), a().get("ENGINE_COMPILE_ONLY")) return n;
1207
+ if (e.getShaderParameter(n, e.COMPILE_STATUS) === !1) throw U(t, e.getShaderInfoLog(n)), Error("Failed to compile fragment shader.");
1208
+ return n;
1219
1209
  }
1220
1210
  var H = /ERROR: [0-9]+:([0-9]+):/g;
1221
- function U(e, t) {
1222
- let n = H.exec(t);
1223
- if (n == null) {
1224
- console.log(`Couldn't parse line number in error: ${t}`), console.log(e);
1211
+ function U(t, n) {
1212
+ let r = H.exec(n);
1213
+ if (r == null) {
1214
+ console.log(`Couldn't parse line number in error: ${n}`), console.log(t);
1225
1215
  return;
1226
1216
  }
1227
- let r = +n[1], i = e.split("\n"), a = i.length.toString().length + 2, s = i.map((e, t) => o((t + 1).toString(), a) + e), c = 0;
1217
+ let i = +r[1], a = t.split("\n"), o = a.length.toString().length + 2, s = a.map((t, n) => e((n + 1).toString(), o) + t), c = 0;
1228
1218
  for (let e = 0; e < s.length; e++) c = Math.max(s[e].length, c);
1229
- let l = s.slice(0, r - 1), u = s.slice(r - 1, r), d = s.slice(r);
1230
- console.log(l.join("\n")), console.log(t.split("\n")[0]), console.log(`%c ${o(u[0], c)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(d.join("\n"));
1219
+ let l = s.slice(0, i - 1), u = s.slice(i - 1, i), d = s.slice(i);
1220
+ console.log(l.join("\n")), console.log(n.split("\n")[0]), console.log(`%c ${e(u[0], c)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(d.join("\n"));
1231
1221
  }
1232
1222
  function qe(e) {
1233
1223
  return W(e, () => e.createProgram(), "Unable to create WebGLProgram.");
1234
1224
  }
1235
- function Je(e, n) {
1236
- if (V(e, () => e.linkProgram(n)), !t().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(n, e.LINK_STATUS) === !1) throw console.log(e.getProgramInfoLog(n)), Error("Failed to link vertex and fragment shaders.");
1225
+ function Je(e, t) {
1226
+ if (V(e, () => e.linkProgram(t)), !a().get("ENGINE_COMPILE_ONLY") && e.getProgramParameter(t, e.LINK_STATUS) === !1) throw console.log(e.getProgramInfoLog(t)), Error("Failed to link vertex and fragment shaders.");
1237
1227
  }
1238
1228
  function Ye(e, t) {
1239
1229
  if (V(e, () => e.validateProgram(t)), e.getProgramParameter(t, e.VALIDATE_STATUS) === !1) throw console.log(e.getProgramInfoLog(t)), Error("Shader program validation failed.");
@@ -1249,15 +1239,15 @@ function Ze(e, t) {
1249
1239
  function Qe(e) {
1250
1240
  return W(e, () => e.createTexture(), "Unable to create WebGLTexture.");
1251
1241
  }
1252
- function $e(e, n) {
1253
- let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE");
1254
- if (e <= 0 || n <= 0) {
1255
- let t = `[${e}x${n}]`;
1256
- throw Error("Requested texture size " + t + " is invalid.");
1242
+ function $e(e, t) {
1243
+ let n = a().getNumber("WEBGL_MAX_TEXTURE_SIZE");
1244
+ if (e <= 0 || t <= 0) {
1245
+ let n = `[${e}x${t}]`;
1246
+ throw Error("Requested texture size " + n + " is invalid.");
1257
1247
  }
1258
- if (e > r || n > r) {
1259
- let t = `[${e}x${n}]`, i = `[${r}x${r}]`;
1260
- throw Error("Requested texture size " + t + " greater than WebGL maximum on this browser / GPU " + i + ".");
1248
+ if (e > n || t > n) {
1249
+ let r = `[${e}x${t}]`, i = `[${n}x${n}]`;
1250
+ throw Error("Requested texture size " + r + " greater than WebGL maximum on this browser / GPU " + i + ".");
1261
1251
  }
1262
1252
  }
1263
1253
  function et(e) {
@@ -1265,7 +1255,7 @@ function et(e) {
1265
1255
  }
1266
1256
  function tt(e, t, n, r, i, a, o) {
1267
1257
  let s = e.getAttribLocation(t, n);
1268
- return s === -1 ? !1 : (V(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), V(e, () => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o)), V(e, () => e.enableVertexAttribArray(s)), !0);
1258
+ return s !== -1 && (V(e, () => e.bindBuffer(e.ARRAY_BUFFER, r)), V(e, () => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o)), V(e, () => e.enableVertexAttribArray(s)), !0);
1269
1259
  }
1270
1260
  function nt(e, t, n) {
1271
1261
  ut(e, n), V(e, () => e.activeTexture(e.TEXTURE0 + n)), V(e, () => e.bindTexture(e.TEXTURE_2D, t));
@@ -1311,7 +1301,7 @@ function ut(e, t) {
1311
1301
  }
1312
1302
  }
1313
1303
  function G(e, t = 2) {
1314
- return s(e.slice(0, e.length - t));
1304
+ return o(e.slice(0, e.length - t));
1315
1305
  }
1316
1306
  function K(e) {
1317
1307
  if (e.length === 0) throw Error("Cannot get rows and columns of an empty shape array.");
@@ -1325,23 +1315,25 @@ function dt(e) {
1325
1315
  ];
1326
1316
  return e.length === 0 || e.length === 1 && e[0] === 1 || (t = [G(e), ...K(e)]), t;
1327
1317
  }
1328
- function ft(e, n = !1) {
1329
- let r = t().getNumber("WEBGL_MAX_TEXTURE_SIZE"), i = t().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
1330
- i === Infinity && t().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (i = r / 2), n && (r *= 2, i *= 2, e = e.map((t, n) => n >= e.length - 2 ? l(e[n]) : e[n]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = a(e).newShape);
1331
- let o = s(e), u = null;
1332
- e.length <= 1 && o <= r ? u = [1, o] : e.length === 2 && e[0] <= r && e[1] <= r ? u = e : e.length === 3 && e[0] * e[1] <= r && e[2] <= r ? u = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= r && e[1] * e[2] <= r ? u = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= r && e[3] <= r ? u = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= r && e[1] * e[2] * e[3] <= r && (u = [e[0], e[1] * e[2] * e[3]]);
1333
- let d = u != null && Math.max(...u) > i && Math.min(...u) <= (n ? 2 : 1) && Math.min(...u) > 0;
1334
- if (u == null || d) if (n) {
1335
- let t = G(e), n = 2, r = 2;
1336
- e.length && ([n, r] = K(e)), o = n / 2 * t * (r / 2), u = c(o).map((e) => e * 2);
1337
- } else u = c(o);
1318
+ function ft(e, r = !1) {
1319
+ let s = a().getNumber("WEBGL_MAX_TEXTURE_SIZE"), c = a().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE");
1320
+ c === Infinity && a().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (c = s / 2), r && (s *= 2, c *= 2, e = e.map((n, r) => r >= e.length - 2 ? t(e[r]) : e[r]), e.length === 1 && (e = [2, e[0]])), e.length !== 2 && (e = i(e).newShape);
1321
+ let l = o(e), u = null;
1322
+ e.length <= 1 && l <= s ? u = [1, l] : e.length === 2 && e[0] <= s && e[1] <= s ? u = e : e.length === 3 && e[0] * e[1] <= s && e[2] <= s ? u = [e[0] * e[1], e[2]] : e.length === 3 && e[0] <= s && e[1] * e[2] <= s ? u = [e[0], e[1] * e[2]] : e.length === 4 && e[0] * e[1] * e[2] <= s && e[3] <= s ? u = [e[0] * e[1] * e[2], e[3]] : e.length === 4 && e[0] <= s && e[1] * e[2] * e[3] <= s && (u = [e[0], e[1] * e[2] * e[3]]);
1323
+ let d = u != null && Math.max(...u) > c && Math.min(...u) <= (r ? 2 : 1) && Math.min(...u) > 0;
1324
+ if (u == null || d) {
1325
+ if (r) {
1326
+ let t = G(e), r = 2, i = 2;
1327
+ e.length && ([r, i] = K(e)), l = r / 2 * t * (i / 2), u = n(l).map((e) => e * 2);
1328
+ } else u = n(l);
1329
+ }
1338
1330
  return u;
1339
1331
  }
1340
1332
  function q(e) {
1341
1333
  return e % 2 == 0;
1342
1334
  }
1343
1335
  function pt(e, t) {
1344
- if (e = e.slice(-2), t = t.slice(-2), n(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0) return !0;
1336
+ if (e = e.slice(-2), t = t.slice(-2), s(e, t) || !e.length || !t.length || e[0] === 0 || e[1] === 0 || t[0] === 0 || t[1] === 0) return !0;
1345
1337
  if (e.length !== t.length) {
1346
1338
  let n = e[e.length - 1], r = t[t.length - 1];
1347
1339
  if (n === r || q(n) && q(r) && (e[0] === 1 || t[0] === 1)) return !0;
@@ -1416,37 +1408,36 @@ function bt(e, t) {
1416
1408
  return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(i), a;
1417
1409
  }
1418
1410
  function xt(e) {
1419
- return e === 2 ? F(e).fenceSync != null : !1;
1411
+ return e === 2 && F(e).fenceSync != null;
1420
1412
  }
1421
1413
  function St(e, t) {
1422
1414
  Array.isArray(e) || (e = [e]), e.forEach((e) => {
1423
- e != null && r(e.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
1415
+ e != null && l(e.dtype !== "complex64", () => `${t} does not support complex64 tensors in the WebGL backend.`);
1424
1416
  });
1425
1417
  }
1426
- //#endregion
1427
- //#region node_modules/@tensorflow/tfjs-backend-webgl/dist/gpgpu_math.js
1428
- function Ct(e, n, r, i) {
1429
- let a = r.map((e, t) => {
1418
+ // node_modules/@tensorflow/tfjs-backend-webgl/dist/gpgpu_math.js
1419
+ function Ct(e, t, n, r) {
1420
+ let i = n.map((e, n) => {
1430
1421
  let r = {
1431
1422
  logicalShape: e.shape,
1432
1423
  texShape: e.isUniform ? null : e.texData.texShape,
1433
1424
  isUniform: e.isUniform,
1434
- isPacked: e.isUniform ? !1 : e.texData.isPacked,
1425
+ isPacked: !e.isUniform && e.texData.isPacked,
1435
1426
  flatOffset: null
1436
1427
  };
1437
1428
  return e.texData != null && e.texData.slice != null && e.texData.slice.flatOffset > 0 && (r.flatOffset = e.texData.slice.flatOffset), {
1438
- name: n.variableNames[t],
1429
+ name: t.variableNames[n],
1439
1430
  shapeInfo: r
1440
1431
  };
1441
- }), o = a.map((e) => e.shapeInfo), s = {
1442
- logicalShape: i.shape,
1443
- texShape: i.texData.texShape,
1432
+ }), o = i.map((e) => e.shapeInfo), s = {
1433
+ logicalShape: r.shape,
1434
+ texShape: r.texData.texShape,
1444
1435
  isUniform: !1,
1445
- isPacked: i.texData.isPacked,
1436
+ isPacked: r.texData.isPacked,
1446
1437
  flatOffset: null
1447
- }, c = b(a, s, n), l = Ke(e.gl, c), u = e.createProgram(l);
1448
- return t().get("ENGINE_COMPILE_ONLY") ? {
1449
- program: n,
1438
+ }, c = b(i, s, t), l = Ke(e.gl, c), u = e.createProgram(l);
1439
+ return a().get("ENGINE_COMPILE_ONLY") ? {
1440
+ program: t,
1450
1441
  fragmentShader: l,
1451
1442
  source: c,
1452
1443
  webGLProgram: u,
@@ -1460,29 +1451,29 @@ function Ct(e, n, r, i) {
1460
1451
  outShapeStridesLocation: null,
1461
1452
  outTexShapeLocation: null
1462
1453
  } : (e.buildVao(u), Object.assign({
1463
- program: n,
1454
+ program: t,
1464
1455
  fragmentShader: l,
1465
1456
  source: c,
1466
1457
  webGLProgram: u,
1467
1458
  inShapeInfos: o,
1468
1459
  outShapeInfo: s
1469
- }, Q(e, n, u)));
1460
+ }, Q(e, t, u)));
1470
1461
  }
1471
- function Q(e, n, r) {
1472
- let i = [], a = [], o, s, c, l = null, u = null;
1473
- u = e.getUniformLocation(r, "NAN", !1), t().getNumber("WEBGL_VERSION") === 1 && (l = e.getUniformLocation(r, "INFINITY", !1));
1474
- for (let t of n.variableNames) {
1462
+ function Q(e, t, n) {
1463
+ let r = [], i = [], o, s, c, l = null, u = null;
1464
+ u = e.getUniformLocation(n, "NAN", !1), a().getNumber("WEBGL_VERSION") === 1 && (l = e.getUniformLocation(n, "INFINITY", !1));
1465
+ for (let i of t.variableNames) {
1475
1466
  let a = {
1476
- name: t,
1477
- uniform: e.getUniformLocation(r, t, !1),
1478
- offset: e.getUniformLocation(r, `offset${t}`, !1)
1467
+ name: i,
1468
+ uniform: e.getUniformLocation(n, i, !1),
1469
+ offset: e.getUniformLocation(n, `offset${i}`, !1)
1479
1470
  };
1480
- n.enableShapeUniforms && (a.shape = e.getUniformLocation(r, `${t}Shape`, !1), a.texShape = e.getUniformLocation(r, `${t}TexShape`, !1)), i.push(a);
1471
+ t.enableShapeUniforms && (a.shape = e.getUniformLocation(n, `${i}Shape`, !1), a.texShape = e.getUniformLocation(n, `${i}TexShape`, !1)), r.push(a);
1481
1472
  }
1482
- if (n.enableShapeUniforms && (o = e.getUniformLocation(r, "outShape", !1), c = e.getUniformLocation(r, "outShapeStrides", !1), s = e.getUniformLocation(r, "outTexShape", !1)), n.customUniforms) for (let t of n.customUniforms) a.push(e.getUniformLocation(r, t.name, !1));
1473
+ if (t.enableShapeUniforms && (o = e.getUniformLocation(n, "outShape", !1), c = e.getUniformLocation(n, "outShapeStrides", !1), s = e.getUniformLocation(n, "outTexShape", !1)), t.customUniforms) for (let r of t.customUniforms) i.push(e.getUniformLocation(n, r.name, !1));
1483
1474
  return {
1484
- variablesLocations: i,
1485
- customUniformLocations: a,
1475
+ variablesLocations: r,
1476
+ customUniformLocations: i,
1486
1477
  infLoc: l,
1487
1478
  nanLoc: u,
1488
1479
  outShapeLocation: o,
@@ -1492,83 +1483,72 @@ function Q(e, n, r) {
1492
1483
  }
1493
1484
  function $(e, t) {
1494
1485
  if (e.length !== t.length) throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`);
1495
- e.forEach((e, r) => {
1496
- let i = e.logicalShape, a = t[r], o = a.shape;
1497
- if (!n(i, o)) throw Error(`Binary was compiled with different shapes than the current args. Shapes ${i} and ${o} must match`);
1498
- if (e.isUniform && a.isUniform) return;
1499
- let s = e.texShape, c = a.isUniform ? null : a.texData.texShape;
1500
- if (!n(s, c)) throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${s} and ${c} must match`);
1486
+ e.forEach((e, n) => {
1487
+ let r = e.logicalShape, i = t[n], a = i.shape;
1488
+ if (!s(r, a)) throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${a} must match`);
1489
+ if (e.isUniform && i.isUniform) return;
1490
+ let o = e.texShape, c = i.isUniform ? null : i.texData.texShape;
1491
+ if (!s(o, c)) throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${c} must match`);
1501
1492
  });
1502
1493
  }
1503
- function wt(e, n, r, a, o) {
1504
- n.program.enableShapeUniforms || ($(n.inShapeInfos, r), $([n.outShapeInfo], [a]));
1505
- let c = a.texData.texture, l = a.texData.texShape;
1506
- a.texData.isPacked ? e.setOutputPackedMatrixTexture(c.texture, l[0], l[1]) : e.setOutputMatrixTexture(c.texture, l[0], l[1]), e.setProgram(n.webGLProgram), e.bindVertexArray(n.webGLProgram.vao), t().getNumber("WEBGL_VERSION") === 1 && n.infLoc !== null && e.gl.uniform1f(n.infLoc, Infinity), n.nanLoc !== null && e.gl.uniform1f(n.nanLoc, NaN);
1507
- for (let t = 0; t < r.length; ++t) {
1508
- let i = r[t], { uniform: a, offset: o, shape: c, texShape: l } = n.variablesLocations[t];
1494
+ function wt(e, t, n, i, s) {
1495
+ t.program.enableShapeUniforms || ($(t.inShapeInfos, n), $([t.outShapeInfo], [i]));
1496
+ let c = i.texData.texture, l = i.texData.texShape;
1497
+ i.texData.isPacked ? e.setOutputPackedMatrixTexture(c.texture, l[0], l[1]) : e.setOutputMatrixTexture(c.texture, l[0], l[1]), e.setProgram(t.webGLProgram), e.bindVertexArray(t.webGLProgram.vao), a().getNumber("WEBGL_VERSION") === 1 && t.infLoc !== null && e.gl.uniform1f(t.infLoc, Infinity), t.nanLoc !== null && e.gl.uniform1f(t.nanLoc, NaN);
1498
+ for (let r = 0; r < n.length; ++r) {
1499
+ let i = n[r], { uniform: a, offset: s, shape: c, texShape: l } = t.variablesLocations[r];
1509
1500
  if (c) {
1510
- let { uniformShape: t } = A(n.program.packedInputs, i.shape, i.texData.texShape);
1511
- switch (t.length) {
1501
+ let { uniformShape: n } = A(t.program.packedInputs, i.shape, i.texData.texShape);
1502
+ switch (n.length) {
1512
1503
  case 1:
1513
- e.gl.uniform1iv(c, new Int32Array(t));
1504
+ e.gl.uniform1iv(c, new Int32Array(n));
1514
1505
  break;
1515
1506
  case 2:
1516
- e.gl.uniform2iv(c, new Int32Array(t));
1507
+ e.gl.uniform2iv(c, new Int32Array(n));
1517
1508
  break;
1518
1509
  case 3:
1519
- e.gl.uniform3iv(c, new Int32Array(t));
1520
- break;
1521
- case 4:
1522
- e.gl.uniform4iv(c, new Int32Array(t));
1510
+ e.gl.uniform3iv(c, new Int32Array(n));
1523
1511
  break;
1524
- default: break;
1512
+ case 4: e.gl.uniform4iv(c, new Int32Array(n));
1525
1513
  }
1526
1514
  }
1527
1515
  if (l && e.gl.uniform2i(l, i.texData.texShape[0], i.texData.texShape[1]), a != null) {
1528
1516
  if (i.isUniform) {
1529
- if (s(i.shape) < 2) e.gl.uniform1f(a, i.uniformValues[0]);
1517
+ if (o(i.shape) < 2) e.gl.uniform1f(a, i.uniformValues[0]);
1530
1518
  else {
1531
1519
  let t = i.uniformValues;
1532
1520
  t instanceof Float32Array || (t = new Float32Array(t)), e.gl.uniform1fv(a, t);
1533
1521
  }
1534
- continue;
1535
- }
1536
- i.texData.slice != null && o != null && e.gl.uniform1i(o, i.texData.slice.flatOffset), e.setInputMatrixTexture(i.texData.texture.texture, a, t);
1522
+ } else i.texData.slice != null && s != null && e.gl.uniform1i(s, i.texData.slice.flatOffset), e.setInputMatrixTexture(i.texData.texture.texture, a, r);
1537
1523
  }
1538
1524
  }
1539
- let u = n.outShapeLocation;
1540
- if (u) switch (a.shape.length) {
1525
+ let u = t.outShapeLocation;
1526
+ if (u) switch (i.shape.length) {
1541
1527
  case 1:
1542
- e.gl.uniform1iv(u, new Int32Array(a.shape));
1528
+ e.gl.uniform1iv(u, new Int32Array(i.shape));
1543
1529
  break;
1544
1530
  case 2:
1545
- e.gl.uniform2iv(u, new Int32Array(a.shape));
1531
+ e.gl.uniform2iv(u, new Int32Array(i.shape));
1546
1532
  break;
1547
1533
  case 3:
1548
- e.gl.uniform3iv(u, new Int32Array(a.shape));
1534
+ e.gl.uniform3iv(u, new Int32Array(i.shape));
1549
1535
  break;
1550
- case 4:
1551
- e.gl.uniform4iv(u, new Int32Array(a.shape));
1552
- break;
1553
- default: break;
1536
+ case 4: e.gl.uniform4iv(u, new Int32Array(i.shape));
1554
1537
  }
1555
- if (n.outShapeStridesLocation) {
1556
- let t = i(a.shape);
1557
- switch (a.shape.length) {
1538
+ if (t.outShapeStridesLocation) {
1539
+ let n = r(i.shape);
1540
+ switch (i.shape.length) {
1558
1541
  case 2:
1559
- e.gl.uniform1iv(n.outShapeStridesLocation, new Int32Array(t));
1542
+ e.gl.uniform1iv(t.outShapeStridesLocation, new Int32Array(n));
1560
1543
  break;
1561
1544
  case 3:
1562
- e.gl.uniform2iv(n.outShapeStridesLocation, new Int32Array(t));
1563
- break;
1564
- case 4:
1565
- e.gl.uniform3iv(n.outShapeStridesLocation, new Int32Array(t));
1545
+ e.gl.uniform2iv(t.outShapeStridesLocation, new Int32Array(n));
1566
1546
  break;
1567
- default: break;
1547
+ case 4: e.gl.uniform3iv(t.outShapeStridesLocation, new Int32Array(n));
1568
1548
  }
1569
1549
  }
1570
- if (n.outTexShapeLocation && e.gl.uniform2i(n.outTexShapeLocation, a.texData.texShape[0], a.texData.texShape[1]), n.program.customUniforms && o) for (let t = 0; t < n.program.customUniforms.length; ++t) {
1571
- let r = n.program.customUniforms[t], i = n.customUniformLocations[t], a = o[t];
1550
+ if (t.outTexShapeLocation && e.gl.uniform2i(t.outTexShapeLocation, i.texData.texShape[0], i.texData.texShape[1]), t.program.customUniforms && s) for (let n = 0; n < t.program.customUniforms.length; ++n) {
1551
+ let r = t.program.customUniforms[n], i = t.customUniformLocations[n], a = s[n];
1572
1552
  if (r.type === "float") e.gl.uniform1fv(i, a);
1573
1553
  else if (r.type === "vec2") e.gl.uniform2fv(i, a);
1574
1554
  else if (r.type === "vec3") e.gl.uniform3fv(i, a);
@@ -1581,32 +1561,31 @@ function wt(e, n, r, a, o) {
1581
1561
  }
1582
1562
  e.executeProgram();
1583
1563
  }
1584
- function Tt(r, a, o) {
1585
- let c = "";
1586
- a.concat(o).forEach((t) => {
1564
+ function Tt(e, t, n) {
1565
+ let i = "";
1566
+ t.concat(n).forEach((t) => {
1587
1567
  let a = t.texData != null && t.texData.slice != null && t.texData.slice.flatOffset > 0;
1588
- if (r.enableShapeUniforms && !t.isUniform) {
1589
- let l = t.texData.texShape, { useSqueezeShape: u, uniformShape: d, keptDims: f } = A(r.packedInputs, t.shape, l), p = "", m = "", h = "";
1590
- if (d.length === 1 && r.packedInputs) {
1568
+ if (e.enableShapeUniforms && !t.isUniform) {
1569
+ let l = t.texData.texShape, { useSqueezeShape: u, uniformShape: d, keptDims: f } = A(e.packedInputs, t.shape, l), p = "", m = "", h = "";
1570
+ if (d.length === 1 && e.packedInputs) {
1591
1571
  let e = [Math.ceil(l[0] / 2), Math.ceil(l[1] / 2)];
1592
1572
  p = `${e[0] > 1}_${e[1] > 1}`;
1593
- } else if (d.length === 2 && !r.packedInputs) m = `${d[0] > 1}_${d[1] > 1}`;
1594
- else if (d.length > 2 && !r.packedInputs) {
1595
- let e = i(d);
1573
+ } else if (d.length === 2 && !e.packedInputs) m = `${d[0] > 1}_${d[1] > 1}`;
1574
+ else if (d.length > 2 && !e.packedInputs) {
1575
+ let e = r(d);
1596
1576
  h = `${e[0] === l[1]}_${e[e.length - 1] === l[1]}`;
1597
1577
  }
1598
- let g = t.shape.length, _ = d.length === 2 && n(t.shape, l), v = s(t.shape) === 1, y = e(t.shape, o.shape), b = !r.packedInputs && g === o.shape.length && n(l, o.texData.texShape), x = r.packedInputs || d.length > 2 ? "" : `${l[0] > 1}_${l[1] > 1}`;
1599
- c += `${g}_${b}_${u ? f : ""}_${d.length}_${v}_${y}_${_}_${p}_${m}_${h}_${x}_${a}`;
1578
+ let g = t.shape.length, _ = d.length === 2 && s(t.shape, l), v = o(t.shape) === 1, y = c(t.shape, n.shape), b = !e.packedInputs && g === n.shape.length && s(l, n.texData.texShape), x = e.packedInputs || d.length > 2 ? "" : `${l[0] > 1}_${l[1] > 1}`;
1579
+ i += `${g}_${b}_${u ? f : ""}_${d.length}_${v}_${y}_${_}_${p}_${m}_${h}_${x}_${a}`;
1600
1580
  } else {
1601
1581
  let e = t.isUniform ? "uniform" : t.texData.texShape;
1602
- c += `${t.shape}_${e}_${a}`;
1582
+ i += `${t.shape}_${e}_${a}`;
1603
1583
  }
1604
1584
  });
1605
- let l = r.userCode, u = r.constructor.name;
1606
- return u += "_" + c + "_" + l + `${t().getNumber("WEBGL_VERSION")}`, u;
1585
+ let l = e.userCode, u = e.constructor.name;
1586
+ return u += "_" + i + "_" + l + `${a().getNumber("WEBGL_VERSION")}`, u;
1607
1587
  }
1608
1588
  function Et(e) {
1609
- return t().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4;
1589
+ return a().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4;
1610
1590
  }
1611
- //#endregion
1612
1591
  export { g as $, yt as A, I as B, K as C, mt as D, gt as E, U as F, Re as G, L as H, st as I, Fe as J, B as K, ct as L, xt as M, _t as N, X as O, Je as P, v as Q, Ye as R, rt as S, ft as T, Le as U, R as V, z as W, Me as X, F as Y, k as Z, Ge as _, Et as a, ht as b, at as c, He as d, _ as et, et as f, Qe as g, Xe as h, wt as i, d as it, pt as j, vt as k, tt as l, Ze as m, Q as n, h as nt, St as o, qe as p, Ie as q, Tt as r, p as rt, ot as s, Ct as t, f as tt, V as u, G as v, dt as w, it as x, We as y, $e as z };