@genai-fi/nanogpt 0.4.1 → 0.4.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 (87) hide show
  1. package/dist/Generator.js +3 -3
  2. package/dist/NanoGPTModel.js +83 -70
  3. package/dist/TeachableLLM.js +1 -1
  4. package/dist/{random_width-CMHmdbSu.js → TiedEmbedding-CnJ1bx4q.js} +760 -719
  5. package/dist/{axis_util-DeydwOoC.js → axis_util-BgTGy5w8.js} +1 -1
  6. package/dist/{concat-DS_qH7MI.js → concat-CuRsVY-K.js} +1 -1
  7. package/dist/dropout-DfDdklfL.js +193 -0
  8. package/dist/{gather-BUmJIS8n.js → gather-ZYRWhmXR.js} +1 -1
  9. package/dist/gelu-CnCt17Lk.js +26 -0
  10. package/dist/{index-XjBAhiFO.js → index-C4JCoBvj.js} +61 -61
  11. package/dist/kernel_funcs_utils-CAd1h9X1.js +388 -0
  12. package/dist/layers/CausalSelfAttention.js +71 -70
  13. package/dist/layers/MLP.d.ts +3 -1
  14. package/dist/layers/MLP.js +93 -5
  15. package/dist/layers/RMSNorm.js +3 -3
  16. package/dist/layers/RoPECache.js +3 -3
  17. package/dist/layers/TiedEmbedding.js +6 -46
  18. package/dist/layers/TransformerBlock.js +2 -2
  19. package/dist/{log_sum_exp-DJPkVZZn.js → log_sum_exp-BswFnwOb.js} +5 -5
  20. package/dist/main.js +1 -1
  21. package/dist/{mat_mul-CKwFEV1Q.js → mat_mul-415y5Qn2.js} +1 -1
  22. package/dist/{max-DJvEiCAJ.js → max-CP_9O2Yd.js} +1 -1
  23. package/dist/{moments-CrWRPcR3.js → moments-CjeIaVdp.js} +3 -3
  24. package/dist/{norm-BzY929B_.js → norm-CZM380I3.js} +5 -5
  25. package/dist/{ones-BO01zpJG.js → ones-Bf3YR48P.js} +2 -2
  26. package/dist/ops/appendCache.js +1 -1
  27. package/dist/ops/attentionMask.d.ts +1 -1
  28. package/dist/ops/attentionMask.js +4 -4
  29. package/dist/ops/cpu/appendCache.js +2 -2
  30. package/dist/ops/cpu/attentionMask.js +13 -9
  31. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  32. package/dist/ops/cpu/gatherSub.js +3 -3
  33. package/dist/ops/cpu/gelu.d.ts +1 -0
  34. package/dist/ops/cpu/gelu.js +40 -0
  35. package/dist/ops/cpu/mulDropout.js +1 -1
  36. package/dist/ops/cpu/qkv.js +3 -3
  37. package/dist/ops/cpu/rope.js +5 -5
  38. package/dist/ops/cpu/scatterSub.js +4 -4
  39. package/dist/ops/fusedSoftmax.js +1 -1
  40. package/dist/ops/gatherSub.js +1 -1
  41. package/dist/ops/gelu.d.ts +3 -0
  42. package/dist/ops/gelu.js +8 -0
  43. package/dist/ops/grads/attentionMask.js +1 -1
  44. package/dist/ops/grads/fusedSoftmax.js +2 -2
  45. package/dist/ops/grads/gelu.d.ts +2 -0
  46. package/dist/ops/grads/gelu.js +5 -0
  47. package/dist/ops/grads/qkv.js +1 -1
  48. package/dist/ops/grads/rope.js +1 -1
  49. package/dist/ops/mulDrop.js +1 -1
  50. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  51. package/dist/ops/qkv.js +1 -1
  52. package/dist/ops/scatterSub.js +1 -1
  53. package/dist/ops/webgl/appendCache.js +1 -1
  54. package/dist/ops/webgl/attentionMask.js +19 -18
  55. package/dist/ops/webgl/fusedSoftmax.js +483 -782
  56. package/dist/ops/webgl/gatherSub.js +1 -1
  57. package/dist/ops/webgl/gelu.d.ts +2 -0
  58. package/dist/ops/webgl/gelu.js +50 -0
  59. package/dist/ops/webgl/mulDropout.js +1 -1
  60. package/dist/ops/webgl/qkv.js +1 -1
  61. package/dist/ops/webgl/rope.js +1 -1
  62. package/dist/ops/webgl/scatterSub.js +1 -1
  63. package/dist/{range-DQMNzBWs.js → range-9AzeApCc.js} +1 -1
  64. package/dist/{reshape-DFzh97Sc.js → reshape-Boe4DuIO.js} +1 -1
  65. package/dist/{sin-BYM-U4Ut.js → sin-KmhiDuMa.js} +1 -1
  66. package/dist/{slice_util-CnVNPQI-.js → slice_util-19zDNNSn.js} +2 -2
  67. package/dist/{softmax-4DOn6cPq.js → softmax-Cujsg4ay.js} +1 -1
  68. package/dist/{split-CkbeVdF8.js → split-DbcNm1-i.js} +1 -1
  69. package/dist/{stack-DaIMO5iX.js → stack-D1YjmgKN.js} +1 -1
  70. package/dist/{sum-C6u3xMi3.js → sum-R28pucR5.js} +1 -1
  71. package/dist/{tensor-Cu1fU7H7.js → tensor-BVeHdl7V.js} +1 -1
  72. package/dist/{tensor2d-D0CKdG6B.js → tensor2d-DqFGNs_K.js} +1 -1
  73. package/dist/{tfjs_backend-Bzl2SrRo.js → tfjs_backend-Cug-PH75.js} +826 -1015
  74. package/dist/training/AdamExt.js +1 -1
  75. package/dist/training/DatasetBuilder.js +3 -3
  76. package/dist/training/FullTrainer.js +1 -1
  77. package/dist/training/Trainer.js +5 -5
  78. package/dist/training/sparseCrossEntropy.js +4 -4
  79. package/dist/utilities/dummy.js +2 -2
  80. package/dist/utilities/generate.js +3 -3
  81. package/dist/utilities/load.js +1 -1
  82. package/dist/utilities/profile.js +1 -1
  83. package/dist/utilities/weights.js +2 -2
  84. package/dist/{variable-BS4AKqNU.js → variable-LJT9Ld63.js} +1 -1
  85. package/dist/{zeros-CmJFiC84.js → zeros-dnQxFgAD.js} +1 -1
  86. package/package.json +1 -1
  87. package/dist/MLP-KHhikThU.js +0 -83
@@ -1,18 +1,18 @@
1
- import { o as p, h as l, E as d, af as oe, ag as ae, j as f, ah as ie, D as Cn, ai as ce, aj as v, ak as ue, al as le, am as fe, an as pe, a1 as he, ao as In, ap as de, p as Y, aq as me, ar as ge, as as $e, at as be, au as ke, av as xe, aw as we, ax as ye, x as L, ay as _e, az as Ae, k as zn, aA as Ie, aB as Ee, aC as Te, aD as Se, aE as Ne, aF as De, I as Me, J as Oe, K as Ve, aG as ve, t as P, aH as dn, aI as Pe, aa as Be, aJ as K, a5 as C, b as A, aK as Re, n as Vn, c as vn, aL as Pn, aM as Ke, aN as qe, aO as Fe, aP as je, aQ as Ge, aR as Le, f as Ce, aS as ze, aT as Ue, s as R, aU as Je, w as mn, a as We, ae as Bn, aV as Ye, $ as Xe } from "./index-XjBAhiFO.js";
2
- import { r as $ } from "./reshape-DFzh97Sc.js";
3
- import { s as Un } from "./split-CkbeVdF8.js";
4
- import { s as j } from "./sum-C6u3xMi3.js";
5
- import { b as gn } from "./slice_util-CnVNPQI-.js";
6
- import { r as ln } from "./range-DQMNzBWs.js";
7
- import { t as Ze } from "./tensor-Cu1fU7H7.js";
8
- import { s as fn } from "./stack-DaIMO5iX.js";
9
- import { c as He, z as Qe } from "./zeros-CmJFiC84.js";
10
- import { n as Jn } from "./norm-BzY929B_.js";
11
- import { c as G } from "./concat-DS_qH7MI.js";
12
- import { m as _ } from "./mat_mul-CKwFEV1Q.js";
13
- import { t as $n } from "./tensor2d-D0CKdG6B.js";
14
- import { s as Wn } from "./index-C4L8Cm77.js";
15
- import { g as nt } from "./gather-BUmJIS8n.js";
1
+ import { o as f, h as l, E as d, an as nn, ao as tn, j as p, ap as sn, D as Ve, aq as rn, al as P, ar as on, as as an, at as cn, au as un, a1 as ln, aa as pn, p as Y, av as fn, aw as hn, ax as dn, ay as mn, az as gn, aA as $n, aB as bn, aC as kn, x as C, aD as xn, aE as wn, aF as An, aG as yn, aH as _n, aI as In, aJ as En, aK as Sn, I as Tn, J as Nn, K as Dn, aL as Mn, t as K, aM as he, b as I, aN as On, a5 as U, n as Me, c as Oe, aO as Be, aP as Bn, aQ as Pn, aR as Kn, aS as Rn, aT as qn, aU as jn, f as Fn, aV as Gn, aW as Ln, ad as L, s as q, aX as Vn, w as de, a as Cn, ai as Pe, aY as vn, $ as zn } from "./index-C4JCoBvj.js";
2
+ import { r as $ } from "./reshape-Boe4DuIO.js";
3
+ import { s as Ce } from "./split-DbcNm1-i.js";
4
+ import { s as G } from "./sum-R28pucR5.js";
5
+ import { b as me } from "./slice_util-19zDNNSn.js";
6
+ import { r as ue } from "./range-9AzeApCc.js";
7
+ import { t as Wn } from "./tensor-BVeHdl7V.js";
8
+ import { s as le } from "./stack-D1YjmgKN.js";
9
+ import { c as Jn, z as Yn } from "./zeros-dnQxFgAD.js";
10
+ import { n as ve } from "./norm-CZM380I3.js";
11
+ import { c as V } from "./concat-CuRsVY-K.js";
12
+ import { m as y } from "./mat_mul-415y5Qn2.js";
13
+ import { t as ge } from "./tensor2d-DqFGNs_K.js";
14
+ import { r as Un, d as Xn } from "./dropout-DfDdklfL.js";
15
+ import { g as Zn } from "./gather-ZYRWhmXR.js";
16
16
  /**
17
17
  * @license
18
18
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -29,11 +29,11 @@ import { g as nt } from "./gather-BUmJIS8n.js";
29
29
  * limitations under the License.
30
30
  * =============================================================================
31
31
  */
32
- function et(n) {
33
- const t = { x: l(n, "x", "sigmoid", "float32") };
34
- return d.runKernel(oe, t);
32
+ function Hn(e) {
33
+ const t = { x: l(e, "x", "sigmoid", "float32") };
34
+ return d.runKernel(nn, t);
35
35
  }
36
- const tt = /* @__PURE__ */ p({ sigmoid_: et });
36
+ const Qn = /* @__PURE__ */ f({ sigmoid_: Hn });
37
37
  /**
38
38
  * @license
39
39
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -50,14 +50,14 @@ const tt = /* @__PURE__ */ p({ sigmoid_: et });
50
50
  * limitations under the License.
51
51
  * =============================================================================
52
52
  */
53
- function st(n, e, t) {
54
- const s = l(n, "x", "slice", "string_or_numeric");
53
+ function et(e, n, t) {
54
+ const s = l(e, "x", "slice", "string_or_numeric");
55
55
  if (s.rank === 0)
56
56
  throw new Error("Slicing scalar is not possible");
57
- const r = { x: s }, o = { begin: e, size: t };
58
- return d.runKernel(ae, r, o);
57
+ const r = { x: s }, o = { begin: n, size: t };
58
+ return d.runKernel(tn, r, o);
59
59
  }
60
- const I = /* @__PURE__ */ p({ slice_: st });
60
+ const _ = /* @__PURE__ */ f({ slice_: et });
61
61
  /**
62
62
  * @license
63
63
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -74,13 +74,13 @@ const I = /* @__PURE__ */ p({ slice_: st });
74
74
  * limitations under the License.
75
75
  * =============================================================================
76
76
  */
77
- function rt(n, e, t) {
78
- const s = l(n, "x", "bincount"), r = l(e, "weights", "bincount");
79
- f(s.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${s.dtype}`), f(t >= 0, () => `size must be non-negative, but got ${t}.`), f(r.size === s.size || r.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);
77
+ function nt(e, n, t) {
78
+ const s = l(e, "x", "bincount"), r = l(n, "weights", "bincount");
79
+ p(s.dtype === "int32", () => `Error in bincount: input dtype must be int32, but got ${s.dtype}`), p(t >= 0, () => `size must be non-negative, but got ${t}.`), p(r.size === s.size || r.size === 0, () => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${s.shape}, weights shape: ${r.shape}.`);
80
80
  const o = { x: s, weights: r }, a = { size: t };
81
- return d.runKernel(ie, o, a);
81
+ return d.runKernel(sn, o, a);
82
82
  }
83
- const ot = /* @__PURE__ */ p({ bincount_: rt });
83
+ const tt = /* @__PURE__ */ f({ bincount_: nt });
84
84
  /**
85
85
  * @license
86
86
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -97,34 +97,34 @@ const ot = /* @__PURE__ */ p({ bincount_: rt });
97
97
  * limitations under the License.
98
98
  * =============================================================================
99
99
  */
100
- function at(n, e, t) {
101
- const s = l(n, "x", "clipByValue");
102
- if (f(e <= t, () => `Error in clip: min (${e}) must be less than or equal to max (${t}).`), e === t)
103
- return Cn(s.shape, e, s.dtype);
104
- const r = { x: s }, o = { clipValueMin: e, clipValueMax: t };
105
- return d.runKernel(ce, r, o);
100
+ function st(e, n, t) {
101
+ const s = l(e, "x", "clipByValue");
102
+ if (p(n <= t, () => `Error in clip: min (${n}) must be less than or equal to max (${t}).`), n === t)
103
+ return Ve(s.shape, n, s.dtype);
104
+ const r = { x: s }, o = { clipValueMin: n, clipValueMax: t };
105
+ return d.runKernel(rn, r, o);
106
106
  }
107
- const it = /* @__PURE__ */ p({ clipByValue_: at });
108
- function ct(n) {
109
- return G(
110
- n,
107
+ const rt = /* @__PURE__ */ f({ clipByValue_: st });
108
+ function ot(e) {
109
+ return V(
110
+ e,
111
111
  0
112
112
  /* axis */
113
113
  );
114
114
  }
115
- const ut = /* @__PURE__ */ p({ concat1d_: ct });
116
- function lt(n, e) {
117
- return G(n, e);
115
+ const at = /* @__PURE__ */ f({ concat1d_: ot });
116
+ function it(e, n) {
117
+ return V(e, n);
118
118
  }
119
- const ft = /* @__PURE__ */ p({ concat2d_: lt });
120
- function pt(n, e) {
121
- return G(n, e);
119
+ const ct = /* @__PURE__ */ f({ concat2d_: it });
120
+ function ut(e, n) {
121
+ return V(e, n);
122
122
  }
123
- const ht = /* @__PURE__ */ p({ concat3d_: pt });
124
- function dt(n, e) {
125
- return G(n, e);
123
+ const lt = /* @__PURE__ */ f({ concat3d_: ut });
124
+ function pt(e, n) {
125
+ return V(e, n);
126
126
  }
127
- const mt = /* @__PURE__ */ p({ concat4d_: dt });
127
+ const ft = /* @__PURE__ */ f({ concat4d_: pt });
128
128
  /**
129
129
  * @license
130
130
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -141,15 +141,15 @@ const mt = /* @__PURE__ */ p({ concat4d_: dt });
141
141
  * limitations under the License.
142
142
  * =============================================================================
143
143
  */
144
- function gt(n, e, t) {
145
- const s = l(e, "a", "where"), r = l(t, "b", "where"), o = l(n, "condition", "where", "bool"), a = v(v(o.shape, s.shape), r.shape), i = gn(o, a), u = gn(s, a), c = gn(r, a), m = {
144
+ function ht(e, n, t) {
145
+ const s = l(n, "a", "where"), r = l(t, "b", "where"), o = l(e, "condition", "where", "bool"), a = P(P(o.shape, s.shape), r.shape), i = me(o, a), u = me(s, a), c = me(r, a), m = {
146
146
  condition: i,
147
147
  t: u,
148
148
  e: c
149
149
  };
150
- return d.runKernel(ue, m);
150
+ return d.runKernel(on, m);
151
151
  }
152
- const nn = /* @__PURE__ */ p({ where_: gt });
152
+ const ee = /* @__PURE__ */ f({ where_: ht });
153
153
  /**
154
154
  * @license
155
155
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -166,11 +166,11 @@ const nn = /* @__PURE__ */ p({ where_: gt });
166
166
  * limitations under the License.
167
167
  * =============================================================================
168
168
  */
169
- function $t(n, ...e) {
170
- const t = e.map((r, o) => l(r, `tensors${o}`, "einsum")), s = { equation: n };
171
- return d.runKernel(le, t, s);
169
+ function dt(e, ...n) {
170
+ const t = n.map((r, o) => l(r, `tensors${o}`, "einsum")), s = { equation: e };
171
+ return d.runKernel(an, t, s);
172
172
  }
173
- const rn = /* @__PURE__ */ p({ einsum_: $t });
173
+ const re = /* @__PURE__ */ f({ einsum_: dt });
174
174
  /**
175
175
  * @license
176
176
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -187,11 +187,11 @@ const rn = /* @__PURE__ */ p({ einsum_: $t });
187
187
  * limitations under the License.
188
188
  * =============================================================================
189
189
  */
190
- function bt(n) {
191
- const t = { x: l(n, "x", "elu", "float32") };
192
- return d.runKernel(fe, t);
190
+ function mt(e) {
191
+ const t = { x: l(e, "x", "elu", "float32") };
192
+ return d.runKernel(cn, t);
193
193
  }
194
- const Yn = /* @__PURE__ */ p({ elu_: bt });
194
+ const ze = /* @__PURE__ */ f({ elu_: mt });
195
195
  /**
196
196
  * @license
197
197
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -208,13 +208,13 @@ const Yn = /* @__PURE__ */ p({ elu_: bt });
208
208
  * limitations under the License.
209
209
  * =============================================================================
210
210
  */
211
- function kt(n, e = 0) {
212
- const t = l(n, "x", "expandDims", "string_or_numeric");
213
- f(e <= t.rank, () => "Axis must be <= rank of the tensor");
214
- const s = { input: t }, r = { dim: e };
215
- return d.runKernel(pe, s, r);
211
+ function gt(e, n = 0) {
212
+ const t = l(e, "x", "expandDims", "string_or_numeric");
213
+ p(n <= t.rank, () => "Axis must be <= rank of the tensor");
214
+ const s = { input: t }, r = { dim: n };
215
+ return d.runKernel(un, s, r);
216
216
  }
217
- const W = /* @__PURE__ */ p({ expandDims_: kt });
217
+ const J = /* @__PURE__ */ f({ expandDims_: gt });
218
218
  /**
219
219
  * @license
220
220
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -231,13 +231,13 @@ const W = /* @__PURE__ */ p({ expandDims_: kt });
231
231
  * limitations under the License.
232
232
  * =============================================================================
233
233
  */
234
- function xt(n, e) {
235
- const t = l(n, "x", "tile", "string_or_numeric");
236
- f(t.rank === e.length, () => `Error in transpose: rank of input ${t.rank} must match length of reps ${e}.`);
237
- const s = { x: t }, r = { reps: e };
238
- return d.runKernel(he, s, r);
234
+ function $t(e, n) {
235
+ const t = l(e, "x", "tile", "string_or_numeric");
236
+ p(t.rank === n.length, () => `Error in transpose: rank of input ${t.rank} must match length of reps ${n}.`);
237
+ const s = { x: t }, r = { reps: n };
238
+ return d.runKernel(ln, s, r);
239
239
  }
240
- const on = /* @__PURE__ */ p({ tile_: xt });
240
+ const oe = /* @__PURE__ */ f({ tile_: $t });
241
241
  /**
242
242
  * @license
243
243
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -254,20 +254,20 @@ const on = /* @__PURE__ */ p({ tile_: xt });
254
254
  * limitations under the License.
255
255
  * =============================================================================
256
256
  */
257
- function wt(n, e, t, s = "float32") {
258
- e == null && (e = n);
259
- const r = In([n, e], s), o = n <= e ? n : e;
257
+ function bt(e, n, t, s = "float32") {
258
+ n == null && (n = e);
259
+ const r = pn([e, n], s), o = e <= n ? e : n;
260
260
  for (let i = 0; i < o; ++i)
261
261
  r.set(1, i, i);
262
- const a = $(r.toTensor(), [n, e]);
262
+ const a = $(r.toTensor(), [e, n]);
263
263
  if (t == null)
264
264
  return a;
265
265
  if (t.length === 1)
266
- return on(W(a, 0), [t[0], 1, 1]);
266
+ return oe(J(a, 0), [t[0], 1, 1]);
267
267
  if (t.length === 2)
268
- return on(W(W(a, 0), 0), [t[0], t[1], 1, 1]);
268
+ return oe(J(J(a, 0), 0), [t[0], t[1], 1, 1]);
269
269
  if (t.length === 3)
270
- return on(W(W(W(a, 0), 0), 0), [
270
+ return oe(J(J(J(a, 0), 0), 0), [
271
271
  t[0],
272
272
  t[1],
273
273
  t[2],
@@ -276,28 +276,7 @@ function wt(n, e, t, s = "float32") {
276
276
  ]);
277
277
  throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${t.length}D.`);
278
278
  }
279
- const yt = /* @__PURE__ */ p({ eye_: wt });
280
- /**
281
- * @license
282
- * Copyright 2018 Google LLC. All Rights Reserved.
283
- * Licensed under the Apache License, Version 2.0 (the "License");
284
- * you may not use this file except in compliance with the License.
285
- * You may obtain a copy of the License at
286
- *
287
- * http://www.apache.org/licenses/LICENSE-2.0
288
- *
289
- * Unless required by applicable law or agreed to in writing, software
290
- * distributed under the License is distributed on an "AS IS" BASIS,
291
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
292
- * See the License for the specific language governing permissions and
293
- * limitations under the License.
294
- * =============================================================================
295
- */
296
- function _t(n) {
297
- const t = { x: l(n, "x", "floor", "float32") };
298
- return d.runKernel(de, t);
299
- }
300
- const At = /* @__PURE__ */ p({ floor_: _t });
279
+ const kt = /* @__PURE__ */ f({ eye_: bt });
301
280
  /**
302
281
  * @license
303
282
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -314,13 +293,13 @@ const At = /* @__PURE__ */ p({ floor_: _t });
314
293
  * limitations under the License.
315
294
  * =============================================================================
316
295
  */
317
- function It(n, e) {
318
- let t = l(n, "a", "greater", "string_or_numeric"), s = l(e, "b", "greater", "string_or_numeric");
319
- [t, s] = Y(t, s), v(t.shape, s.shape);
296
+ function xt(e, n) {
297
+ let t = l(e, "a", "greater", "string_or_numeric"), s = l(n, "b", "greater", "string_or_numeric");
298
+ [t, s] = Y(t, s), P(t.shape, s.shape);
320
299
  const r = { a: t, b: s };
321
- return d.runKernel(me, r);
300
+ return d.runKernel(fn, r);
322
301
  }
323
- const En = /* @__PURE__ */ p({ greater_: It });
302
+ const _e = /* @__PURE__ */ f({ greater_: xt });
324
303
  /**
325
304
  * @license
326
305
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -337,13 +316,13 @@ const En = /* @__PURE__ */ p({ greater_: It });
337
316
  * limitations under the License.
338
317
  * =============================================================================
339
318
  */
340
- function Et(n, e) {
341
- let t = l(n, "a", "greaterEqual", "string_or_numeric"), s = l(e, "b", "greaterEqual", "string_or_numeric");
342
- [t, s] = Y(t, s), v(t.shape, s.shape);
319
+ function wt(e, n) {
320
+ let t = l(e, "a", "greaterEqual", "string_or_numeric"), s = l(n, "b", "greaterEqual", "string_or_numeric");
321
+ [t, s] = Y(t, s), P(t.shape, s.shape);
343
322
  const r = { a: t, b: s };
344
- return d.runKernel(ge, r);
323
+ return d.runKernel(hn, r);
345
324
  }
346
- const Tt = /* @__PURE__ */ p({ greaterEqual_: Et });
325
+ const At = /* @__PURE__ */ f({ greaterEqual_: wt });
347
326
  /**
348
327
  * @license
349
328
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -360,11 +339,11 @@ const Tt = /* @__PURE__ */ p({ greaterEqual_: Et });
360
339
  * limitations under the License.
361
340
  * =============================================================================
362
341
  */
363
- function St(n) {
364
- const t = { input: l(n, "input", "imag") };
365
- return d.runKernel($e, t);
342
+ function yt(e) {
343
+ const t = { input: l(e, "input", "imag") };
344
+ return d.runKernel(dn, t);
366
345
  }
367
- const Nt = /* @__PURE__ */ p({ imag_: St });
346
+ const _t = /* @__PURE__ */ f({ imag_: yt });
368
347
  /**
369
348
  * @license
370
349
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -381,11 +360,11 @@ const Nt = /* @__PURE__ */ p({ imag_: St });
381
360
  * limitations under the License.
382
361
  * =============================================================================
383
362
  */
384
- function Dt(n, e = 0.2) {
385
- const s = { x: l(n, "x", "leakyRelu") }, r = { alpha: e };
386
- return d.runKernel(be, s, r);
363
+ function It(e, n = 0.2) {
364
+ const s = { x: l(e, "x", "leakyRelu") }, r = { alpha: n };
365
+ return d.runKernel(mn, s, r);
387
366
  }
388
- const Mt = /* @__PURE__ */ p({ leakyRelu_: Dt });
367
+ const Et = /* @__PURE__ */ f({ leakyRelu_: It });
389
368
  /**
390
369
  * @license
391
370
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -402,13 +381,13 @@ const Mt = /* @__PURE__ */ p({ leakyRelu_: Dt });
402
381
  * limitations under the License.
403
382
  * =============================================================================
404
383
  */
405
- function Ot(n, e) {
406
- let t = l(n, "a", "less", "string_or_numeric"), s = l(e, "b", "less", "string_or_numeric");
407
- [t, s] = Y(t, s), v(t.shape, s.shape);
384
+ function St(e, n) {
385
+ let t = l(e, "a", "less", "string_or_numeric"), s = l(n, "b", "less", "string_or_numeric");
386
+ [t, s] = Y(t, s), P(t.shape, s.shape);
408
387
  const r = { a: t, b: s };
409
- return d.runKernel(ke, r);
388
+ return d.runKernel(gn, r);
410
389
  }
411
- const Rn = /* @__PURE__ */ p({ less_: Ot });
390
+ const Ke = /* @__PURE__ */ f({ less_: St });
412
391
  /**
413
392
  * @license
414
393
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -425,13 +404,13 @@ const Rn = /* @__PURE__ */ p({ less_: Ot });
425
404
  * limitations under the License.
426
405
  * =============================================================================
427
406
  */
428
- function Vt(n, e) {
429
- let t = l(n, "a", "lessEqual", "string_or_numeric"), s = l(e, "b", "lessEqual", "string_or_numeric");
430
- [t, s] = Y(t, s), v(t.shape, s.shape);
407
+ function Tt(e, n) {
408
+ let t = l(e, "a", "lessEqual", "string_or_numeric"), s = l(n, "b", "lessEqual", "string_or_numeric");
409
+ [t, s] = Y(t, s), P(t.shape, s.shape);
431
410
  const r = { a: t, b: s };
432
- return d.runKernel(xe, r);
411
+ return d.runKernel($n, r);
433
412
  }
434
- const Xn = /* @__PURE__ */ p({ lessEqual_: Vt });
413
+ const We = /* @__PURE__ */ f({ lessEqual_: Tt });
435
414
  /**
436
415
  * @license
437
416
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -448,11 +427,11 @@ const Xn = /* @__PURE__ */ p({ lessEqual_: Vt });
448
427
  * limitations under the License.
449
428
  * =============================================================================
450
429
  */
451
- function vt(n) {
452
- const t = { x: l(n, "x", "neg") };
453
- return d.runKernel(we, t);
430
+ function Nt(e) {
431
+ const t = { x: l(e, "x", "neg") };
432
+ return d.runKernel(bn, t);
454
433
  }
455
- const Tn = /* @__PURE__ */ p({ neg_: vt });
434
+ const Ie = /* @__PURE__ */ f({ neg_: Nt });
456
435
  /**
457
436
  * @license
458
437
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -469,13 +448,13 @@ const Tn = /* @__PURE__ */ p({ neg_: vt });
469
448
  * limitations under the License.
470
449
  * =============================================================================
471
450
  */
472
- function Pt(n, e) {
473
- const t = l(n, "a", "logicalAnd", "bool"), s = l(e, "b", "logicalAnd", "bool");
474
- v(t.shape, s.shape);
451
+ function Dt(e, n) {
452
+ const t = l(e, "a", "logicalAnd", "bool"), s = l(n, "b", "logicalAnd", "bool");
453
+ P(t.shape, s.shape);
475
454
  const r = { a: t, b: s };
476
- return d.runKernel(ye, r);
455
+ return d.runKernel(kn, r);
477
456
  }
478
- const Bt = /* @__PURE__ */ p({ logicalAnd_: Pt });
457
+ const Mt = /* @__PURE__ */ f({ logicalAnd_: Dt });
479
458
  /**
480
459
  * @license
481
460
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -492,120 +471,13 @@ const Bt = /* @__PURE__ */ p({ logicalAnd_: Pt });
492
471
  * limitations under the License.
493
472
  * =============================================================================
494
473
  */
495
- function Rt(n, e) {
496
- let t = l(n, "a", "minimum"), s = l(e, "b", "minimum");
497
- [t, s] = Y(t, s), t.dtype === "bool" && (t = L(t, "int32"), s = L(s, "int32")), v(t.shape, s.shape);
474
+ function Ot(e, n) {
475
+ let t = l(e, "a", "minimum"), s = l(n, "b", "minimum");
476
+ [t, s] = Y(t, s), t.dtype === "bool" && (t = C(t, "int32"), s = C(s, "int32")), P(t.shape, s.shape);
498
477
  const r = { a: t, b: s };
499
- return d.runKernel(_e, r);
500
- }
501
- const Kn = /* @__PURE__ */ p({ minimum_: Rt });
502
- /**
503
- * @license
504
- * Copyright 2020 Google LLC. All Rights Reserved.
505
- * Licensed under the Apache License, Version 2.0 (the "License");
506
- * you may not use this file except in compliance with the License.
507
- * You may obtain a copy of the License at
508
- *
509
- * http://www.apache.org/licenses/LICENSE-2.0
510
- *
511
- * Unless required by applicable law or agreed to in writing, software
512
- * distributed under the License is distributed on an "AS IS" BASIS,
513
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
514
- * See the License for the specific language governing permissions and
515
- * limitations under the License.
516
- * =============================================================================
517
- */
518
- function Kt(n, e) {
519
- const t = l(n, "x", "prelu"), s = l(e, "alpha", "prelu"), r = { x: t, alpha: s };
520
- return d.runKernel(Ae, r);
521
- }
522
- const qt = /* @__PURE__ */ p({ prelu_: Kt });
523
- /**
524
- * @license
525
- * Copyright 2018 Google LLC. All Rights Reserved.
526
- * Licensed under the Apache License, Version 2.0 (the "License");
527
- * you may not use this file except in compliance with the License.
528
- * You may obtain a copy of the License at
529
- *
530
- * http://www.apache.org/licenses/LICENSE-2.0
531
- *
532
- * Unless required by applicable law or agreed to in writing, software
533
- * distributed under the License is distributed on an "AS IS" BASIS,
534
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
535
- * See the License for the specific language governing permissions and
536
- * limitations under the License.
537
- * =============================================================================
538
- */
539
- class Ft {
540
- constructor(e, t, s, r, o) {
541
- this.mean = e, this.stdDev = t, this.dtype = s, this.nextVal = NaN, this.truncated = r, this.truncated && (this.upper = this.mean + this.stdDev * 2, this.lower = this.mean - this.stdDev * 2);
542
- const a = o || Math.random();
543
- this.random = Wn.alea(a.toString());
544
- }
545
- /** Returns next sample from a Gaussian distribution. */
546
- nextValue() {
547
- if (!isNaN(this.nextVal)) {
548
- const r = this.nextVal;
549
- return this.nextVal = NaN, r;
550
- }
551
- let e, t, s = !1;
552
- for (; !s; ) {
553
- let r, o, a;
554
- do
555
- r = 2 * this.random() - 1, o = 2 * this.random() - 1, a = r * r + o * o;
556
- while (a >= 1 || a === 0);
557
- const i = Math.sqrt(-2 * Math.log(a) / a);
558
- e = this.mean + this.stdDev * r * i, t = this.mean + this.stdDev * o * i, (!this.truncated || this.isValidTruncated(e)) && (s = !0);
559
- }
560
- return (!this.truncated || this.isValidTruncated(t)) && (this.nextVal = this.convertValue(t)), this.convertValue(e);
561
- }
562
- /** Handles proper rounding for non-floating-point numbers. */
563
- convertValue(e) {
564
- return this.dtype == null || this.dtype === "float32" ? e : Math.round(e);
565
- }
566
- /** Returns true if less than 2-standard-deviations from the mean. */
567
- isValidTruncated(e) {
568
- return e <= this.upper && e >= this.lower;
569
- }
570
- }
571
- class jt {
572
- constructor(e = 0, t = 1, s, r) {
573
- if (this.canReturnFloat = () => this.dtype == null || this.dtype === "float32", this.min = e, this.range = t - e, this.dtype = s, r == null && (r = Math.random()), typeof r == "number" && (r = r.toString()), !this.canReturnFloat() && this.range <= 1)
574
- throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`);
575
- this.random = Wn.alea(r);
576
- }
577
- convertValue(e) {
578
- return this.canReturnFloat() ? e : Math.round(e);
579
- }
580
- nextValue() {
581
- return this.convertValue(this.min + this.range * this.random());
582
- }
583
- }
584
- /**
585
- * @license
586
- * Copyright 2020 Google LLC. All Rights Reserved.
587
- * Licensed under the Apache License, Version 2.0 (the "License");
588
- * you may not use this file except in compliance with the License.
589
- * You may obtain a copy of the License at
590
- *
591
- * http://www.apache.org/licenses/LICENSE-2.0
592
- *
593
- * Unless required by applicable law or agreed to in writing, software
594
- * distributed under the License is distributed on an "AS IS" BASIS,
595
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
596
- * See the License for the specific language governing permissions and
597
- * limitations under the License.
598
- * =============================================================================
599
- */
600
- function Gt(n, e = 0, t = 1, s, r) {
601
- if (zn(n), s != null && s === "bool")
602
- throw new Error(`Unsupported data type ${s}`);
603
- const o = new Ft(e, t, s, !1, r), a = In(n, s);
604
- for (let i = 0; i < a.values.length; i++)
605
- a.values[i] = o.nextValue();
606
- return a.toTensor();
478
+ return d.runKernel(xn, r);
607
479
  }
608
- const Lt = /* @__PURE__ */ p({ randomNormal_: Gt });
480
+ const Re = /* @__PURE__ */ f({ minimum_: Ot });
609
481
  /**
610
482
  * @license
611
483
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -622,14 +494,11 @@ const Lt = /* @__PURE__ */ p({ randomNormal_: Gt });
622
494
  * limitations under the License.
623
495
  * =============================================================================
624
496
  */
625
- function Ct(n, e = 0, t = 1, s = "float32", r) {
626
- zn(n);
627
- const o = In(n, s), a = new jt(e, t, null, r);
628
- for (let i = 0; i < o.values.length; i++)
629
- o.values[i] = a.nextValue();
630
- return o.toTensor();
497
+ function Bt(e, n) {
498
+ const t = l(e, "x", "prelu"), s = l(n, "alpha", "prelu"), r = { x: t, alpha: s };
499
+ return d.runKernel(wn, r);
631
500
  }
632
- const zt = /* @__PURE__ */ p({ randomUniform_: Ct });
501
+ const Pt = /* @__PURE__ */ f({ prelu_: Bt });
633
502
  /**
634
503
  * @license
635
504
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -646,11 +515,11 @@ const zt = /* @__PURE__ */ p({ randomUniform_: Ct });
646
515
  * limitations under the License.
647
516
  * =============================================================================
648
517
  */
649
- function Ut(n) {
650
- const t = { input: l(n, "input", "real") };
651
- return d.runKernel(Ie, t);
518
+ function Kt(e) {
519
+ const t = { input: l(e, "input", "real") };
520
+ return d.runKernel(An, t);
652
521
  }
653
- const Jt = /* @__PURE__ */ p({ real_: Ut });
522
+ const Rt = /* @__PURE__ */ f({ real_: Kt });
654
523
  /**
655
524
  * @license
656
525
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -667,11 +536,11 @@ const Jt = /* @__PURE__ */ p({ real_: Ut });
667
536
  * limitations under the License.
668
537
  * =============================================================================
669
538
  */
670
- function Wt(n) {
671
- const t = { x: l(n, "x", "relu") };
672
- return d.runKernel(Ee, t);
539
+ function qt(e) {
540
+ const t = { x: l(e, "x", "relu") };
541
+ return d.runKernel(yn, t);
673
542
  }
674
- const Yt = /* @__PURE__ */ p({ relu_: Wt });
543
+ const jt = /* @__PURE__ */ f({ relu_: qt });
675
544
  /**
676
545
  * @license
677
546
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -688,11 +557,11 @@ const Yt = /* @__PURE__ */ p({ relu_: Wt });
688
557
  * limitations under the License.
689
558
  * =============================================================================
690
559
  */
691
- function Xt(n) {
692
- const t = { x: l(n, "x", "relu6") };
693
- return d.runKernel(Te, t);
560
+ function Ft(e) {
561
+ const t = { x: l(e, "x", "relu6") };
562
+ return d.runKernel(_n, t);
694
563
  }
695
- const Zt = /* @__PURE__ */ p({ relu6_: Xt });
564
+ const Gt = /* @__PURE__ */ f({ relu6_: Ft });
696
565
  /**
697
566
  * @license
698
567
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -709,11 +578,11 @@ const Zt = /* @__PURE__ */ p({ relu6_: Xt });
709
578
  * limitations under the License.
710
579
  * =============================================================================
711
580
  */
712
- function Ht(n) {
713
- const t = { x: l(n, "x", "round") };
714
- return d.runKernel(Se, t);
581
+ function Lt(e) {
582
+ const t = { x: l(e, "x", "round") };
583
+ return d.runKernel(In, t);
715
584
  }
716
- const Qt = /* @__PURE__ */ p({ round_: Ht });
585
+ const Vt = /* @__PURE__ */ f({ round_: Lt });
717
586
  /**
718
587
  * @license
719
588
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -730,11 +599,11 @@ const Qt = /* @__PURE__ */ p({ round_: Ht });
730
599
  * limitations under the License.
731
600
  * =============================================================================
732
601
  */
733
- function ns(n, e, t) {
734
- const s = l(n, "x", "slice1d");
735
- return f(s.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`), I(s, [e], [t]);
602
+ function Ct(e, n, t) {
603
+ const s = l(e, "x", "slice1d");
604
+ return p(s.rank === 1, () => `slice1d expects a rank-1 tensor, but got a rank-${s.rank} tensor`), _(s, [n], [t]);
736
605
  }
737
- const Sn = /* @__PURE__ */ p({ slice1d_: ns });
606
+ const Ee = /* @__PURE__ */ f({ slice1d_: Ct });
738
607
  /**
739
608
  * @license
740
609
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -751,11 +620,11 @@ const Sn = /* @__PURE__ */ p({ slice1d_: ns });
751
620
  * limitations under the License.
752
621
  * =============================================================================
753
622
  */
754
- function es(n, e, t) {
755
- const s = l(n, "x", "slice2d");
756
- return f(s.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`), I(s, e, t);
623
+ function vt(e, n, t) {
624
+ const s = l(e, "x", "slice2d");
625
+ return p(s.rank === 2, () => `slice2d expects a rank-2 tensor, but got a rank-${s.rank} tensor`), _(s, n, t);
757
626
  }
758
- const Zn = /* @__PURE__ */ p({ slice2d_: es });
627
+ const Je = /* @__PURE__ */ f({ slice2d_: vt });
759
628
  /**
760
629
  * @license
761
630
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -772,11 +641,11 @@ const Zn = /* @__PURE__ */ p({ slice2d_: es });
772
641
  * limitations under the License.
773
642
  * =============================================================================
774
643
  */
775
- function ts(n, e, t) {
776
- const s = l(n, "x", "slice3d");
777
- return f(s.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`), I(s, e, t);
644
+ function zt(e, n, t) {
645
+ const s = l(e, "x", "slice3d");
646
+ return p(s.rank === 3, () => `slice3d expects a rank-3 tensor, but got a rank-${s.rank} tensor`), _(s, n, t);
778
647
  }
779
- const Nn = /* @__PURE__ */ p({ slice3d_: ts });
648
+ const Se = /* @__PURE__ */ f({ slice3d_: zt });
780
649
  /**
781
650
  * @license
782
651
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -793,11 +662,11 @@ const Nn = /* @__PURE__ */ p({ slice3d_: ts });
793
662
  * limitations under the License.
794
663
  * =============================================================================
795
664
  */
796
- function ss(n, e, t) {
797
- const s = l(n, "x", "slice4d");
798
- return f(s.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`), I(s, e, t);
665
+ function Wt(e, n, t) {
666
+ const s = l(e, "x", "slice4d");
667
+ return p(s.rank === 4, () => `slice4d expects a rank-4 tensor, but got a rank-${s.rank} tensor`), _(s, n, t);
799
668
  }
800
- const pn = /* @__PURE__ */ p({ slice4d_: ss });
669
+ const pe = /* @__PURE__ */ f({ slice4d_: Wt });
801
670
  /**
802
671
  * @license
803
672
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -814,11 +683,11 @@ const pn = /* @__PURE__ */ p({ slice4d_: ss });
814
683
  * limitations under the License.
815
684
  * =============================================================================
816
685
  */
817
- function rs(n, e) {
818
- const t = l(n, "x", "squeeze", "string_or_numeric");
819
- return $(t, Ne(t.shape, e).newShape);
686
+ function Jt(e, n) {
687
+ const t = l(e, "x", "squeeze", "string_or_numeric");
688
+ return $(t, En(t.shape, n).newShape);
820
689
  }
821
- const os = /* @__PURE__ */ p({ squeeze_: rs });
690
+ const Yt = /* @__PURE__ */ f({ squeeze_: Jt });
822
691
  /**
823
692
  * @license
824
693
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -835,11 +704,11 @@ const os = /* @__PURE__ */ p({ squeeze_: rs });
835
704
  * limitations under the License.
836
705
  * =============================================================================
837
706
  */
838
- function as(n, e = 0) {
839
- const s = { x: l(n, "x", "step") }, r = { alpha: e };
840
- return d.runKernel(De, s, r);
707
+ function Ut(e, n = 0) {
708
+ const s = { x: l(e, "x", "step") }, r = { alpha: n };
709
+ return d.runKernel(Sn, s, r);
841
710
  }
842
- const is = /* @__PURE__ */ p({ step_: as });
711
+ const Xt = /* @__PURE__ */ f({ step_: Ut });
843
712
  /**
844
713
  * @license
845
714
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -856,12 +725,12 @@ const is = /* @__PURE__ */ p({ step_: as });
856
725
  * limitations under the License.
857
726
  * =============================================================================
858
727
  */
859
- function V(n, e) {
860
- Me(n);
861
- const t = Oe(n, e);
728
+ function B(e, n) {
729
+ Tn(e);
730
+ const t = Nn(e, n);
862
731
  if (t.length !== 1)
863
732
  throw new Error("tensor1d() requires values to be a flat/TypedArray");
864
- return Ve(n, null, t, e);
733
+ return Dn(e, null, t, n);
865
734
  }
866
735
  /**
867
736
  * @license
@@ -879,13 +748,13 @@ function V(n, e) {
879
748
  * limitations under the License.
880
749
  * =============================================================================
881
750
  */
882
- function cs(n, e = 0) {
883
- const t = l(n, "x", "unstack", "string_or_numeric");
884
- f(e >= -t.shape.length && e < t.shape.length, () => `Axis = ${e} is not in [-${t.shape.length}, ${t.shape.length})`);
885
- const s = { value: t }, r = { axis: e };
886
- return d.runKernel(ve, s, r);
751
+ function Zt(e, n = 0) {
752
+ const t = l(e, "x", "unstack", "string_or_numeric");
753
+ p(n >= -t.shape.length && n < t.shape.length, () => `Axis = ${n} is not in [-${t.shape.length}, ${t.shape.length})`);
754
+ const s = { value: t }, r = { axis: n };
755
+ return d.runKernel(Mn, s, r);
887
756
  }
888
- const Hn = /* @__PURE__ */ p({ unstack_: cs });
757
+ const Ye = /* @__PURE__ */ f({ unstack_: Zt });
889
758
  /**
890
759
  * @license
891
760
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -902,19 +771,19 @@ const Hn = /* @__PURE__ */ p({ unstack_: cs });
902
771
  * limitations under the License.
903
772
  * =============================================================================
904
773
  */
905
- function us(n, e, t) {
906
- const s = l(n, "x", "transpose");
907
- if (e == null && (e = s.shape.map((a, i) => i).reverse()), f(s.rank === e.length, () => `Error in transpose: rank of input ${s.rank} must match length of perm ${e}.`), e.forEach((a) => {
908
- f(a >= 0 && a < s.rank, () => `All entries in 'perm' must be between 0 and ${s.rank - 1} but got ${e}`);
774
+ function Ht(e, n, t) {
775
+ const s = l(e, "x", "transpose");
776
+ if (n == null && (n = s.shape.map((a, i) => i).reverse()), p(s.rank === n.length, () => `Error in transpose: rank of input ${s.rank} must match length of perm ${n}.`), n.forEach((a) => {
777
+ p(a >= 0 && a < s.rank, () => `All entries in 'perm' must be between 0 and ${s.rank - 1} but got ${n}`);
909
778
  }), s.rank <= 1)
910
779
  return s.clone();
911
- const r = { x: s }, o = { perm: e };
912
- return s.dtype === "complex64" ? P(() => {
913
- let a = Jt(s), i = Nt(s);
914
- return a = d.runKernel(dn, { x: a }, o), i = d.runKernel(dn, { x: i }, o), t && (i = Tn(i)), He(a, i);
915
- }) : d.runKernel(dn, r, o);
780
+ const r = { x: s }, o = { perm: n };
781
+ return s.dtype === "complex64" ? K(() => {
782
+ let a = Rt(s), i = _t(s);
783
+ return a = d.runKernel(he, { x: a }, o), i = d.runKernel(he, { x: i }, o), t && (i = Ie(i)), Jn(a, i);
784
+ }) : d.runKernel(he, r, o);
916
785
  }
917
- const wn = /* @__PURE__ */ p({ transpose_: us });
786
+ const xe = /* @__PURE__ */ f({ transpose_: Ht });
918
787
  /**
919
788
  * @license
920
789
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -931,89 +800,36 @@ const wn = /* @__PURE__ */ p({ transpose_: us });
931
800
  * limitations under the License.
932
801
  * =============================================================================
933
802
  */
934
- function ls(n, e) {
935
- if (e == null)
936
- return n.shape.slice();
937
- if (Pe(n.shape, e))
938
- return e;
939
- if (n.shape.length === e.length) {
940
- const t = [];
941
- for (let s = 0; s < n.shape.length; s++)
942
- e[s] == null && n.shape[s] != null ? t.push(n.shape[s]) : t.push(e[s]);
943
- return t;
944
- }
945
- return e;
946
- }
947
- /**
948
- * @license
949
- * Copyright 2018 Google LLC. All Rights Reserved.
950
- * Licensed under the Apache License, Version 2.0 (the "License");
951
- * you may not use this file except in compliance with the License.
952
- * You may obtain a copy of the License at
953
- *
954
- * http://www.apache.org/licenses/LICENSE-2.0
955
- *
956
- * Unless required by applicable law or agreed to in writing, software
957
- * distributed under the License is distributed on an "AS IS" BASIS,
958
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
959
- * See the License for the specific language governing permissions and
960
- * limitations under the License.
961
- * =============================================================================
962
- */
963
- function fs(n, e, t, s) {
964
- const r = l(n, "x", "dropout");
965
- if (f(r.dtype === "float32", () => `x has to be a floating point tensor since it's going to be scaled, but got a ${r.dtype} tensor instead.`), f(e >= 0 && e < 1, () => `rate must be a float in the range [0, 1), but got ${e}.`), e === 0)
966
- return n instanceof Be ? r.clone() : r;
967
- const o = ls(r, t), a = 1 - e, i = K(At(C(zt(o, 0, 1, "float32", s), a)), a);
968
- return A(r, i);
969
- }
970
- const ps = /* @__PURE__ */ p({ dropout_: fs });
971
- /**
972
- * @license
973
- * Copyright 2019 Google LLC. All Rights Reserved.
974
- * Licensed under the Apache License, Version 2.0 (the "License");
975
- * you may not use this file except in compliance with the License.
976
- * You may obtain a copy of the License at
977
- *
978
- * http://www.apache.org/licenses/LICENSE-2.0
979
- *
980
- * Unless required by applicable law or agreed to in writing, software
981
- * distributed under the License is distributed on an "AS IS" BASIS,
982
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
983
- * See the License for the specific language governing permissions and
984
- * limitations under the License.
985
- * =============================================================================
986
- */
987
- function hs(n, e, t) {
803
+ function Qt(e, n, t) {
988
804
  if (t == null || t === "linear")
989
- return n;
805
+ return e;
990
806
  if (t === "relu")
991
- return A(n, is(e));
807
+ return I(e, Xt(n));
992
808
  throw new Error(`Cannot compute gradient for fused activation ${t}.`);
993
809
  }
994
- function ds(n, e) {
995
- let t = e;
996
- const s = Re(n.shape, e.shape);
997
- return s.length > 0 && (t = j(t, s)), $(t, n.shape);
810
+ function es(e, n) {
811
+ let t = n;
812
+ const s = On(e.shape, n.shape);
813
+ return s.length > 0 && (t = G(t, s)), $(t, e.shape);
998
814
  }
999
- function ms(n, e, t, s) {
1000
- if (e === "linear")
1001
- return n;
1002
- if (e === "relu")
1003
- return Yt(n);
1004
- if (e === "elu")
1005
- return Yn(n);
1006
- if (e === "relu6")
1007
- return Zt(n);
1008
- if (e === "prelu")
1009
- return qt(n, t);
1010
- if (e === "leakyrelu")
1011
- return Mt(n, s);
1012
- if (e === "sigmoid")
1013
- return tt(n);
1014
- throw new Error(`Unknown fused activation ${e}.`);
1015
- }
1016
- const gs = (n, e) => !(n > 0) || e === "linear";
815
+ function ns(e, n, t, s) {
816
+ if (n === "linear")
817
+ return e;
818
+ if (n === "relu")
819
+ return jt(e);
820
+ if (n === "elu")
821
+ return ze(e);
822
+ if (n === "relu6")
823
+ return Gt(e);
824
+ if (n === "prelu")
825
+ return Pt(e, t);
826
+ if (n === "leakyrelu")
827
+ return Et(e, s);
828
+ if (n === "sigmoid")
829
+ return Qn(e);
830
+ throw new Error(`Unknown fused activation ${n}.`);
831
+ }
832
+ const ts = (e, n) => !(e > 0) || n === "linear";
1017
833
  /**
1018
834
  * @license
1019
835
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -1030,49 +846,49 @@ const gs = (n, e) => !(n > 0) || e === "linear";
1030
846
  * limitations under the License.
1031
847
  * =============================================================================
1032
848
  */
1033
- function $s({ a: n, b: e, transposeA: t = !1, transposeB: s = !1, bias: r, activation: o = "linear", preluActivationWeights: a, leakyreluAlpha: i = 0.2 }) {
1034
- if (gs(d.state.gradientDepth, o) === !1) {
1035
- let U = _(n, e, t, s);
1036
- return r != null && (U = C(U, r)), ms(U, o, a, i);
849
+ function ss({ a: e, b: n, transposeA: t = !1, transposeB: s = !1, bias: r, activation: o = "linear", preluActivationWeights: a, leakyreluAlpha: i = 0.2 }) {
850
+ if (ts(d.state.gradientDepth, o) === !1) {
851
+ let z = y(e, n, t, s);
852
+ return r != null && (z = U(z, r)), ns(z, o, a, i);
1037
853
  }
1038
- let u = l(n, "a", "fused matMul"), c = l(e, "b", "fused matMul");
854
+ let u = l(e, "a", "fused matMul"), c = l(n, "b", "fused matMul");
1039
855
  [u, c] = Y(u, c);
1040
- const m = t ? u.shape[u.rank - 2] : u.shape[u.rank - 1], h = s ? c.shape[c.rank - 1] : c.shape[c.rank - 2], b = t ? u.shape[u.rank - 1] : u.shape[u.rank - 2], g = s ? c.shape[c.rank - 2] : c.shape[c.rank - 1], x = u.shape.slice(0, -2), w = c.shape.slice(0, -2), k = Vn(x), E = Vn(w);
1041
- f(m === h, () => `Error in fused matMul: inner shapes (${m}) and (${h}) of Tensors with shapes ${u.shape} and ${c.shape} and transposeA=${t} and transposeB=${s} must match.`);
1042
- const S = v(u.shape.slice(0, -2), c.shape.slice(0, -2)).concat([b, g]), M = t ? $(u, [k, m, b]) : $(u, [k, b, m]), O = s ? $(c, [E, g, h]) : $(c, [E, h, g]);
856
+ const m = t ? u.shape[u.rank - 2] : u.shape[u.rank - 1], h = s ? c.shape[c.rank - 1] : c.shape[c.rank - 2], b = t ? u.shape[u.rank - 1] : u.shape[u.rank - 2], g = s ? c.shape[c.rank - 2] : c.shape[c.rank - 1], x = u.shape.slice(0, -2), w = c.shape.slice(0, -2), k = Me(x), E = Me(w);
857
+ p(m === h, () => `Error in fused matMul: inner shapes (${m}) and (${h}) of Tensors with shapes ${u.shape} and ${c.shape} and transposeA=${t} and transposeB=${s} must match.`);
858
+ const T = P(u.shape.slice(0, -2), c.shape.slice(0, -2)).concat([b, g]), M = t ? $(u, [k, m, b]) : $(u, [k, b, m]), O = s ? $(c, [E, g, h]) : $(c, [E, h, g]);
1043
859
  let N;
1044
- r != null && (N = l(r, "bias", "fused matMul"), [N] = Y(N, u), v(S, N.shape));
1045
- let tn;
1046
- a != null && (tn = l(a, "prelu weights", "fused matMul"));
1047
- const z = (U, sn) => {
1048
- const [q, F, J, un] = sn, B = hs($(U, J.shape), J, o);
860
+ r != null && (N = l(r, "bias", "fused matMul"), [N] = Y(N, u), P(T, N.shape));
861
+ let te;
862
+ a != null && (te = l(a, "prelu weights", "fused matMul"));
863
+ const v = (z, se) => {
864
+ const [j, F, W, ce] = se, R = Qt($(z, W.shape), W, o);
1049
865
  let Z, H;
1050
- if (!t && !s ? (Z = _(B, F, !1, !0), H = _(q, B, !0, !1)) : !t && s ? (Z = _(B, F, !1, !1), H = _(B, q, !0, !1)) : t && !s ? (Z = _(F, B, !1, !0), H = _(q, B, !1, !1)) : (Z = _(F, B, !0, !0), H = _(B, q, !0, !0)), r != null) {
1051
- const re = ds(un, B);
1052
- return [Z, H, re];
866
+ if (!t && !s ? (Z = y(R, F, !1, !0), H = y(j, R, !0, !1)) : !t && s ? (Z = y(R, F, !1, !1), H = y(R, j, !0, !1)) : t && !s ? (Z = y(F, R, !1, !0), H = y(j, R, !1, !1)) : (Z = y(F, R, !0, !0), H = y(R, j, !0, !0)), r != null) {
867
+ const en = es(ce, R);
868
+ return [Z, H, en];
1053
869
  } else
1054
870
  return [Z, H];
1055
871
  }, X = {
1056
872
  a: M,
1057
873
  b: O,
1058
874
  bias: N,
1059
- preluActivationWeights: tn
1060
- }, On = { transposeA: t, transposeB: s, activation: o, leakyreluAlpha: i };
1061
- return r == null ? vn((sn, q, F) => {
1062
- const J = (
875
+ preluActivationWeights: te
876
+ }, De = { transposeA: t, transposeB: s, activation: o, leakyreluAlpha: i };
877
+ return r == null ? Oe((se, j, F) => {
878
+ const W = (
1063
879
  // tslint:disable-next-line: no-unnecessary-type-assertion
1064
- d.runKernel(Pn, X, On)
880
+ d.runKernel(Be, X, De)
1065
881
  );
1066
- return F([sn, q, J]), { value: $(J, S), gradFunc: z };
1067
- })(M, O) : vn((sn, q, F, J) => {
1068
- const un = (
882
+ return F([se, j, W]), { value: $(W, T), gradFunc: v };
883
+ })(M, O) : Oe((se, j, F, W) => {
884
+ const ce = (
1069
885
  // tslint:disable-next-line: no-unnecessary-type-assertion
1070
- d.runKernel(Pn, X, On)
886
+ d.runKernel(Be, X, De)
1071
887
  );
1072
- return J([sn, q, un, F]), { value: $(un, S), gradFunc: z };
888
+ return W([se, j, ce, F]), { value: $(ce, T), gradFunc: v };
1073
889
  })(M, O, N);
1074
890
  }
1075
- const qn = /* @__PURE__ */ p({ fusedMatMul_: $s });
891
+ const qe = /* @__PURE__ */ f({ fusedMatMul_: ss });
1076
892
  /**
1077
893
  * @license
1078
894
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1089,13 +905,13 @@ const qn = /* @__PURE__ */ p({ fusedMatMul_: $s });
1089
905
  * limitations under the License.
1090
906
  * =============================================================================
1091
907
  */
1092
- function bs(n, e, t, s, r = "bilinear", o = 0) {
1093
- const a = l(n, "image", "cropAndResize"), i = l(e, "boxes", "cropAndResize", "float32"), u = l(t, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
1094
- f(a.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`), f(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`), f(u.rank === 1 && u.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), f(s.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`), f(s[0] >= 1 && s[1] >= 1, () => `cropSize must be atleast [1,1], but was ${s}`), f(r === "bilinear" || r === "nearest", () => `method must be bilinear or nearest, but was ${r}`);
908
+ function rs(e, n, t, s, r = "bilinear", o = 0) {
909
+ const a = l(e, "image", "cropAndResize"), i = l(n, "boxes", "cropAndResize", "float32"), u = l(t, "boxInd", "cropAndResize", "int32"), c = i.shape[0];
910
+ p(a.rank === 4, () => `Error in cropAndResize: image must be rank 4,but got rank ${a.rank}.`), p(i.rank === 2 && i.shape[1] === 4, () => `Error in cropAndResize: boxes must be have size [${c},4] but had shape ${i.shape}.`), p(u.rank === 1 && u.shape[0] === c, () => `Error in cropAndResize: boxInd must be have size [${c}] but had shape ${i.shape}.`), p(s.length === 2, () => `Error in cropAndResize: cropSize must be of length 2, but got length ${s.length}.`), p(s[0] >= 1 && s[1] >= 1, () => `cropSize must be atleast [1,1], but was ${s}`), p(r === "bilinear" || r === "nearest", () => `method must be bilinear or nearest, but was ${r}`);
1095
911
  const m = { image: a, boxes: i, boxInd: u }, h = { method: r, extrapolationValue: o, cropSize: s };
1096
- return d.runKernel(Ke, m, h);
912
+ return d.runKernel(Bn, m, h);
1097
913
  }
1098
- const ks = /* @__PURE__ */ p({ cropAndResize_: bs });
914
+ const os = /* @__PURE__ */ f({ cropAndResize_: rs });
1099
915
  /**
1100
916
  * @license
1101
917
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1112,13 +928,13 @@ const ks = /* @__PURE__ */ p({ cropAndResize_: bs });
1112
928
  * limitations under the License.
1113
929
  * =============================================================================
1114
930
  */
1115
- function xs(n) {
1116
- const e = l(n, "image", "flipLeftRight", "float32");
1117
- f(e.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${e.rank}.`);
1118
- const t = { image: e };
1119
- return d.runKernel(qe, t, {});
931
+ function as(e) {
932
+ const n = l(e, "image", "flipLeftRight", "float32");
933
+ p(n.rank === 4, () => `Error in flipLeftRight: image must be rank 4,but got rank ${n.rank}.`);
934
+ const t = { image: n };
935
+ return d.runKernel(Pn, t, {});
1120
936
  }
1121
- const ws = /* @__PURE__ */ p({ flipLeftRight_: xs });
937
+ const is = /* @__PURE__ */ f({ flipLeftRight_: as });
1122
938
  /**
1123
939
  * @license
1124
940
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1135,13 +951,13 @@ const ws = /* @__PURE__ */ p({ flipLeftRight_: xs });
1135
951
  * limitations under the License.
1136
952
  * =============================================================================
1137
953
  */
1138
- function ys(n) {
1139
- const e = l(n, "image", "grayscaleToRGB"), t = e.rank - 1, s = e.shape[t];
1140
- f(e.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${e.rank}.`), f(s === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);
1141
- const r = new Array(e.rank);
1142
- return r.fill(1, 0, t), r[t] = 3, on(e, r);
954
+ function cs(e) {
955
+ const n = l(e, "image", "grayscaleToRGB"), t = n.rank - 1, s = n.shape[t];
956
+ p(n.rank >= 2, () => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${n.rank}.`), p(s === 1, () => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${s}.`);
957
+ const r = new Array(n.rank);
958
+ return r.fill(1, 0, t), r[t] = 3, oe(n, r);
1143
959
  }
1144
- const _s = /* @__PURE__ */ p({ grayscaleToRGB_: ys });
960
+ const us = /* @__PURE__ */ f({ grayscaleToRGB_: cs });
1145
961
  /**
1146
962
  * @license
1147
963
  * Copyright 2023 Google LLC.
@@ -1158,33 +974,33 @@ const _s = /* @__PURE__ */ p({ grayscaleToRGB_: ys });
1158
974
  * limitations under the License.
1159
975
  * =============================================================================
1160
976
  */
1161
- function As(n) {
1162
- const e = l(n, "image", "RGBToGrayscale"), t = e.rank - 1, s = e.shape[t];
1163
- f(e.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${e.rank}.`), f(s === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);
1164
- const r = e.dtype, o = L(e, "float32"), a = V([0.2989, 0.587, 0.114]);
977
+ function ls(e) {
978
+ const n = l(e, "image", "RGBToGrayscale"), t = n.rank - 1, s = n.shape[t];
979
+ p(n.rank >= 2, () => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${n.rank}.`), p(s === 3, () => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${s}.`);
980
+ const r = n.dtype, o = C(n, "float32"), a = B([0.2989, 0.587, 0.114]);
1165
981
  let i;
1166
- switch (e.rank) {
982
+ switch (n.rank) {
1167
983
  case 2:
1168
- i = rn("ij,j->i", o, a);
984
+ i = re("ij,j->i", o, a);
1169
985
  break;
1170
986
  case 3:
1171
- i = rn("ijk,k->ij", o, a);
987
+ i = re("ijk,k->ij", o, a);
1172
988
  break;
1173
989
  case 4:
1174
- i = rn("ijkl,l->ijk", o, a);
990
+ i = re("ijkl,l->ijk", o, a);
1175
991
  break;
1176
992
  case 5:
1177
- i = rn("ijklm,m->ijkl", o, a);
993
+ i = re("ijklm,m->ijkl", o, a);
1178
994
  break;
1179
995
  case 6:
1180
- i = rn("ijklmn,n->ijklm", o, a);
996
+ i = re("ijklmn,n->ijklm", o, a);
1181
997
  break;
1182
998
  default:
1183
999
  throw new Error("Not a valid tensor rank.");
1184
1000
  }
1185
- return i = W(i, -1), L(i, r);
1001
+ return i = J(i, -1), C(i, r);
1186
1002
  }
1187
- const Is = /* @__PURE__ */ p({ rgbToGrayscale_: As });
1003
+ const ps = /* @__PURE__ */ f({ rgbToGrayscale_: ls });
1188
1004
  /**
1189
1005
  * @license
1190
1006
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1201,13 +1017,13 @@ const Is = /* @__PURE__ */ p({ rgbToGrayscale_: As });
1201
1017
  * limitations under the License.
1202
1018
  * =============================================================================
1203
1019
  */
1204
- function Es(n, e, t = 0, s = 0.5) {
1205
- const r = l(n, "image", "rotateWithOffset", "float32");
1206
- f(r.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);
1207
- const o = { image: r }, a = { radians: e, fillValue: t, center: s };
1208
- return d.runKernel(Fe, o, a);
1020
+ function fs(e, n, t = 0, s = 0.5) {
1021
+ const r = l(e, "image", "rotateWithOffset", "float32");
1022
+ p(r.rank === 4, () => `Error in rotateWithOffset: image must be rank 4,but got rank ${r.rank}.`);
1023
+ const o = { image: r }, a = { radians: n, fillValue: t, center: s };
1024
+ return d.runKernel(Kn, o, a);
1209
1025
  }
1210
- const Ts = /* @__PURE__ */ p({ rotateWithOffset_: Es });
1026
+ const hs = /* @__PURE__ */ f({ rotateWithOffset_: fs });
1211
1027
  /**
1212
1028
  * @license
1213
1029
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1224,10 +1040,10 @@ const Ts = /* @__PURE__ */ p({ rotateWithOffset_: Es });
1224
1040
  * limitations under the License.
1225
1041
  * =============================================================================
1226
1042
  */
1227
- function en(n, e, t, s, r, o) {
1043
+ function ne(e, n, t, s, r, o) {
1228
1044
  s == null && (s = 0.5), r == null && (r = Number.NEGATIVE_INFINITY), o == null && (o = 0);
1229
- const a = n.shape[0];
1230
- return t = Math.min(t, a), f(0 <= s && s <= 1, () => `iouThreshold must be in [0, 1], but was '${s}'`), f(n.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${n.rank}'`), f(n.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${n.shape[1]}`), f(e.rank === 1, () => "scores must be a 1D tensor"), f(e.shape[0] === a, () => `scores has incompatible shape with boxes. Expected ${a}, but was ${e.shape[0]}`), f(0 <= o && o <= 1, () => `softNmsSigma must be in [0, 1], but was '${o}'`), { maxOutputSize: t, iouThreshold: s, scoreThreshold: r, softNmsSigma: o };
1045
+ const a = e.shape[0];
1046
+ return t = Math.min(t, a), p(0 <= s && s <= 1, () => `iouThreshold must be in [0, 1], but was '${s}'`), p(e.rank === 2, () => `boxes must be a 2D tensor, but was of rank '${e.rank}'`), p(e.shape[1] === 4, () => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`), p(n.rank === 1, () => "scores must be a 1D tensor"), p(n.shape[0] === a, () => `scores has incompatible shape with boxes. Expected ${a}, but was ${n.shape[0]}`), p(0 <= o && o <= 1, () => `softNmsSigma must be in [0, 1], but was '${o}'`), { maxOutputSize: t, iouThreshold: s, scoreThreshold: r, softNmsSigma: o };
1231
1047
  }
1232
1048
  /**
1233
1049
  * @license
@@ -1245,13 +1061,13 @@ function en(n, e, t, s, r, o) {
1245
1061
  * limitations under the License.
1246
1062
  * =============================================================================
1247
1063
  */
1248
- function Ss(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY) {
1249
- const o = l(n, "boxes", "nonMaxSuppression", "float32"), a = l(e, "scores", "nonMaxSuppression", "float32"), i = en(o, a, t, s, r);
1064
+ function ds(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY) {
1065
+ const o = l(e, "boxes", "nonMaxSuppression", "float32"), a = l(n, "scores", "nonMaxSuppression", "float32"), i = ne(o, a, t, s, r);
1250
1066
  t = i.maxOutputSize, s = i.iouThreshold, r = i.scoreThreshold;
1251
1067
  const u = { maxOutputSize: t, iouThreshold: s, scoreThreshold: r };
1252
- return d.runKernel(je, { boxes: o, scores: a }, u);
1068
+ return d.runKernel(Rn, { boxes: o, scores: a }, u);
1253
1069
  }
1254
- const Ns = /* @__PURE__ */ p({ nonMaxSuppression_: Ss });
1070
+ const ms = /* @__PURE__ */ f({ nonMaxSuppression_: ds });
1255
1071
  /**
1256
1072
  * @license
1257
1073
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -1268,21 +1084,21 @@ const Ns = /* @__PURE__ */ p({ nonMaxSuppression_: Ss });
1268
1084
  * limitations under the License.
1269
1085
  * =============================================================================
1270
1086
  */
1271
- function Ds(n, e, t) {
1272
- const s = Ms(n, e, t), r = s < 0 ? -(s + 1) : s;
1273
- n.splice(r, 0, e);
1087
+ function gs(e, n, t) {
1088
+ const s = $s(e, n, t), r = s < 0 ? -(s + 1) : s;
1089
+ e.splice(r, 0, n);
1274
1090
  }
1275
- function Ms(n, e, t) {
1276
- return Vs(n, e, t || Os);
1091
+ function $s(e, n, t) {
1092
+ return ks(e, n, t || bs);
1277
1093
  }
1278
- function Os(n, e) {
1279
- return n > e ? 1 : n < e ? -1 : 0;
1094
+ function bs(e, n) {
1095
+ return e > n ? 1 : e < n ? -1 : 0;
1280
1096
  }
1281
- function Vs(n, e, t) {
1282
- let s = 0, r = n.length, o = 0, a = !1;
1097
+ function ks(e, n, t) {
1098
+ let s = 0, r = e.length, o = 0, a = !1;
1283
1099
  for (; s < r; ) {
1284
1100
  o = s + (r - s >>> 1);
1285
- const i = t(e, n[o]);
1101
+ const i = t(n, e[o]);
1286
1102
  i > 0 ? s = o + 1 : (r = o, a = !i);
1287
1103
  }
1288
1104
  return a ? s : -s - 1;
@@ -1303,10 +1119,10 @@ function Vs(n, e, t) {
1303
1119
  * limitations under the License.
1304
1120
  * =============================================================================
1305
1121
  */
1306
- function vs(n, e, t, s, r) {
1307
- return Dn(
1308
- n,
1122
+ function xs(e, n, t, s, r) {
1123
+ return Te(
1309
1124
  e,
1125
+ n,
1310
1126
  t,
1311
1127
  s,
1312
1128
  r,
@@ -1314,10 +1130,10 @@ function vs(n, e, t, s, r) {
1314
1130
  /* softNmsSigma */
1315
1131
  );
1316
1132
  }
1317
- function Ps(n, e, t, s, r, o) {
1318
- return Dn(
1319
- n,
1133
+ function ws(e, n, t, s, r, o) {
1134
+ return Te(
1320
1135
  e,
1136
+ n,
1321
1137
  t,
1322
1138
  s,
1323
1139
  r,
@@ -1328,10 +1144,10 @@ function Ps(n, e, t, s, r, o) {
1328
1144
  /* returnValidOutputs */
1329
1145
  );
1330
1146
  }
1331
- function Bs(n, e, t, s, r, o) {
1332
- return Dn(
1333
- n,
1147
+ function As(e, n, t, s, r, o) {
1148
+ return Te(
1334
1149
  e,
1150
+ n,
1335
1151
  t,
1336
1152
  s,
1337
1153
  r,
@@ -1340,46 +1156,46 @@ function Bs(n, e, t, s, r, o) {
1340
1156
  /* returnScoresTensor */
1341
1157
  );
1342
1158
  }
1343
- function Dn(n, e, t, s, r, o, a = !1, i = !1, u = !1) {
1159
+ function Te(e, n, t, s, r, o, a = !1, i = !1, u = !1) {
1344
1160
  const c = [];
1345
- for (let k = 0; k < e.length; k++)
1346
- e[k] > r && c.push({ score: e[k], boxIndex: k, suppressBeginIndex: 0 });
1347
- c.sort(Fn);
1161
+ for (let k = 0; k < n.length; k++)
1162
+ n[k] > r && c.push({ score: n[k], boxIndex: k, suppressBeginIndex: 0 });
1163
+ c.sort(je);
1348
1164
  const m = o > 0 ? -0.5 / o : 0, h = [], b = [];
1349
1165
  for (; h.length < t && c.length > 0; ) {
1350
- const k = c.pop(), { score: E, boxIndex: T, suppressBeginIndex: S } = k;
1166
+ const k = c.pop(), { score: E, boxIndex: S, suppressBeginIndex: T } = k;
1351
1167
  if (E < r)
1352
1168
  break;
1353
1169
  let M = !1;
1354
- for (let O = h.length - 1; O >= S; --O) {
1355
- const N = Rs(n, T, h[O]);
1170
+ for (let O = h.length - 1; O >= T; --O) {
1171
+ const N = ys(e, S, h[O]);
1356
1172
  if (N >= s) {
1357
1173
  M = !0;
1358
1174
  break;
1359
1175
  }
1360
- if (k.score = k.score * Ks(s, m, N), k.score <= r)
1176
+ if (k.score = k.score * _s(s, m, N), k.score <= r)
1361
1177
  break;
1362
1178
  }
1363
- k.suppressBeginIndex = h.length, M || (k.score === E ? (h.push(T), b.push(k.score)) : k.score > r && Ds(c, k, Fn));
1179
+ k.suppressBeginIndex = h.length, M || (k.score === E ? (h.push(S), b.push(k.score)) : k.score > r && gs(c, k, je));
1364
1180
  }
1365
1181
  const g = h.length, x = t - g;
1366
1182
  i && x > 0 && (h.push(...new Array(x).fill(0)), b.push(...new Array(x).fill(0)));
1367
1183
  const w = { selectedIndices: h };
1368
1184
  return a && (w.selectedScores = b), u && (w.validOutputs = g), w;
1369
1185
  }
1370
- function Rs(n, e, t) {
1371
- const s = n.subarray(e * 4, e * 4 + 4), r = n.subarray(t * 4, t * 4 + 4), o = Math.min(s[0], s[2]), a = Math.min(s[1], s[3]), i = Math.max(s[0], s[2]), u = Math.max(s[1], s[3]), c = Math.min(r[0], r[2]), m = Math.min(r[1], r[3]), h = Math.max(r[0], r[2]), b = Math.max(r[1], r[3]), g = (i - o) * (u - a), x = (h - c) * (b - m);
1186
+ function ys(e, n, t) {
1187
+ const s = e.subarray(n * 4, n * 4 + 4), r = e.subarray(t * 4, t * 4 + 4), o = Math.min(s[0], s[2]), a = Math.min(s[1], s[3]), i = Math.max(s[0], s[2]), u = Math.max(s[1], s[3]), c = Math.min(r[0], r[2]), m = Math.min(r[1], r[3]), h = Math.max(r[0], r[2]), b = Math.max(r[1], r[3]), g = (i - o) * (u - a), x = (h - c) * (b - m);
1372
1188
  if (g <= 0 || x <= 0)
1373
1189
  return 0;
1374
- const w = Math.max(o, c), k = Math.max(a, m), E = Math.min(i, h), T = Math.min(u, b), S = Math.max(E - w, 0) * Math.max(T - k, 0);
1375
- return S / (g + x - S);
1190
+ const w = Math.max(o, c), k = Math.max(a, m), E = Math.min(i, h), S = Math.min(u, b), T = Math.max(E - w, 0) * Math.max(S - k, 0);
1191
+ return T / (g + x - T);
1376
1192
  }
1377
- function Ks(n, e, t) {
1378
- const s = Math.exp(e * t * t);
1379
- return t <= n ? s : 0;
1193
+ function _s(e, n, t) {
1194
+ const s = Math.exp(n * t * t);
1195
+ return t <= e ? s : 0;
1380
1196
  }
1381
- function Fn(n, e) {
1382
- return n.score - e.score || n.score === e.score && e.boxIndex - n.boxIndex;
1197
+ function je(e, n) {
1198
+ return e.score - n.score || e.score === n.score && n.boxIndex - e.boxIndex;
1383
1199
  }
1384
1200
  /**
1385
1201
  * @license
@@ -1397,13 +1213,13 @@ function Fn(n, e) {
1397
1213
  * limitations under the License.
1398
1214
  * =============================================================================
1399
1215
  */
1400
- async function qs(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY) {
1401
- const o = l(n, "boxes", "nonMaxSuppressionAsync"), a = l(e, "scores", "nonMaxSuppressionAsync"), i = en(o, a, t, s, r);
1216
+ async function Is(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY) {
1217
+ const o = l(e, "boxes", "nonMaxSuppressionAsync"), a = l(n, "scores", "nonMaxSuppressionAsync"), i = ne(o, a, t, s, r);
1402
1218
  t = i.maxOutputSize, s = i.iouThreshold, r = i.scoreThreshold;
1403
- const u = await Promise.all([o.data(), a.data()]), c = u[0], m = u[1], { selectedIndices: h } = vs(c, m, t, s, r);
1404
- return o !== n && o.dispose(), a !== e && a.dispose(), V(h, "int32");
1219
+ const u = await Promise.all([o.data(), a.data()]), c = u[0], m = u[1], { selectedIndices: h } = xs(c, m, t, s, r);
1220
+ return o !== e && o.dispose(), a !== n && a.dispose(), B(h, "int32");
1405
1221
  }
1406
- const Fs = qs;
1222
+ const Es = Is;
1407
1223
  /**
1408
1224
  * @license
1409
1225
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1420,13 +1236,13 @@ const Fs = qs;
1420
1236
  * limitations under the License.
1421
1237
  * =============================================================================
1422
1238
  */
1423
- function js(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
1424
- const a = l(n, "boxes", "nonMaxSuppression"), i = l(e, "scores", "nonMaxSuppression"), u = en(a, i, t, s, r, o);
1239
+ function Ss(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
1240
+ const a = l(e, "boxes", "nonMaxSuppression"), i = l(n, "scores", "nonMaxSuppression"), u = ne(a, i, t, s, r, o);
1425
1241
  t = u.maxOutputSize, s = u.iouThreshold, r = u.scoreThreshold, o = u.softNmsSigma;
1426
- const c = { boxes: a, scores: i }, m = { maxOutputSize: t, iouThreshold: s, scoreThreshold: r, softNmsSigma: o }, h = d.runKernel(Ge, c, m);
1242
+ const c = { boxes: a, scores: i }, m = { maxOutputSize: t, iouThreshold: s, scoreThreshold: r, softNmsSigma: o }, h = d.runKernel(qn, c, m);
1427
1243
  return { selectedIndices: h[0], selectedScores: h[1] };
1428
1244
  }
1429
- const Gs = /* @__PURE__ */ p({ nonMaxSuppressionWithScore_: js });
1245
+ const Ts = /* @__PURE__ */ f({ nonMaxSuppressionWithScore_: Ss });
1430
1246
  /**
1431
1247
  * @license
1432
1248
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1443,16 +1259,16 @@ const Gs = /* @__PURE__ */ p({ nonMaxSuppressionWithScore_: js });
1443
1259
  * limitations under the License.
1444
1260
  * =============================================================================
1445
1261
  */
1446
- async function Ls(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
1447
- const a = l(n, "boxes", "nonMaxSuppressionAsync"), i = l(e, "scores", "nonMaxSuppressionAsync"), u = en(a, i, t, s, r, o);
1262
+ async function Ns(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = 0) {
1263
+ const a = l(e, "boxes", "nonMaxSuppressionAsync"), i = l(n, "scores", "nonMaxSuppressionAsync"), u = ne(a, i, t, s, r, o);
1448
1264
  t = u.maxOutputSize, s = u.iouThreshold, r = u.scoreThreshold, o = u.softNmsSigma;
1449
- const c = await Promise.all([a.data(), i.data()]), m = c[0], h = c[1], { selectedIndices: b, selectedScores: g } = Bs(m, h, t, s, r, o);
1450
- return a !== n && a.dispose(), i !== e && i.dispose(), {
1451
- selectedIndices: V(b, "int32"),
1452
- selectedScores: V(g)
1265
+ const c = await Promise.all([a.data(), i.data()]), m = c[0], h = c[1], { selectedIndices: b, selectedScores: g } = As(m, h, t, s, r, o);
1266
+ return a !== e && a.dispose(), i !== n && i.dispose(), {
1267
+ selectedIndices: B(b, "int32"),
1268
+ selectedScores: B(g)
1453
1269
  };
1454
1270
  }
1455
- const Cs = Ls;
1271
+ const Ds = Ns;
1456
1272
  /**
1457
1273
  * @license
1458
1274
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1469,8 +1285,8 @@ const Cs = Ls;
1469
1285
  * limitations under the License.
1470
1286
  * =============================================================================
1471
1287
  */
1472
- function zs(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1473
- const a = l(n, "boxes", "nonMaxSuppression"), i = l(e, "scores", "nonMaxSuppression"), u = en(
1288
+ function Ms(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1289
+ const a = l(e, "boxes", "nonMaxSuppression"), i = l(n, "scores", "nonMaxSuppression"), u = ne(
1474
1290
  a,
1475
1291
  i,
1476
1292
  t,
@@ -1483,10 +1299,10 @@ function zs(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1483
1299
  iouThreshold: m,
1484
1300
  scoreThreshold: h,
1485
1301
  padToMaxOutputSize: o
1486
- }, x = d.runKernel(Le, b, g);
1302
+ }, x = d.runKernel(jn, b, g);
1487
1303
  return { selectedIndices: x[0], validOutputs: x[1] };
1488
1304
  }
1489
- const Us = /* @__PURE__ */ p({ nonMaxSuppressionPadded_: zs });
1305
+ const Os = /* @__PURE__ */ f({ nonMaxSuppressionPadded_: Ms });
1490
1306
  /**
1491
1307
  * @license
1492
1308
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1503,8 +1319,8 @@ const Us = /* @__PURE__ */ p({ nonMaxSuppressionPadded_: zs });
1503
1319
  * limitations under the License.
1504
1320
  * =============================================================================
1505
1321
  */
1506
- async function Js(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1507
- const a = l(n, "boxes", "nonMaxSuppressionAsync"), i = l(e, "scores", "nonMaxSuppressionAsync"), u = en(
1322
+ async function Bs(e, n, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1323
+ const a = l(e, "boxes", "nonMaxSuppressionAsync"), i = l(n, "scores", "nonMaxSuppressionAsync"), u = ne(
1508
1324
  a,
1509
1325
  i,
1510
1326
  t,
@@ -1512,13 +1328,13 @@ async function Js(n, e, t, s = 0.5, r = Number.NEGATIVE_INFINITY, o = !1) {
1512
1328
  r,
1513
1329
  null
1514
1330
  /* softNmsSigma */
1515
- ), c = u.maxOutputSize, m = u.iouThreshold, h = u.scoreThreshold, [b, g] = await Promise.all([a.data(), i.data()]), { selectedIndices: x, validOutputs: w } = Ps(b, g, c, m, h, o);
1516
- return a !== n && a.dispose(), i !== e && i.dispose(), {
1517
- selectedIndices: V(x, "int32"),
1518
- validOutputs: Ce(w, "int32")
1331
+ ), c = u.maxOutputSize, m = u.iouThreshold, h = u.scoreThreshold, [b, g] = await Promise.all([a.data(), i.data()]), { selectedIndices: x, validOutputs: w } = ws(b, g, c, m, h, o);
1332
+ return a !== e && a.dispose(), i !== n && i.dispose(), {
1333
+ selectedIndices: B(x, "int32"),
1334
+ validOutputs: Fn(w, "int32")
1519
1335
  };
1520
1336
  }
1521
- const Ws = Js;
1337
+ const Ps = Bs;
1522
1338
  /**
1523
1339
  * @license
1524
1340
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1535,15 +1351,15 @@ const Ws = Js;
1535
1351
  * limitations under the License.
1536
1352
  * =============================================================================
1537
1353
  */
1538
- function Ys(n, e, t = !1, s = !1) {
1539
- const r = l(n, "images", "resizeBilinear");
1540
- f(r.rank === 3 || r.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`), f(e.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${e}.`), f(s === !1 || t === !1, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
1354
+ function Ks(e, n, t = !1, s = !1) {
1355
+ const r = l(e, "images", "resizeBilinear");
1356
+ p(r.rank === 3 || r.rank === 4, () => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${r.rank}.`), p(n.length === 2, () => `Error in resizeBilinear: new shape must 2D, but got shape ${n}.`), p(s === !1 || t === !1, () => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.");
1541
1357
  let o = r, a = !1;
1542
1358
  r.rank === 3 && (a = !0, o = $(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
1543
- const i = { images: o }, u = { alignCorners: t, halfPixelCenters: s, size: e }, c = d.runKernel(ze, i, u);
1359
+ const i = { images: o }, u = { alignCorners: t, halfPixelCenters: s, size: n }, c = d.runKernel(Gn, i, u);
1544
1360
  return a ? $(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
1545
1361
  }
1546
- const Xs = /* @__PURE__ */ p({ resizeBilinear_: Ys });
1362
+ const Rs = /* @__PURE__ */ f({ resizeBilinear_: Ks });
1547
1363
  /**
1548
1364
  * @license
1549
1365
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1560,15 +1376,15 @@ const Xs = /* @__PURE__ */ p({ resizeBilinear_: Ys });
1560
1376
  * limitations under the License.
1561
1377
  * =============================================================================
1562
1378
  */
1563
- function Zs(n, e, t = !1, s = !1) {
1564
- const r = l(n, "images", "resizeNearestNeighbor");
1565
- f(r.rank === 3 || r.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`), f(e.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${e}.`), f(r.dtype === "float32" || r.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), f(s === !1 || t === !1, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
1379
+ function qs(e, n, t = !1, s = !1) {
1380
+ const r = l(e, "images", "resizeNearestNeighbor");
1381
+ p(r.rank === 3 || r.rank === 4, () => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${r.rank}.`), p(n.length === 2, () => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${n}.`), p(r.dtype === "float32" || r.dtype === "int32", () => "`images` must have `int32` or `float32` as dtype"), p(s === !1 || t === !1, () => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.");
1566
1382
  let o = r, a = !1;
1567
1383
  r.rank === 3 && (a = !0, o = $(r, [1, r.shape[0], r.shape[1], r.shape[2]]));
1568
- const i = { images: o }, u = { alignCorners: t, halfPixelCenters: s, size: e }, c = d.runKernel(Ue, i, u);
1384
+ const i = { images: o }, u = { alignCorners: t, halfPixelCenters: s, size: n }, c = d.runKernel(Ln, i, u);
1569
1385
  return a ? $(c, [c.shape[1], c.shape[2], c.shape[3]]) : c;
1570
1386
  }
1571
- const Hs = /* @__PURE__ */ p({ resizeNearestNeighbor_: Zs });
1387
+ const js = /* @__PURE__ */ f({ resizeNearestNeighbor_: qs });
1572
1388
  /**
1573
1389
  * @license
1574
1390
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1585,38 +1401,38 @@ const Hs = /* @__PURE__ */ p({ resizeNearestNeighbor_: Zs });
1585
1401
  * limitations under the License.
1586
1402
  * =============================================================================
1587
1403
  */
1588
- function Qs(n, e = "binary", t = !1, s = 0.5) {
1589
- const r = l(n, "image", "threshold"), o = 0.2989, a = 0.587, i = 0.114, u = r.shape[0] * r.shape[1];
1590
- let c = A(V([s]), 255), m, h, b, g;
1591
- if (f(r.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${r.rank}.`), f(r.shape[2] === 3 || r.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`), f(r.dtype === "int32" || r.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`), f(e === "otsu" || e === "binary", () => `Method must be binary or otsu, but was ${e}`), r.shape[2] === 3) {
1592
- [m, h, b] = Un(r, [1, 1, 1], -1);
1593
- const k = A(m, o), E = A(h, a), T = A(b, i);
1594
- g = C(C(k, E), T);
1404
+ function Fs(e, n = "binary", t = !1, s = 0.5) {
1405
+ const r = l(e, "image", "threshold"), o = 0.2989, a = 0.587, i = 0.114, u = r.shape[0] * r.shape[1];
1406
+ let c = I(B([s]), 255), m, h, b, g;
1407
+ if (p(r.rank === 3, () => `Error in threshold: image must be rank 3,but got rank ${r.rank}.`), p(r.shape[2] === 3 || r.shape[2] === 1, () => `Error in threshold: image color channel must be equal to 3 or 1but got ${r.shape[2]}.`), p(r.dtype === "int32" || r.dtype === "float32", () => `Error in dtype: image dtype must be int32 or float32,but got dtype ${r.dtype}.`), p(n === "otsu" || n === "binary", () => `Method must be binary or otsu, but was ${n}`), r.shape[2] === 3) {
1408
+ [m, h, b] = Ce(r, [1, 1, 1], -1);
1409
+ const k = I(m, o), E = I(h, a), S = I(b, i);
1410
+ g = U(U(k, E), S);
1595
1411
  } else
1596
- g = n;
1597
- if (e === "otsu") {
1598
- const k = ot(L(Qt(g), "int32"), Ze([]), 256);
1599
- c = nr(k, u);
1412
+ g = e;
1413
+ if (n === "otsu") {
1414
+ const k = tt(C(Vt(g), "int32"), Wn([]), 256);
1415
+ c = Gs(k, u);
1600
1416
  }
1601
- const x = t ? Xn(g, c) : En(g, c);
1602
- return L(A(x, 255), "int32");
1603
- }
1604
- function nr(n, e) {
1605
- let t = V([-1]), s = V([0]), r = V([0]), o, a, i, u, c, m;
1606
- for (let h = 0; h < n.size - 1; h++) {
1607
- o = I(n, 0, h + 1), a = I(n, h + 1), c = K(j(o), e), m = K(j(a), e);
1608
- const b = j(A(o, ln(0, o.size)));
1609
- i = K(b, j(o));
1610
- const g = Cn(a.shape, o.size), x = C(ln(0, a.size), g), w = A(a, x);
1611
- u = K(j(w), j(a));
1612
- const k = R(i, u), E = R(i, u), T = A(c, m);
1613
- r = A(A(T, k), E);
1614
- const S = En(r, s);
1615
- s = nn(S, r, s), t = nn(S, V([h]), t);
1417
+ const x = t ? We(g, c) : _e(g, c);
1418
+ return C(I(x, 255), "int32");
1419
+ }
1420
+ function Gs(e, n) {
1421
+ let t = B([-1]), s = B([0]), r = B([0]), o, a, i, u, c, m;
1422
+ for (let h = 0; h < e.size - 1; h++) {
1423
+ o = _(e, 0, h + 1), a = _(e, h + 1), c = L(G(o), n), m = L(G(a), n);
1424
+ const b = G(I(o, ue(0, o.size)));
1425
+ i = L(b, G(o));
1426
+ const g = Ve(a.shape, o.size), x = U(ue(0, a.size), g), w = I(a, x);
1427
+ u = L(G(w), G(a));
1428
+ const k = q(i, u), E = q(i, u), S = I(c, m);
1429
+ r = I(I(S, k), E);
1430
+ const T = _e(r, s);
1431
+ s = ee(T, r, s), t = ee(T, B([h]), t);
1616
1432
  }
1617
1433
  return t;
1618
1434
  }
1619
- const er = /* @__PURE__ */ p({ threshold_: Qs });
1435
+ const Ls = /* @__PURE__ */ f({ threshold_: Fs });
1620
1436
  /**
1621
1437
  * @license
1622
1438
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1633,13 +1449,13 @@ const er = /* @__PURE__ */ p({ threshold_: Qs });
1633
1449
  * limitations under the License.
1634
1450
  * =============================================================================
1635
1451
  */
1636
- function tr(n, e, t = "nearest", s = "constant", r = 0, o) {
1637
- const a = l(n, "image", "transform", "float32"), i = l(e, "transforms", "transform", "float32");
1638
- f(a.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${a.rank}.`), f(i.rank === 2 && (i.shape[0] === a.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), f(o == null || o.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${o}.`);
1452
+ function Vs(e, n, t = "nearest", s = "constant", r = 0, o) {
1453
+ const a = l(e, "image", "transform", "float32"), i = l(n, "transforms", "transform", "float32");
1454
+ p(a.rank === 4, () => `Error in transform: image must be rank 4,but got rank ${a.rank}.`), p(i.rank === 2 && (i.shape[0] === a.shape[0] || i.shape[0] === 1) && i.shape[1] === 8, () => "Error in transform: Input transform should be batch x 8 or 1 x 8"), p(o == null || o.length === 2, () => `Error in transform: outputShape must be [height, width] or null, but got ${o}.`);
1639
1455
  const u = { image: a, transforms: i }, c = { interpolation: t, fillMode: s, fillValue: r, outputShape: o };
1640
- return d.runKernel(Je, u, c);
1456
+ return d.runKernel(Vn, u, c);
1641
1457
  }
1642
- const sr = /* @__PURE__ */ p({ transform_: tr });
1458
+ const Cs = /* @__PURE__ */ f({ transform_: Vs });
1643
1459
  /**
1644
1460
  * @license
1645
1461
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1656,16 +1472,16 @@ const sr = /* @__PURE__ */ p({ transform_: tr });
1656
1472
  * limitations under the License.
1657
1473
  * =============================================================================
1658
1474
  */
1659
- function rr(n, e, t) {
1660
- const s = l(n, "a", "bandPart");
1661
- f(s.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${s.rank}.`);
1475
+ function vs(e, n, t) {
1476
+ const s = l(e, "a", "bandPart");
1477
+ p(s.rank >= 2, () => `bandPart(): Rank must be at least 2, got ${s.rank}.`);
1662
1478
  const r = s.shape, [o, a] = s.shape.slice(-2);
1663
1479
  let i, u;
1664
- typeof e == "number" ? (f(e % 1 === 0, () => `bandPart(): numLower must be an integer, got ${e}.`), f(e <= o, () => `bandPart(): numLower (${e}) must not be greater than the number of rows (${o}).`), i = l(e < 0 ? o : e, "numLower", "bandPart")) : (f(e.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = nn(Rn(e, 0), o, Kn(e, o))), typeof t == "number" ? (f(t % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${t}.`), f(t <= a, () => `bandPart(): numUpper (${t}) must not be greater than the number of columns (${a}).`), u = l(t < 0 ? a : t, "numUpper", "bandPart")) : (f(t.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), u = nn(Rn(t, 0), a, Kn(t, a)));
1665
- const c = $(ln(0, o, 1, "int32"), [-1, 1]), m = ln(0, a, 1, "int32"), h = R(c, m), b = Bt(Xn(h, i), Tt(h, Tn(u))), g = Qe([o, a], s.dtype);
1666
- return $(fn(Hn($(s, [-1, o, a])).map((x) => nn(b, x, g))), r);
1480
+ typeof n == "number" ? (p(n % 1 === 0, () => `bandPart(): numLower must be an integer, got ${n}.`), p(n <= o, () => `bandPart(): numLower (${n}) must not be greater than the number of rows (${o}).`), i = l(n < 0 ? o : n, "numLower", "bandPart")) : (p(n.dtype === "int32", () => "bandPart(): numLower's dtype must be an int32."), i = ee(Ke(n, 0), o, Re(n, o))), typeof t == "number" ? (p(t % 1 === 0, () => `bandPart(): numUpper must be an integer, got ${t}.`), p(t <= a, () => `bandPart(): numUpper (${t}) must not be greater than the number of columns (${a}).`), u = l(t < 0 ? a : t, "numUpper", "bandPart")) : (p(t.dtype === "int32", () => "bandPart(): numUpper's dtype must be an int32."), u = ee(Ke(t, 0), a, Re(t, a)));
1481
+ const c = $(ue(0, o, 1, "int32"), [-1, 1]), m = ue(0, a, 1, "int32"), h = q(c, m), b = Mt(We(h, i), At(h, Ie(u))), g = Yn([o, a], s.dtype);
1482
+ return $(le(Ye($(s, [-1, o, a])).map((x) => ee(b, x, g))), r);
1667
1483
  }
1668
- const or = /* @__PURE__ */ p({ bandPart_: rr });
1484
+ const zs = /* @__PURE__ */ f({ bandPart_: vs });
1669
1485
  /**
1670
1486
  * @license
1671
1487
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1682,30 +1498,30 @@ const or = /* @__PURE__ */ p({ bandPart_: rr });
1682
1498
  * limitations under the License.
1683
1499
  * =============================================================================
1684
1500
  */
1685
- function ar(n) {
1686
- let e;
1687
- if (Array.isArray(n)) {
1688
- e = !1, f(n != null && n.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
1689
- const r = n[0].shape[0];
1690
- for (let o = 1; o < n.length; ++o)
1691
- f(n[o].shape[0] === r, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${n[o].shape[0]} vs. ${r})`);
1501
+ function Ws(e) {
1502
+ let n;
1503
+ if (Array.isArray(e)) {
1504
+ n = !1, p(e != null && e.length > 0, () => "Gram-Schmidt process: input must not be null, undefined, or empty");
1505
+ const r = e[0].shape[0];
1506
+ for (let o = 1; o < e.length; ++o)
1507
+ p(e[o].shape[0] === r, () => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[o].shape[0]} vs. ${r})`);
1692
1508
  } else
1693
- e = !0, n = Un(n, n.shape[0], 0).map((r) => os(r, [0]));
1694
- f(n.length <= n[0].shape[0], () => `Gram-Schmidt: Number of vectors (${n.length}) exceeds number of dimensions (${n[0].shape[0]}).`);
1695
- const t = [], s = n;
1696
- for (let r = 0; r < n.length; ++r)
1509
+ n = !0, e = Ce(e, e.shape[0], 0).map((r) => Yt(r, [0]));
1510
+ p(e.length <= e[0].shape[0], () => `Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`);
1511
+ const t = [], s = e;
1512
+ for (let r = 0; r < e.length; ++r)
1697
1513
  t.push(d.tidy(() => {
1698
1514
  let o = s[r];
1699
1515
  if (r > 0)
1700
1516
  for (let a = 0; a < r; ++a) {
1701
- const i = A(j(A(t[a], o)), t[a]);
1702
- o = R(o, i);
1517
+ const i = I(G(I(t[a], o)), t[a]);
1518
+ o = q(o, i);
1703
1519
  }
1704
- return K(o, Jn(o, "euclidean"));
1520
+ return L(o, ve(o, "euclidean"));
1705
1521
  }));
1706
- return e ? fn(t, 0) : t;
1522
+ return n ? le(t, 0) : t;
1707
1523
  }
1708
- const ir = /* @__PURE__ */ p({ gramSchmidt_: ar });
1524
+ const Js = /* @__PURE__ */ f({ gramSchmidt_: Ws });
1709
1525
  /**
1710
1526
  * @license
1711
1527
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1722,60 +1538,60 @@ const ir = /* @__PURE__ */ p({ gramSchmidt_: ar });
1722
1538
  * limitations under the License.
1723
1539
  * =============================================================================
1724
1540
  */
1725
- function cr(n, e = !1) {
1726
- if (f(n.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${n.rank}`), n.rank === 2)
1727
- return jn(n, e);
1541
+ function Ys(e, n = !1) {
1542
+ if (p(e.rank >= 2, () => `qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`), e.rank === 2)
1543
+ return Fe(e, n);
1728
1544
  {
1729
- const t = n.shape.slice(0, n.shape.length - 2).reduce((u, c) => u * c), s = Hn($(n, [
1545
+ const t = e.shape.slice(0, e.shape.length - 2).reduce((u, c) => u * c), s = Ye($(e, [
1730
1546
  t,
1731
- n.shape[n.shape.length - 2],
1732
- n.shape[n.shape.length - 1]
1547
+ e.shape[e.shape.length - 2],
1548
+ e.shape[e.shape.length - 1]
1733
1549
  ]), 0), r = [], o = [];
1734
1550
  s.forEach((u) => {
1735
- const [c, m] = jn(u, e);
1551
+ const [c, m] = Fe(u, n);
1736
1552
  r.push(c), o.push(m);
1737
1553
  });
1738
- const a = $(fn(r, 0), n.shape), i = $(fn(o, 0), n.shape);
1554
+ const a = $(le(r, 0), e.shape), i = $(le(o, 0), e.shape);
1739
1555
  return [a, i];
1740
1556
  }
1741
1557
  }
1742
- function jn(n, e = !1) {
1558
+ function Fe(e, n = !1) {
1743
1559
  return d.tidy(() => {
1744
- f(n.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${n.shape.length}D Tensor.`);
1745
- const t = n.shape[0], s = n.shape[1];
1746
- let r = yt(t), o = mn(n);
1747
- const a = $n([[1]], [1, 1]);
1748
- let i = mn(a);
1560
+ p(e.shape.length === 2, () => `qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`);
1561
+ const t = e.shape[0], s = e.shape[1];
1562
+ let r = kt(t), o = de(e);
1563
+ const a = ge([[1]], [1, 1]);
1564
+ let i = de(a);
1749
1565
  const u = t >= s ? s : t;
1750
1566
  for (let c = 0; c < u; ++c) {
1751
1567
  const m = o, h = i, b = r;
1752
1568
  [i, o, r] = d.tidy(() => {
1753
- const g = I(o, [c, c], [t - c, 1]), x = Jn(g), w = I(o, [c, c], [1, 1]), k = nn(En(w, 0), $n([[-1]]), $n([[1]])), E = R(w, A(k, x)), T = K(g, E);
1754
- T.shape[0] === 1 ? i = mn(a) : i = G([
1569
+ const g = _(o, [c, c], [t - c, 1]), x = ve(g), w = _(o, [c, c], [1, 1]), k = ee(_e(w, 0), ge([[-1]]), ge([[1]])), E = q(w, I(k, x)), S = L(g, E);
1570
+ S.shape[0] === 1 ? i = de(a) : i = V([
1755
1571
  a,
1756
- I(T, [1, 0], [T.shape[0] - 1, T.shape[1]])
1572
+ _(S, [1, 0], [S.shape[0] - 1, S.shape[1]])
1757
1573
  ], 0);
1758
- const S = Tn(K(_(k, E), x)), M = I(o, [c, 0], [t - c, s]), O = A(S, i), N = wn(i);
1574
+ const T = Ie(L(y(k, E), x)), M = _(o, [c, 0], [t - c, s]), O = I(T, i), N = xe(i);
1759
1575
  if (c === 0)
1760
- o = R(M, _(O, _(N, M)));
1576
+ o = q(M, y(O, y(N, M)));
1761
1577
  else {
1762
- const X = R(M, _(O, _(N, M)));
1763
- o = G([I(o, [0, 0], [c, s]), X], 0);
1578
+ const X = q(M, y(O, y(N, M)));
1579
+ o = V([_(o, [0, 0], [c, s]), X], 0);
1764
1580
  }
1765
- const tn = wn(O), z = I(r, [0, c], [t, r.shape[1] - c]);
1581
+ const te = xe(O), v = _(r, [0, c], [t, r.shape[1] - c]);
1766
1582
  if (c === 0)
1767
- r = R(z, _(_(z, i), tn));
1583
+ r = q(v, y(y(v, i), te));
1768
1584
  else {
1769
- const X = R(z, _(_(z, i), tn));
1770
- r = G([I(r, [0, 0], [t, c]), X], 1);
1585
+ const X = q(v, y(y(v, i), te));
1586
+ r = V([_(r, [0, 0], [t, c]), X], 1);
1771
1587
  }
1772
1588
  return [i, o, r];
1773
- }), We([m, h, b]);
1589
+ }), Cn([m, h, b]);
1774
1590
  }
1775
- return !e && t > s && (r = I(r, [0, 0], [t, s]), o = I(o, [0, 0], [s, s])), [r, o];
1591
+ return !n && t > s && (r = _(r, [0, 0], [t, s]), o = _(o, [0, 0], [s, s])), [r, o];
1776
1592
  });
1777
1593
  }
1778
- const ur = /* @__PURE__ */ p({ qr_: cr });
1594
+ const Us = /* @__PURE__ */ f({ qr_: Ys });
1779
1595
  /**
1780
1596
  * @license
1781
1597
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1792,26 +1608,26 @@ const ur = /* @__PURE__ */ p({ qr_: cr });
1792
1608
  * limitations under the License.
1793
1609
  * =============================================================================
1794
1610
  */
1795
- const Br = {
1796
- flipLeftRight: ws,
1797
- grayscaleToRGB: _s,
1798
- resizeNearestNeighbor: Hs,
1799
- resizeBilinear: Xs,
1800
- rgbToGrayscale: Is,
1801
- rotateWithOffset: Ts,
1802
- cropAndResize: ks,
1803
- nonMaxSuppression: Ns,
1804
- nonMaxSuppressionAsync: Fs,
1805
- nonMaxSuppressionWithScore: Gs,
1806
- nonMaxSuppressionWithScoreAsync: Cs,
1807
- nonMaxSuppressionPadded: Us,
1808
- nonMaxSuppressionPaddedAsync: Ws,
1809
- threshold: er,
1810
- transform: sr
1811
- }, Rr = {
1812
- bandPart: or,
1813
- gramSchmidt: ir,
1814
- qr: ur
1611
+ const Ar = {
1612
+ flipLeftRight: is,
1613
+ grayscaleToRGB: us,
1614
+ resizeNearestNeighbor: js,
1615
+ resizeBilinear: Rs,
1616
+ rgbToGrayscale: ps,
1617
+ rotateWithOffset: hs,
1618
+ cropAndResize: os,
1619
+ nonMaxSuppression: ms,
1620
+ nonMaxSuppressionAsync: Es,
1621
+ nonMaxSuppressionWithScore: Ts,
1622
+ nonMaxSuppressionWithScoreAsync: Ds,
1623
+ nonMaxSuppressionPadded: Os,
1624
+ nonMaxSuppressionPaddedAsync: Ps,
1625
+ threshold: Ls,
1626
+ transform: Cs
1627
+ }, yr = {
1628
+ bandPart: zs,
1629
+ gramSchmidt: Js,
1630
+ qr: Us
1815
1631
  };
1816
1632
  /**
1817
1633
  * @license
@@ -1822,7 +1638,7 @@ const Br = {
1822
1638
  * https://opensource.org/licenses/MIT.
1823
1639
  * =============================================================================
1824
1640
  */
1825
- const lr = ["channelsFirst", "channelsLast"], fr = ["nearest", "bilinear"], pr = ["valid", "same", "causal"], hr = ["max", "avg"], Kr = ["sum", "mul", "concat", "ave"];
1641
+ const Xs = ["channelsFirst", "channelsLast"], Zs = ["nearest", "bilinear"], Hs = ["valid", "same", "causal"], Qs = ["max", "avg"], _r = ["sum", "mul", "concat", "ave"];
1826
1642
  /**
1827
1643
  * @license
1828
1644
  * Copyright 2018 Google LLC
@@ -1832,29 +1648,29 @@ const lr = ["channelsFirst", "channelsLast"], fr = ["nearest", "bilinear"], pr =
1832
1648
  * https://opensource.org/licenses/MIT.
1833
1649
  * =============================================================================
1834
1650
  */
1835
- class Qn extends Error {
1836
- constructor(e) {
1837
- super(e), Object.setPrototypeOf(this, Qn.prototype);
1651
+ class Ue extends Error {
1652
+ constructor(n) {
1653
+ super(n), Object.setPrototypeOf(this, Ue.prototype);
1838
1654
  }
1839
1655
  }
1840
- class ne extends Error {
1841
- constructor(e) {
1842
- super(e), Object.setPrototypeOf(this, ne.prototype);
1656
+ class Xe extends Error {
1657
+ constructor(n) {
1658
+ super(n), Object.setPrototypeOf(this, Xe.prototype);
1843
1659
  }
1844
1660
  }
1845
- class y extends Error {
1846
- constructor(e) {
1847
- super(e), Object.setPrototypeOf(this, y.prototype);
1661
+ class A extends Error {
1662
+ constructor(n) {
1663
+ super(n), Object.setPrototypeOf(this, A.prototype);
1848
1664
  }
1849
1665
  }
1850
- class cn extends Error {
1851
- constructor(e) {
1852
- super(e), Object.setPrototypeOf(this, cn.prototype);
1666
+ class ie extends Error {
1667
+ constructor(n) {
1668
+ super(n), Object.setPrototypeOf(this, ie.prototype);
1853
1669
  }
1854
1670
  }
1855
- class Mn extends Error {
1856
- constructor(e) {
1857
- super(e), Object.setPrototypeOf(this, Mn.prototype);
1671
+ class Ne extends Error {
1672
+ constructor(n) {
1673
+ super(n), Object.setPrototypeOf(this, Ne.prototype);
1858
1674
  }
1859
1675
  }
1860
1676
  /**
@@ -1866,81 +1682,81 @@ class Mn extends Error {
1866
1682
  * https://opensource.org/licenses/MIT.
1867
1683
  * =============================================================================
1868
1684
  */
1869
- function qr(n, e) {
1870
- if (Array.isArray(n)) {
1685
+ function Ir(e, n) {
1686
+ if (Array.isArray(e)) {
1871
1687
  let t = [];
1872
- for (let s = 0; s < e; s++)
1873
- t = t.concat(n);
1688
+ for (let s = 0; s < n; s++)
1689
+ t = t.concat(e);
1874
1690
  return t;
1875
1691
  } else {
1876
- const t = new Array(e);
1877
- return t.fill(n), t;
1692
+ const t = new Array(n);
1693
+ return t.fill(e), t;
1878
1694
  }
1879
1695
  }
1880
- function Gn(n, e) {
1881
- if (!n)
1882
- throw new Mn(e);
1696
+ function Ge(e, n) {
1697
+ if (!e)
1698
+ throw new Ne(n);
1883
1699
  }
1884
- function Fr(n, e) {
1700
+ function Er(e, n) {
1885
1701
  let t = 0;
1886
- for (const s of n)
1887
- s === e && t++;
1702
+ for (const s of e)
1703
+ s === n && t++;
1888
1704
  return t;
1889
1705
  }
1890
- function jr(n) {
1891
- return n.length === 1 ? n[0] : n;
1706
+ function Sr(e) {
1707
+ return e.length === 1 ? e[0] : e;
1892
1708
  }
1893
- function Gr(n) {
1894
- return Array.isArray(n) ? n : [n];
1709
+ function Tr(e) {
1710
+ return Array.isArray(e) ? e : [e];
1895
1711
  }
1896
- function Lr(n) {
1897
- const t = n.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
1712
+ function Nr(e) {
1713
+ const t = e.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase();
1898
1714
  return t[0] !== "_" ? t : "private" + t;
1899
1715
  }
1900
- function Cr(n) {
1901
- return n.length <= 1 || n.indexOf("_") === -1 ? n : n.replace(/[_]+(\w|$)/g, (e, t) => t.toUpperCase());
1716
+ function Dr(e) {
1717
+ return e.length <= 1 || e.indexOf("_") === -1 ? e : e.replace(/[_]+(\w|$)/g, (n, t) => t.toUpperCase());
1902
1718
  }
1903
1719
  let D = {};
1904
- function zr(n) {
1905
- if (n == null)
1720
+ function Mr(e) {
1721
+ if (e == null)
1906
1722
  return null;
1907
- const e = {};
1908
- return e.className = n.getClassName(), e.config = n.getConfig(), e;
1723
+ const n = {};
1724
+ return n.className = e.getClassName(), n.config = e.getConfig(), n;
1909
1725
  }
1910
- function yn(n) {
1911
- if (!(n == null || typeof n != "object"))
1912
- if (Array.isArray(n))
1913
- n.forEach((e) => yn(e));
1726
+ function we(e) {
1727
+ if (!(e == null || typeof e != "object"))
1728
+ if (Array.isArray(e))
1729
+ e.forEach((n) => we(n));
1914
1730
  else {
1915
- const e = Object.keys(n);
1916
- for (const t of e) {
1917
- const s = n[t];
1918
- s != null && typeof s == "object" && (!Array.isArray(s) && s.type === "ndarray" && typeof s.value == "number" ? n[t] = s.value : yn(s));
1731
+ const n = Object.keys(e);
1732
+ for (const t of n) {
1733
+ const s = e[t];
1734
+ s != null && typeof s == "object" && (!Array.isArray(s) && s.type === "ndarray" && typeof s.value == "number" ? e[t] = s.value : we(s));
1919
1735
  }
1920
1736
  }
1921
1737
  }
1922
- function Ur(n, e = {}, t = {}, s = "object", r = !1) {
1923
- if (typeof n == "string") {
1924
- const o = n;
1738
+ function Or(e, n = {}, t = {}, s = "object", r = !1) {
1739
+ if (typeof e == "string") {
1740
+ const o = e;
1925
1741
  let a;
1926
1742
  if (o in t)
1927
1743
  a = t[o];
1928
1744
  else if (o in D)
1929
1745
  a = D[o];
1930
- else if (a = e[o], a == null)
1931
- throw new y(`Unknown ${s}: ${n}. This may be due to one of the following reasons:
1746
+ else if (a = n[o], a == null)
1747
+ throw new A(`Unknown ${s}: ${e}. This may be due to one of the following reasons:
1932
1748
  1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
1933
1749
  2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);
1934
1750
  return a;
1935
1751
  } else {
1936
- const o = n;
1752
+ const o = e;
1937
1753
  if (o.className == null || o.config == null)
1938
- throw new y(`${s}: Improper config format: ${JSON.stringify(o)}.
1754
+ throw new A(`${s}: Improper config format: ${JSON.stringify(o)}.
1939
1755
  'className' and 'config' must set.`);
1940
1756
  const a = o.className;
1941
1757
  let i, u;
1942
- if (a in t ? [i, u] = t[a] : a in D ? [i, u] = D.className : a in e && ([i, u] = e[a]), i == null)
1943
- throw new y(`Unknown ${s}: ${a}. This may be due to one of the following reasons:
1758
+ if (a in t ? [i, u] = t[a] : a in D ? [i, u] = D.className : a in n && ([i, u] = n[a]), i == null)
1759
+ throw new A(`Unknown ${s}: ${a}. This may be due to one of the following reasons:
1944
1760
  1. The ${s} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.
1945
1761
  2. The custom ${s} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`);
1946
1762
  if (u != null) {
@@ -1954,7 +1770,7 @@ function Ur(n, e = {}, t = {}, s = "object", r = !1) {
1954
1770
  const h = Object.assign({}, D);
1955
1771
  for (const g of Object.keys(t))
1956
1772
  D[g] = t[g];
1957
- yn(o.config);
1773
+ we(o.config);
1958
1774
  const b = u(i, o.config, t, r);
1959
1775
  return D = Object.assign({}, h), b;
1960
1776
  } else {
@@ -1966,50 +1782,50 @@ function Ur(n, e = {}, t = {}, s = "object", r = !1) {
1966
1782
  }
1967
1783
  }
1968
1784
  }
1969
- function dr(n, e) {
1970
- return n < e ? -1 : n > e ? 1 : 0;
1785
+ function er(e, n) {
1786
+ return e < n ? -1 : e > n ? 1 : 0;
1971
1787
  }
1972
- function Jr(n, e) {
1973
- return -1 * dr(n, e);
1788
+ function Br(e, n) {
1789
+ return -1 * er(e, n);
1974
1790
  }
1975
- function Wr(n) {
1976
- if (n == null)
1977
- return n;
1978
- const e = [];
1979
- for (const t of n)
1980
- e.indexOf(t) === -1 && e.push(t);
1981
- return e;
1982
- }
1983
- function Yr(n) {
1984
- if (n == null)
1985
- throw new y(`Invalid value in obj: ${JSON.stringify(n)}`);
1986
- for (const e in n)
1987
- if (n.hasOwnProperty(e))
1791
+ function Pr(e) {
1792
+ if (e == null)
1793
+ return e;
1794
+ const n = [];
1795
+ for (const t of e)
1796
+ n.indexOf(t) === -1 && n.push(t);
1797
+ return n;
1798
+ }
1799
+ function Kr(e) {
1800
+ if (e == null)
1801
+ throw new A(`Invalid value in obj: ${JSON.stringify(e)}`);
1802
+ for (const n in e)
1803
+ if (e.hasOwnProperty(n))
1988
1804
  return !1;
1989
1805
  return !0;
1990
1806
  }
1991
- function hn(n, e, t) {
1992
- if (t != null && n.indexOf(t) < 0)
1993
- throw new y(`${t} is not a valid ${e}. Valid values are ${n} or null/undefined.`);
1807
+ function fe(e, n, t) {
1808
+ if (t != null && e.indexOf(t) < 0)
1809
+ throw new A(`${t} is not a valid ${n}. Valid values are ${e} or null/undefined.`);
1994
1810
  }
1995
- function Xr(n, e, t = 0, s = 1 / 0) {
1996
- return Gn(t >= 0), Gn(s >= t), Array.isArray(n) && n.length >= t && n.length <= s && n.every((r) => typeof r === e);
1811
+ function Rr(e, n, t = 0, s = 1 / 0) {
1812
+ return Ge(t >= 0), Ge(s >= t), Array.isArray(e) && e.length >= t && e.length <= s && e.every((r) => typeof r === n);
1997
1813
  }
1998
- function mr(n, e) {
1999
- Array.isArray(n) ? (f(n.length > 0, () => `${e} is unexpectedly an empty array.`), n.forEach((t, s) => mr(t, `element ${s + 1} of ${e}`))) : f(Number.isInteger(n) && n > 0, () => `Expected ${e} to be a positive integer, but got ${ee(n)}.`);
1814
+ function nr(e, n) {
1815
+ Array.isArray(e) ? (p(e.length > 0, () => `${n} is unexpectedly an empty array.`), e.forEach((t, s) => nr(t, `element ${s + 1} of ${n}`))) : p(Number.isInteger(e) && e > 0, () => `Expected ${n} to be a positive integer, but got ${Ze(e)}.`);
2000
1816
  }
2001
- function ee(n) {
2002
- return n === null ? "null" : Array.isArray(n) ? "[" + n.map((e) => ee(e)).join(",") + "]" : typeof n == "string" ? `"${n}"` : `${n}`;
1817
+ function Ze(e) {
1818
+ return e === null ? "null" : Array.isArray(e) ? "[" + e.map((n) => Ze(n)).join(",") + "]" : typeof e == "string" ? `"${e}"` : `${e}`;
2003
1819
  }
2004
- function Zr(n, e, t) {
2005
- let s = t != null ? t() : Bn(), r;
1820
+ function qr(e, n, t) {
1821
+ let s = t != null ? t() : Pe(), r;
2006
1822
  return (...a) => {
2007
- const i = t != null ? t() : Bn();
2008
- return i - s < e || (s = i, r = n(...a)), r;
1823
+ const i = t != null ? t() : Pe();
1824
+ return i - s < n || (s = i, r = e(...a)), r;
2009
1825
  };
2010
1826
  }
2011
- function Hr(n) {
2012
- return n === "relu" ? "relu" : n === "linear" ? "linear" : n === "elu" ? "elu" : null;
1827
+ function jr(e) {
1828
+ return e === "relu" ? "relu" : e === "linear" ? "linear" : e === "elu" ? "elu" : null;
2013
1829
  }
2014
1830
  /**
2015
1831
  * @license
@@ -2021,50 +1837,50 @@ function Hr(n) {
2021
1837
  * =============================================================================
2022
1838
  */
2023
1839
  const Q = /* @__PURE__ */ new Map();
2024
- function gr(n) {
2025
- hn(lr, "DataFormat", n);
1840
+ function tr(e) {
1841
+ fe(Xs, "DataFormat", e);
2026
1842
  }
2027
- function Qr(n) {
2028
- hn(fr, "InterpolationFormat", n);
1843
+ function Fr(e) {
1844
+ fe(Zs, "InterpolationFormat", e);
2029
1845
  }
2030
- function no(n) {
2031
- hn(pr, "PaddingMode", n);
1846
+ function Gr(e) {
1847
+ fe(Hs, "PaddingMode", e);
2032
1848
  }
2033
- function eo(n) {
2034
- hn(hr, "PoolMode", n);
1849
+ function Lr(e) {
1850
+ fe(Qs, "PoolMode", e);
2035
1851
  }
2036
- const an = [], Ln = "/";
2037
- function to(n, e) {
2038
- an.push(n);
1852
+ const ae = [], Le = "/";
1853
+ function Vr(e, n) {
1854
+ ae.push(e);
2039
1855
  try {
2040
- const t = e();
2041
- return an.pop(), t;
1856
+ const t = n();
1857
+ return ae.pop(), t;
2042
1858
  } catch (t) {
2043
- throw an.pop(), t;
1859
+ throw ae.pop(), t;
2044
1860
  }
2045
1861
  }
2046
- function $r() {
2047
- return an.length === 0 ? "" : an.join(Ln) + Ln;
2048
- }
2049
- function so(n) {
2050
- if (!te(n))
2051
- throw new Error("Not a valid tensor name: '" + n + "'");
2052
- return $r() + n;
2053
- }
2054
- function ro(n) {
2055
- if (!te(n))
2056
- throw new Error("Not a valid tensor name: '" + n + "'");
2057
- Q.has(n) || Q.set(n, 0);
2058
- const e = Q.get(n);
2059
- if (Q.set(n, Q.get(n) + 1), e > 0) {
2060
- const t = `${n}_${e}`;
1862
+ function sr() {
1863
+ return ae.length === 0 ? "" : ae.join(Le) + Le;
1864
+ }
1865
+ function Cr(e) {
1866
+ if (!He(e))
1867
+ throw new Error("Not a valid tensor name: '" + e + "'");
1868
+ return sr() + e;
1869
+ }
1870
+ function vr(e) {
1871
+ if (!He(e))
1872
+ throw new Error("Not a valid tensor name: '" + e + "'");
1873
+ Q.has(e) || Q.set(e, 0);
1874
+ const n = Q.get(e);
1875
+ if (Q.set(e, Q.get(e) + 1), n > 0) {
1876
+ const t = `${e}_${n}`;
2061
1877
  return Q.set(t, 1), t;
2062
1878
  } else
2063
- return n;
1879
+ return e;
2064
1880
  }
2065
- const br = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);
2066
- function te(n) {
2067
- return !!n.match(br);
1881
+ const rr = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/);
1882
+ function He(e) {
1883
+ return !!e.match(rr);
2068
1884
  }
2069
1885
  /**
2070
1886
  * @license
@@ -2075,41 +1891,41 @@ function te(n) {
2075
1891
  * https://opensource.org/licenses/MIT.
2076
1892
  * =============================================================================
2077
1893
  */
2078
- function oo(n) {
2079
- return n === parseInt(n.toString(), 10);
1894
+ function zr(e) {
1895
+ return e === parseInt(e.toString(), 10);
2080
1896
  }
2081
- function se(n, e, t) {
2082
- e == null && (e = 0), t == null && (t = n.length);
1897
+ function Qe(e, n, t) {
1898
+ n == null && (n = 0), t == null && (t = e.length);
2083
1899
  let s = 1;
2084
- for (let r = e; r < t; ++r)
2085
- s *= n[r];
1900
+ for (let r = n; r < t; ++r)
1901
+ s *= e[r];
2086
1902
  return s;
2087
1903
  }
2088
- function ao(n) {
2089
- if (n.length === 0)
1904
+ function Wr(e) {
1905
+ if (e.length === 0)
2090
1906
  return Number.NaN;
2091
- let e = Number.POSITIVE_INFINITY;
2092
- for (let t = 0; t < n.length; t++) {
2093
- const s = n[t];
2094
- s < e && (e = s);
1907
+ let n = Number.POSITIVE_INFINITY;
1908
+ for (let t = 0; t < e.length; t++) {
1909
+ const s = e[t];
1910
+ s < n && (n = s);
2095
1911
  }
2096
- return e;
1912
+ return n;
2097
1913
  }
2098
- function io(n) {
2099
- if (n.length === 0)
1914
+ function Jr(e) {
1915
+ if (e.length === 0)
2100
1916
  return Number.NaN;
2101
- let e = Number.NEGATIVE_INFINITY;
2102
- for (let t = 0; t < n.length; t++) {
2103
- const s = n[t];
2104
- s > e && (e = s);
1917
+ let n = Number.NEGATIVE_INFINITY;
1918
+ for (let t = 0; t < e.length; t++) {
1919
+ const s = e[t];
1920
+ s > n && (n = s);
2105
1921
  }
2106
- return e;
1922
+ return n;
2107
1923
  }
2108
- function co(n, e) {
2109
- if (e < n)
2110
- throw new y(`end (${e}) < begin (${n}) is forbidden.`);
1924
+ function Yr(e, n) {
1925
+ if (n < e)
1926
+ throw new A(`end (${n}) < begin (${e}) is forbidden.`);
2111
1927
  const t = [];
2112
- for (let s = n; s < e; ++s)
1928
+ for (let s = e; s < n; ++s)
2113
1929
  t.push(s);
2114
1930
  return t;
2115
1931
  }
@@ -2122,11 +1938,11 @@ function co(n, e) {
2122
1938
  * https://opensource.org/licenses/MIT.
2123
1939
  * =============================================================================
2124
1940
  */
2125
- let bn;
2126
- function uo() {
2127
- return bn == null && (bn = Ye().epsilon()), bn;
1941
+ let $e;
1942
+ function Ur() {
1943
+ return $e == null && ($e = vn().epsilon()), $e;
2128
1944
  }
2129
- function _n() {
1945
+ function Ae() {
2130
1946
  return "channelsLast";
2131
1947
  }
2132
1948
  /**
@@ -2138,323 +1954,318 @@ function _n() {
2138
1954
  * https://opensource.org/licenses/MIT.
2139
1955
  * =============================================================================
2140
1956
  */
2141
- function lo(n, e) {
2142
- return L(n, e);
1957
+ function Xr(e, n) {
1958
+ return C(e, n);
2143
1959
  }
2144
- function kr(n, e = -1) {
2145
- const t = n.shape.slice();
2146
- return e < 0 && (e = t.length + e + 1), t.splice(e, 0, 1), $(n, t);
1960
+ function or(e, n = -1) {
1961
+ const t = e.shape.slice();
1962
+ return n < 0 && (n = t.length + n + 1), t.splice(n, 0, 1), $(e, t);
2147
1963
  }
2148
- function fo(n, e) {
2149
- return P(() => {
2150
- if (n.shape.length !== 2)
2151
- throw new y(`repeat() expects a rank-2 tensor, but received a rank-${n.shape.length} tensor.`);
2152
- const t = kr(n, 1);
2153
- return xr(t, [1, e, 1]);
1964
+ function Zr(e, n) {
1965
+ return K(() => {
1966
+ if (e.shape.length !== 2)
1967
+ throw new A(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`);
1968
+ const t = or(e, 1);
1969
+ return ar(t, [1, n, 1]);
2154
1970
  });
2155
1971
  }
2156
- function po(n) {
2157
- const e = [se(n.shape)];
2158
- return $(n, e);
1972
+ function Hr(e) {
1973
+ const n = [Qe(e.shape)];
1974
+ return $(e, n);
2159
1975
  }
2160
- function ho(n) {
2161
- if (n.rank <= 1)
2162
- throw new y(`batchFlatten requires a minimum rank of 2. Got rank: ${n.rank}.`);
2163
- const e = [n.shape[0], se(n.shape, 1)];
2164
- return $(n, e);
1976
+ function Qr(e) {
1977
+ if (e.rank <= 1)
1978
+ throw new A(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`);
1979
+ const n = [e.shape[0], Qe(e.shape, 1)];
1980
+ return $(e, n);
2165
1981
  }
2166
- function kn(n, e, t) {
2167
- return P(() => {
2168
- switch (n.rank) {
1982
+ function be(e, n, t) {
1983
+ return K(() => {
1984
+ switch (e.rank) {
2169
1985
  case 1:
2170
- return Sn(n, e, t);
1986
+ return Ee(e, n, t);
2171
1987
  case 2:
2172
- return Zn(n, [e, 0], [t, n.shape[1]]);
1988
+ return Je(e, [n, 0], [t, e.shape[1]]);
2173
1989
  case 3:
2174
- return Nn(n, [e, 0, 0], [t, n.shape[1], n.shape[2]]);
1990
+ return Se(e, [n, 0, 0], [t, e.shape[1], e.shape[2]]);
2175
1991
  case 4:
2176
- return pn(n, [e, 0, 0, 0], [t, n.shape[1], n.shape[2], n.shape[3]]);
1992
+ return pe(e, [n, 0, 0, 0], [t, e.shape[1], e.shape[2], e.shape[3]]);
2177
1993
  case 5:
2178
- return I(n, [e, 0, 0, 0, 0], [
1994
+ return _(e, [n, 0, 0, 0, 0], [
2179
1995
  t,
2180
- n.shape[1],
2181
- n.shape[2],
2182
- n.shape[3],
2183
- n.shape[4]
1996
+ e.shape[1],
1997
+ e.shape[2],
1998
+ e.shape[3],
1999
+ e.shape[4]
2184
2000
  ]);
2185
2001
  case 6:
2186
- return I(n, [e, 0, 0, 0, 0, 0], [
2002
+ return _(e, [n, 0, 0, 0, 0, 0], [
2187
2003
  t,
2188
- n.shape[1],
2189
- n.shape[2],
2190
- n.shape[3],
2191
- n.shape[4],
2192
- n.shape[5]
2004
+ e.shape[1],
2005
+ e.shape[2],
2006
+ e.shape[3],
2007
+ e.shape[4],
2008
+ e.shape[5]
2193
2009
  ]);
2194
2010
  default:
2195
- throw new y(`sliceAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`);
2011
+ throw new A(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`);
2196
2012
  }
2197
2013
  });
2198
2014
  }
2199
- function xn(n, e, t) {
2200
- return P(() => {
2201
- switch (n.rank) {
2015
+ function ke(e, n, t) {
2016
+ return K(() => {
2017
+ switch (e.rank) {
2202
2018
  case 1:
2203
- return Sn(n, e, t);
2019
+ return Ee(e, n, t);
2204
2020
  case 2:
2205
- return Zn(n, [0, e], [n.shape[0], t]);
2021
+ return Je(e, [0, n], [e.shape[0], t]);
2206
2022
  case 3:
2207
- return Nn(n, [0, 0, e], [n.shape[0], n.shape[1], t]);
2023
+ return Se(e, [0, 0, n], [e.shape[0], e.shape[1], t]);
2208
2024
  case 4:
2209
- return pn(n, [0, 0, 0, e], [n.shape[0], n.shape[1], n.shape[2], t]);
2025
+ return pe(e, [0, 0, 0, n], [e.shape[0], e.shape[1], e.shape[2], t]);
2210
2026
  default:
2211
- throw new y(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`);
2027
+ throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`);
2212
2028
  }
2213
2029
  });
2214
2030
  }
2215
- function mo(n, e, t, s) {
2216
- return P(() => {
2217
- switch (n.rank) {
2031
+ function eo(e, n, t, s) {
2032
+ return K(() => {
2033
+ switch (e.rank) {
2218
2034
  case 1:
2219
- return Sn(n, e, t);
2035
+ return Ee(e, n, t);
2220
2036
  case 2:
2221
2037
  switch (s) {
2222
2038
  case 1:
2223
- return kn(n, e, t);
2039
+ return be(e, n, t);
2224
2040
  case 2:
2225
- return xn(n, e, t);
2041
+ return ke(e, n, t);
2226
2042
  default:
2227
- throw new y(`The axis is not within the rank of the tensor ${s}`);
2043
+ throw new A(`The axis is not within the rank of the tensor ${s}`);
2228
2044
  }
2229
2045
  case 3:
2230
2046
  switch (s) {
2231
2047
  case 1:
2232
- return kn(n, e, t);
2048
+ return be(e, n, t);
2233
2049
  case 2:
2234
- return Nn(n, [0, e, 0], [n.shape[0], t, n.shape[2]]);
2050
+ return Se(e, [0, n, 0], [e.shape[0], t, e.shape[2]]);
2235
2051
  case 3:
2236
- return xn(n, e, t);
2052
+ return ke(e, n, t);
2237
2053
  default:
2238
- throw new y(`The axis is not within the rank of the tensor ${s}`);
2054
+ throw new A(`The axis is not within the rank of the tensor ${s}`);
2239
2055
  }
2240
2056
  case 4:
2241
2057
  switch (s) {
2242
2058
  case 1:
2243
- return kn(n, e, t);
2059
+ return be(e, n, t);
2244
2060
  case 2:
2245
- return pn(n, [0, e, 0, 0], [n.shape[0], t, n.shape[2], n.shape[3]]);
2061
+ return pe(e, [0, n, 0, 0], [e.shape[0], t, e.shape[2], e.shape[3]]);
2246
2062
  case 3:
2247
- return pn(n, [0, 0, e, 0], [n.shape[0], n.shape[1], t, n.shape[3]]);
2063
+ return pe(e, [0, 0, n, 0], [e.shape[0], e.shape[1], t, e.shape[3]]);
2248
2064
  case 4:
2249
- return xn(n, e, t);
2065
+ return ke(e, n, t);
2250
2066
  default:
2251
- throw new y(`The axis is not within the rank of the tensor ${s}`);
2067
+ throw new A(`The axis is not within the rank of the tensor ${s}`);
2252
2068
  }
2253
2069
  default:
2254
- throw new y(`sliceAlongLastAxis() received an unsupported tensor rank: ${n.rank}`);
2070
+ throw new A(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`);
2255
2071
  }
2256
2072
  });
2257
2073
  }
2258
- function go(n, e = -1) {
2074
+ function no(e, n = -1) {
2259
2075
  let t;
2260
- return e < 0 && (t = n[0].rank, t !== 0 ? e = t : e = 0), e === n[0].rank && (e = -1), G(n, e);
2076
+ return n < 0 && (t = e[0].rank, t !== 0 ? n = t : n = 0), n === e[0].rank && (n = -1), V(e, n);
2261
2077
  }
2262
- function $o(n, e) {
2263
- switch (n.rank) {
2078
+ function to(e, n) {
2079
+ switch (e.rank) {
2264
2080
  case 1:
2265
- return ut([n, e]);
2081
+ return at([e, n]);
2266
2082
  case 2:
2267
- return ft([n, e], 0);
2083
+ return ct([e, n], 0);
2268
2084
  case 3:
2269
- return ht([n, e], 0);
2085
+ return lt([e, n], 0);
2270
2086
  case 4:
2271
- return mt([n, e], 0);
2087
+ return ft([e, n], 0);
2272
2088
  default:
2273
- throw new y(`concatAlongFirstAxis() received an unsupported tensor rank: ${n.rank}`);
2089
+ throw new A(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`);
2274
2090
  }
2275
2091
  }
2276
- function xr(n, e) {
2277
- if (Array.isArray(e) || (e = [e]), n.rank !== e.length)
2278
- throw new y(`The length of input n (${e.length}) does not match the number of dimensions in input x (${n.rank})`);
2279
- return on(n, e);
2092
+ function ar(e, n) {
2093
+ if (Array.isArray(n) || (n = [n]), e.rank !== n.length)
2094
+ throw new A(`The length of input n (${n.length}) does not match the number of dimensions in input x (${e.rank})`);
2095
+ return oe(e, n);
2280
2096
  }
2281
- function bo(n, e = 0, t = 1, s, r) {
2282
- return Lt(n, e, t, s, r);
2097
+ function so(e, n = 0, t = 1, s, r) {
2098
+ return Un(e, n, t, s, r);
2283
2099
  }
2284
- function ko(n, e, t, s) {
2285
- if (n.rank < 2 || e.rank < 2)
2286
- throw new cn(`dot requires both inputs to be rank >= 2 but got x shape = ${n.shape} and y shape = ${e.shape}`);
2287
- if (e.rank >= 3) {
2288
- const r = n.shape.slice(-1)[0], o = e.shape.slice(-2)[0];
2100
+ function ro(e, n, t, s) {
2101
+ if (e.rank < 2 || n.rank < 2)
2102
+ throw new ie(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${n.shape}`);
2103
+ if (n.rank >= 3) {
2104
+ const r = e.shape.slice(-1)[0], o = n.shape.slice(-2)[0];
2289
2105
  if (r !== o)
2290
- throw new cn(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${n.shape} and y shape = ${e.shape}`);
2106
+ throw new ie(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${n.shape}`);
2291
2107
  }
2292
- if (n.rank === 2 && e.rank === 2)
2293
- return qn({
2294
- a: n,
2295
- b: e,
2108
+ if (e.rank === 2 && n.rank === 2)
2109
+ return qe({
2110
+ a: e,
2111
+ b: n,
2296
2112
  transposeA: !1,
2297
2113
  transposeB: !1,
2298
- bias: s ? An(n.rank, s, _n()) : null,
2114
+ bias: s ? ye(e.rank, s, Ae()) : null,
2299
2115
  activation: t
2300
2116
  });
2301
2117
  {
2302
- const r = n.shape.slice(), o = r.pop();
2303
- n = $(n, [-1, o]);
2304
- const a = e.shape.slice(), i = a.pop(), u = a.pop(), c = [...a, i], m = Array.from({ length: e.rank }, (x, w) => w === 0 ? e.rank - 2 : w <= e.rank - 2 ? w - 1 : w);
2305
- e = $(wn(e, m), [u, -1]);
2118
+ const r = e.shape.slice(), o = r.pop();
2119
+ e = $(e, [-1, o]);
2120
+ const a = n.shape.slice(), i = a.pop(), u = a.pop(), c = [...a, i], m = Array.from({ length: n.rank }, (x, w) => w === 0 ? n.rank - 2 : w <= n.rank - 2 ? w - 1 : w);
2121
+ n = $(xe(n, m), [u, -1]);
2306
2122
  const h = [...r, ...c];
2307
- return $(qn({
2308
- a: n,
2309
- b: e,
2123
+ return $(qe({
2124
+ a: e,
2125
+ b: n,
2310
2126
  transposeA: !1,
2311
2127
  transposeB: !1,
2312
- bias: s ? An(n.rank, s, _n()) : null,
2128
+ bias: s ? ye(e.rank, s, Ae()) : null,
2313
2129
  activation: t
2314
2130
  }), h);
2315
2131
  }
2316
2132
  }
2317
- function xo(n, e, t) {
2318
- return P(() => (Array.isArray(e) ? e = V(e, "int32") : e = L(e, "int32"), nt(n, e, t)));
2133
+ function oo(e, n, t) {
2134
+ return K(() => (Array.isArray(n) ? n = B(n, "int32") : n = C(n, "int32"), Zn(e, n, t)));
2319
2135
  }
2320
- function wo(n) {
2321
- return A(n, n);
2136
+ function ao(e) {
2137
+ return I(e, e);
2322
2138
  }
2323
- function An(n, e, t) {
2324
- const s = e.shape;
2325
- if (e.rank !== 1 && e.rank !== n)
2326
- throw new y(`Unexpected bias dimensions: ${e.rank}; expected it to be 1 or ${n}`);
2327
- if (n === 5) {
2139
+ function ye(e, n, t) {
2140
+ const s = n.shape;
2141
+ if (n.rank !== 1 && n.rank !== e)
2142
+ throw new A(`Unexpected bias dimensions: ${n.rank}; expected it to be 1 or ${e}`);
2143
+ if (e === 5) {
2328
2144
  if (t === "channelsFirst")
2329
- return s.length === 1 ? $(e, [1, s[0], 1, 1, 1]) : $(e, [1, s[3], s[0], s[1], s[2]]);
2145
+ return s.length === 1 ? $(n, [1, s[0], 1, 1, 1]) : $(n, [1, s[3], s[0], s[1], s[2]]);
2330
2146
  if (t === "channelsLast")
2331
- return s.length === 1 ? $(e, [1, 1, 1, 1, s[0]]) : $(e, [1].concat(s));
2332
- } else if (n === 4) {
2147
+ return s.length === 1 ? $(n, [1, 1, 1, 1, s[0]]) : $(n, [1].concat(s));
2148
+ } else if (e === 4) {
2333
2149
  if (t === "channelsFirst")
2334
- return s.length === 1 ? $(e, [1, s[0], 1, 1]) : $(e, [1, s[2], s[0], s[1]]);
2150
+ return s.length === 1 ? $(n, [1, s[0], 1, 1]) : $(n, [1, s[2], s[0], s[1]]);
2335
2151
  if (t === "channelsLast")
2336
- return s.length === 1 ? $(e, [1, 1, 1, s[0]]) : $(e, [1].concat(s));
2337
- } else if (n === 3) {
2152
+ return s.length === 1 ? $(n, [1, 1, 1, s[0]]) : $(n, [1].concat(s));
2153
+ } else if (e === 3) {
2338
2154
  if (t === "channelsFirst")
2339
- return s.length === 1 ? $(e, [1, s[0], 1]) : $(e, [1, s[1], s[0]]);
2155
+ return s.length === 1 ? $(n, [1, s[0], 1]) : $(n, [1, s[1], s[0]]);
2340
2156
  if (t === "channelsLast")
2341
- return s.length === 1 ? $(e, [1, 1, s[0]]) : $(e, [1].concat(s));
2342
- } else if (n < 3)
2343
- return e;
2344
- throw new y(`Unsupported input rank by biasAdd: ${e.rank}`);
2157
+ return s.length === 1 ? $(n, [1, 1, s[0]]) : $(n, [1].concat(s));
2158
+ } else if (e < 3)
2159
+ return n;
2160
+ throw new A(`Unsupported input rank by biasAdd: ${n.rank}`);
2345
2161
  }
2346
- function yo(n, e, t) {
2347
- return P(() => (t == null && (t = _n()), gr(t), C(n, An(n.rank, e, t))));
2162
+ function io(e, n, t) {
2163
+ return K(() => (t == null && (t = Ae()), tr(t), U(e, ye(e.rank, n, t))));
2348
2164
  }
2349
- function _o(n, e = 1) {
2350
- if (e !== 1)
2351
- throw new cn(`Support for alpha values other than 1 (${e}) is not implemented yet.`);
2352
- return Yn(n);
2165
+ function co(e, n = 1) {
2166
+ if (n !== 1)
2167
+ throw new ie(`Support for alpha values other than 1 (${n}) is not implemented yet.`);
2168
+ return ze(e);
2353
2169
  }
2354
- function Ao(n) {
2355
- return P(() => K(n, C(Xe(n), 1)));
2170
+ function uo(e) {
2171
+ return K(() => L(e, U(zn(e), 1)));
2356
2172
  }
2357
- function Io(n, e, t, s) {
2358
- return P(() => ps(n, e, t, s));
2173
+ function lo(e, n, t, s) {
2174
+ return K(() => Xn(e, n, t, s));
2359
2175
  }
2360
- function Eo(n) {
2361
- return P(() => {
2362
- const e = C(0.5, A(0.2, n));
2363
- return it(e, 0, 1);
2176
+ function po(e) {
2177
+ return K(() => {
2178
+ const n = U(0.5, I(0.2, e));
2179
+ return rt(n, 0, 1);
2364
2180
  });
2365
2181
  }
2366
- function To(n, e, t = !1) {
2367
- return t ? n() : e();
2182
+ function fo(e, n, t = !1) {
2183
+ return t ? e() : n();
2368
2184
  }
2369
2185
  export {
2370
- Jr as $,
2371
- Qn as A,
2372
- Tt as B,
2373
- Xn as C,
2374
- wn as D,
2375
- on as E,
2376
- En as F,
2377
- Rn as G,
2378
- I as H,
2379
- At as I,
2380
- Hn as J,
2381
- tt as K,
2382
- W as L,
2383
- Ft as M,
2384
- cn as N,
2385
- it as O,
2386
- uo as P,
2387
- Yt as Q,
2388
- ne as R,
2389
- Zr as S,
2390
- po as T,
2391
- wo as U,
2392
- y as V,
2393
- Gn as W,
2394
- lo as X,
2395
- os as Y,
2396
- Cr as Z,
2397
- Wr as _,
2398
- ps as a,
2399
- qr as a0,
2186
+ or as $,
2187
+ Ue as A,
2188
+ oe as B,
2189
+ _e as C,
2190
+ Ke as D,
2191
+ _ as E,
2192
+ Ye as F,
2193
+ Qn as G,
2194
+ J as H,
2195
+ rt as I,
2196
+ Ur as J,
2197
+ jt as K,
2198
+ qr as L,
2199
+ Hr as M,
2200
+ ie as N,
2201
+ ao as O,
2202
+ Ge as P,
2203
+ Xr as Q,
2204
+ Xe as R,
2205
+ Yt as S,
2206
+ Dr as T,
2207
+ Pr as U,
2208
+ A as V,
2209
+ Br as W,
2210
+ Ir as X,
2211
+ Kr as Y,
2212
+ B as Z,
2213
+ be as _,
2214
+ ns as a,
2215
+ oo as a0,
2400
2216
  Yr as a1,
2401
- V as a2,
2402
- kn as a3,
2403
- kr as a4,
2404
- xo as a5,
2405
- co as a6,
2406
- Fr as a7,
2407
- _o as a8,
2408
- Kn as a9,
2409
- Eo as aa,
2410
- Ao as ab,
2411
- Mt as ac,
2412
- qt as ad,
2413
- Yn as ae,
2414
- io as af,
2415
- oo as ag,
2416
- Xr as ah,
2417
- yo as ai,
2418
- mo as aj,
2419
- Qr as ak,
2420
- Br as al,
2421
- mr as am,
2422
- Hr as an,
2423
- no as ao,
2424
- _n as ap,
2425
- xr as aq,
2426
- ao as ar,
2427
- $o as as,
2428
- To as at,
2429
- Io as au,
2430
- go as av,
2431
- ho as aw,
2432
- fo as ax,
2433
- eo as ay,
2434
- Kr as az,
2435
- ms as b,
2436
- ds as c,
2437
- ko as d,
2438
- yt as e,
2439
- zt as f,
2440
- hs as g,
2441
- bo as h,
2442
- hn as i,
2443
- gr as j,
2444
- se as k,
2445
- Rr as l,
2446
- Ur as m,
2447
- zr as n,
2448
- so as o,
2449
- ro as p,
2450
- jr as q,
2451
- Lt as r,
2452
- gs as s,
2453
- Lr as t,
2454
- Gr as u,
2455
- to as v,
2456
- nn as w,
2457
- is as x,
2458
- Tn as y,
2459
- Bt as z
2217
+ Er as a2,
2218
+ co as a3,
2219
+ Re as a4,
2220
+ po as a5,
2221
+ uo as a6,
2222
+ Et as a7,
2223
+ Pt as a8,
2224
+ ze as a9,
2225
+ Jr as aa,
2226
+ zr as ab,
2227
+ Rr as ac,
2228
+ io as ad,
2229
+ eo as ae,
2230
+ Fr as af,
2231
+ Ar as ag,
2232
+ nr as ah,
2233
+ jr as ai,
2234
+ Gr as aj,
2235
+ Ae as ak,
2236
+ ar as al,
2237
+ Wr as am,
2238
+ to as an,
2239
+ fo as ao,
2240
+ lo as ap,
2241
+ no as aq,
2242
+ Qr as ar,
2243
+ Zr as as,
2244
+ Lr as at,
2245
+ _r as au,
2246
+ es as b,
2247
+ fe as c,
2248
+ ro as d,
2249
+ kt as e,
2250
+ tr as f,
2251
+ Qt as g,
2252
+ Qe as h,
2253
+ Or as i,
2254
+ Mr as j,
2255
+ Cr as k,
2256
+ yr as l,
2257
+ vr as m,
2258
+ Sr as n,
2259
+ Tr as o,
2260
+ Vr as p,
2261
+ Xt as q,
2262
+ so as r,
2263
+ ts as s,
2264
+ Nr as t,
2265
+ Ie as u,
2266
+ Mt as v,
2267
+ ee as w,
2268
+ At as x,
2269
+ We as y,
2270
+ xe as z
2460
2271
  };