@genai-fi/nanogpt 0.8.0 → 0.8.2

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 (162) hide show
  1. package/dist/Generator.d.ts +2 -1
  2. package/dist/Generator.js +44 -37
  3. package/dist/{RealDiv-N8TpOMYv.js → RealDiv-D_q39E3A.js} +14 -14
  4. package/dist/{Reshape-B-lWQRnF.js → Reshape-41YpQqEo.js} +1 -1
  5. package/dist/{Reshape-Bo8HzP8V.js → Reshape-Bh_jzKzV.js} +2 -2
  6. package/dist/TeachableLLM.js +7 -5
  7. package/dist/{axis_util-DubwyOhW.js → axis_util-Did9235A.js} +1 -1
  8. package/dist/backend.js +2 -2
  9. package/dist/{backend_util-BJ-_jSeK.js → backend_util-yC3YH1jo.js} +17 -17
  10. package/dist/{broadcast_to-BYfCp5iL.js → broadcast_to-CUvOdOT5.js} +2 -2
  11. package/dist/checks/appendCache.d.ts +1 -0
  12. package/dist/checks/appendCache.js +22 -0
  13. package/dist/checks/attentionMask.d.ts +1 -0
  14. package/dist/checks/attentionMask.js +37 -0
  15. package/dist/checks/check.d.ts +9 -0
  16. package/dist/checks/check.js +20 -0
  17. package/dist/checks/gelu.d.ts +1 -0
  18. package/dist/checks/gelu.js +18 -0
  19. package/dist/checks/index.d.ts +22 -0
  20. package/dist/checks/index.js +24 -0
  21. package/dist/checks/normRMS.d.ts +1 -0
  22. package/dist/checks/normRMS.js +16 -0
  23. package/dist/checks/normRMSGrad.d.ts +1 -0
  24. package/dist/checks/normRMSGrad.js +12 -0
  25. package/dist/checks/qkv.d.ts +1 -0
  26. package/dist/checks/qkv.js +50 -0
  27. package/dist/checks/rope.d.ts +1 -0
  28. package/dist/checks/rope.js +38 -0
  29. package/dist/checks/weights.d.ts +16 -0
  30. package/dist/checks/weights.js +29 -0
  31. package/dist/{concat-BmDqqFsa.js → concat-pHiVqR3L.js} +1 -1
  32. package/dist/{dataset-CJmEGu6D.js → dataset-DPPl-iLT.js} +7 -7
  33. package/dist/{dropout-sx0sjVAT.js → dropout-CcKSfOYE.js} +11 -11
  34. package/dist/{exports_initializers-DAKM8UO9.js → exports_initializers-DKk7-bsx.js} +1 -1
  35. package/dist/{gather-C1siEkdp.js → gather-CPg6ZlQA.js} +1 -1
  36. package/dist/{gelu-Bd3UBBxg.js → gelu-BkcmEEyD.js} +1 -1
  37. package/dist/{gpgpu_math-TFLxaLkw.js → gpgpu_math-D_ODOLix.js} +2 -2
  38. package/dist/{index-CUQrfsw_.js → index-DdmHGZjq.js} +655 -647
  39. package/dist/{index-BaPo_0H8.js → index-evZ57wr4.js} +10 -10
  40. package/dist/{kernel_funcs_utils-P9aFa232.js → kernel_funcs_utils-CDfFpUab.js} +15 -15
  41. package/dist/layers/BaseLayer.js +2 -2
  42. package/dist/layers/CausalSelfAttention.js +29 -29
  43. package/dist/layers/MLP.js +18 -18
  44. package/dist/layers/PositionEmbedding.js +5 -5
  45. package/dist/layers/RMSNorm.js +3 -3
  46. package/dist/layers/RoPECache.js +4 -4
  47. package/dist/layers/TiedEmbedding.js +11 -11
  48. package/dist/layers/TransformerBlock.js +1 -1
  49. package/dist/loader/loadTransformers.js +1 -1
  50. package/dist/loader/oldZipLoad.js +9 -7
  51. package/dist/{log_sum_exp-C142qZqY.js → log_sum_exp-C8yFJfZz.js} +45 -24
  52. package/dist/main.d.ts +2 -0
  53. package/dist/main.js +9 -7
  54. package/dist/{mat_mul-DMkduNJu.js → mat_mul-Dpy2mMRu.js} +1 -1
  55. package/dist/{mod-uUuj4gSb.js → mod-CbibJi3D.js} +1 -1
  56. package/dist/models/NanoGPTV1.js +1 -1
  57. package/dist/models/model.js +9 -7
  58. package/dist/{mulmat_packed_gpu-Cm2gw-c8.js → mulmat_packed_gpu-q_Gmwyld.js} +1 -1
  59. package/dist/{ones-ZdgQGBCP.js → ones-BAqVh-eA.js} +2 -2
  60. package/dist/ops/adamAdjust.js +1 -1
  61. package/dist/ops/adamMoments.js +1 -1
  62. package/dist/ops/appendCache.js +3 -3
  63. package/dist/ops/attentionMask.js +1 -1
  64. package/dist/ops/cpu/adamAdjust.js +1 -1
  65. package/dist/ops/cpu/adamMoments.js +2 -2
  66. package/dist/ops/cpu/appendCache.js +2 -2
  67. package/dist/ops/cpu/attentionMask.js +5 -5
  68. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  69. package/dist/ops/cpu/gatherSub.js +5 -5
  70. package/dist/ops/cpu/gelu.js +1 -1
  71. package/dist/ops/cpu/matMulGelu.js +2 -2
  72. package/dist/ops/cpu/matMulMul.js +1 -1
  73. package/dist/ops/cpu/mulDropout.js +1 -1
  74. package/dist/ops/cpu/normRMS.js +1 -1
  75. package/dist/ops/cpu/qkv.js +3 -3
  76. package/dist/ops/cpu/rope.js +5 -5
  77. package/dist/ops/cpu/scatterSub.js +13 -13
  78. package/dist/ops/fusedSoftmax.js +1 -1
  79. package/dist/ops/gatherSub.js +1 -1
  80. package/dist/ops/gelu.js +2 -2
  81. package/dist/ops/grads/attentionMask.js +1 -1
  82. package/dist/ops/grads/fusedSoftmax.js +2 -2
  83. package/dist/ops/grads/gelu.js +2 -2
  84. package/dist/ops/grads/matMulGelu.js +1 -1
  85. package/dist/ops/grads/normRMS.js +1 -1
  86. package/dist/ops/grads/qkv.js +1 -1
  87. package/dist/ops/grads/rope.js +1 -1
  88. package/dist/ops/matMulGelu.js +1 -1
  89. package/dist/ops/matMulMul.js +1 -1
  90. package/dist/ops/mulDrop.js +1 -1
  91. package/dist/ops/normRMS.js +1 -1
  92. package/dist/ops/qkv.js +1 -1
  93. package/dist/ops/rope.js +4 -4
  94. package/dist/ops/scatterSub.js +1 -1
  95. package/dist/ops/webgl/adamAdjust.js +2 -2
  96. package/dist/ops/webgl/adamMoments.js +1 -1
  97. package/dist/ops/webgl/appendCache.js +1 -1
  98. package/dist/ops/webgl/attentionMask.js +1 -1
  99. package/dist/ops/webgl/fusedSoftmax.js +4 -4
  100. package/dist/ops/webgl/gatherSub.js +1 -1
  101. package/dist/ops/webgl/gelu.js +2 -2
  102. package/dist/ops/webgl/log.js +3 -3
  103. package/dist/ops/webgl/matMulGelu.js +4 -4
  104. package/dist/ops/webgl/matMulMul.js +1 -1
  105. package/dist/ops/webgl/mulDropout.js +1 -1
  106. package/dist/ops/webgl/normRMS.js +2 -2
  107. package/dist/ops/webgl/qkv.js +1 -1
  108. package/dist/ops/webgl/rope.js +1 -1
  109. package/dist/ops/webgl/scatterSub.js +1 -1
  110. package/dist/ops/webgpu/adamAdjust.js +3 -3
  111. package/dist/ops/webgpu/adamMoments.js +3 -3
  112. package/dist/ops/webgpu/appendCache.js +3 -3
  113. package/dist/ops/webgpu/attentionMask.js +3 -3
  114. package/dist/ops/webgpu/gatherSub.js +3 -3
  115. package/dist/ops/webgpu/gelu.js +3 -3
  116. package/dist/ops/webgpu/normRMS.js +2 -2
  117. package/dist/ops/webgpu/normRMSGrad.js +5 -5
  118. package/dist/ops/webgpu/qkv.js +3 -3
  119. package/dist/ops/webgpu/rope.js +3 -3
  120. package/dist/ops/webgpu/scatterSub.js +3 -3
  121. package/dist/ops/webgpu/utils/reductions.js +4 -4
  122. package/dist/ops-542ai2vG.js +1525 -0
  123. package/dist/{random_width-D8Pwy_na.js → random_width-DKGeiFuR.js} +1514 -1581
  124. package/dist/{range-LVHrSLdi.js → range-BcUvLuf5.js} +1 -1
  125. package/dist/{reciprocal-CaR9e67G.js → reciprocal-DhDWSKiD.js} +1 -1
  126. package/dist/{register_all_kernels-DUshvVWP.js → register_all_kernels-Do9VvZmo.js} +2312 -2335
  127. package/dist/{max-B3JOcNGb.js → relu-B1AXs7p5.js} +6 -6
  128. package/dist/{reshape-DEfQGSin.js → reshape-WeJkT3ja.js} +1 -1
  129. package/dist/{scatter_nd_util-CUPPNLaA.js → scatter_nd_util-B7yDhiQr.js} +1 -1
  130. package/dist/{selu_util-8vv5JxQV.js → selu_util-BgUO9gHY.js} +125 -146
  131. package/dist/{shared-D1elLckx.js → shared-CZiWmQCI.js} +1 -1
  132. package/dist/{shared-CkNorDcU.js → shared-V6D_md-c.js} +120 -120
  133. package/dist/{sin-D2CKKmyR.js → sin-CPxad7Am.js} +1 -1
  134. package/dist/{slice-BnyE-M_7.js → slice-B7jXtPnp.js} +1 -1
  135. package/dist/{softmax-DLoZWYBx.js → softmax-BfsyI4As.js} +1 -1
  136. package/dist/{split-By_n4TKP.js → split-BPxr8_8m.js} +1 -1
  137. package/dist/{stack-DkdFLq37.js → stack-BNwLzE43.js} +1 -1
  138. package/dist/{sum-l_0SqM4h.js → sum-ByFINZgi.js} +1 -1
  139. package/dist/{tensor-BAQdLqoU.js → tensor-DbqgIV9B.js} +1 -1
  140. package/dist/tensor1d-CtJq5BOv.js +27 -0
  141. package/dist/{tensor2d-BHy261cI.js → tensor2d-CObBWBkW.js} +1 -1
  142. package/dist/tensor4d-DLtk7Nxh.js +30 -0
  143. package/dist/training/Adam.js +2 -2
  144. package/dist/training/AdamExt.js +1 -1
  145. package/dist/training/DatasetBuilder.js +2 -2
  146. package/dist/training/FullTrainer.js +1 -1
  147. package/dist/training/Trainer.js +2 -2
  148. package/dist/training/sparseCrossEntropy.js +8 -9
  149. package/dist/utilities/arrayClose.d.ts +1 -1
  150. package/dist/utilities/arrayClose.js +16 -7
  151. package/dist/utilities/dummy.js +2 -2
  152. package/dist/utilities/multinomialCPU.js +2 -2
  153. package/dist/utilities/performance.js +1 -1
  154. package/dist/utilities/profile.js +1 -1
  155. package/dist/utilities/safetensors.js +2 -2
  156. package/dist/utilities/weights.js +2 -2
  157. package/dist/{variable-C9hihzDB.js → variable-DPFOJyRG.js} +1 -1
  158. package/dist/{webgpu_program-dFEVbDPL.js → webgpu_program-Dhk9R5aG.js} +1 -1
  159. package/dist/{webgpu_util-DLImlSc6.js → webgpu_util-BqGnZg8t.js} +1 -1
  160. package/dist/{zeros-VZ72lWXM.js → zeros-Dnwix0p4.js} +1 -1
  161. package/package.json +1 -1
  162. package/dist/ops-C_1K_-35.js +0 -1202
@@ -1,4 +1,4 @@
1
- import { B as r, C as e, E as x, X as c } from "./index-CUQrfsw_.js";
1
+ import { C as o, D as e, E as s, _ as t } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -15,11 +15,11 @@ import { B as r, C as e, E as x, X as c } from "./index-CUQrfsw_.js";
15
15
  * limitations under the License.
16
16
  * =============================================================================
17
17
  */
18
- function m(n, s = null, o = !1) {
19
- const t = { x: e(n, "x", "max") }, a = { reductionIndices: s, keepDims: o };
20
- return x.runKernel(c, t, a);
18
+ function u(r) {
19
+ const n = { x: e(r, "x", "relu") };
20
+ return s.runKernel(t, n);
21
21
  }
22
- const l = /* @__PURE__ */ r({ max_: m });
22
+ const l = /* @__PURE__ */ o({ relu_: u });
23
23
  export {
24
- l as m
24
+ l as r
25
25
  };
@@ -1,4 +1,4 @@
1
- import { B as o, C as t, E as a, U as p } from "./index-CUQrfsw_.js";
1
+ import { C as o, D as t, E as a, V as p } from "./index-DdmHGZjq.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1,4 +1,4 @@
1
- import { j as p, a2 as w } from "./index-CUQrfsw_.js";
1
+ import { j as p, a3 as w } from "./index-DdmHGZjq.js";
2
2
  function k(o, t, r) {
3
3
  const n = t.rank > 1 ? t.shape[t.rank - 1] : 1, e = t.rank > 1 ? t.rank - 1 : 1, h = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${r.shape}, indices.shape: ${t.shape}, shape: ${o}, sliceDim: ${n}, and batchDim: ${e}.`;
4
4
  if (r.rank < e)
@@ -1,6 +1,7 @@
1
- import { n as N, as as H, B as _, C as S, E as L, at as te, au as ne, ap as se, ar as re, av as ie, aw as oe, ax as le, a as ue, ay as fe, az as O } from "./index-CUQrfsw_.js";
2
- import { r as ce } from "./reshape-DEfQGSin.js";
3
- import { s as ae } from "./sum-l_0SqM4h.js";
1
+ import { n as D, aq as H, C, D as N, E as G, ar as te, as as ne, at as se, au as re, av as ie, aw as oe, a as le, ax as ue, ay as R } from "./index-DdmHGZjq.js";
2
+ import { r as fe } from "./relu-B1AXs7p5.js";
3
+ import { r as ce } from "./reshape-WeJkT3ja.js";
4
+ import { s as ae } from "./sum-ByFINZgi.js";
4
5
  /**
5
6
  * @license
6
7
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -17,9 +18,9 @@ import { s as ae } from "./sum-l_0SqM4h.js";
17
18
  * limitations under the License.
18
19
  * =============================================================================
19
20
  */
20
- function Be(e, t, n, s, r = "NHWC", u) {
21
+ function Ke(e, t, n, s, r = "NHWC", u) {
21
22
  const i = e[3], o = [...t, i], c = Ae(r);
22
- return B(e, o, n, u, s, null, null, c);
23
+ return X(e, o, n, u, s, null, null, c);
23
24
  }
24
25
  function Xe(e, t, n, s, r, u, i = "channelsLast") {
25
26
  const [o, c] = T(t);
@@ -30,9 +31,9 @@ function Xe(e, t, n, s, r, u, i = "channelsLast") {
30
31
  a = [o, c, e[1], e[1]];
31
32
  else
32
33
  throw new Error(`Unknown dataFormat ${i}`);
33
- return B(e, a, n, s, r, u, !1, i);
34
+ return X(e, a, n, s, r, u, !1, i);
34
35
  }
35
- function je(e, t, n, s, r, u, i = "NDHWC") {
36
+ function Be(e, t, n, s, r, u, i = "NDHWC") {
36
37
  const [o, c, a] = W(t);
37
38
  let p, g;
38
39
  if (i === "NDHWC")
@@ -43,7 +44,7 @@ function je(e, t, n, s, r, u, i = "NDHWC") {
43
44
  throw new Error(`Unknown dataFormat ${i}`);
44
45
  return he(e, p, n, s, r, !1, g, u);
45
46
  }
46
- function B(e, t, n, s, r, u, i = !1, o = "channelsLast") {
47
+ function X(e, t, n, s, r, u, i = !1, o = "channelsLast") {
47
48
  let [c, a, p, g] = [-1, -1, -1, -1];
48
49
  if (o === "channelsLast")
49
50
  [c, a, p, g] = e;
@@ -51,17 +52,17 @@ function B(e, t, n, s, r, u, i = !1, o = "channelsLast") {
51
52
  [c, g, a, p] = e;
52
53
  else
53
54
  throw new Error(`Unknown dataFormat ${o}`);
54
- const [l, h, , d] = t, [A, m] = T(n), [b, k] = T(s), f = G(l, b), w = G(h, k), { padInfo: E, outHeight: I, outWidth: x } = de(r, a, p, A, m, f, w, u, o), y = i ? d * g : d;
55
+ const [l, h, , d] = t, [A, m] = T(n), [b, k] = T(s), f = L(l, b), w = L(h, k), { padInfo: E, outHeight: I, outWidth: y } = de(r, a, p, A, m, f, w, u, o), x = i ? d * g : d;
55
56
  let $;
56
- return o === "channelsFirst" ? $ = [c, y, I, x] : o === "channelsLast" && ($ = [c, I, x, y]), {
57
+ return o === "channelsFirst" ? $ = [c, x, I, y] : o === "channelsLast" && ($ = [c, I, y, x]), {
57
58
  batchSize: c,
58
59
  dataFormat: o,
59
60
  inHeight: a,
60
61
  inWidth: p,
61
62
  inChannels: g,
62
63
  outHeight: I,
63
- outWidth: x,
64
- outChannels: y,
64
+ outWidth: y,
65
+ outChannels: x,
65
66
  padInfo: E,
66
67
  strideHeight: A,
67
68
  strideWidth: m,
@@ -84,9 +85,9 @@ function he(e, t, n, s, r, u = !1, i = "channelsLast", o) {
84
85
  [c, l, a, p, g] = e;
85
86
  else
86
87
  throw new Error(`Unknown dataFormat ${i}`);
87
- const [h, d, A, , m] = t, [b, k, f] = W(n), [w, E, I] = W(s), x = G(h, w), y = G(d, E), $ = G(A, I), { padInfo: C, outDepth: M, outHeight: D, outWidth: F } = me(r, a, p, g, b, k, f, x, y, $, o), V = u ? m * l : m;
88
+ const [h, d, A, , m] = t, [b, k, f] = W(n), [w, E, I] = W(s), y = L(h, w), x = L(d, E), $ = L(A, I), { padInfo: _, outDepth: M, outHeight: S, outWidth: F } = me(r, a, p, g, b, k, f, y, x, $, o), V = u ? m * l : m;
88
89
  let U;
89
- return i === "channelsFirst" ? U = [c, V, M, D, F] : i === "channelsLast" && (U = [c, M, D, F, V]), {
90
+ return i === "channelsFirst" ? U = [c, V, M, S, F] : i === "channelsLast" && (U = [c, M, S, F, V]), {
90
91
  batchSize: c,
91
92
  dataFormat: i,
92
93
  inDepth: a,
@@ -94,18 +95,18 @@ function he(e, t, n, s, r, u = !1, i = "channelsLast", o) {
94
95
  inWidth: g,
95
96
  inChannels: l,
96
97
  outDepth: M,
97
- outHeight: D,
98
+ outHeight: S,
98
99
  outWidth: F,
99
100
  outChannels: V,
100
- padInfo: C,
101
+ padInfo: _,
101
102
  strideDepth: b,
102
103
  strideHeight: k,
103
104
  strideWidth: f,
104
105
  filterDepth: h,
105
106
  filterHeight: d,
106
107
  filterWidth: A,
107
- effectiveFilterDepth: x,
108
- effectiveFilterHeight: y,
108
+ effectiveFilterDepth: y,
109
+ effectiveFilterHeight: x,
109
110
  effectiveFilterWidth: $,
110
111
  dilationDepth: w,
111
112
  dilationHeight: E,
@@ -116,19 +117,19 @@ function he(e, t, n, s, r, u = !1, i = "channelsLast", o) {
116
117
  };
117
118
  }
118
119
  function ge(e, t, n, s, r) {
119
- s == null && (s = X(e, t, n));
120
- const u = e[0], i = e[1], o = R((u - t + 2 * s) / n + 1, r), c = R((i - t + 2 * s) / n + 1, r);
120
+ s == null && (s = B(e, t, n));
121
+ const u = e[0], i = e[1], o = O((u - t + 2 * s) / n + 1, r), c = O((i - t + 2 * s) / n + 1, r);
121
122
  return [o, c];
122
123
  }
123
124
  function pe(e, t, n, s, r, u) {
124
- r == null && (r = X(e, t[0], s[0]));
125
+ r == null && (r = B(e, t[0], s[0]));
125
126
  const i = [0, 0, 0, n];
126
127
  for (let o = 0; o < 3; o++)
127
- e[o] + 2 * r >= t[o] && (i[o] = R((e[o] - t[o] + 2 * r) / s[o] + 1, u));
128
+ e[o] + 2 * r >= t[o] && (i[o] = O((e[o] - t[o] + 2 * r) / s[o] + 1, u));
128
129
  return i;
129
130
  }
130
- function X(e, t, n, s = 1) {
131
- const r = G(t, s);
131
+ function B(e, t, n, s = 1) {
132
+ const r = L(t, s);
132
133
  return Math.floor((e[0] * (n - 1) - n + r) / 2);
133
134
  }
134
135
  function T(e) {
@@ -137,7 +138,7 @@ function T(e) {
137
138
  function W(e) {
138
139
  return typeof e == "number" ? [e, e, e] : e;
139
140
  }
140
- function G(e, t) {
141
+ function L(e, t) {
141
142
  return t <= 1 ? e : e + (e - 1) * (t - 1);
142
143
  }
143
144
  function de(e, t, n, s, r, u, i, o, c) {
@@ -154,7 +155,7 @@ function de(e, t, n, s, r, u, i, o, c) {
154
155
  a = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, p = Math.ceil((t - u + 1) / s), g = Math.ceil((n - i + 1) / r);
155
156
  else if (typeof e == "object") {
156
157
  const l = c === "channelsLast" ? e[1][0] : e[2][0], h = c === "channelsLast" ? e[1][1] : e[2][1], d = c === "channelsLast" ? e[2][0] : e[3][0], A = c === "channelsLast" ? e[2][1] : e[3][1];
157
- a = { top: l, bottom: h, left: d, right: A, type: l === 0 && h === 0 && d === 0 && A === 0 ? "VALID" : "EXPLICIT" }, p = R((t - u + l + h) / s + 1, o), g = R((n - i + d + A) / r + 1, o);
158
+ a = { top: l, bottom: h, left: d, right: A, type: l === 0 && h === 0 && d === 0 && A === 0 ? "VALID" : "EXPLICIT" }, p = O((t - u + l + h) / s + 1, o), g = O((n - i + d + A) / r + 1, o);
158
159
  } else
159
160
  throw Error(`Unknown padding parameter: ${e}`);
160
161
  return { padInfo: a, outHeight: p, outWidth: g };
@@ -175,13 +176,13 @@ function me(e, t, n, s, r, u, i, o, c, a, p) {
175
176
  l = m[0], h = m[1], d = m[2];
176
177
  } else if (e === "same") {
177
178
  l = Math.ceil(t / r), h = Math.ceil(n / u), d = Math.ceil(s / i);
178
- const A = (l - 1) * r + o - t, m = (h - 1) * u + c - n, b = (d - 1) * i + a - s, k = Math.floor(A / 2), f = A - k, w = Math.floor(m / 2), E = m - w, I = Math.floor(b / 2), x = b - I;
179
- g = { top: w, bottom: E, left: I, right: x, front: k, back: f, type: "SAME" };
179
+ const A = (l - 1) * r + o - t, m = (h - 1) * u + c - n, b = (d - 1) * i + a - s, k = Math.floor(A / 2), f = A - k, w = Math.floor(m / 2), E = m - w, I = Math.floor(b / 2), y = b - I;
180
+ g = { top: w, bottom: E, left: I, right: y, front: k, back: f, type: "SAME" };
180
181
  } else
181
182
  throw Error(`Unknown padding parameter: ${e}`);
182
183
  return { padInfo: g, outDepth: l, outHeight: h, outWidth: d };
183
184
  }
184
- function R(e, t) {
185
+ function O(e, t) {
185
186
  if (!t)
186
187
  return Math.trunc(e);
187
188
  switch (t) {
@@ -199,10 +200,10 @@ function P(e) {
199
200
  const [t, n, s] = T(e);
200
201
  return t === 1 && n === 1 && s === 1;
201
202
  }
202
- function qe(e, t) {
203
+ function je(e, t) {
203
204
  return P(e) || P(t);
204
205
  }
205
- function Je(e) {
206
+ function qe(e) {
206
207
  return T(e).every((t) => t > 0);
207
208
  }
208
209
  function Ae(e) {
@@ -212,16 +213,16 @@ function Ae(e) {
212
213
  return "channelsFirst";
213
214
  throw new Error(`Unknown dataFormat ${e}`);
214
215
  }
215
- function Qe(e, t, n) {
216
+ function Je(e, t, n) {
216
217
  if (n != null) {
217
218
  if (typeof t == "string")
218
219
  throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);
219
220
  if (typeof t == "number")
220
- N(H(t), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);
221
+ D(H(t), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`);
221
222
  else if (typeof t == "object")
222
223
  t.forEach((s) => {
223
224
  s.forEach((r) => {
224
- N(H(r), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${r}.`);
225
+ D(H(r), () => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${r}.`);
225
226
  });
226
227
  });
227
228
  else
@@ -245,10 +246,10 @@ function Qe(e, t, n) {
245
246
  * =============================================================================
246
247
  */
247
248
  function we(e) {
248
- const n = { x: S(e, "x", "sigmoid", "float32") };
249
- return L.runKernel(te, n);
249
+ const n = { x: N(e, "x", "sigmoid", "float32") };
250
+ return G.runKernel(te, n);
250
251
  }
251
- const Ee = /* @__PURE__ */ _({ sigmoid_: we });
252
+ const Ee = /* @__PURE__ */ C({ sigmoid_: we });
252
253
  /**
253
254
  * @license
254
255
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -266,10 +267,10 @@ const Ee = /* @__PURE__ */ _({ sigmoid_: we });
266
267
  * =============================================================================
267
268
  */
268
269
  function be(e) {
269
- const n = { x: S(e, "x", "elu", "float32") };
270
- return L.runKernel(ne, n);
270
+ const n = { x: N(e, "x", "elu", "float32") };
271
+ return G.runKernel(ne, n);
271
272
  }
272
- const $e = /* @__PURE__ */ _({ elu_: be });
273
+ const $e = /* @__PURE__ */ C({ elu_: be });
273
274
  /**
274
275
  * @license
275
276
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -287,10 +288,10 @@ const $e = /* @__PURE__ */ _({ elu_: be });
287
288
  * =============================================================================
288
289
  */
289
290
  function Ie(e, t = 0.2) {
290
- const s = { x: S(e, "x", "leakyRelu") }, r = { alpha: t };
291
- return L.runKernel(se, s, r);
291
+ const s = { x: N(e, "x", "leakyRelu") }, r = { alpha: t };
292
+ return G.runKernel(se, s, r);
292
293
  }
293
- const xe = /* @__PURE__ */ _({ leakyRelu_: Ie });
294
+ const ye = /* @__PURE__ */ C({ leakyRelu_: Ie });
294
295
  /**
295
296
  * @license
296
297
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -307,11 +308,11 @@ const xe = /* @__PURE__ */ _({ leakyRelu_: Ie });
307
308
  * limitations under the License.
308
309
  * =============================================================================
309
310
  */
310
- function ye(e, t) {
311
- const n = S(e, "x", "prelu"), s = S(t, "alpha", "prelu"), r = { x: n, alpha: s };
312
- return L.runKernel(re, r);
311
+ function xe(e, t) {
312
+ const n = N(e, "x", "prelu"), s = N(t, "alpha", "prelu"), r = { x: n, alpha: s };
313
+ return G.runKernel(re, r);
313
314
  }
314
- const Me = /* @__PURE__ */ _({ prelu_: ye });
315
+ const Me = /* @__PURE__ */ C({ prelu_: xe });
315
316
  /**
316
317
  * @license
317
318
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -329,31 +330,10 @@ const Me = /* @__PURE__ */ _({ prelu_: ye });
329
330
  * =============================================================================
330
331
  */
331
332
  function ke(e) {
332
- const n = { x: S(e, "x", "relu") };
333
- return L.runKernel(ie, n);
333
+ const n = { x: N(e, "x", "relu6") };
334
+ return G.runKernel(ie, n);
334
335
  }
335
- const Se = /* @__PURE__ */ _({ relu_: ke });
336
- /**
337
- * @license
338
- * Copyright 2020 Google LLC. All Rights Reserved.
339
- * Licensed under the Apache License, Version 2.0 (the "License");
340
- * you may not use this file except in compliance with the License.
341
- * You may obtain a copy of the License at
342
- *
343
- * http://www.apache.org/licenses/LICENSE-2.0
344
- *
345
- * Unless required by applicable law or agreed to in writing, software
346
- * distributed under the License is distributed on an "AS IS" BASIS,
347
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
348
- * See the License for the specific language governing permissions and
349
- * limitations under the License.
350
- * =============================================================================
351
- */
352
- function De(e) {
353
- const n = { x: S(e, "x", "relu6") };
354
- return L.runKernel(oe, n);
355
- }
356
- const Ne = /* @__PURE__ */ _({ relu6_: De });
336
+ const Se = /* @__PURE__ */ C({ relu6_: ke });
357
337
  /**
358
338
  * @license
359
339
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -370,11 +350,11 @@ const Ne = /* @__PURE__ */ _({ relu6_: De });
370
350
  * limitations under the License.
371
351
  * =============================================================================
372
352
  */
373
- function _e(e, t = 0) {
374
- const s = { x: S(e, "x", "step") }, r = { alpha: t };
375
- return L.runKernel(le, s, r);
353
+ function De(e, t = 0) {
354
+ const s = { x: N(e, "x", "step") }, r = { alpha: t };
355
+ return G.runKernel(oe, s, r);
376
356
  }
377
- const Le = /* @__PURE__ */ _({ step_: _e });
357
+ const Ne = /* @__PURE__ */ C({ step_: De });
378
358
  /**
379
359
  * @license
380
360
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -391,36 +371,36 @@ const Le = /* @__PURE__ */ _({ step_: _e });
391
371
  * limitations under the License.
392
372
  * =============================================================================
393
373
  */
394
- function Ye(e, t, n) {
374
+ function Qe(e, t, n) {
395
375
  if (n == null || n === "linear")
396
376
  return e;
397
377
  if (n === "relu")
398
- return ue(e, Le(t));
378
+ return le(e, Ne(t));
399
379
  throw new Error(`Cannot compute gradient for fused activation ${n}.`);
400
380
  }
401
- function Ze(e, t) {
381
+ function Ye(e, t) {
402
382
  let n = t;
403
- const s = fe(e.shape, t.shape);
383
+ const s = ue(e.shape, t.shape);
404
384
  return s.length > 0 && (n = ae(n, s)), ce(n, e.shape);
405
385
  }
406
- function ze(e, t, n, s) {
386
+ function Ze(e, t, n, s) {
407
387
  if (t === "linear")
408
388
  return e;
409
389
  if (t === "relu")
410
- return Se(e);
390
+ return fe(e);
411
391
  if (t === "elu")
412
392
  return $e(e);
413
393
  if (t === "relu6")
414
- return Ne(e);
394
+ return Se(e);
415
395
  if (t === "prelu")
416
396
  return Me(e, n);
417
397
  if (t === "leakyrelu")
418
- return xe(e, s);
398
+ return ye(e, s);
419
399
  if (t === "sigmoid")
420
400
  return Ee(e);
421
401
  throw new Error(`Unknown fused activation ${t}.`);
422
402
  }
423
- const et = (e, t) => !(e > 0) || t === "linear";
403
+ const ze = (e, t) => !(e > 0) || t === "linear";
424
404
  /**
425
405
  * @license
426
406
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -437,21 +417,21 @@ const et = (e, t) => !(e > 0) || t === "linear";
437
417
  * limitations under the License.
438
418
  * =============================================================================
439
419
  */
440
- const v = -2, Ce = -1;
441
- function Ge(e, t, n) {
420
+ const v = -2, _e = -1;
421
+ function Le(e, t, n) {
442
422
  const s = e.shape.length;
443
- N(s === t.length, () => `Error in slice${s}D: Length of begin ${t} must match the rank of the array (${s}).`), N(s === n.length, () => `Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);
423
+ D(s === t.length, () => `Error in slice${s}D: Length of begin ${t} must match the rank of the array (${s}).`), D(s === n.length, () => `Error in slice${s}D: Length of size ${n} must match the rank of the array (${s}).`);
444
424
  for (let r = 0; r < s; ++r)
445
- N(t[r] + n[r] <= e.shape[r], () => `Error in slice${s}D: begin[${r}] + size[${r}] (${t[r] + n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`);
425
+ D(t[r] + n[r] <= e.shape[r], () => `Error in slice${s}D: begin[${r}] + size[${r}] (${t[r] + n[r]}) would overflow input.shape[${r}] (${e.shape[r]})`);
446
426
  }
447
- function Te(e) {
427
+ function Ce(e) {
448
428
  const t = [];
449
429
  let n = 0;
450
430
  for (; e > 0; )
451
431
  e & 1 && t.push(n), e /= 2, n++;
452
432
  return t;
453
433
  }
454
- function Re(e, t, n) {
434
+ function Ge(e, t, n) {
455
435
  const s = [];
456
436
  for (let r = 0; r < e.length; r++)
457
437
  s[r] = Math.ceil((t[r] - e[r]) / n[r]);
@@ -479,7 +459,7 @@ function J(e, t) {
479
459
  n.push(t + s);
480
460
  return n;
481
461
  }
482
- function Oe(e, t, n, s, r, u, i, o, c) {
462
+ function Te(e, t, n, s, r, u, i, o, c) {
483
463
  const a = e.length;
484
464
  let p = new Array(a), g = new Array(a), l = new Array(a);
485
465
  if (t.length && n > 0) {
@@ -518,7 +498,7 @@ function Y(e, t, n, s, r) {
518
498
  }
519
499
  for (let o = 0; o < u.length; o++) {
520
500
  const c = r[o];
521
- u[o] < 0 && (u[o] += c), u[o] = O(0, u[o], r[o]);
501
+ u[o] < 0 && (u[o] += c), u[o] = R(0, u[o], r[o]);
522
502
  }
523
503
  return u;
524
504
  }
@@ -531,16 +511,16 @@ function z(e, t, n, s, r, u) {
531
511
  const o = n[r] || 1;
532
512
  (e & 1 << r || u & 1 << r || i == null) && (o > 0 ? i = Number.MIN_SAFE_INTEGER : i = Number.MAX_SAFE_INTEGER);
533
513
  const c = s[r];
534
- return i < 0 && (i += c), i = O(0, i, c - 1), i;
514
+ return i < 0 && (i += c), i = R(0, i, c - 1), i;
535
515
  }
536
516
  function ee(e, t, n, s, r, u) {
537
517
  let i = t[r];
538
518
  const o = n[r] || 1;
539
519
  (e & 1 << r || u & 1 << r || i == null) && (o > 0 ? i = Number.MAX_SAFE_INTEGER : i = Number.MIN_SAFE_INTEGER);
540
520
  const c = s[r];
541
- return i < 0 && (i += c), o > 0 ? i = O(0, i, c) : i = O(-1, i, c - 1), i;
521
+ return i < 0 && (i += c), o > 0 ? i = R(0, i, c) : i = R(-1, i, c - 1), i;
542
522
  }
543
- function Fe(e, t, n) {
523
+ function Oe(e, t, n) {
544
524
  let s = n.length;
545
525
  for (let r = 0; r < n.length; r++)
546
526
  if (n[r] > 1) {
@@ -552,22 +532,22 @@ function Fe(e, t, n) {
552
532
  return !1;
553
533
  return !0;
554
534
  }
555
- function Ve(e, t) {
535
+ function Re(e, t) {
556
536
  let n = e.length > 0 ? e[e.length - 1] : 1;
557
537
  for (let s = 0; s < e.length - 1; s++)
558
538
  n += e[s] * t[s];
559
539
  return n;
560
540
  }
561
- function Ue(e, t, n) {
541
+ function Fe(e, t, n) {
562
542
  let s;
563
543
  const r = e.shape.length;
564
544
  typeof t == "number" ? s = [t, ...new Array(r - 1).fill(0)] : t.length < r ? s = t.concat(new Array(r - t.length).fill(0)) : s = t.slice(), s.forEach((i) => {
565
- N(i !== -1, () => "slice() does not support negative begin indexing.");
545
+ D(i !== -1, () => "slice() does not support negative begin indexing.");
566
546
  });
567
547
  let u;
568
- return n == null ? u = new Array(r).fill(-1) : typeof n == "number" ? u = [n, ...new Array(r - 1).fill(-1)] : n.length < r ? u = n.concat(new Array(r - n.length).fill(-1)) : u = n, u = u.map((i, o) => i >= 0 ? i : (N(i === -1, () => `Negative size values should be exactly -1 but got ${i} for the slice() size at index ${o}.`), e.shape[o] - s[o])), [s, u];
548
+ return n == null ? u = new Array(r).fill(-1) : typeof n == "number" ? u = [n, ...new Array(r - 1).fill(-1)] : n.length < r ? u = n.concat(new Array(r - n.length).fill(-1)) : u = n, u = u.map((i, o) => i >= 0 ? i : (D(i === -1, () => `Negative size values should be exactly -1 but got ${i} for the slice() size at index ${o}.`), e.shape[o] - s[o])), [s, u];
569
549
  }
570
- function We(e, t, n, s, r, u, i, o, c) {
550
+ function Ve(e, t, n, s, r, u, i, o, c) {
571
551
  let a;
572
552
  if (s == null ? (a = new Array(t.length), a.fill(1)) : a = s, i != null && (i & i - 1) !== 0)
573
553
  throw new Error("Multiple ellipses in slice is not allowed.");
@@ -594,7 +574,7 @@ function We(e, t, n, s, r, u, i, o, c) {
594
574
  beginValid: !1,
595
575
  endValid: !1
596
576
  };
597
- ve(g, l);
577
+ Ue(g, l);
598
578
  let h = !0, d = !0, A = !0;
599
579
  const m = [], b = [];
600
580
  for (let f = 0; f < e.length; ++f) {
@@ -605,27 +585,27 @@ function We(e, t, n, s, r, u, i, o, c) {
605
585
  m.push(w ? 1 : -1);
606
586
  continue;
607
587
  }
608
- const I = [l.beginMask & 1 << f, l.endMask & 1 << f], x = [
588
+ const I = [l.beginMask & 1 << f, l.endMask & 1 << f], y = [
609
589
  l.strides[f] > 0 ? 0 : -1,
610
590
  l.strides[f] > 0 ? E : E - 1
611
591
  ];
612
592
  if (w && l.strides[f] <= 0)
613
593
  throw Error("only stride 1 allowed on non-range indexing.");
614
594
  A = A && l.strides[f] === 1;
615
- const y = !!(l.beginMask & 1 << f && l.endMask & 1 << f);
595
+ const x = !!(l.beginMask & 1 << f && l.endMask & 1 << f);
616
596
  if (l.beginValid && l.endValid) {
617
597
  if (w) {
618
- const D = l.begin[f] < 0 ? E + l.begin[f] : l.begin[f];
619
- if (l.begin[f] = D, l.end[f] = l.begin[f] + 1, D < 0 || D >= E)
598
+ const S = l.begin[f] < 0 ? E + l.begin[f] : l.begin[f];
599
+ if (l.begin[f] = S, l.end[f] = l.begin[f] + 1, S < 0 || S >= E)
620
600
  throw Error(`slice index ${l.begin[f]} of dimension ${f} out of bounds.`);
621
601
  } else
622
- l.begin[f] = K(l.begin[f], 0, l.strides[f], E, I, x), l.end[f] = K(l.end[f], 1, l.strides[f], E, I, x);
602
+ l.begin[f] = K(l.begin[f], 0, l.strides[f], E, I, y), l.end[f] = K(l.end[f], 1, l.strides[f], E, I, y);
623
603
  const M = l.strides[f] === 1 && l.begin[f] === 0 && l.end[f] === E;
624
604
  h = h && M, d = d && (f === 0 && l.strides[f] === 1 || M);
625
605
  } else
626
- h = h && l.strides[f] === 1 && y, d = d && (f === 0 && l.strides[f] === 1 || y);
627
- let $, C = !1;
628
- if (l.beginValid && l.endValid ? ($ = l.end[f] - l.begin[f], C = !0) : w ? ($ = 1, C = !0) : y && E >= 0 && (l.strides[f] < 0 ? $ = -E : $ = E, C = !0), C) {
606
+ h = h && l.strides[f] === 1 && x, d = d && (f === 0 && l.strides[f] === 1 || x);
607
+ let $, _ = !1;
608
+ if (l.beginValid && l.endValid ? ($ = l.end[f] - l.begin[f], _ = !0) : w ? ($ = 1, _ = !0) : x && E >= 0 && (l.strides[f] < 0 ? $ = -E : $ = E, _ = !0), _) {
629
609
  let M;
630
610
  $ === 0 || $ < 0 != l.strides[f] < 0 ? M = 0 : M = Math.trunc($ / l.strides[f]) + ($ % l.strides[f] !== 0 ? 1 : 0), m.push(M);
631
611
  } else
@@ -646,7 +626,7 @@ function We(e, t, n, s, r, u, i, o, c) {
646
626
  strides: l.strides
647
627
  };
648
628
  }
649
- function ve(e, t) {
629
+ function Ue(e, t) {
650
630
  t.beginMask = 0, t.endMask = 0, t.shrinkAxisMask = 0;
651
631
  let n = 0;
652
632
  t.beginValid = e.begin != null, t.endValid = e.end != null, t.begin = new Array(t.dims), t.end = new Array(t.dims), t.strides = new Array(t.dims), t.finalShapeGatherIndices = [], t.finalShapeGatherIndicesSparse = [], t.inputShapeGatherIndicesSparse = new Array(t.dims);
@@ -660,7 +640,7 @@ function ve(e, t) {
660
640
  else {
661
641
  if (n === t.begin.length)
662
642
  throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`);
663
- e.begin != null && (t.begin[n] = e.begin[s]), e.end != null && (t.end[n] = e.end[s]), t.strides[n] = e.strides[s], e.beginMask & 1 << s && (t.beginMask |= 1 << n), e.endMask & 1 << s && (t.endMask |= 1 << n), e.shrinkAxisMask & 1 << s ? (t.finalShapeGatherIndices.push(Ce), t.finalShapeGatherIndicesSparse.push(-1), t.shrinkAxisMask |= 1 << n) : (t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(s)), t.inputShapeGatherIndicesSparse[n] = s, n++;
643
+ e.begin != null && (t.begin[n] = e.begin[s]), e.end != null && (t.end[n] = e.end[s]), t.strides[n] = e.strides[s], e.beginMask & 1 << s && (t.beginMask |= 1 << n), e.endMask & 1 << s && (t.endMask |= 1 << n), e.shrinkAxisMask & 1 << s ? (t.finalShapeGatherIndices.push(_e), t.finalShapeGatherIndicesSparse.push(-1), t.shrinkAxisMask |= 1 << n) : (t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(s)), t.inputShapeGatherIndicesSparse[n] = s, n++;
664
644
  }
665
645
  }
666
646
  function K(e, t, n, s, r, u) {
@@ -671,16 +651,16 @@ function K(e, t, n, s, r, u) {
671
651
  return i < u[0] ? u[0] : i > u[1] ? u[1] : i;
672
652
  }
673
653
  }
674
- const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
654
+ const et = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
675
655
  __proto__: null,
676
- assertParamsValid: Ge,
677
- computeFlatOffset: Ve,
678
- computeOutShape: Re,
679
- getNormalizedAxes: Oe,
680
- isSliceContinous: Fe,
681
- maskToAxes: Te,
682
- parseSliceParams: Ue,
683
- sliceInfo: We,
656
+ assertParamsValid: Le,
657
+ computeFlatOffset: Re,
658
+ computeOutShape: Ge,
659
+ getNormalizedAxes: Te,
660
+ isSliceContinous: Oe,
661
+ maskToAxes: Ce,
662
+ parseSliceParams: Fe,
663
+ sliceInfo: Ve,
684
664
  startForAxis: z,
685
665
  startIndicesWithElidedDims: Q,
686
666
  stopForAxis: ee,
@@ -704,37 +684,36 @@ const tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
704
684
  * limitations under the License.
705
685
  * =============================================================================
706
686
  */
707
- const nt = 1.7580993408473768, st = 1.0507009873554805;
687
+ const tt = 1.7580993408473768, nt = 1.0507009873554805;
708
688
  export {
709
- Me as A,
710
- We as B,
711
- Re as C,
712
- Ne as D,
713
- st as S,
714
- nt as a,
715
- ze as b,
716
- Qe as c,
717
- B as d,
689
+ Ve as A,
690
+ Ge as B,
691
+ Se as C,
692
+ nt as S,
693
+ tt as a,
694
+ Ze as b,
695
+ Je as c,
696
+ X as d,
718
697
  he as e,
719
- X as f,
720
- Be as g,
698
+ B as f,
699
+ Ke as g,
721
700
  Xe as h,
722
- je as i,
701
+ Be as i,
723
702
  Ae as j,
724
- qe as k,
725
- Ze as l,
726
- Ye as m,
727
- tt as n,
728
- Je as o,
729
- Ue as p,
730
- Ge as q,
731
- Fe as r,
732
- et as s,
703
+ je as k,
704
+ Ye as l,
705
+ Qe as m,
706
+ et as n,
707
+ qe as o,
708
+ Fe as p,
709
+ Le as q,
710
+ Oe as r,
711
+ ze as s,
733
712
  P as t,
734
- Ve as u,
735
- Le as v,
713
+ Re as u,
714
+ Ne as v,
736
715
  Ee as w,
737
716
  $e as x,
738
- Se as y,
739
- xe as z
717
+ ye as y,
718
+ Me as z
740
719
  };
@@ -1,4 +1,4 @@
1
- import { s as l } from "./shared-CkNorDcU.js";
1
+ import { s as l } from "./shared-V6D_md-c.js";
2
2
  /**
3
3
  * @license
4
4
  * Copyright 2020 Google LLC. All Rights Reserved.