@genai-fi/nanogpt 0.10.2 → 0.11.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 (262) hide show
  1. package/dist/Generator.d.ts +10 -5
  2. package/dist/Generator.js +11760 -146
  3. package/dist/{RealDiv-zz7FpkKX.js → RealDiv-Ds-jvL09.js} +28 -30
  4. package/dist/Reshape-Cd6e-Otn.js +14 -0
  5. package/dist/{Reshape-CHdUjC72.js → Reshape-Ct266DEk.js} +21 -23
  6. package/dist/TeachableLLM.d.ts +4 -3
  7. package/dist/TeachableLLM.js +15 -16
  8. package/dist/Trainer.d.ts +2 -2
  9. package/dist/Trainer.js +6 -6
  10. package/dist/{axis_util-BsIr9ZNu.js → axis_util-DofAuy0p.js} +1 -1
  11. package/dist/backend.js +2 -2
  12. package/dist/{backend_util-B1XRLuq9.js → backend_util-C7NWHpv7.js} +72 -73
  13. package/dist/{backend_webgpu-CqpfEImu.js → backend_webgpu-B0Vls736.js} +52 -54
  14. package/dist/broadcast_to-DDaNMbX7.js +28 -0
  15. package/dist/checks/appendCache.js +2 -2
  16. package/dist/checks/attentionMask.js +3 -3
  17. package/dist/checks/gelu.js +2 -2
  18. package/dist/checks/matMulGelu.js +7 -11
  19. package/dist/checks/normRMS.js +9 -9
  20. package/dist/checks/normRMSGrad.js +3 -3
  21. package/dist/checks/packUnpack.js +2 -2
  22. package/dist/checks/qkv.js +11 -12
  23. package/dist/checks/rope.js +2 -2
  24. package/dist/clip_by_value-Dn5tzexi.js +12 -0
  25. package/dist/complex-DClmWqJt.js +11 -0
  26. package/dist/concat-C6X3AAlQ.js +17 -0
  27. package/dist/{concat_util-iBYIyuQe.js → concat_util-CHsJFZJJ.js} +1 -1
  28. package/dist/{dataset-D2P7rHAw.js → dataset-DcjWqUVQ.js} +135 -137
  29. package/dist/dropout-OxuaJz6z.js +92 -0
  30. package/dist/expand_dims-BzfJK2uc.js +11 -0
  31. package/dist/{exports_initializers-CZSUJoVE.js → exports_initializers-eS9QJ6ut.js} +1 -1
  32. package/dist/floor-DIb-lN_u.js +9 -0
  33. package/dist/gather-BcO5UQNJ.js +9 -0
  34. package/dist/{gelu-Bmhopi0J.js → gelu-DqTbCx5x.js} +10 -11
  35. package/dist/{gpgpu_math-DsCcikas.js → gpgpu_math-CJcbnKPC.js} +841 -1015
  36. package/dist/index-D0RBWjq8.js +3520 -0
  37. package/dist/{index-DRyE072i.js → index-Dj5TkmPY.js} +330 -331
  38. package/dist/{kernel_funcs_utils-CWfOAPGO.js → kernel_funcs_utils-CSaumNDs.js} +132 -134
  39. package/dist/layers/BaseLayer.js +15 -16
  40. package/dist/layers/CausalSelfAttention.js +6 -6
  41. package/dist/layers/MLP.js +4 -4
  42. package/dist/layers/PositionEmbedding.js +7 -7
  43. package/dist/layers/RMSNorm.js +3 -3
  44. package/dist/layers/RoPECache.js +9 -9
  45. package/dist/layers/TiedEmbedding.js +6 -6
  46. package/dist/layers/TransformerBlock.js +1 -1
  47. package/dist/loader/loadTransformers.js +1 -1
  48. package/dist/loader/oldZipLoad.js +21 -22
  49. package/dist/log_sum_exp-VLZgbFAH.js +39 -0
  50. package/dist/main.d.ts +1 -1
  51. package/dist/main.js +49 -50
  52. package/dist/{matMul16-fEAJ4smh.js → matMul16-cDxwemKj.js} +14 -15
  53. package/dist/matMulGelu-B2s_80-H.js +163 -0
  54. package/dist/mat_mul-DxpNTCRz.js +11 -0
  55. package/dist/mod-PrOKlFxH.js +11 -0
  56. package/dist/models/NanoGPTV1.js +2 -2
  57. package/dist/models/model.js +13 -14
  58. package/dist/ones-BX_wEgzB.js +14 -0
  59. package/dist/ops/adamAdjust.js +1 -1
  60. package/dist/ops/adamMoments.js +1 -1
  61. package/dist/ops/add16.js +1 -1
  62. package/dist/ops/appendCache.js +3 -3
  63. package/dist/ops/attentionMask.js +1 -1
  64. package/dist/ops/concat16.js +2 -2
  65. package/dist/ops/cpu/adamAdjust.js +12 -13
  66. package/dist/ops/cpu/adamMoments.js +6 -7
  67. package/dist/ops/cpu/appendCache.js +7 -8
  68. package/dist/ops/cpu/attentionMask.js +11 -11
  69. package/dist/ops/cpu/fusedSoftmax.js +10 -11
  70. package/dist/ops/cpu/gatherSub.js +10 -11
  71. package/dist/ops/cpu/gelu.js +14 -15
  72. package/dist/ops/cpu/matMul16.js +6 -7
  73. package/dist/ops/cpu/matMulGelu.js +5 -6
  74. package/dist/ops/cpu/matMulMul.js +3 -4
  75. package/dist/ops/cpu/mulDropout.js +3 -4
  76. package/dist/ops/cpu/normRMS.js +11 -12
  77. package/dist/ops/cpu/qkv.js +8 -9
  78. package/dist/ops/cpu/rope.js +9 -10
  79. package/dist/ops/cpu/scatterSub.js +14 -16
  80. package/dist/ops/dot16.js +2 -2
  81. package/dist/ops/gatherSub.js +1 -1
  82. package/dist/ops/gelu.js +2 -2
  83. package/dist/ops/grads/add16.js +10 -11
  84. package/dist/ops/grads/attentionMask.js +5 -6
  85. package/dist/ops/grads/gelu.js +3 -4
  86. package/dist/ops/grads/matMul16.js +4 -5
  87. package/dist/ops/grads/matMulGelu.js +8 -9
  88. package/dist/ops/grads/normRMS.js +9 -10
  89. package/dist/ops/grads/pack16.js +4 -5
  90. package/dist/ops/grads/qkv.js +17 -19
  91. package/dist/ops/grads/rope.js +3 -5
  92. package/dist/ops/grads/softmax16.js +3 -4
  93. package/dist/ops/grads/unpack16.js +3 -4
  94. package/dist/ops/grads/utils.d.ts +1 -0
  95. package/dist/ops/grads/utils.js +8 -4
  96. package/dist/ops/matMul16.js +3 -3
  97. package/dist/ops/matMulGelu.js +2 -2
  98. package/dist/ops/matMulMul.js +1 -1
  99. package/dist/ops/mul16.js +1 -1
  100. package/dist/ops/mulDrop.js +1 -1
  101. package/dist/ops/normRMS.js +1 -1
  102. package/dist/ops/pack16.js +3 -4
  103. package/dist/ops/qkv.js +4 -8
  104. package/dist/ops/reshape16.js +16 -18
  105. package/dist/ops/rope.d.ts +1 -1
  106. package/dist/ops/rope.js +3 -8
  107. package/dist/ops/scatterSub.js +1 -1
  108. package/dist/ops/slice16.js +2 -2
  109. package/dist/ops/softmax16.js +5 -8
  110. package/dist/ops/sub16.js +1 -1
  111. package/dist/ops/sum16.js +2 -2
  112. package/dist/ops/transpose16.js +23 -24
  113. package/dist/ops/unpack16.js +2 -2
  114. package/dist/ops/webgl/adamAdjust.js +2 -3
  115. package/dist/ops/webgl/adamMoments.js +1 -2
  116. package/dist/ops/webgl/appendCache.js +1 -2
  117. package/dist/ops/webgl/attentionMask.js +5 -6
  118. package/dist/ops/webgl/fusedSoftmax.js +6 -8
  119. package/dist/ops/webgl/gatherSub.js +6 -7
  120. package/dist/ops/webgl/gelu.js +2 -3
  121. package/dist/ops/webgl/log.js +11 -12
  122. package/dist/ops/webgl/matMul16.js +15 -16
  123. package/dist/ops/webgl/matMulGelu.js +7 -111
  124. package/dist/ops/webgl/matMulMul.js +14 -15
  125. package/dist/ops/webgl/mulDropout.js +8 -9
  126. package/dist/ops/webgl/normRMS.js +7 -8
  127. package/dist/ops/webgl/qkv.js +5 -6
  128. package/dist/ops/webgl/rope.js +7 -8
  129. package/dist/ops/webgl/scatterSub.js +5 -6
  130. package/dist/ops/webgpu/adamAdjust.js +10 -12
  131. package/dist/ops/webgpu/adamMoments.js +8 -10
  132. package/dist/ops/webgpu/add16.js +8 -9
  133. package/dist/ops/webgpu/appendCache.js +23 -25
  134. package/dist/ops/webgpu/attentionMask.js +10 -12
  135. package/dist/ops/webgpu/attentionMask32_program.js +2 -2
  136. package/dist/ops/webgpu/concat16.js +12 -14
  137. package/dist/ops/webgpu/gatherSub.js +9 -11
  138. package/dist/ops/webgpu/gelu.js +28 -29
  139. package/dist/ops/webgpu/matMul16.js +26 -28
  140. package/dist/ops/webgpu/matMul16_program.js +4 -5
  141. package/dist/ops/webgpu/mul16.js +7 -8
  142. package/dist/ops/webgpu/normRMS.js +17 -19
  143. package/dist/ops/webgpu/normRMSGrad.js +21 -28
  144. package/dist/ops/webgpu/pack16.js +12 -13
  145. package/dist/ops/webgpu/pack16_program.js +2 -2
  146. package/dist/ops/webgpu/qkv.js +13 -15
  147. package/dist/ops/webgpu/rope.js +25 -27
  148. package/dist/ops/webgpu/scatterSub.js +7 -9
  149. package/dist/ops/webgpu/slice16.js +21 -23
  150. package/dist/ops/webgpu/softmax16.js +17 -19
  151. package/dist/ops/webgpu/softmax16_program.js +2 -2
  152. package/dist/ops/webgpu/softmax16_subgroup_program.js +2 -2
  153. package/dist/ops/webgpu/softmax16grad.js +7 -8
  154. package/dist/ops/webgpu/sub16.js +8 -9
  155. package/dist/ops/webgpu/sum16.js +19 -21
  156. package/dist/ops/webgpu/transpose16.js +19 -20
  157. package/dist/ops/webgpu/transpose16_program.js +2 -2
  158. package/dist/ops/webgpu/transpose16_shared_program.js +11 -12
  159. package/dist/ops/webgpu/unpack16.js +3 -4
  160. package/dist/ops/webgpu/utils/binary_op.js +7 -8
  161. package/dist/ops/webgpu/utils/reductions.js +14 -22
  162. package/dist/ops-FJapAPfm.js +476 -0
  163. package/dist/pack16-k4jq6aMX.js +39 -0
  164. package/dist/patches/webgpu_backend.js +19 -20
  165. package/dist/patches/webgpu_base.js +1 -1
  166. package/dist/patches/webgpu_program.js +15 -16
  167. package/dist/{random_width-BVV9HveY.js → random_width-UGQn4OWb.js} +2506 -2761
  168. package/dist/range-CuGvVN2c.js +10 -0
  169. package/dist/relu-Cf80uA2p.js +9 -0
  170. package/dist/reshape-CkjKPPqB.js +9 -0
  171. package/dist/resize_nearest_neighbor-DB8k9KN_.js +175 -0
  172. package/dist/rope-BmZmp9uP.js +24 -0
  173. package/dist/{scatter_nd_util-C7zXRT_h.js → scatter_nd_util-BY22Cc-C.js} +1 -1
  174. package/dist/selu_util-BuLbmbrl.js +44 -0
  175. package/dist/{shared-CHhxz-O5.js → shared-B7USJZgw.js} +1 -1
  176. package/dist/{shared-D2NP_CpY.js → shared-BQboIImQ.js} +379 -381
  177. package/dist/slice-Aqy7KbJh.js +12 -0
  178. package/dist/{slice_util-DyjSAD0u.js → slice_util-D8CQRenR.js} +7 -7
  179. package/dist/{softmax-C9JQEtnO.js → softmax-faLoUZVT.js} +4 -5
  180. package/dist/split-BNz5jcGc.js +9 -0
  181. package/dist/squeeze--YMgaAAf.js +10 -0
  182. package/dist/stack-WJK22CFn.js +11 -0
  183. package/dist/step-dXR33iOg.js +261 -0
  184. package/dist/sum-BdplSvq_.js +11 -0
  185. package/dist/{tensor-0r5yOo2R.js → tensor-BQqrDvpx.js} +1 -1
  186. package/dist/tensor1d-LxP9asMm.js +11 -0
  187. package/dist/{tensor2d-CSB4KOb0.js → tensor2d-BN1sSfQO.js} +6 -7
  188. package/dist/{tensor4d-D7bLqGqz.js → tensor4d-DVwr7pLF.js} +6 -7
  189. package/dist/{tfjs_backend-CNkSTL0c.js → tfjs_backend-Vi4JfLzT.js} +256 -265
  190. package/dist/tile-CvN_LyVr.js +11 -0
  191. package/dist/tokeniser/BaseTokeniser.d.ts +27 -0
  192. package/dist/tokeniser/BaseTokeniser.js +94 -0
  193. package/dist/tokeniser/CharTokeniser.d.ts +4 -3
  194. package/dist/tokeniser/CharTokeniser.js +46 -32
  195. package/dist/tokeniser/bpe.d.ts +4 -3
  196. package/dist/tokeniser/bpe.js +60 -45
  197. package/dist/tokeniser/type.d.ts +11 -0
  198. package/dist/training/Adam.js +2 -2
  199. package/dist/training/AdamExt.js +1 -1
  200. package/dist/training/DatasetBuilder.d.ts +2 -2
  201. package/dist/training/DatasetBuilder.js +32 -36
  202. package/dist/training/FullTrainer.js +1 -1
  203. package/dist/training/Trainer.d.ts +3 -3
  204. package/dist/training/Trainer.js +2 -2
  205. package/dist/training/sparseCrossEntropy.js +5 -5
  206. package/dist/transpose-JawVKyZy.js +36 -0
  207. package/dist/unsorted_segment_sum-LAbmE9G4.js +277 -0
  208. package/dist/utilities/dummy.js +3 -3
  209. package/dist/utilities/multinomialCPU.js +2 -2
  210. package/dist/utilities/packed.d.ts +1 -4
  211. package/dist/utilities/packed.js +10 -745
  212. package/dist/utilities/performance.js +1 -1
  213. package/dist/utilities/profile.js +1 -1
  214. package/dist/utilities/safetensors.js +2 -2
  215. package/dist/utilities/sentences.js +5 -5
  216. package/dist/utilities/weights.js +2 -2
  217. package/dist/{variable-DzfrwYuP.js → variable-DQ9yYgEU.js} +1 -1
  218. package/dist/{webgpu_program-DzaQiqel.js → webgpu_program-CAE4RICo.js} +177 -171
  219. package/dist/{webgpu_util-0_ubCEHJ.js → webgpu_util-BdovYhXr.js} +34 -35
  220. package/dist/zeros-DeiE2zTa.js +13 -0
  221. package/dist/zeros_like-BAz3iKru.js +721 -0
  222. package/package.json +4 -2
  223. package/dist/Reshape-CDVLyVfz.js +0 -16
  224. package/dist/broadcast_to-B0ChcDaz.js +0 -30
  225. package/dist/complex-BBiRlsVq.js +0 -13
  226. package/dist/concat-DmBLPVGC.js +0 -19
  227. package/dist/dropout-B1x1kYMa.js +0 -99
  228. package/dist/expand_dims-ouvfxQ1n.js +0 -13
  229. package/dist/gather-CH9sdacz.js +0 -10
  230. package/dist/index-D6Q1lPZO.js +0 -2157
  231. package/dist/log_sum_exp-D3ftBNY5.js +0 -41
  232. package/dist/mat_mul-C59XWcJd.js +0 -12
  233. package/dist/mod-DESSvHIU.js +0 -12
  234. package/dist/mulmat_packed_gpu-Coh6qbJk.js +0 -55
  235. package/dist/ones-jU9jlQvM.js +0 -15
  236. package/dist/ops-BFDtP6th.js +0 -645
  237. package/dist/pack16-CmVZs6af.js +0 -41
  238. package/dist/patches/PackedTensor.d.ts +0 -12
  239. package/dist/patches/PackedTensor.js +0 -11
  240. package/dist/patches/engine.d.ts +0 -261
  241. package/dist/patches/engine.js +0 -12
  242. package/dist/patches/tape.d.ts +0 -12
  243. package/dist/patches/tape.js +0 -5
  244. package/dist/range-ZZZD60Fx.js +0 -11
  245. package/dist/reciprocal-CrYlsAGD.js +0 -10
  246. package/dist/register_all_kernels-nvj2k7OC.js +0 -12307
  247. package/dist/relu-BYDneVPn.js +0 -10
  248. package/dist/reshape-CaPQzFvz.js +0 -10
  249. package/dist/rope-s4W2XO9B.js +0 -32
  250. package/dist/selu_util-BGPXmd4B.js +0 -303
  251. package/dist/sin-Djs4aQiu.js +0 -16
  252. package/dist/slice-DvovR5wq.js +0 -13
  253. package/dist/split-DBck65sX.js +0 -10
  254. package/dist/squeeze-C00Ipm_7.js +0 -11
  255. package/dist/stack-ChnHwRpX.js +0 -13
  256. package/dist/sum-ywRJj3Zr.js +0 -12
  257. package/dist/tensor-CzmOBsdf.js +0 -909
  258. package/dist/tensor1d-BlUT89BP.js +0 -12
  259. package/dist/tensor_util-DfwaWayG.js +0 -523
  260. package/dist/tile-CR074jmp.js +0 -13
  261. package/dist/transpose-DH4gmHvu.js +0 -38
  262. package/dist/zeros-DBFVbpv5.js +0 -14
@@ -1,10 +1,8 @@
1
- import { isPackedTensor as w } from "../../utilities/packed.js";
2
- import { e as x } from "../../webgpu_program-DzaQiqel.js";
3
- import { f as l, c as m } from "../../webgpu_util-0_ubCEHJ.js";
4
- import "../../index-D6Q1lPZO.js";
5
- import { j as b } from "../../tensor-CzmOBsdf.js";
6
- import { r as v } from "../../tensor_util-DfwaWayG.js";
7
- class k {
1
+ import { isPackedTensor as y } from "../../utilities/packed.js";
2
+ import { e as c } from "../../webgpu_program-CAE4RICo.js";
3
+ import { f as x, c as l } from "../../webgpu_util-BdovYhXr.js";
4
+ import { h as w, a7 as b } from "../../index-D0RBWjq8.js";
5
+ class v {
8
6
  variableNames = ["x", "sin", "cos"];
9
7
  outputShape;
10
8
  shaderKey = "Rope";
@@ -13,13 +11,13 @@ class k {
13
11
  workgroupSize = [64, 1, 1];
14
12
  size = !0;
15
13
  uniforms = "pastLen: i32";
16
- constructor(e, s, r, t) {
17
- this.shaderKey = `Rope_${t}`, this.outputShape = [e, s, r, t], this.dispatchLayout = l(this.outputShape), this.dispatch = m(this.dispatchLayout, this.outputShape, this.workgroupSize);
14
+ constructor(e, o, a, t) {
15
+ this.shaderKey = `Rope_${t}`, this.outputShape = [e, o, a, t], this.dispatchLayout = x(this.outputShape), this.dispatch = l(this.dispatchLayout, this.outputShape, this.workgroupSize);
18
16
  }
19
17
  getUserCode() {
20
18
  const e = this.outputShape[3];
21
19
  return `
22
- ${x("index")} {
20
+ ${c("index")} {
23
21
  if (index < uniforms.size) {
24
22
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
25
23
  let b = coords[0];
@@ -64,7 +62,7 @@ class k {
64
62
  `;
65
63
  }
66
64
  }
67
- class L {
65
+ class k {
68
66
  variableNames = ["x", "sin", "cos"];
69
67
  outputShape;
70
68
  shaderKey = "Rope";
@@ -73,12 +71,12 @@ class L {
73
71
  workgroupSize = [64, 1, 1];
74
72
  size = !0;
75
73
  uniforms = "pastLen: i32";
76
- constructor(e, s, r, t) {
77
- this.shaderKey = `Rope_${t}`, this.outputShape = [e, s, r, t / 2], this.dispatchLayout = l(this.outputShape), this.dispatch = m(this.dispatchLayout, this.outputShape, this.workgroupSize);
74
+ constructor(e, o, a, t) {
75
+ this.shaderKey = `Rope_${t}`, this.outputShape = [e, o, a, t / 2], this.dispatchLayout = x(this.outputShape), this.dispatch = l(this.dispatchLayout, this.outputShape, this.workgroupSize);
78
76
  }
79
77
  getUserCode() {
80
78
  return `
81
- ${x("index")} {
79
+ ${c("index")} {
82
80
  if (index < uniforms.size) {
83
81
  let coords = getCoordsFromIndex(index); // [b, h, t, d]
84
82
  let b = coords[0];
@@ -116,22 +114,22 @@ class L {
116
114
  `;
117
115
  }
118
116
  }
119
- function P(i) {
120
- const { x: e } = i.inputs, { pastLen: s, negSin: r, ropeCache: t } = i.attrs, f = i.backend, a = w(e), p = e.shape[0], h = e.shape[1], n = e.shape[2], d = a ? e.shape[3] * 2 : e.shape[3], o = r ? t.getNegSin() : t.getSin(), u = t.getCos();
121
- if (b(o.shape, u.shape, "Error in Rope: "), o.shape[0] < n + s)
117
+ function L(i) {
118
+ const { x: e } = i.inputs, { pastLen: o, negSin: a, ropeCache: t } = i.attrs, m = i.backend, d = y(e), p = e.shape[0], h = e.shape[1], r = e.shape[2], n = d ? e.shape[3] * 2 : e.shape[3], s = a ? t.getNegSin() : t.getSin(), u = t.getCos();
119
+ if (b(s.shape, u.shape, "Error in Rope: "), s.shape[0] < r + o)
122
120
  throw new Error(
123
- `Sin tensor shape ${o.shape} is not compatible with seqLength ${n} and pastLen ${s}.`
121
+ `Sin tensor shape ${s.shape} is not compatible with seqLength ${r} and pastLen ${o}.`
124
122
  );
125
- if (o.shape[1] * 2 < d)
126
- throw new Error(`Sin tensor shape ${o.shape} is not compatible with feature dimension ${d}.`);
127
- if (o.shape.length !== 3)
128
- throw new Error(`Sin tensor must be 3-dimensional, but got shape ${o.shape}.`);
129
- const S = a ? new L(p, h, n, d) : new k(p, h, n, d), g = [{ type: "int32", data: [s] }], y = a ? "int32" : e.dtype, c = f.runWebGPUProgram(S, [e, o, u], y, g);
130
- return c.packed = a, c;
123
+ if (s.shape[1] * 2 < n)
124
+ throw new Error(`Sin tensor shape ${s.shape} is not compatible with feature dimension ${n}.`);
125
+ if (s.shape.length !== 3)
126
+ throw new Error(`Sin tensor must be 3-dimensional, but got shape ${s.shape}.`);
127
+ const f = d ? new k(p, h, r, n) : new v(p, h, r, n), S = [{ type: "int32", data: [o] }], g = d ? "packedF16" : e.dtype;
128
+ return m.runWebGPUProgram(f, [e, s, u], g, S);
131
129
  }
132
- const $ = {
130
+ const P = {
133
131
  kernelName: "Rope",
134
132
  backendName: "webgpu",
135
- kernelFunc: P
133
+ kernelFunc: L
136
134
  };
137
- v($);
135
+ w(P);
@@ -1,8 +1,6 @@
1
- import { e as p } from "../../webgpu_program-DzaQiqel.js";
2
- import { f as u, c as d } from "../../webgpu_util-0_ubCEHJ.js";
3
- import "../../index-D6Q1lPZO.js";
4
- import { j as s } from "../../tensor-CzmOBsdf.js";
5
- import { r as h } from "../../tensor_util-DfwaWayG.js";
1
+ import { e as p } from "../../webgpu_program-CAE4RICo.js";
2
+ import { f as u, c as d } from "../../webgpu_util-BdovYhXr.js";
3
+ import { h, a7 as o } from "../../index-D0RBWjq8.js";
6
4
  class b {
7
5
  variableNames = ["labels", "softmaxProbs", "dy"];
8
6
  outputShape;
@@ -28,11 +26,11 @@ class b {
28
26
  `;
29
27
  }
30
28
  }
31
- function f(o) {
32
- const { logits: t, labels: e, dy: a } = o.inputs, c = o.backend, r = e.shape[0], i = t.shape[1];
33
- s(a.shape, [r], "Error in EfficientScatterSub dy: "), s(t.shape, [r, i], "Error in EfficientScatterSub logits: "), s(e.shape, [r], "Error in EfficientScatterSub labels: ");
29
+ function f(a) {
30
+ const { logits: t, labels: e, dy: s } = a.inputs, c = a.backend, r = e.shape[0], i = t.shape[1];
31
+ o(s.shape, [r], "Error in EfficientScatterSub dy: "), o(t.shape, [r, i], "Error in EfficientScatterSub logits: "), o(e.shape, [r], "Error in EfficientScatterSub labels: ");
34
32
  const n = new b(r, i);
35
- return c.runWebGPUProgram(n, [e, t, a], "float32");
33
+ return c.runWebGPUProgram(n, [e, t, s], "float32");
36
34
  }
37
35
  const l = {
38
36
  kernelName: "EfficientScatterSub",
@@ -1,10 +1,8 @@
1
- import { b as c, c as f, e as l } from "../../webgpu_program-DzaQiqel.js";
2
- import { f as g, c as S } from "../../webgpu_util-0_ubCEHJ.js";
3
- import "../../index-D6Q1lPZO.js";
4
- import { r as k } from "../../tensor_util-DfwaWayG.js";
5
- import { p as y, a as $ } from "../../slice_util-DyjSAD0u.js";
6
- import { s as x } from "../../tensor-CzmOBsdf.js";
7
- function b(o) {
1
+ import { b as u, c as m, e as l } from "../../webgpu_program-CAE4RICo.js";
2
+ import { f, c as g } from "../../webgpu_util-BdovYhXr.js";
3
+ import { h as S, V as k } from "../../index-D0RBWjq8.js";
4
+ import { p as y, a as $ } from "../../slice_util-D8CQRenR.js";
5
+ function x(o) {
8
6
  switch (o) {
9
7
  case 1:
10
8
  return "1D";
@@ -17,7 +15,7 @@ function b(o) {
17
15
  }
18
16
  return "";
19
17
  }
20
- class w {
18
+ class b {
21
19
  variableNames = ["source"];
22
20
  uniforms;
23
21
  outputShape;
@@ -30,42 +28,42 @@ class w {
30
28
  start;
31
29
  size = !0;
32
30
  constructor(e, t) {
33
- this.outputShape = t, this.rank = t.length, this.dispatchLayout = g(this.outputShape), this.dispatch = S(this.dispatchLayout, this.outputShape, this.workgroupSize, [
31
+ this.outputShape = t, this.rank = t.length, this.dispatchLayout = f(this.outputShape), this.dispatch = g(this.dispatchLayout, this.outputShape, this.workgroupSize, [
34
32
  this.workPerThread,
35
33
  1,
36
34
  1
37
- ]), this.start = e, this.uniforms = `start : ${c(e.length)}, `, this.shaderKey = "slice";
35
+ ]), this.start = e, this.uniforms = `start : ${u(e.length)}, `, this.shaderKey = "slice";
38
36
  }
39
37
  getUserCode() {
40
- const e = c(this.rank);
38
+ const e = u(this.rank);
41
39
  let t;
42
- return this.start.length === 1 ? t = this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : t = this.outputShape.map((r, s) => `sourceLoc.${p[s]} = uniforms.start.${f(s)} + coords.${p[s]};`), `
40
+ return this.start.length === 1 ? t = this.outputShape.map(() => "sourceLoc = uniforms.start + coords;") : t = this.outputShape.map((r, s) => `sourceLoc.${c[s]} = uniforms.start.${m(s)} + coords.${c[s]};`), `
43
41
  ${l("index")} {
44
42
  if (index < uniforms.size) {
45
43
  var sourceLoc : ${e};
46
44
  let coords = getCoordsFromIndex(index);
47
45
  ${t.join(`
48
46
  `)}
49
- result[index] = source[getIndexFromCoords${b(this.rank)}(sourceLoc, uniforms.sourceShape)];
47
+ result[index] = source[getIndexFromCoords${x(this.rank)}(sourceLoc, uniforms.sourceShape)];
50
48
  }
51
49
  }
52
50
  `;
53
51
  }
54
52
  }
55
- const p = ["x", "y", "z", "w", "u", "v"];
56
- function C(o) {
57
- const { inputs: e, backend: t, attrs: n } = o, { x: r } = e, { begin: s, size: h } = n, [i, a] = y(r, s, h);
58
- if ($(r, i, a), x(a) === 0)
53
+ const c = ["x", "y", "z", "w", "u", "v"];
54
+ function w(o) {
55
+ const { inputs: e, backend: t, attrs: n } = o, { x: r } = e, { begin: s, size: p } = n, [i, a] = y(r, s, p);
56
+ if ($(r, i, a), k(a) === 0)
59
57
  return t.makeTensorInfo(a, r.dtype, []);
60
- const d = new w(i, a), m = [{ type: "int32", data: i }], u = t.runWebGPUProgram(d, [r], r.dtype, m);
61
- return u.packed = !0, u;
58
+ const h = new b(i, a), d = [{ type: "int32", data: i }];
59
+ return t.runWebGPUProgram(h, [r], r.dtype, d);
62
60
  }
63
- const D = {
61
+ const C = {
64
62
  kernelName: "Slice16",
65
63
  backendName: "webgpu",
66
- kernelFunc: C
64
+ kernelFunc: w
67
65
  };
68
- k(D);
66
+ S(C);
69
67
  export {
70
- C as slice
68
+ w as slice
71
69
  };
@@ -1,23 +1,21 @@
1
- import { e as S } from "../../index-D6Q1lPZO.js";
2
- import { reshape16 as h } from "../reshape16.js";
3
- import b from "./softmax16_program.js";
4
- import d from "./softmax16_subgroup_program.js";
5
- import x from "./utils/deviceInfo.js";
6
- import { r as k } from "../../tensor_util-DfwaWayG.js";
7
- import { r as l } from "../../reshape-CaPQzFvz.js";
8
- import { s as z } from "../../tensor-CzmOBsdf.js";
9
- function I(a) {
10
- const { inputs: m, backend: e, attrs: p } = a, { logits: o } = m, { dim: s } = p, i = e.subgroupMinSize, c = e.subgroupMaxSize, u = x(e).subgroupsSupported, r = l(o, [
11
- z(o.shape) / o.shape[s],
12
- o.shape[s]
13
- ]), f = u ? new d(r.shape, i, c) : new b(r.shape), n = e.runWebGPUProgram(f, [r], "int32");
14
- n.packed = !0, r.dispose();
15
- const t = S().makeTensorFromTensorInfo(n), g = h(t, o.shape);
16
- return t.dispose(), g;
1
+ import { h, V as S, e as b } from "../../index-D0RBWjq8.js";
2
+ import { reshape16 as d } from "../reshape16.js";
3
+ import x from "./softmax16_program.js";
4
+ import k from "./softmax16_subgroup_program.js";
5
+ import l from "./utils/deviceInfo.js";
6
+ import { r as z } from "../../reshape-CkjKPPqB.js";
7
+ function F(a) {
8
+ const { inputs: t, backend: o, attrs: p } = a, { logits: e } = t, { dim: r } = p, m = o.subgroupMinSize, i = o.subgroupMaxSize, c = l(o).subgroupsSupported, s = z(e, [
9
+ S(e.shape) / e.shape[r],
10
+ e.shape[r]
11
+ ]), u = c ? new k(s.shape, m, i) : new x(s.shape), f = o.runWebGPUProgram(u, [s], "packedF16");
12
+ s.dispose();
13
+ const n = b().makeTensorFromTensorInfo(f), g = d(n, e.shape);
14
+ return n.dispose(), g;
17
15
  }
18
- const P = {
16
+ const I = {
19
17
  kernelName: "Softmax16",
20
18
  backendName: "webgpu",
21
- kernelFunc: I
19
+ kernelFunc: F
22
20
  };
23
- k(P);
21
+ h(I);
@@ -1,5 +1,5 @@
1
- import { e } from "../../webgpu_program-DzaQiqel.js";
2
- import { f as o } from "../../webgpu_util-0_ubCEHJ.js";
1
+ import { e } from "../../webgpu_program-CAE4RICo.js";
2
+ import { f as o } from "../../webgpu_util-BdovYhXr.js";
3
3
  class i {
4
4
  variableNames = ["logits"];
5
5
  outputShape;
@@ -1,5 +1,5 @@
1
- import { e as o } from "../../webgpu_program-DzaQiqel.js";
2
- import { f as u } from "../../webgpu_util-0_ubCEHJ.js";
1
+ import { e as o } from "../../webgpu_program-CAE4RICo.js";
2
+ import { f as u } from "../../webgpu_util-BdovYhXr.js";
3
3
  class i {
4
4
  variableNames = ["logits"];
5
5
  outputShape;
@@ -1,8 +1,7 @@
1
- import "../../index-D6Q1lPZO.js";
2
- import { createReduceInfo as p, reduce as m, ReduceProgram as i } from "./utils/reductions.js";
1
+ import { h as p } from "../../index-D0RBWjq8.js";
2
+ import { createReduceInfo as m, reduce as l, ReduceProgram as i } from "./utils/reductions.js";
3
3
  import { isPackedTensor as n } from "../../utilities/packed.js";
4
- import l from "./utils/deviceInfo.js";
5
- import { r as k } from "../../tensor_util-DfwaWayG.js";
4
+ import k from "./utils/deviceInfo.js";
6
5
  class x extends i {
7
6
  constructor(e, t) {
8
7
  super(e, t, { reductionOp: "sum", elementwise: !0 }, !0), this.shaderKey = "SoftmaxGrad16", this.variableNames = ["dy", "softmaxOutput"], this.variableComponents = [1, 1];
@@ -24,15 +23,15 @@ class x extends i {
24
23
  }
25
24
  }
26
25
  function b(o) {
27
- const { dy: e, softmaxOutput: t } = o.inputs, r = o.backend, s = l(r), u = n(e), c = n(t);
26
+ const { dy: e, softmaxOutput: t } = o.inputs, r = o.backend, s = k(r), u = n(e), c = n(t);
28
27
  if (!(u && c))
29
28
  throw new Error("softmaxGradGPU: dy and softmaxOutput must be packed tensors");
30
- const a = [e, t], f = p(a, -1), d = new x(s, f);
31
- return m(d, a, r);
29
+ const a = [e, t], f = m(a, -1), d = new x(s, f);
30
+ return l(d, a, r);
32
31
  }
33
32
  const v = {
34
33
  kernelName: "Softmax16Grad",
35
34
  backendName: "webgpu",
36
35
  kernelFunc: b
37
36
  };
38
- k(v);
37
+ p(v);
@@ -1,14 +1,13 @@
1
- import "../../index-D6Q1lPZO.js";
2
- import { BinaryOpProgram as p } from "./utils/binary_op.js";
3
- import { B as m } from "../../binary_op_util-pKXltfxI.js";
4
- import { r as s } from "../../tensor_util-DfwaWayG.js";
5
- function c(r) {
6
- const { a: e, b: n } = r.inputs, t = r.backend, a = new p(m.SUB, e.shape, n.shape), o = t.runWebGPUProgram(a, [e, n], "int32");
7
- return o.packed = !0, o;
1
+ import { h as t } from "../../index-D0RBWjq8.js";
2
+ import { BinaryOpProgram as s } from "./utils/binary_op.js";
3
+ import { B as p } from "../../binary_op_util-pKXltfxI.js";
4
+ function c(e) {
5
+ const { a: r, b: n } = e.inputs, o = e.backend, a = new s(p.SUB, r.shape, n.shape);
6
+ return o.runWebGPUProgram(a, [r, n], "packedF16");
8
7
  }
9
- const i = {
8
+ const m = {
10
9
  kernelName: "Sub16",
11
10
  backendName: "webgpu",
12
11
  kernelFunc: c
13
12
  };
14
- s(i);
13
+ t(m);
@@ -1,40 +1,38 @@
1
- import { createReduceInfo as g, reduce as h, ReduceProgram as x } from "./utils/reductions.js";
2
- import "../../index-D6Q1lPZO.js";
3
- import { isPackedTensor as k } from "../../utilities/packed.js";
4
- import { transpose16 as A } from "../transpose16.js";
5
- import P from "./utils/deviceInfo.js";
6
- import { r as b } from "../../tensor_util-DfwaWayG.js";
7
- import { s as I } from "../../sum-ywRJj3Zr.js";
8
- import { p as w } from "../../tensor-CzmOBsdf.js";
9
- import { a as D, b as K } from "../../axis_util-BsIr9ZNu.js";
1
+ import { createReduceInfo as h, reduce as g, ReduceProgram as x } from "./utils/reductions.js";
2
+ import { h as k, af as A } from "../../index-D0RBWjq8.js";
3
+ import { isPackedTensor as P } from "../../utilities/packed.js";
4
+ import { transpose16 as b } from "../transpose16.js";
5
+ import I from "./utils/deviceInfo.js";
6
+ import { s as w } from "../../sum-BdplSvq_.js";
7
+ import { a as D, b as K } from "../../axis_util-DofAuy0p.js";
10
8
  class v extends x {
11
9
  shaderKey = "sum16";
12
- constructor(e, o, t) {
10
+ constructor(e, t, o) {
13
11
  super(
14
12
  e,
15
- o,
13
+ t,
16
14
  {
17
15
  reductionOp: "sum",
18
16
  elementwise: !1
19
17
  },
20
- t
21
- ), t && (this.shaderKey += "_packed");
18
+ o
19
+ ), o && (this.shaderKey += "_packed");
22
20
  }
23
21
  }
24
22
  function y(r) {
25
- const { x: e } = r.inputs, { axis: o, keepDims: t } = r.attrs, m = r.backend, a = [], p = P(m), c = k(e);
26
- if (!c)
27
- return I(e, o, t);
28
- let n = w(o ?? -1, e.shape);
23
+ const { x: e } = r.inputs, { axis: t, keepDims: o } = r.attrs, a = r.backend, c = [], u = I(a), m = P(e);
24
+ if (!m)
25
+ return w(e, t, o);
26
+ let n = A(t ?? -1, e.shape);
29
27
  const i = D(n, e.shape.length);
30
28
  let s = e;
31
- i != null && (s = A(e, i), n = K(n.length, s.shape.length), a.push(s));
32
- const u = g([s], -1), f = new v(p, u, c), d = h(f, [s], m);
33
- return a.forEach((l) => l.dispose()), d;
29
+ i != null && (s = b(e, i), n = K(n.length, s.shape.length), c.push(s));
30
+ const p = h([s], -1), f = new v(u, p, m), d = g(f, [s], a);
31
+ return c.forEach((l) => l.dispose()), d;
34
32
  }
35
33
  const N = {
36
34
  kernelName: "Sum16",
37
35
  backendName: "webgpu",
38
36
  kernelFunc: y
39
37
  };
40
- b(N);
38
+ k(N);
@@ -1,29 +1,28 @@
1
1
  import { isPackedTensor as d } from "../../utilities/packed.js";
2
- import { e as k } from "../../index-D6Q1lPZO.js";
3
- import { reshape16 as i } from "../reshape16.js";
4
- import l from "./transpose16_shared_program.js";
5
- import P from "./transpose16_program.js";
6
- import { r as b } from "../../tensor_util-DfwaWayG.js";
7
- import { t as T } from "../../transpose-DH4gmHvu.js";
8
- function w(a) {
9
- const { inputs: u, attrs: h } = a, { x: e } = u, { perm: r } = h, m = a.backend, c = d(e);
10
- if (c && r[r.length - 1] !== e.shape.length - 1) {
11
- const n = e.shape.length, t = n === 4 ? r.map((s) => s - 1).filter((s) => s >= 0) : r, p = n === 4 ? i(e, [e.shape[0] * e.shape[1], e.shape[2], e.shape[3]]) : e, f = new l(p.shape, t), o = m.runWebGPUProgram(f, [p], "int32");
12
- if (o.packed = !0, n === 4) {
13
- p.dispose();
14
- const s = k().makeTensorFromTensorInfo(o), g = i(s, [
2
+ import { h as k, e as l } from "../../index-D0RBWjq8.js";
3
+ import { reshape16 as u } from "../reshape16.js";
4
+ import P from "./transpose16_shared_program.js";
5
+ import b from "./transpose16_program.js";
6
+ import { t as T } from "../../transpose-JawVKyZy.js";
7
+ function w(p) {
8
+ const { inputs: h, attrs: i } = p, { x: e } = h, { perm: r } = i, a = p.backend, m = d(e);
9
+ if (m && r[r.length - 1] !== e.shape.length - 1) {
10
+ const o = e.shape.length, c = o === 4 ? r.map((s) => s - 1).filter((s) => s >= 0) : r, t = o === 4 ? u(e, [e.shape[0] * e.shape[1], e.shape[2], e.shape[3]]) : e, f = new P(t.shape, c), n = a.runWebGPUProgram(f, [t], "packedF16");
11
+ if (o === 4) {
12
+ t.dispose();
13
+ const s = l().makeTensorFromTensorInfo(n), g = u(s, [
15
14
  e.shape[0],
16
15
  e.shape[1],
17
- o.shape[1],
18
- o.shape[2]
16
+ n.shape[1],
17
+ n.shape[2]
19
18
  ]);
20
19
  return s.dispose(), g;
21
20
  }
22
- return o;
21
+ return n;
23
22
  }
24
- if (c) {
25
- const n = new P(e.shape, r), t = m.runWebGPUProgram(n, [e], "int32");
26
- return t.packed = !0, t;
23
+ if (m) {
24
+ const o = new b(e.shape, r);
25
+ return a.runWebGPUProgram(o, [e], "packedF16");
27
26
  } else
28
27
  return T(e, r);
29
28
  }
@@ -32,4 +31,4 @@ const F = {
32
31
  backendName: "webgpu",
33
32
  kernelFunc: w
34
33
  };
35
- b(F);
34
+ k(F);
@@ -1,5 +1,5 @@
1
- import { f as a, c as i } from "../../webgpu_util-0_ubCEHJ.js";
2
- import { b as h, e as d, c as n } from "../../webgpu_program-DzaQiqel.js";
1
+ import { f as a, c as i } from "../../webgpu_util-BdovYhXr.js";
2
+ import { b as h, e as d, c as n } from "../../webgpu_program-CAE4RICo.js";
3
3
  function p(r) {
4
4
  const e = r.length;
5
5
  if (e > 6)
@@ -1,8 +1,7 @@
1
- import { c as a } from "../../webgpu_util-0_ubCEHJ.js";
2
- import { e as p } from "../../webgpu_program-DzaQiqel.js";
3
- import "../../index-D6Q1lPZO.js";
4
- import { a as l } from "../../tensor-CzmOBsdf.js";
5
- class y {
1
+ import { c as a } from "../../webgpu_util-BdovYhXr.js";
2
+ import { e as l } from "../../webgpu_program-CAE4RICo.js";
3
+ import { y as p } from "../../index-D0RBWjq8.js";
4
+ class n {
6
5
  variableNames = ["A"];
7
6
  outputShape;
8
7
  shaderKey;
@@ -12,22 +11,22 @@ class y {
12
11
  // Nick: Reduce to 8x8
13
12
  workgroupSize = [8, 8, 1];
14
13
  constructor(t, o) {
15
- const i = t.length, e = new Array(i), u = t.slice();
16
- u[u.length - 1] *= 2;
17
- for (let r = 0; r < e.length; r++)
18
- e[r] = u[o[r]];
14
+ const i = t.length, e = new Array(i), r = t.slice();
15
+ r[r.length - 1] *= 2;
16
+ for (let u = 0; u < e.length; u++)
17
+ e[u] = r[o[u]];
19
18
  e[e.length - 1] /= 2, this.outputShape = e, this.dispatchLayout = i === 2 ? { x: [0], y: [1] } : { x: [1], y: [2], z: [0] }, this.dispatch = a(this.dispatchLayout, this.outputShape, this.workgroupSize, [2, 1, 1]), this.shaderKey = `transposeShared16_${i}`;
20
19
  }
21
20
  getUserCode() {
22
21
  const t = this.outputShape.length;
23
- l(
22
+ p(
24
23
  this.workgroupSize[0] === this.workgroupSize[1],
25
24
  () => `Must be a square tile, current tile shape is ${this.workgroupSize[0]} x ${this.workgroupSize[1]}`
26
25
  );
27
26
  const o = this.workgroupSize[0] * 2;
28
27
  return `
29
28
  var<workgroup> tile : array<array<f32, ${o + 1}>, ${o}>;
30
- ${p()} {
29
+ ${l()} {
31
30
  var x = i32(workgroupId.x) * ${o / 2} + i32(localId.x);
32
31
  var y = i32(workgroupId.y) * ${o} + i32(localId.y);
33
32
  let batch = ${t === 3 ? "i32(workgroupId.z)" : "0"};
@@ -67,5 +66,5 @@ class y {
67
66
  }
68
67
  }
69
68
  export {
70
- y as default
69
+ n as default
71
70
  };
@@ -1,7 +1,6 @@
1
- import { f as c, c as r } from "../../webgpu_util-0_ubCEHJ.js";
2
- import { e as u } from "../../webgpu_program-DzaQiqel.js";
3
- import "../../index-D6Q1lPZO.js";
4
- import { r as p } from "../../tensor_util-DfwaWayG.js";
1
+ import { f as c, c as r } from "../../webgpu_util-BdovYhXr.js";
2
+ import { e as u } from "../../webgpu_program-CAE4RICo.js";
3
+ import { h as p } from "../../index-D0RBWjq8.js";
5
4
  class l {
6
5
  outputShape;
7
6
  shaderKey = "Unpack16";
@@ -1,10 +1,9 @@
1
- import { f as s, c as n } from "../../../webgpu_util-0_ubCEHJ.js";
1
+ import { f as s, c as n } from "../../../webgpu_util-BdovYhXr.js";
2
2
  import { g as p } from "../../../binary_op_util-pKXltfxI.js";
3
- import { B as g } from "../../../binary_op_util-pKXltfxI.js";
4
- import { j as u } from "../../../index-D6Q1lPZO.js";
5
- import { e as l } from "../../../webgpu_program-DzaQiqel.js";
6
- import { l as r } from "../../../tensor-CzmOBsdf.js";
7
- class y {
3
+ import { B as b } from "../../../binary_op_util-pKXltfxI.js";
4
+ import { $ as u, ag as r } from "../../../index-D0RBWjq8.js";
5
+ import { e as l } from "../../../webgpu_program-CAE4RICo.js";
6
+ class x {
8
7
  dispatch;
9
8
  dispatchLayout;
10
9
  outputComponent;
@@ -74,6 +73,6 @@ class y {
74
73
  }
75
74
  }
76
75
  export {
77
- y as BinaryOpProgram,
78
- g as BinaryOpType
76
+ x as BinaryOpProgram,
77
+ b as BinaryOpType
79
78
  };
@@ -1,9 +1,8 @@
1
- import { e as l } from "../../../index-D6Q1lPZO.js";
2
- import { e as a } from "../../../webgpu_program-DzaQiqel.js";
3
- import { reshape16 as S } from "../../reshape16.js";
4
- import { f as b } from "../../../webgpu_util-0_ubCEHJ.js";
5
- import { p as f, s as c } from "../../../tensor-CzmOBsdf.js";
6
- import { c as h } from "../../../axis_util-BsIr9ZNu.js";
1
+ import { af as l, V as c, e as S } from "../../../index-D0RBWjq8.js";
2
+ import { e as a } from "../../../webgpu_program-CAE4RICo.js";
3
+ import { reshape16 as b } from "../../reshape16.js";
4
+ import { f } from "../../../webgpu_util-BdovYhXr.js";
5
+ import { c as h } from "../../../axis_util-DofAuy0p.js";
7
6
  function d(e, u, t, i) {
8
7
  return e && !u ? `
9
8
  bestValue = subgroupAdd(bestValue);
@@ -173,11 +172,11 @@ function x(e) {
173
172
  }
174
173
  `;
175
174
  }
176
- function C(e, u) {
177
- const t = e[0], n = f(u, t.shape), [, r] = h(t.shape, n), o = c(r), p = c(t.shape) / o;
175
+ function L(e, u) {
176
+ const t = e[0], n = l(u, t.shape), [, r] = h(t.shape, n), o = c(r), p = c(t.shape) / o;
178
177
  return { windowSize: o, inSize: o, batchSize: p, outSize: 1 };
179
178
  }
180
- class y {
179
+ class C {
181
180
  outputShape;
182
181
  shaderKey = "reduce16";
183
182
  dispatchLayout;
@@ -198,7 +197,7 @@ class y {
198
197
  constructor(u, t, i, n) {
199
198
  this.params = i, this.inputShape = [t.batchSize, t.inSize], this.deviceInfo = u, this.packed = n;
200
199
  const r = t.inSize % 64 === 0 ? 64 : 32;
201
- u.subgroupsSupported ? (this.workgroupSize = [Math.min(r, u.subgroupMaxSize), 1, 1], this.subgroups = !0, u.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = r, this.outputShape = i.elementwise ? [t.batchSize, t.inSize] : [t.batchSize / 2], this.dispatchLayout = b(this.outputShape), this.dispatch = [i.elementwise ? t.batchSize : t.batchSize / 2, 1, 1], this.outputComponent = 1, this.variableComponents = [1], this.elementwise = i.elementwise === !0;
200
+ u.subgroupsSupported ? (this.workgroupSize = [Math.min(r, u.subgroupMaxSize), 1, 1], this.subgroups = !0, u.variableSubgroups && (this.subgroupBuiltins = !0)) : this.workgroupSize[0] = r, this.outputShape = i.elementwise ? [t.batchSize, t.inSize] : [t.batchSize / 2], this.dispatchLayout = f(this.outputShape), this.dispatch = [i.elementwise ? t.batchSize : t.batchSize / 2, 1, 1], this.outputComponent = 1, this.variableComponents = [1], this.elementwise = i.elementwise === !0;
202
201
  }
203
202
  getWriteSnippet() {
204
203
  return this.packed ? "result[outputIndex] = i32(pack2x16float(bestValue));" : "result[outputIndex] = bestValue;";
@@ -238,22 +237,15 @@ class y {
238
237
  });
239
238
  }
240
239
  }
241
- function X(e, u, t) {
242
- const i = u[0], r = [{ type: "int32", data: [e.inputShape[e.inputShape.length - 1]] }], o = t.runWebGPUProgram(
243
- e,
244
- u,
245
- e.packed ? "int32" : "float32",
246
- r
247
- );
248
- o.packed = e.packed ?? !1;
249
- const s = l().makeTensorFromTensorInfo(o), p = S(
240
+ function y(e, u, t) {
241
+ const i = u[0], r = [{ type: "int32", data: [e.inputShape[e.inputShape.length - 1]] }], o = t.runWebGPUProgram(e, u, e.packed ? "packedF16" : "float32", r), s = S().makeTensorFromTensorInfo(o), p = b(
250
242
  s,
251
243
  e.elementwise ? i.shape : e.packed ? [...i.shape.slice(0, -2), i.shape[i.shape.length - 2] / 2] : [...i.shape.slice(0, -2), i.shape[i.shape.length - 2]]
252
244
  );
253
245
  return s.dispose(), p;
254
246
  }
255
247
  export {
256
- y as ReduceProgram,
257
- C as createReduceInfo,
258
- X as reduce
248
+ C as ReduceProgram,
249
+ L as createReduceInfo,
250
+ y as reduce
259
251
  };