@genai-fi/nanogpt 0.6.3 → 0.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/Generator.js +17 -13
  2. package/dist/NanoGPTModel.d.ts +2 -2
  3. package/dist/NanoGPTModel.js +104 -136
  4. package/dist/{RealDiv-BYViZwhN.js → RealDiv-CVYNbZxu.js} +30 -29
  5. package/dist/{Reshape-t7Kcikjk.js → Reshape-CEsEp0AI.js} +5 -5
  6. package/dist/Reshape-Do18N3gO.js +30 -0
  7. package/dist/TeachableLLM.js +9 -5
  8. package/dist/{TiedEmbedding-9WeDwvjO.js → TiedEmbedding-ccLBFiZi.js} +4 -4
  9. package/dist/{axis_util-Bu4h7XWV.js → axis_util-5DTW2tFV.js} +3 -3
  10. package/dist/backend.d.ts +1 -0
  11. package/dist/backend.js +7 -0
  12. package/dist/backend_util-C9Ut8n0Q.js +749 -0
  13. package/dist/{broadcast_to-DARN-DBD.js → broadcast_to-Ba9h_8DO.js} +2 -2
  14. package/dist/{concat-5aPGqw3Z.js → concat-CbXTetof.js} +8 -8
  15. package/dist/{dataset-pgqp-YfL.js → dataset-U3PrjwgU.js} +7 -7
  16. package/dist/{dropout-Bciw46HT.js → dropout-DPfPgWWe.js} +8 -8
  17. package/dist/{gather-DjyCjmOD.js → gather-Bbh8DHhM.js} +1 -1
  18. package/dist/gelu-BFwVnd1r.js +26 -0
  19. package/dist/gpgpu_math-DffelNS-.js +2371 -0
  20. package/dist/index-DYD_yPa-.js +12076 -0
  21. package/dist/{index-BAzbokzv.js → index-UdZhlibC.js} +414 -398
  22. package/dist/{kernel_funcs_utils-CUxJCg0g.js → kernel_funcs_utils-CXDy3EN7.js} +31 -30
  23. package/dist/layers/BaseLayer.js +2 -2
  24. package/dist/layers/CausalSelfAttention.js +8 -8
  25. package/dist/layers/MLP.js +5 -5
  26. package/dist/layers/RMSNorm.js +3 -3
  27. package/dist/layers/RoPECache.js +4 -4
  28. package/dist/layers/TiedEmbedding.js +5 -5
  29. package/dist/layers/TransformerBlock.js +1 -1
  30. package/dist/loader/loadTransformers.js +1 -1
  31. package/dist/loader/oldZipLoad.js +11 -7
  32. package/dist/{log_sum_exp-YEo2h3gb.js → log_sum_exp-BnmCkHWl.js} +16 -16
  33. package/dist/main.d.ts +13 -0
  34. package/dist/main.js +44 -23
  35. package/dist/{mat_mul-7121rsJk.js → mat_mul-dwmZz69e.js} +4 -4
  36. package/dist/{max-DtlIuVeW.js → max-ByjEGoFx.js} +3 -3
  37. package/dist/{mulmat_packed_gpu-D4nKF7Je.js → mulmat_packed_gpu-IGPBp6h9.js} +1 -1
  38. package/dist/non_max_suppression_impl-CsEgBuMA.js +134 -0
  39. package/dist/{ones-BBlSRqn1.js → ones-C8Mfln6-.js} +2 -2
  40. package/dist/ops/adamAdjust.d.ts +2 -0
  41. package/dist/ops/adamAdjust.js +9 -0
  42. package/dist/ops/adamMoments.d.ts +2 -0
  43. package/dist/ops/adamMoments.js +9 -0
  44. package/dist/ops/appendCache.js +3 -3
  45. package/dist/ops/attentionMask.js +1 -1
  46. package/dist/ops/cpu/adamAdjust.d.ts +1 -0
  47. package/dist/ops/cpu/adamAdjust.js +18 -0
  48. package/dist/ops/cpu/adamMoments.d.ts +1 -0
  49. package/dist/ops/cpu/adamMoments.js +16 -0
  50. package/dist/ops/cpu/appendCache.js +8 -8
  51. package/dist/ops/cpu/attentionMask.js +9 -9
  52. package/dist/ops/cpu/fusedSoftmax.js +17 -11
  53. package/dist/ops/cpu/gatherSub.js +7 -7
  54. package/dist/ops/cpu/gelu.js +13 -13
  55. package/dist/ops/cpu/matMulGelu.js +36 -24
  56. package/dist/ops/cpu/matMulMul.js +14 -8
  57. package/dist/ops/cpu/mulDropout.js +9 -3
  58. package/dist/ops/cpu/normRMS.js +5 -5
  59. package/dist/ops/cpu/qkv.js +3 -3
  60. package/dist/ops/cpu/rope.js +5 -5
  61. package/dist/ops/cpu/scatterSub.js +11 -11
  62. package/dist/ops/fusedSoftmax.js +1 -1
  63. package/dist/ops/gatherSub.js +1 -1
  64. package/dist/ops/gelu.js +2 -2
  65. package/dist/ops/grads/attentionMask.js +1 -1
  66. package/dist/ops/grads/fusedSoftmax.js +2 -2
  67. package/dist/ops/grads/gelu.js +3 -24
  68. package/dist/ops/grads/matMulGelu.js +5 -5
  69. package/dist/ops/grads/normRMS.js +6 -6
  70. package/dist/ops/grads/qkv.js +1 -1
  71. package/dist/ops/grads/rope.js +3 -3
  72. package/dist/ops/matMulGelu.js +1 -1
  73. package/dist/ops/matMulMul.js +1 -1
  74. package/dist/ops/mulDrop.js +1 -1
  75. package/dist/ops/normRMS.js +1 -1
  76. package/dist/ops/qkv.js +1 -1
  77. package/dist/ops/rope.js +4 -4
  78. package/dist/ops/scatterSub.js +1 -1
  79. package/dist/ops/webgl/adamAdjust.d.ts +1 -0
  80. package/dist/ops/webgl/adamAdjust.js +50 -0
  81. package/dist/ops/webgl/adamMoments.d.ts +1 -0
  82. package/dist/ops/webgl/adamMoments.js +38 -0
  83. package/dist/ops/webgl/appendCache.js +1 -1
  84. package/dist/ops/webgl/attentionMask.js +1 -1
  85. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  86. package/dist/ops/webgl/gatherSub.js +8 -8
  87. package/dist/ops/webgl/gelu.js +2 -2
  88. package/dist/ops/webgl/log.js +5 -5
  89. package/dist/ops/webgl/matMulGelu.js +17 -17
  90. package/dist/ops/webgl/matMulMul.js +1 -1
  91. package/dist/ops/webgl/mulDropout.js +4 -4
  92. package/dist/ops/webgl/normRMS.js +2 -2
  93. package/dist/ops/webgl/qkv.js +1 -1
  94. package/dist/ops/webgl/rope.js +1 -1
  95. package/dist/ops/webgl/scatterSub.js +1 -1
  96. package/dist/ops/webgpu/adamAdjust.d.ts +1 -0
  97. package/dist/ops/webgpu/adamAdjust.js +52 -0
  98. package/dist/ops/webgpu/adamMoments.d.ts +1 -0
  99. package/dist/ops/webgpu/adamMoments.js +51 -0
  100. package/dist/ops/webgpu/appendCache.d.ts +1 -0
  101. package/dist/ops/webgpu/appendCache.js +57 -0
  102. package/dist/ops/webgpu/attentionMask.d.ts +1 -0
  103. package/dist/ops/webgpu/attentionMask.js +65 -0
  104. package/dist/ops/webgpu/gatherSub.d.ts +1 -0
  105. package/dist/ops/webgpu/gatherSub.js +52 -0
  106. package/dist/ops/webgpu/gelu.d.ts +14 -0
  107. package/dist/ops/webgpu/gelu.js +87 -0
  108. package/dist/ops/webgpu/index.d.ts +0 -0
  109. package/dist/ops/webgpu/index.js +11 -0
  110. package/dist/ops/webgpu/normRMS.d.ts +1 -0
  111. package/dist/ops/webgpu/normRMS.js +41 -0
  112. package/dist/ops/webgpu/normRMSGrad.d.ts +1 -0
  113. package/dist/ops/webgpu/normRMSGrad.js +128 -0
  114. package/dist/ops/webgpu/qkv.d.ts +1 -0
  115. package/dist/ops/webgpu/qkv.js +57 -0
  116. package/dist/ops/webgpu/rope.d.ts +1 -0
  117. package/dist/ops/webgpu/rope.js +69 -0
  118. package/dist/ops/webgpu/scatterSub.d.ts +1 -0
  119. package/dist/ops/webgpu/scatterSub.js +38 -0
  120. package/dist/ops/webgpu/utils/reductions.d.ts +9 -0
  121. package/dist/ops/webgpu/utils/reductions.js +68 -0
  122. package/dist/{ops-C0sQEcPw.js → ops-aRTXR2Sr.js} +433 -508
  123. package/dist/{random_width-DWzaOgrn.js → random_width-DbSpgl4o.js} +144 -144
  124. package/dist/{range-DYsrnfiy.js → range-D9CZhVlR.js} +1 -1
  125. package/dist/{reciprocal-CJQeasVa.js → reciprocal-CGB48wZB.js} +1 -1
  126. package/dist/{register_all_kernels-BfFCQAqs.js → register_all_kernels-DnbAyBXt.js} +203 -200
  127. package/dist/{reshape-krWGKraP.js → reshape-BR0eoLYN.js} +1 -1
  128. package/dist/{scatter_nd_util-93ln7Hut.js → scatter_nd_util-OjyAxku2.js} +3 -3
  129. package/dist/{selu_util-sntGesxr.js → selu_util-Ce6pu9IM.js} +44 -44
  130. package/dist/{shared-Ca6iDobD.js → shared-Czipaeb6.js} +541 -606
  131. package/dist/shared-DS5waSIY.js +69 -0
  132. package/dist/{sin-D_h-qCSx.js → sin-CiBxrDqX.js} +1 -1
  133. package/dist/slice-BHbDHObE.js +28 -0
  134. package/dist/{softmax-fsdtf6JC.js → softmax-JMEIUo2J.js} +1 -1
  135. package/dist/{split-eiktj-6L.js → split-CRU0PjVV.js} +4 -4
  136. package/dist/{stack-dfEEz2OY.js → stack-ikk2Y8_P.js} +2 -2
  137. package/dist/{sum-BE_Irnim.js → sum-NLYbiDag.js} +3 -3
  138. package/dist/{tensor-Xyi595sG.js → tensor-Do9PKbIE.js} +1 -1
  139. package/dist/{tensor2d-CPEkynbH.js → tensor2d-CWHxHpLh.js} +1 -1
  140. package/dist/training/Adam.d.ts +22 -0
  141. package/dist/training/Adam.js +93 -0
  142. package/dist/training/AdamExt.d.ts +1 -1
  143. package/dist/training/AdamExt.js +13 -12
  144. package/dist/training/DatasetBuilder.js +2 -2
  145. package/dist/training/Evaluator.js +1 -1
  146. package/dist/training/FullTrainer.js +27 -27
  147. package/dist/training/Trainer.d.ts +5 -6
  148. package/dist/training/Trainer.js +54 -55
  149. package/dist/training/sparseCrossEntropy.d.ts +0 -4
  150. package/dist/training/sparseCrossEntropy.js +7 -7
  151. package/dist/utilities/arrayClose.d.ts +1 -0
  152. package/dist/utilities/arrayClose.js +11 -0
  153. package/dist/utilities/dummy.js +19 -19
  154. package/dist/utilities/generate.js +15 -16
  155. package/dist/utilities/multinomialCPU.d.ts +2 -0
  156. package/dist/utilities/multinomialCPU.js +13 -0
  157. package/dist/utilities/performance.d.ts +2 -0
  158. package/dist/utilities/performance.js +16 -0
  159. package/dist/utilities/profile.d.ts +1 -0
  160. package/dist/utilities/profile.js +9 -6
  161. package/dist/utilities/safetensors.js +2 -2
  162. package/dist/utilities/weights.js +2 -2
  163. package/dist/{variable-wSS22xj5.js → variable-BTBkayv_.js} +1 -1
  164. package/dist/webgpu_program-WaoMq-WD.js +548 -0
  165. package/dist/webgpu_util-DhSeP4b6.js +80 -0
  166. package/dist/{zeros-YJDE7oRb.js → zeros-DnPT2nD4.js} +10 -10
  167. package/package.json +2 -1
  168. package/dist/gpgpu_math-CNslybmD.js +0 -3115
  169. package/dist/norm-CzltS9Fz.js +0 -86
@@ -0,0 +1,134 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2019 Google LLC. All Rights Reserved.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ * =============================================================================
16
+ */
17
+ function J(e, t, o) {
18
+ const n = k(e, t, o), s = n < 0 ? -(n + 1) : n;
19
+ e.splice(s, 0, t);
20
+ }
21
+ function k(e, t, o) {
22
+ return A(e, t, o || v);
23
+ }
24
+ function v(e, t) {
25
+ return e > t ? 1 : e < t ? -1 : 0;
26
+ }
27
+ function A(e, t, o) {
28
+ let n = 0, s = e.length, r = 0, u = !1;
29
+ for (; n < s; ) {
30
+ r = n + (s - n >>> 1);
31
+ const l = o(t, e[r]);
32
+ l > 0 ? n = r + 1 : (s = r, u = !l);
33
+ }
34
+ return u ? n : -n - 1;
35
+ }
36
+ /**
37
+ * @license
38
+ * Copyright 2020 Google LLC. All Rights Reserved.
39
+ * Licensed under the Apache License, Version 2.0 (the "License");
40
+ * you may not use this file except in compliance with the License.
41
+ * You may obtain a copy of the License at
42
+ *
43
+ * http://www.apache.org/licenses/LICENSE-2.0
44
+ *
45
+ * Unless required by applicable law or agreed to in writing, software
46
+ * distributed under the License is distributed on an "AS IS" BASIS,
47
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
48
+ * See the License for the specific language governing permissions and
49
+ * limitations under the License.
50
+ * =============================================================================
51
+ */
52
+ function O(e, t, o, n, s) {
53
+ return y(
54
+ e,
55
+ t,
56
+ o,
57
+ n,
58
+ s,
59
+ 0
60
+ /* softNmsSigma */
61
+ );
62
+ }
63
+ function P(e, t, o, n, s, r) {
64
+ return y(
65
+ e,
66
+ t,
67
+ o,
68
+ n,
69
+ s,
70
+ 0,
71
+ !1,
72
+ r,
73
+ !0
74
+ /* returnValidOutputs */
75
+ );
76
+ }
77
+ function X(e, t, o, n, s, r) {
78
+ return y(
79
+ e,
80
+ t,
81
+ o,
82
+ n,
83
+ s,
84
+ r,
85
+ !0
86
+ /* returnScoresTensor */
87
+ );
88
+ }
89
+ function y(e, t, o, n, s, r, u = !1, l = !1, h = !1) {
90
+ const c = [];
91
+ for (let i = 0; i < t.length; i++)
92
+ t[i] > s && c.push({ score: t[i], boxIndex: i, suppressBeginIndex: 0 });
93
+ c.sort(C);
94
+ const d = r > 0 ? -0.5 / r : 0, a = [], f = [];
95
+ for (; a.length < o && c.length > 0; ) {
96
+ const i = c.pop(), { score: M, boxIndex: I, suppressBeginIndex: g } = i;
97
+ if (M < s)
98
+ break;
99
+ let S = !1;
100
+ for (let b = a.length - 1; b >= g; --b) {
101
+ const w = B(e, I, a[b]);
102
+ if (w >= n) {
103
+ S = !0;
104
+ break;
105
+ }
106
+ if (i.score = i.score * V(n, d, w), i.score <= s)
107
+ break;
108
+ }
109
+ i.suppressBeginIndex = a.length, S || (i.score === M ? (a.push(I), f.push(i.score)) : i.score > s && J(c, i, C));
110
+ }
111
+ const x = a.length, p = o - x;
112
+ l && p > 0 && (a.push(...new Array(p).fill(0)), f.push(...new Array(p).fill(0)));
113
+ const m = { selectedIndices: a };
114
+ return u && (m.selectedScores = f), h && (m.validOutputs = x), m;
115
+ }
116
+ function B(e, t, o) {
117
+ const n = e.subarray(t * 4, t * 4 + 4), s = e.subarray(o * 4, o * 4 + 4), r = Math.min(n[0], n[2]), u = Math.min(n[1], n[3]), l = Math.max(n[0], n[2]), h = Math.max(n[1], n[3]), c = Math.min(s[0], s[2]), d = Math.min(s[1], s[3]), a = Math.max(s[0], s[2]), f = Math.max(s[1], s[3]), x = (l - r) * (h - u), p = (a - c) * (f - d);
118
+ if (x <= 0 || p <= 0)
119
+ return 0;
120
+ const m = Math.max(r, c), i = Math.max(u, d), M = Math.min(l, a), I = Math.min(h, f), g = Math.max(M - m, 0) * Math.max(I - i, 0);
121
+ return g / (x + p - g);
122
+ }
123
+ function V(e, t, o) {
124
+ const n = Math.exp(t * o * o);
125
+ return o <= e ? n : 0;
126
+ }
127
+ function C(e, t) {
128
+ return e.score - t.score || e.score === t.score && t.boxIndex - e.boxIndex;
129
+ }
130
+ export {
131
+ X as a,
132
+ P as b,
133
+ O as n
134
+ };
@@ -1,5 +1,5 @@
1
- import { x as n, y as t, g as m, E as i } from "./index-BAzbokzv.js";
2
- import { z as c, c as f } from "./zeros-YJDE7oRb.js";
1
+ import { F as n, H as t, j as m, E as i } from "./index-UdZhlibC.js";
2
+ import { z as c, c as f } from "./zeros-DnPT2nD4.js";
3
3
  /**
4
4
  * @license
5
5
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -0,0 +1,2 @@
1
+ import { Tensor } from '@tensorflow/tfjs-core';
2
+ export declare function adamAdjust(moments: Tensor, value: Tensor, beta1: number, beta2: number, epsilon: number, learningRate: number): Tensor;
@@ -0,0 +1,9 @@
1
+ import { e as i } from "../index-UdZhlibC.js";
2
+ import "./cpu/adamAdjust.js";
3
+ import "./webgl/adamAdjust.js";
4
+ function p(r, t, e, n, m, o) {
5
+ return i().runKernel("AdamAdjust", { moments: r, value: t }, { beta1: e, beta2: n, epsilon: m, learningRate: o });
6
+ }
7
+ export {
8
+ p as adamAdjust
9
+ };
@@ -0,0 +1,2 @@
1
+ import { Tensor } from '@tensorflow/tfjs-core';
2
+ export declare function adamMoments(moments: Tensor, gradient: Tensor, beta1: number, beta2: number): Tensor;
@@ -0,0 +1,9 @@
1
+ import { e as o } from "../index-UdZhlibC.js";
2
+ import "./cpu/adamMoments.js";
3
+ import "./webgl/adamMoments.js";
4
+ function p(e, n, r, m) {
5
+ return o().runKernel("AdamMoments", { moments: e, gradient: n }, { beta1: r, beta2: m });
6
+ }
7
+ export {
8
+ p as adamMoments
9
+ };
@@ -1,8 +1,8 @@
1
- import { e as a } from "../index-BAzbokzv.js";
1
+ import { e as a } from "../index-UdZhlibC.js";
2
2
  import "./cpu/appendCache.js";
3
3
  import "./webgl/appendCache.js";
4
- import { c as s } from "../concat-5aPGqw3Z.js";
5
- import { z as c } from "../zeros-YJDE7oRb.js";
4
+ import { c as s } from "../concat-CbXTetof.js";
5
+ import { z as c } from "../zeros-DnPT2nD4.js";
6
6
  function i(r, p, n, o) {
7
7
  if (!o) {
8
8
  const e = r.shape[2];
@@ -1,4 +1,4 @@
1
- import { e as o } from "../index-BAzbokzv.js";
1
+ import { e as o } from "../index-UdZhlibC.js";
2
2
  import "./cpu/attentionMask.js";
3
3
  import "./webgl/attentionMask.js";
4
4
  import "./grads/attentionMask.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ import { f as k, n as t, o as i, a as q, q as z } from "../../index-UdZhlibC.js";
2
+ function A(a) {
3
+ const { moments: n, value: r } = a.inputs, { beta1: l, beta2: u, epsilon: m, learningRate: d } = a.attrs, e = n.shape.length, c = new Array(e).fill(0), s = n.shape.slice();
4
+ s[e - 1] = 1;
5
+ const o = c.slice();
6
+ o[e - 1] = 1;
7
+ const b = s.slice(), p = n.slice(c, s).squeeze([e - 1]), M = n.slice(o, b).squeeze([e - 1]), f = t(p, l), g = t(M, u);
8
+ return i(
9
+ q(t(f, i(z(g), m ?? 1e-8)), -d),
10
+ r
11
+ );
12
+ }
13
+ const C = {
14
+ kernelName: "AdamAdjust",
15
+ backendName: "cpu",
16
+ kernelFunc: A
17
+ };
18
+ k(C);
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import { f as p } from "../../index-UdZhlibC.js";
2
+ import { s as f } from "../../stack-ikk2Y8_P.js";
3
+ function b(t) {
4
+ const { moments: n, gradient: c } = t.inputs, { beta1: o, beta2: m } = t.attrs, e = n.shape.length, a = new Array(e).fill(0), s = n.shape.slice();
5
+ s[e - 1] = 1;
6
+ const i = a.slice();
7
+ i[e - 1] = 1;
8
+ const r = s.slice(), l = n.slice(a, s).squeeze([e - 1]), u = n.slice(i, r).squeeze([e - 1]), M = l.mul(o).add(c.mul(1 - o)), d = u.mul(m).add(c.square().mul(1 - m));
9
+ return f([M, d], -1);
10
+ }
11
+ const g = {
12
+ kernelName: "AdamMoments",
13
+ backendName: "cpu",
14
+ kernelFunc: b
15
+ };
16
+ p(g);
@@ -1,13 +1,13 @@
1
- import { r as d } from "../../index-BAzbokzv.js";
2
- import { c as h } from "../../concat-5aPGqw3Z.js";
1
+ import { f as d } from "../../index-UdZhlibC.js";
2
+ import { c as h } from "../../concat-CbXTetof.js";
3
3
  function u(p) {
4
- const { cache: n, item: s } = p.inputs, { maxSize: r, pastLen: c } = p.attrs, t = n.shape[0], o = n.shape[1], a = n.shape[3], e = s.shape[2];
5
- if (c + e <= r) {
6
- const f = n.slice([0, 0, 0, 0], [t, o, c, a]), m = n.slice([0, 0, c + e, 0], [t, o, r - c - e, a]), i = e < e ? s.slice([0, 0, 0, 0], [t, o, e, a]) : s, k = h([f, i, m], 2);
7
- return f.dispose(), m.dispose(), i !== s && i.dispose(), k;
4
+ const { cache: n, item: s } = p.inputs, { maxSize: i, pastLen: c } = p.attrs, t = n.shape[0], o = n.shape[1], a = n.shape[3], e = s.shape[2];
5
+ if (c + e <= i) {
6
+ const l = n.slice([0, 0, 0, 0], [t, o, c, a]), m = n.slice([0, 0, c + e, 0], [t, o, i - c - e, a]), r = e < e ? s.slice([0, 0, 0, 0], [t, o, e, a]) : s, k = h([l, r, m], 2);
7
+ return l.dispose(), m.dispose(), r !== s && r.dispose(), k;
8
8
  }
9
- const l = n.slice([0, 0, e, 0], [t, o, r - e, a]), C = h([l, s], 2);
10
- return l.dispose(), C;
9
+ const f = n.slice([0, 0, e, 0], [t, o, i - e, a]), C = h([f, s], 2);
10
+ return f.dispose(), C;
11
11
  }
12
12
  const w = {
13
13
  kernelName: "AppendCache",
@@ -1,21 +1,21 @@
1
- import { r as a, f as p, s as u } from "../../index-BAzbokzv.js";
2
- import { l as N, w as b } from "../../ops-C0sQEcPw.js";
3
- import { o as A } from "../../ones-BBlSRqn1.js";
4
- import { z as I } from "../../zeros-YJDE7oRb.js";
5
- import { m as g } from "../../mat_mul-7121rsJk.js";
1
+ import { f as a, h as p, b as u } from "../../index-UdZhlibC.js";
2
+ import { l as N, w as b } from "../../ops-aRTXR2Sr.js";
3
+ import { o as A } from "../../ones-C8Mfln6-.js";
4
+ import { z as I } from "../../zeros-DnPT2nD4.js";
5
+ import { m as g } from "../../mat_mul-dwmZz69e.js";
6
6
  function o(n) {
7
7
  const { q: s, k: e } = n.inputs, { divisor: r } = n.attrs, c = s.shape[2], t = e.shape[2], m = N.bandPart(A([t, t]), -1, 0).cast("bool"), l = I([t, t]), i = p([t, t], Number.NEGATIVE_INFINITY), f = b(m, l, i), k = g(s, e, !1, !0).mul(u(r)), d = f.slice([0, 0], [c, t]).expandDims(0).expandDims(0);
8
8
  return k.add(d);
9
9
  }
10
- const w = {
10
+ const h = {
11
11
  kernelName: "AttentionMask",
12
12
  backendName: "cpu",
13
13
  kernelFunc: o
14
14
  };
15
- a(w);
16
- const M = {
15
+ a(h);
16
+ const w = {
17
17
  kernelName: "AttentionMask",
18
18
  backendName: "tensorflow",
19
19
  kernelFunc: o
20
20
  };
21
- a(M);
21
+ a(w);
@@ -1,23 +1,29 @@
1
- import { r as n } from "../../index-BAzbokzv.js";
2
- import { s as f } from "../../softmax-fsdtf6JC.js";
3
- function r(t) {
4
- const { inputs: s, attrs: i } = t, { logits: o } = s, { dim: a, dropoutRate: e } = i;
1
+ import { f as e } from "../../index-UdZhlibC.js";
2
+ import { s as f } from "../../softmax-JMEIUo2J.js";
3
+ function n(t) {
4
+ const { inputs: s, attrs: a } = t, { logits: o } = s, { dim: i, dropoutRate: r } = a;
5
5
  if (!o)
6
6
  throw new Error("Error in softmax: input logits is null");
7
- return e !== void 0 && e > 0 && console.warn("Dropout in fusedSoftmax not implemented for CPU backend, skipping dropout."), f(o, a);
7
+ return r !== void 0 && r > 0 && console.warn("Dropout in fusedSoftmax not implemented for CPU backend, skipping dropout."), f(o, i);
8
8
  }
9
9
  const m = {
10
10
  kernelName: "FusedSoftmax",
11
11
  backendName: "cpu",
12
- kernelFunc: r
12
+ kernelFunc: n
13
13
  };
14
- n(m);
15
- const l = {
14
+ e(m);
15
+ const u = {
16
16
  kernelName: "FusedSoftmax",
17
17
  backendName: "tensorflow",
18
- kernelFunc: r
18
+ kernelFunc: n
19
+ };
20
+ e(u);
21
+ const l = {
22
+ kernelName: "FusedSoftmax",
23
+ backendName: "webgpu",
24
+ kernelFunc: n
19
25
  };
20
- n(l);
26
+ e(l);
21
27
  export {
22
- r as softmaxCPU
28
+ n as softmaxCPU
23
29
  };
@@ -1,6 +1,6 @@
1
- import { o as u, q as c, E as g, Y as h, r as m, b as p } from "../../index-BAzbokzv.js";
2
- import { r as l } from "../../range-DYsrnfiy.js";
3
- import { s as N } from "../../stack-dfEEz2OY.js";
1
+ import { B as u, C as c, E as g, a4 as h, f as m, c as p } from "../../index-UdZhlibC.js";
2
+ import { r as f } from "../../range-D9CZhVlR.js";
3
+ import { s as l } from "../../stack-ikk2Y8_P.js";
4
4
  /**
5
5
  * @license
6
6
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -17,14 +17,14 @@ import { s as N } from "../../stack-dfEEz2OY.js";
17
17
  * limitations under the License.
18
18
  * =============================================================================
19
19
  */
20
- function b(e, t) {
20
+ function N(e, t) {
21
21
  const n = c(t, "indices", "gatherND", "int32"), s = { params: c(e, "x", "gatherND", "string_or_numeric"), indices: n };
22
22
  return g.runKernel(h, s);
23
23
  }
24
- const f = /* @__PURE__ */ u({ gatherND_: b });
24
+ const b = /* @__PURE__ */ u({ gatherND_: N });
25
25
  function d(e) {
26
- const { values: t, labels: n, logits: r } = e.inputs, s = n.shape[0], o = l(0, s, 1, "int32"), a = N([o, n], 1), i = f(r, a);
27
- return p(t, i);
26
+ const { values: t, labels: n, logits: r } = e.inputs, s = n.shape[0], a = f(0, s, 1, "int32"), i = l([a, n], 1), o = b(r, i);
27
+ return p(t, o);
28
28
  }
29
29
  const k = {
30
30
  kernelName: "EfficientGatherSub",
@@ -1,29 +1,29 @@
1
- import { r as t, t as d } from "../../index-BAzbokzv.js";
1
+ import { f as t, t as d } from "../../index-UdZhlibC.js";
2
2
  const o = 0.7978845608028654, c = 0.044715;
3
- function m(u) {
4
- const { inputs: l } = u, { x: e } = l, n = e;
3
+ function m(r) {
4
+ const { inputs: u } = r, { x: n } = u, e = n;
5
5
  return d(() => {
6
- const r = n.mul(n).mul(n), s = n.add(r.mul(c)).mul(o).tanh().add(1).mul(0.5);
7
- return n.mul(s);
6
+ const l = e.pow(3), s = e.add(l.mul(c)).mul(o).tanh().add(1).mul(0.5);
7
+ return e.mul(s);
8
8
  });
9
9
  }
10
- const K = {
10
+ const p = {
11
11
  kernelName: "Gelu",
12
12
  backendName: "cpu",
13
13
  kernelFunc: m
14
14
  };
15
- t(K);
16
- const p = {
15
+ t(p);
16
+ const K = {
17
17
  kernelName: "Gelu",
18
18
  backendName: "tensorflow",
19
19
  kernelFunc: m
20
20
  };
21
- t(p);
22
- function i(u) {
23
- const { dy: l, x: e } = u.inputs;
21
+ t(K);
22
+ function i(r) {
23
+ const { dy: u, x: n } = r.inputs;
24
24
  return d(() => {
25
- const n = e.square(), r = n.mul(e), a = e.add(r.mul(c)).mul(o).tanh(), f = a.square().neg().add(1), k = n.mul(3 * c).add(1), g = a.add(1).mul(0.5), G = e.mul(f).mul(o).mul(k).mul(0.5), N = g.add(G);
26
- return l.mul(N);
25
+ const e = n.square(), l = e.mul(n), a = n.add(l.mul(c)).mul(o).tanh(), f = a.square().neg().add(1), k = e.mul(3 * c).add(1), g = a.add(1).mul(0.5), G = n.mul(f).mul(o).mul(k).mul(0.5), N = g.add(G);
26
+ return u.mul(N);
27
27
  });
28
28
  }
29
29
  const x = {
@@ -1,40 +1,52 @@
1
- import { r as a, t as i } from "../../index-BAzbokzv.js";
2
- const c = 0.7978845608028654, m = 0.044715;
3
- function M(o) {
4
- const { inputs: s } = o, { x: t, kernel: l } = s, e = t, u = l;
5
- return i(() => {
6
- const n = e.matMul(u), d = n.mul(n).mul(n), r = n.add(d.mul(m)).mul(c).tanh().add(1).mul(0.5);
7
- return n.mul(r);
1
+ import { f as e, t as m } from "../../index-UdZhlibC.js";
2
+ import { g as d, d as M } from "../../gelu-BFwVnd1r.js";
3
+ function c(t) {
4
+ const { inputs: u } = t, { x: n, kernel: l } = u, a = n, r = l;
5
+ return m(() => {
6
+ const o = a.matMul(r);
7
+ return d(o);
8
8
  });
9
9
  }
10
- const b = {
10
+ const G = {
11
11
  kernelName: "MatMulGelu",
12
12
  backendName: "cpu",
13
- kernelFunc: M
13
+ kernelFunc: c
14
14
  };
15
- a(b);
16
- const w = {
15
+ e(G);
16
+ const i = {
17
17
  kernelName: "MatMulGelu",
18
18
  backendName: "tensorflow",
19
- kernelFunc: M
19
+ kernelFunc: c
20
20
  };
21
- a(w);
22
- function f(o) {
23
- const { dy: s, x: t, kernel: l } = o.inputs;
24
- return i(() => {
25
- const e = t.matMul(l), u = e.square(), n = u.mul(e), r = e.add(n.mul(m)).mul(c).tanh(), G = r.square().neg().add(1), g = u.mul(3 * m).add(1), p = r.add(1).mul(0.5), N = e.mul(G).mul(c).mul(g).mul(0.5), K = p.add(N), k = s.mul(K), h = k.matMul(l.transpose()), F = t.transpose().matMul(k);
26
- return [h, F];
21
+ e(i);
22
+ const f = {
23
+ kernelName: "MatMulGelu",
24
+ backendName: "webgpu",
25
+ kernelFunc: c
26
+ };
27
+ e(f);
28
+ function s(t) {
29
+ const { dy: u, x: n, kernel: l } = t.inputs;
30
+ return m(() => {
31
+ const a = n.matMul(l), r = M(u, a), o = r.matMul(l.transpose()), k = n.transpose().matMul(r);
32
+ return [o, k];
27
33
  });
28
34
  }
29
- const x = {
35
+ const g = {
30
36
  kernelName: "MatMulGeluGrad",
31
37
  backendName: "cpu",
32
- kernelFunc: f
38
+ kernelFunc: s
33
39
  };
34
- a(x);
35
- const C = {
40
+ e(g);
41
+ const p = {
36
42
  kernelName: "MatMulGeluGrad",
37
43
  backendName: "tensorflow",
38
- kernelFunc: f
44
+ kernelFunc: s
45
+ };
46
+ e(p);
47
+ const N = {
48
+ kernelName: "MatMulGeluGrad",
49
+ backendName: "webgpu",
50
+ kernelFunc: s
39
51
  };
40
- a(C);
52
+ e(N);
@@ -1,17 +1,23 @@
1
- import { r as n, t as M } from "../../index-BAzbokzv.js";
2
- function e(t) {
3
- const { inputs: r, attrs: o } = t, { transposeA: s, transposeB: l } = o, { x: c, kernel: u, y: a } = r, m = c, i = u, k = a;
4
- return M(() => m.matMul(i, s, l).mul(k));
1
+ import { f as e, t as i } from "../../index-UdZhlibC.js";
2
+ function n(t) {
3
+ const { inputs: r, attrs: l } = t, { transposeA: o, transposeB: s } = l, { x: u, kernel: a, y: c } = r, m = u, k = a, M = c;
4
+ return i(() => m.matMul(k, o, s).mul(M));
5
5
  }
6
6
  const f = {
7
7
  kernelName: "MatMulMul",
8
8
  backendName: "cpu",
9
- kernelFunc: e
9
+ kernelFunc: n
10
10
  };
11
- n(f);
11
+ e(f);
12
12
  const p = {
13
13
  kernelName: "MatMulMul",
14
14
  backendName: "tensorflow",
15
- kernelFunc: e
15
+ kernelFunc: n
16
16
  };
17
- n(p);
17
+ e(p);
18
+ const g = {
19
+ kernelName: "MatMulMul",
20
+ backendName: "webgpu",
21
+ kernelFunc: n
22
+ };
23
+ e(g);
@@ -1,7 +1,7 @@
1
- import { r as e, a as u } from "../../index-BAzbokzv.js";
1
+ import { f as e, a as t } from "../../index-UdZhlibC.js";
2
2
  function n(o) {
3
- const { inputs: r } = o, { a: l, b: t } = r;
4
- return console.warn("Using fallback mulDrop implementation without dropout."), u(l, t);
3
+ const { inputs: r } = o, { a: l, b: u } = r;
4
+ return console.warn("Using fallback mulDrop implementation without dropout."), t(l, u);
5
5
  }
6
6
  const a = {
7
7
  kernelName: "MulDropout",
@@ -15,3 +15,9 @@ const c = {
15
15
  kernelFunc: n
16
16
  };
17
17
  e(c);
18
+ const m = {
19
+ kernelName: "MulDropout",
20
+ backendName: "webgpu",
21
+ kernelFunc: n
22
+ };
23
+ e(m);
@@ -1,4 +1,4 @@
1
- import { r as o, t as d } from "../../index-BAzbokzv.js";
1
+ import { f as o, t as d } from "../../index-UdZhlibC.js";
2
2
  function i(t) {
3
3
  const { inputs: e } = t, { x: n, gamma: s } = e, r = n, a = s;
4
4
  return d(() => {
@@ -6,12 +6,12 @@ function i(t) {
6
6
  return r.mul(u).mul(a);
7
7
  });
8
8
  }
9
- const f = {
9
+ const k = {
10
10
  kernelName: "RMSNorm",
11
11
  backendName: "cpu",
12
12
  kernelFunc: i
13
13
  };
14
- o(f);
14
+ o(k);
15
15
  const g = {
16
16
  kernelName: "RMSNorm",
17
17
  backendName: "tensorflow",
@@ -21,8 +21,8 @@ o(g);
21
21
  function N(t) {
22
22
  const { dy: e, x: n, gamma: s } = t.inputs;
23
23
  return d(() => {
24
- const r = n.shape[n.shape.length - 1], a = n.square().mean(-1, !0), m = a.add(1e-8).rsqrt(), u = n.mul(m), l = e.mul(u).sum([0, 1]), c = e.mul(s), k = c.mul(n).sum(-1, !0).div(r);
25
- return [c.mul(m).sub(n.mul(k).mul(m).div(a.add(1e-8))), l];
24
+ const r = n.shape[n.shape.length - 1], a = n.square().mean(-1, !0), m = a.add(1e-8).rsqrt(), u = n.mul(m), l = e.mul(u).sum([0, 1]), c = e.mul(s), f = c.mul(n).sum(-1, !0).div(r);
25
+ return [c.mul(m).sub(n.mul(f).mul(m).div(a.add(1e-8))), l];
26
26
  });
27
27
  }
28
28
  const S = {
@@ -1,6 +1,6 @@
1
- import { r as q } from "../../index-BAzbokzv.js";
2
- import { r as o } from "../../reshape-krWGKraP.js";
3
- import { s as x } from "../../split-eiktj-6L.js";
1
+ import { f as q } from "../../index-UdZhlibC.js";
2
+ import { r as o } from "../../reshape-BR0eoLYN.js";
3
+ import { s as x } from "../../split-CRU0PjVV.js";
4
4
  function v(p) {
5
5
  const { x: c, kernel: K } = p.inputs, { heads: n } = p.attrs, [s, e, t] = c.shape, a = o(c, [s * e, t]), i = a.dot(K);
6
6
  a.dispose();
@@ -1,8 +1,8 @@
1
- import { r as S } from "../../index-BAzbokzv.js";
2
- import { r as F } from "../../range-DYsrnfiy.js";
3
- import { g as I } from "../../gather-DjyCjmOD.js";
4
- import { s as E } from "../../stack-dfEEz2OY.js";
5
- import { c as T } from "../../concat-5aPGqw3Z.js";
1
+ import { f as S } from "../../index-UdZhlibC.js";
2
+ import { r as F } from "../../range-D9CZhVlR.js";
3
+ import { g as I } from "../../gather-Bbh8DHhM.js";
4
+ import { s as E } from "../../stack-ikk2Y8_P.js";
5
+ import { c as T } from "../../concat-CbXTetof.js";
6
6
  function U(t, c, p, o, r) {
7
7
  const n = o.shape[3], s = p;
8
8
  if (s > n) return o;
@@ -1,8 +1,8 @@
1
- import { o as f, x as g, q as r, E as l, X as N, r as b, b as S, a as h } from "../../index-BAzbokzv.js";
2
- import { v as D } from "../../scatter_nd_util-93ln7Hut.js";
3
- import { r as k } from "../../range-DYsrnfiy.js";
4
- import { s as v } from "../../stack-dfEEz2OY.js";
5
- import { o as E } from "../../ones-BBlSRqn1.js";
1
+ import { B as f, F as g, C as r, E as l, a3 as N, f as b, c as S, a as h } from "../../index-UdZhlibC.js";
2
+ import { v as D } from "../../scatter_nd_util-OjyAxku2.js";
3
+ import { r as k } from "../../range-D9CZhVlR.js";
4
+ import { s as v } from "../../stack-ikk2Y8_P.js";
5
+ import { o as E } from "../../ones-C8Mfln6-.js";
6
6
  /**
7
7
  * @license
8
8
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -26,14 +26,14 @@ function I(a, e, s) {
26
26
  const c = { indices: n, updates: t }, o = { shape: s };
27
27
  return l.runKernel(N, c, o);
28
28
  }
29
- const K = /* @__PURE__ */ f({ scatterND_: I });
30
- function L(a) {
31
- const { logits: e, labels: s, dy: n } = a.inputs, t = s.shape[0], c = e.shape[1], o = k(0, t, 1, "int32"), i = v([o, s], 1), d = E([t]), u = K(i, d, [t, c]), p = S(e, u), m = n.reshape([t, 1]);
29
+ const C = /* @__PURE__ */ f({ scatterND_: I });
30
+ function K(a) {
31
+ const { logits: e, labels: s, dy: n } = a.inputs, t = s.shape[0], c = e.shape[1], o = k(0, t, 1, "int32"), i = v([o, s], 1), d = E([t]), u = C(i, d, [t, c]), p = S(e, u), m = n.reshape([t, 1]);
32
32
  return h(p, m);
33
33
  }
34
- const T = {
34
+ const L = {
35
35
  kernelName: "EfficientScatterSub",
36
36
  backendName: "cpu",
37
- kernelFunc: L
37
+ kernelFunc: K
38
38
  };
39
- b(T);
39
+ b(L);
@@ -1,4 +1,4 @@
1
- import { e as t } from "../index-BAzbokzv.js";
1
+ import { e as t } from "../index-UdZhlibC.js";
2
2
  import "./cpu/fusedSoftmax.js";
3
3
  import "./webgl/fusedSoftmax.js";
4
4
  import "./grads/fusedSoftmax.js";
@@ -1,4 +1,4 @@
1
- import { e as n } from "../index-BAzbokzv.js";
1
+ import { e as n } from "../index-UdZhlibC.js";
2
2
  import "./cpu/gatherSub.js";
3
3
  import "./webgl/gatherSub.js";
4
4
  function f(r, e, t) {