@genai-fi/nanogpt 0.6.0 → 0.6.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 (121) hide show
  1. package/dist/Generator.js +7 -7
  2. package/dist/NanoGPTModel.js +70 -121
  3. package/dist/RealDiv-BYViZwhN.js +540 -0
  4. package/dist/Reshape-t7Kcikjk.js +127 -0
  5. package/dist/TeachableLLM.d.ts +2 -0
  6. package/dist/TeachableLLM.js +34 -27
  7. package/dist/{TiedEmbedding-BhxWO8QR.js → TiedEmbedding-9WeDwvjO.js} +12 -13
  8. package/dist/{axis_util-D17qZRQm.js → axis_util-Bu4h7XWV.js} +14 -12
  9. package/dist/{broadcast_to-BMQLjvt_.js → broadcast_to-DARN-DBD.js} +2 -2
  10. package/dist/{concat-DhZfF1GY.js → concat-5aPGqw3Z.js} +3 -3
  11. package/dist/{dataset-oilnemHf.js → dataset-pgqp-YfL.js} +3 -3
  12. package/dist/{dropout-CrMQPCeG.js → dropout-Bciw46HT.js} +7 -7
  13. package/dist/{gather-DZCMHZuN.js → gather-DjyCjmOD.js} +1 -1
  14. package/dist/gpgpu_math-CNslybmD.js +3115 -0
  15. package/dist/{index-bMBtI-WR.js → index-BAzbokzv.js} +846 -649
  16. package/dist/{kernel_funcs_utils-CNmjLWnB.js → kernel_funcs_utils-CUxJCg0g.js} +232 -138
  17. package/dist/layers/BaseLayer.js +2 -2
  18. package/dist/layers/CausalSelfAttention.js +6 -6
  19. package/dist/layers/MLP.js +5 -5
  20. package/dist/layers/RMSNorm.js +3 -3
  21. package/dist/layers/RoPECache.js +13 -33
  22. package/dist/layers/TiedEmbedding.js +6 -7
  23. package/dist/layers/TransformerBlock.js +1 -1
  24. package/dist/loader/load.d.ts +13 -0
  25. package/dist/loader/load.js +27 -0
  26. package/dist/loader/loadHF.d.ts +7 -0
  27. package/dist/loader/loadHF.js +22 -0
  28. package/dist/{utilities/load.d.ts → loader/loadTransformers.d.ts} +11 -11
  29. package/dist/loader/loadTransformers.js +28 -0
  30. package/dist/loader/newZipLoad.d.ts +8 -0
  31. package/dist/loader/newZipLoad.js +21 -0
  32. package/dist/loader/oldZipLoad.d.ts +7 -0
  33. package/dist/loader/oldZipLoad.js +76 -0
  34. package/dist/{log_sum_exp-BHdkCb4s.js → log_sum_exp-YEo2h3gb.js} +14 -14
  35. package/dist/main.js +23 -20
  36. package/dist/{mat_mul-BsrLfy81.js → mat_mul-7121rsJk.js} +1 -1
  37. package/dist/{max-DechV4Bc.js → max-DtlIuVeW.js} +1 -1
  38. package/dist/mulmat_packed_gpu-D4nKF7Je.js +71 -0
  39. package/dist/{norm-B9hWHZH1.js → norm-CzltS9Fz.js} +16 -16
  40. package/dist/{ones-g0K8jVwm.js → ones-BBlSRqn1.js} +2 -2
  41. package/dist/ops/appendCache.js +3 -3
  42. package/dist/ops/attentionMask.js +1 -1
  43. package/dist/ops/cpu/appendCache.js +2 -2
  44. package/dist/ops/cpu/attentionMask.js +6 -6
  45. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  46. package/dist/ops/cpu/gatherSub.js +9 -9
  47. package/dist/ops/cpu/gelu.js +1 -1
  48. package/dist/ops/cpu/matMulGelu.js +1 -1
  49. package/dist/ops/cpu/matMulMul.js +1 -1
  50. package/dist/ops/cpu/mulDropout.js +1 -1
  51. package/dist/ops/cpu/normRMS.js +1 -1
  52. package/dist/ops/cpu/qkv.js +3 -3
  53. package/dist/ops/cpu/rope.js +5 -5
  54. package/dist/ops/cpu/scatterSub.js +17 -48
  55. package/dist/ops/fusedSoftmax.js +1 -1
  56. package/dist/ops/gatherSub.js +1 -1
  57. package/dist/ops/gelu.js +1 -1
  58. package/dist/ops/grads/attentionMask.js +1 -1
  59. package/dist/ops/grads/fusedSoftmax.js +4 -4
  60. package/dist/ops/grads/gelu.js +1 -1
  61. package/dist/ops/grads/matMulGelu.js +1 -1
  62. package/dist/ops/grads/normRMS.js +1 -1
  63. package/dist/ops/grads/qkv.js +1 -1
  64. package/dist/ops/grads/rope.js +1 -1
  65. package/dist/ops/matMulGelu.js +1 -1
  66. package/dist/ops/matMulMul.js +1 -1
  67. package/dist/ops/mulDrop.js +1 -1
  68. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  69. package/dist/ops/normRMS.js +1 -1
  70. package/dist/ops/qkv.js +1 -1
  71. package/dist/ops/rope.js +8 -4
  72. package/dist/ops/scatterSub.js +1 -1
  73. package/dist/ops/webgl/appendCache.js +1 -1
  74. package/dist/ops/webgl/attentionMask.js +1 -1
  75. package/dist/ops/webgl/fusedSoftmax.js +29 -560
  76. package/dist/ops/webgl/gatherSub.js +1 -1
  77. package/dist/ops/webgl/gelu.js +2 -2
  78. package/dist/ops/webgl/log.js +3 -3
  79. package/dist/ops/webgl/matMulGelu.js +46 -113
  80. package/dist/ops/webgl/matMulMul.js +1 -1
  81. package/dist/ops/webgl/mulDropout.js +1 -1
  82. package/dist/ops/webgl/normRMS.js +2 -2
  83. package/dist/ops/webgl/qkv.js +1 -1
  84. package/dist/ops/webgl/rope.js +1 -1
  85. package/dist/ops/webgl/scatterSub.js +1 -1
  86. package/dist/{ops-Mv7Ta72x.js → ops-C0sQEcPw.js} +117 -109
  87. package/dist/{random_width-BBAWzDym.js → random_width-DWzaOgrn.js} +6925 -6291
  88. package/dist/{range-DMaG9A3G.js → range-DYsrnfiy.js} +1 -1
  89. package/dist/{gpgpu_math-Ctc31slO.js → reciprocal-CJQeasVa.js} +7 -5
  90. package/dist/register_all_kernels-BfFCQAqs.js +21397 -0
  91. package/dist/{reshape-T4yDEqoF.js → reshape-krWGKraP.js} +1 -1
  92. package/dist/scatter_nd_util-93ln7Hut.js +46 -0
  93. package/dist/selu_util-sntGesxr.js +740 -0
  94. package/dist/{shared-XNAoXhOa.js → shared-Ca6iDobD.js} +1462 -1089
  95. package/dist/{sin-EEhbrRO_.js → sin-D_h-qCSx.js} +1 -1
  96. package/dist/{softmax-B2_IKPDR.js → softmax-fsdtf6JC.js} +1 -1
  97. package/dist/{split-dcks18H1.js → split-eiktj-6L.js} +1 -1
  98. package/dist/{stack-lpJ5kYvE.js → stack-dfEEz2OY.js} +2 -2
  99. package/dist/{sum-CutF5lj2.js → sum-BE_Irnim.js} +1 -1
  100. package/dist/{tensor-C15NA2LA.js → tensor-Xyi595sG.js} +1 -1
  101. package/dist/{tensor2d-DZ_e5eKM.js → tensor2d-CPEkynbH.js} +1 -1
  102. package/dist/training/AdamExt.js +1 -1
  103. package/dist/training/DatasetBuilder.js +2 -2
  104. package/dist/training/FullTrainer.js +1 -1
  105. package/dist/training/Trainer.js +3 -3
  106. package/dist/training/sparseCrossEntropy.js +5 -5
  107. package/dist/utilities/dummy.d.ts +6 -0
  108. package/dist/utilities/dummy.js +31 -10
  109. package/dist/utilities/generate.js +3 -3
  110. package/dist/utilities/profile.d.ts +5 -0
  111. package/dist/utilities/profile.js +10 -7
  112. package/dist/utilities/safetensors.js +2 -2
  113. package/dist/utilities/save.js +1 -1
  114. package/dist/utilities/weights.js +2 -2
  115. package/dist/{variable-CdRKKp8x.js → variable-wSS22xj5.js} +1 -1
  116. package/dist/{zeros-CAbHfODe.js → zeros-YJDE7oRb.js} +4 -4
  117. package/package.json +2 -8
  118. package/dist/Reshape-CLOrdpve.js +0 -212
  119. package/dist/slice_util-Ddk0uxGJ.js +0 -49
  120. package/dist/tfjs_backend-BDb8r9qx.js +0 -1010
  121. package/dist/utilities/load.js +0 -99
@@ -1,30 +1,30 @@
1
- import { q as $, Q as yt, ac as Y, b1 as nt, b2 as dt, b3 as gt, b4 as ht, b5 as Lt, Z as rt, ak as k, b6 as q, b7 as Mt, U as Nt, l as $t, t as At, b8 as ct, an as ut, b9 as tt, a1 as Dt } from "./index-bMBtI-WR.js";
2
- import { f as bt, c as Pt } from "./kernel_funcs_utils-CNmjLWnB.js";
3
- import { c as Wt } from "./axis_util-D17qZRQm.js";
4
- import { b as qt } from "./broadcast_to-BMQLjvt_.js";
5
- import { r as Vt } from "./reshape-T4yDEqoF.js";
6
- import { i as Ut, c as zt } from "./slice_util-Ddk0uxGJ.js";
7
- import { g as Gt } from "./_commonjsHelpers-ByX85dGu.js";
8
- function jt(e, t) {
1
+ import { i as qt, bc as _e, g as A, h as Ut, W as K, bd as et, aH as ht, be as gt, bf as at, _ as Ve, $ as st, ak as De, a$ as We, bg as $e, bh as ze, bi as Be, bj as Mt, ah as H, bk as Ot, bl as D, bm as Lt, bn as At, a8 as _t, bo as Vt, ag as Dt, bp as Wt, aT as $t, aU as zt, aW as Bt, aX as Gt, a9 as jt, bq as Zt, a_ as Ht, br as Kt, aY as Ge, am as je, bs as Xt, b2 as Ze, bt as He, p as Yt, u as Ke, t as Xe, bu as Jt, bv as wt, ap as Qt, aO as Ye, bw as te, bx as ee, by as ne, aG as pt, bz as se, bA as ot } from "./index-BAzbokzv.js";
2
+ import { h as it, m as kt, k as Je, l as Qe, R as tn, v as en, n as nn, o as sn, p as on, q as rn, r as an, s as ln, t as cn, w as un, x as hn, y as fn, z as Nt, A as gn, B as dn, C as mn } from "./gpgpu_math-CNslybmD.js";
3
+ import { g as pn, a as In, e as wn, c as bn } from "./axis_util-Bu4h7XWV.js";
4
+ import { b as xn } from "./broadcast_to-DARN-DBD.js";
5
+ import { r as En } from "./reshape-krWGKraP.js";
6
+ import { p as Fn, q as yn, r as kn, u as Nn } from "./selu_util-sntGesxr.js";
7
+ import { g as Sn } from "./_commonjsHelpers-ByX85dGu.js";
8
+ function vn(e, t) {
9
9
  for (var n = 0; n < t.length; n++) {
10
- const r = t[n];
11
- if (typeof r != "string" && !Array.isArray(r)) {
12
- for (const o in r)
10
+ const s = t[n];
11
+ if (typeof s != "string" && !Array.isArray(s)) {
12
+ for (const o in s)
13
13
  if (o !== "default" && !(o in e)) {
14
- const s = Object.getOwnPropertyDescriptor(r, o);
15
- s && Object.defineProperty(e, o, s.get ? s : {
14
+ const a = Object.getOwnPropertyDescriptor(s, o);
15
+ a && Object.defineProperty(e, o, a.get ? a : {
16
16
  enumerable: !0,
17
- get: () => r[o]
17
+ get: () => s[o]
18
18
  });
19
19
  }
20
20
  }
21
21
  }
22
22
  return Object.freeze(Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }));
23
23
  }
24
- var at, mt;
25
- function Zt() {
26
- if (mt) return at;
27
- mt = 1, at = t;
24
+ var It, St;
25
+ function Tn() {
26
+ if (St) return It;
27
+ St = 1, It = t;
28
28
  var e = null;
29
29
  try {
30
30
  e = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
@@ -317,327 +317,327 @@ function Zt() {
317
317
  ])), {}).exports;
318
318
  } catch {
319
319
  }
320
- function t(w, l, F) {
321
- this.low = w | 0, this.high = l | 0, this.unsigned = !!F;
320
+ function t(w, c, E) {
321
+ this.low = w | 0, this.high = c | 0, this.unsigned = !!E;
322
322
  }
323
323
  t.prototype.__isLong__, Object.defineProperty(t.prototype, "__isLong__", { value: !0 });
324
324
  function n(w) {
325
325
  return (w && w.__isLong__) === !0;
326
326
  }
327
327
  t.isLong = n;
328
- var r = {}, o = {};
329
- function s(w, l) {
330
- var F, T, _;
331
- return l ? (w >>>= 0, (_ = 0 <= w && w < 256) && (T = o[w], T) ? T : (F = u(w, (w | 0) < 0 ? -1 : 0, !0), _ && (o[w] = F), F)) : (w |= 0, (_ = -128 <= w && w < 128) && (T = r[w], T) ? T : (F = u(w, w < 0 ? -1 : 0, !1), _ && (r[w] = F), F));
328
+ var s = {}, o = {};
329
+ function a(w, c) {
330
+ var E, N, q;
331
+ return c ? (w >>>= 0, (q = 0 <= w && w < 256) && (N = o[w], N) ? N : (E = i(w, (w | 0) < 0 ? -1 : 0, !0), q && (o[w] = E), E)) : (w |= 0, (q = -128 <= w && w < 128) && (N = s[w], N) ? N : (E = i(w, w < 0 ? -1 : 0, !1), q && (s[w] = E), E));
332
332
  }
333
- t.fromInt = s;
334
- function i(w, l) {
333
+ t.fromInt = a;
334
+ function r(w, c) {
335
335
  if (isNaN(w))
336
- return l ? E : d;
337
- if (l) {
336
+ return c ? b : d;
337
+ if (c) {
338
338
  if (w < 0)
339
- return E;
339
+ return b;
340
340
  if (w >= m)
341
- return z;
341
+ return C;
342
342
  } else {
343
- if (w <= -b)
344
- return L;
345
- if (w + 1 >= b)
346
- return V;
343
+ if (w <= -F)
344
+ return v;
345
+ if (w + 1 >= F)
346
+ return P;
347
347
  }
348
- return w < 0 ? i(-w, l).neg() : u(w % I | 0, w / I | 0, l);
348
+ return w < 0 ? r(-w, c).neg() : i(w % I | 0, w / I | 0, c);
349
349
  }
350
- t.fromNumber = i;
351
- function u(w, l, F) {
352
- return new t(w, l, F);
350
+ t.fromNumber = r;
351
+ function i(w, c, E) {
352
+ return new t(w, c, E);
353
353
  }
354
- t.fromBits = u;
355
- var a = Math.pow;
356
- function h(w, l, F) {
354
+ t.fromBits = i;
355
+ var l = Math.pow;
356
+ function u(w, c, E) {
357
357
  if (w.length === 0)
358
358
  throw Error("empty string");
359
359
  if (w === "NaN" || w === "Infinity" || w === "+Infinity" || w === "-Infinity")
360
360
  return d;
361
- if (typeof l == "number" ? (F = l, l = !1) : l = !!l, F = F || 10, F < 2 || 36 < F)
361
+ if (typeof c == "number" ? (E = c, c = !1) : c = !!c, E = E || 10, E < 2 || 36 < E)
362
362
  throw RangeError("radix");
363
- var T;
364
- if ((T = w.indexOf("-")) > 0)
363
+ var N;
364
+ if ((N = w.indexOf("-")) > 0)
365
365
  throw Error("interior hyphen");
366
- if (T === 0)
367
- return h(w.substring(1), l, F).neg();
368
- for (var _ = i(a(F, 8)), O = d, M = 0; M < w.length; M += 8) {
369
- var G = Math.min(8, w.length - M), Z = parseInt(w.substring(M, M + G), F);
370
- if (G < 8) {
371
- var P = i(a(F, G));
372
- O = O.mul(P).add(i(Z));
366
+ if (N === 0)
367
+ return u(w.substring(1), c, E).neg();
368
+ for (var q = r(l(E, 8)), R = d, M = 0; M < w.length; M += 8) {
369
+ var $ = Math.min(8, w.length - M), G = parseInt(w.substring(M, M + $), E);
370
+ if ($ < 8) {
371
+ var _ = r(l(E, $));
372
+ R = R.mul(_).add(r(G));
373
373
  } else
374
- O = O.mul(_), O = O.add(i(Z));
374
+ R = R.mul(q), R = R.add(r(G));
375
375
  }
376
- return O.unsigned = l, O;
376
+ return R.unsigned = c, R;
377
377
  }
378
- t.fromString = h;
379
- function c(w, l) {
380
- return typeof w == "number" ? i(w, l) : typeof w == "string" ? h(w, l) : u(w.low, w.high, typeof l == "boolean" ? l : w.unsigned);
378
+ t.fromString = u;
379
+ function h(w, c) {
380
+ return typeof w == "number" ? r(w, c) : typeof w == "string" ? u(w, c) : i(w.low, w.high, typeof c == "boolean" ? c : w.unsigned);
381
381
  }
382
- t.fromValue = c;
383
- var f = 65536, p = 1 << 24, I = f * f, m = I * I, b = m / 2, g = s(p), d = s(0);
382
+ t.fromValue = h;
383
+ var f = 65536, p = 1 << 24, I = f * f, m = I * I, F = m / 2, g = a(p), d = a(0);
384
384
  t.ZERO = d;
385
- var E = s(0, !0);
386
- t.UZERO = E;
387
- var R = s(1);
388
- t.ONE = R;
389
- var x = s(1, !0);
390
- t.UONE = x;
391
- var D = s(-1);
392
- t.NEG_ONE = D;
393
- var V = u(-1, 2147483647, !1);
394
- t.MAX_VALUE = V;
395
- var z = u(-1, -1, !0);
396
- t.MAX_UNSIGNED_VALUE = z;
397
- var L = u(0, -2147483648, !1);
398
- t.MIN_VALUE = L;
399
- var S = t.prototype;
400
- return S.toInt = function() {
385
+ var b = a(0, !0);
386
+ t.UZERO = b;
387
+ var k = a(1);
388
+ t.ONE = k;
389
+ var y = a(1, !0);
390
+ t.UONE = y;
391
+ var S = a(-1);
392
+ t.NEG_ONE = S;
393
+ var P = i(-1, 2147483647, !1);
394
+ t.MAX_VALUE = P;
395
+ var C = i(-1, -1, !0);
396
+ t.MAX_UNSIGNED_VALUE = C;
397
+ var v = i(0, -2147483648, !1);
398
+ t.MIN_VALUE = v;
399
+ var x = t.prototype;
400
+ return x.toInt = function() {
401
401
  return this.unsigned ? this.low >>> 0 : this.low;
402
- }, S.toNumber = function() {
402
+ }, x.toNumber = function() {
403
403
  return this.unsigned ? (this.high >>> 0) * I + (this.low >>> 0) : this.high * I + (this.low >>> 0);
404
- }, S.toString = function(l) {
405
- if (l = l || 10, l < 2 || 36 < l)
404
+ }, x.toString = function(c) {
405
+ if (c = c || 10, c < 2 || 36 < c)
406
406
  throw RangeError("radix");
407
407
  if (this.isZero())
408
408
  return "0";
409
409
  if (this.isNegative())
410
- if (this.eq(L)) {
411
- var F = i(l), T = this.div(F), _ = T.mul(F).sub(this);
412
- return T.toString(l) + _.toInt().toString(l);
410
+ if (this.eq(v)) {
411
+ var E = r(c), N = this.div(E), q = N.mul(E).sub(this);
412
+ return N.toString(c) + q.toInt().toString(c);
413
413
  } else
414
- return "-" + this.neg().toString(l);
415
- for (var O = i(a(l, 6), this.unsigned), M = this, G = ""; ; ) {
416
- var Z = M.div(O), P = M.sub(Z.mul(O)).toInt() >>> 0, y = P.toString(l);
417
- if (M = Z, M.isZero())
418
- return y + G;
419
- for (; y.length < 6; )
420
- y = "0" + y;
421
- G = "" + y + G;
414
+ return "-" + this.neg().toString(c);
415
+ for (var R = r(l(c, 6), this.unsigned), M = this, $ = ""; ; ) {
416
+ var G = M.div(R), _ = M.sub(G.mul(R)).toInt() >>> 0, U = _.toString(c);
417
+ if (M = G, M.isZero())
418
+ return U + $;
419
+ for (; U.length < 6; )
420
+ U = "0" + U;
421
+ $ = "" + U + $;
422
422
  }
423
- }, S.getHighBits = function() {
423
+ }, x.getHighBits = function() {
424
424
  return this.high;
425
- }, S.getHighBitsUnsigned = function() {
425
+ }, x.getHighBitsUnsigned = function() {
426
426
  return this.high >>> 0;
427
- }, S.getLowBits = function() {
427
+ }, x.getLowBits = function() {
428
428
  return this.low;
429
- }, S.getLowBitsUnsigned = function() {
429
+ }, x.getLowBitsUnsigned = function() {
430
430
  return this.low >>> 0;
431
- }, S.getNumBitsAbs = function() {
431
+ }, x.getNumBitsAbs = function() {
432
432
  if (this.isNegative())
433
- return this.eq(L) ? 64 : this.neg().getNumBitsAbs();
434
- for (var l = this.high != 0 ? this.high : this.low, F = 31; F > 0 && (l & 1 << F) == 0; F--)
433
+ return this.eq(v) ? 64 : this.neg().getNumBitsAbs();
434
+ for (var c = this.high != 0 ? this.high : this.low, E = 31; E > 0 && (c & 1 << E) == 0; E--)
435
435
  ;
436
- return this.high != 0 ? F + 33 : F + 1;
437
- }, S.isZero = function() {
436
+ return this.high != 0 ? E + 33 : E + 1;
437
+ }, x.isZero = function() {
438
438
  return this.high === 0 && this.low === 0;
439
- }, S.eqz = S.isZero, S.isNegative = function() {
439
+ }, x.eqz = x.isZero, x.isNegative = function() {
440
440
  return !this.unsigned && this.high < 0;
441
- }, S.isPositive = function() {
441
+ }, x.isPositive = function() {
442
442
  return this.unsigned || this.high >= 0;
443
- }, S.isOdd = function() {
443
+ }, x.isOdd = function() {
444
444
  return (this.low & 1) === 1;
445
- }, S.isEven = function() {
445
+ }, x.isEven = function() {
446
446
  return (this.low & 1) === 0;
447
- }, S.equals = function(l) {
448
- return n(l) || (l = c(l)), this.unsigned !== l.unsigned && this.high >>> 31 === 1 && l.high >>> 31 === 1 ? !1 : this.high === l.high && this.low === l.low;
449
- }, S.eq = S.equals, S.notEquals = function(l) {
447
+ }, x.equals = function(c) {
448
+ return n(c) || (c = h(c)), this.unsigned !== c.unsigned && this.high >>> 31 === 1 && c.high >>> 31 === 1 ? !1 : this.high === c.high && this.low === c.low;
449
+ }, x.eq = x.equals, x.notEquals = function(c) {
450
450
  return !this.eq(
451
451
  /* validates */
452
- l
452
+ c
453
453
  );
454
- }, S.neq = S.notEquals, S.ne = S.notEquals, S.lessThan = function(l) {
454
+ }, x.neq = x.notEquals, x.ne = x.notEquals, x.lessThan = function(c) {
455
455
  return this.comp(
456
456
  /* validates */
457
- l
457
+ c
458
458
  ) < 0;
459
- }, S.lt = S.lessThan, S.lessThanOrEqual = function(l) {
459
+ }, x.lt = x.lessThan, x.lessThanOrEqual = function(c) {
460
460
  return this.comp(
461
461
  /* validates */
462
- l
462
+ c
463
463
  ) <= 0;
464
- }, S.lte = S.lessThanOrEqual, S.le = S.lessThanOrEqual, S.greaterThan = function(l) {
464
+ }, x.lte = x.lessThanOrEqual, x.le = x.lessThanOrEqual, x.greaterThan = function(c) {
465
465
  return this.comp(
466
466
  /* validates */
467
- l
467
+ c
468
468
  ) > 0;
469
- }, S.gt = S.greaterThan, S.greaterThanOrEqual = function(l) {
469
+ }, x.gt = x.greaterThan, x.greaterThanOrEqual = function(c) {
470
470
  return this.comp(
471
471
  /* validates */
472
- l
472
+ c
473
473
  ) >= 0;
474
- }, S.gte = S.greaterThanOrEqual, S.ge = S.greaterThanOrEqual, S.compare = function(l) {
475
- if (n(l) || (l = c(l)), this.eq(l))
474
+ }, x.gte = x.greaterThanOrEqual, x.ge = x.greaterThanOrEqual, x.compare = function(c) {
475
+ if (n(c) || (c = h(c)), this.eq(c))
476
476
  return 0;
477
- var F = this.isNegative(), T = l.isNegative();
478
- return F && !T ? -1 : !F && T ? 1 : this.unsigned ? l.high >>> 0 > this.high >>> 0 || l.high === this.high && l.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(l).isNegative() ? -1 : 1;
479
- }, S.comp = S.compare, S.negate = function() {
480
- return !this.unsigned && this.eq(L) ? L : this.not().add(R);
481
- }, S.neg = S.negate, S.add = function(l) {
482
- n(l) || (l = c(l));
483
- var F = this.high >>> 16, T = this.high & 65535, _ = this.low >>> 16, O = this.low & 65535, M = l.high >>> 16, G = l.high & 65535, Z = l.low >>> 16, P = l.low & 65535, y = 0, C = 0, A = 0, j = 0;
484
- return j += O + P, A += j >>> 16, j &= 65535, A += _ + Z, C += A >>> 16, A &= 65535, C += T + G, y += C >>> 16, C &= 65535, y += F + M, y &= 65535, u(A << 16 | j, y << 16 | C, this.unsigned);
485
- }, S.subtract = function(l) {
486
- return n(l) || (l = c(l)), this.add(l.neg());
487
- }, S.sub = S.subtract, S.multiply = function(l) {
477
+ var E = this.isNegative(), N = c.isNegative();
478
+ return E && !N ? -1 : !E && N ? 1 : this.unsigned ? c.high >>> 0 > this.high >>> 0 || c.high === this.high && c.low >>> 0 > this.low >>> 0 ? -1 : 1 : this.sub(c).isNegative() ? -1 : 1;
479
+ }, x.comp = x.compare, x.negate = function() {
480
+ return !this.unsigned && this.eq(v) ? v : this.not().add(k);
481
+ }, x.neg = x.negate, x.add = function(c) {
482
+ n(c) || (c = h(c));
483
+ var E = this.high >>> 16, N = this.high & 65535, q = this.low >>> 16, R = this.low & 65535, M = c.high >>> 16, $ = c.high & 65535, G = c.low >>> 16, _ = c.low & 65535, U = 0, j = 0, L = 0, B = 0;
484
+ return B += R + _, L += B >>> 16, B &= 65535, L += q + G, j += L >>> 16, L &= 65535, j += N + $, U += j >>> 16, j &= 65535, U += E + M, U &= 65535, i(L << 16 | B, U << 16 | j, this.unsigned);
485
+ }, x.subtract = function(c) {
486
+ return n(c) || (c = h(c)), this.add(c.neg());
487
+ }, x.sub = x.subtract, x.multiply = function(c) {
488
488
  if (this.isZero())
489
489
  return d;
490
- if (n(l) || (l = c(l)), e) {
491
- var F = e.mul(
490
+ if (n(c) || (c = h(c)), e) {
491
+ var E = e.mul(
492
492
  this.low,
493
493
  this.high,
494
- l.low,
495
- l.high
494
+ c.low,
495
+ c.high
496
496
  );
497
- return u(F, e.get_high(), this.unsigned);
497
+ return i(E, e.get_high(), this.unsigned);
498
498
  }
499
- if (l.isZero())
499
+ if (c.isZero())
500
500
  return d;
501
- if (this.eq(L))
502
- return l.isOdd() ? L : d;
503
- if (l.eq(L))
504
- return this.isOdd() ? L : d;
501
+ if (this.eq(v))
502
+ return c.isOdd() ? v : d;
503
+ if (c.eq(v))
504
+ return this.isOdd() ? v : d;
505
505
  if (this.isNegative())
506
- return l.isNegative() ? this.neg().mul(l.neg()) : this.neg().mul(l).neg();
507
- if (l.isNegative())
508
- return this.mul(l.neg()).neg();
509
- if (this.lt(g) && l.lt(g))
510
- return i(this.toNumber() * l.toNumber(), this.unsigned);
511
- var T = this.high >>> 16, _ = this.high & 65535, O = this.low >>> 16, M = this.low & 65535, G = l.high >>> 16, Z = l.high & 65535, P = l.low >>> 16, y = l.low & 65535, C = 0, A = 0, j = 0, ot = 0;
512
- return ot += M * y, j += ot >>> 16, ot &= 65535, j += O * y, A += j >>> 16, j &= 65535, j += M * P, A += j >>> 16, j &= 65535, A += _ * y, C += A >>> 16, A &= 65535, A += O * P, C += A >>> 16, A &= 65535, A += M * Z, C += A >>> 16, A &= 65535, C += T * y + _ * P + O * Z + M * G, C &= 65535, u(j << 16 | ot, C << 16 | A, this.unsigned);
513
- }, S.mul = S.multiply, S.divide = function(l) {
514
- if (n(l) || (l = c(l)), l.isZero())
506
+ return c.isNegative() ? this.neg().mul(c.neg()) : this.neg().mul(c).neg();
507
+ if (c.isNegative())
508
+ return this.mul(c.neg()).neg();
509
+ if (this.lt(g) && c.lt(g))
510
+ return r(this.toNumber() * c.toNumber(), this.unsigned);
511
+ var N = this.high >>> 16, q = this.high & 65535, R = this.low >>> 16, M = this.low & 65535, $ = c.high >>> 16, G = c.high & 65535, _ = c.low >>> 16, U = c.low & 65535, j = 0, L = 0, B = 0, ct = 0;
512
+ return ct += M * U, B += ct >>> 16, ct &= 65535, B += R * U, L += B >>> 16, B &= 65535, B += M * _, L += B >>> 16, B &= 65535, L += q * U, j += L >>> 16, L &= 65535, L += R * _, j += L >>> 16, L &= 65535, L += M * G, j += L >>> 16, L &= 65535, j += N * U + q * _ + R * G + M * $, j &= 65535, i(B << 16 | ct, j << 16 | L, this.unsigned);
513
+ }, x.mul = x.multiply, x.divide = function(c) {
514
+ if (n(c) || (c = h(c)), c.isZero())
515
515
  throw Error("division by zero");
516
516
  if (e) {
517
- if (!this.unsigned && this.high === -2147483648 && l.low === -1 && l.high === -1)
517
+ if (!this.unsigned && this.high === -2147483648 && c.low === -1 && c.high === -1)
518
518
  return this;
519
- var F = (this.unsigned ? e.div_u : e.div_s)(
519
+ var E = (this.unsigned ? e.div_u : e.div_s)(
520
520
  this.low,
521
521
  this.high,
522
- l.low,
523
- l.high
522
+ c.low,
523
+ c.high
524
524
  );
525
- return u(F, e.get_high(), this.unsigned);
525
+ return i(E, e.get_high(), this.unsigned);
526
526
  }
527
527
  if (this.isZero())
528
- return this.unsigned ? E : d;
529
- var T, _, O;
528
+ return this.unsigned ? b : d;
529
+ var N, q, R;
530
530
  if (this.unsigned) {
531
- if (l.unsigned || (l = l.toUnsigned()), l.gt(this))
532
- return E;
533
- if (l.gt(this.shru(1)))
534
- return x;
535
- O = E;
531
+ if (c.unsigned || (c = c.toUnsigned()), c.gt(this))
532
+ return b;
533
+ if (c.gt(this.shru(1)))
534
+ return y;
535
+ R = b;
536
536
  } else {
537
- if (this.eq(L)) {
538
- if (l.eq(R) || l.eq(D))
539
- return L;
540
- if (l.eq(L))
541
- return R;
537
+ if (this.eq(v)) {
538
+ if (c.eq(k) || c.eq(S))
539
+ return v;
540
+ if (c.eq(v))
541
+ return k;
542
542
  var M = this.shr(1);
543
- return T = M.div(l).shl(1), T.eq(d) ? l.isNegative() ? R : D : (_ = this.sub(l.mul(T)), O = T.add(_.div(l)), O);
544
- } else if (l.eq(L))
545
- return this.unsigned ? E : d;
543
+ return N = M.div(c).shl(1), N.eq(d) ? c.isNegative() ? k : S : (q = this.sub(c.mul(N)), R = N.add(q.div(c)), R);
544
+ } else if (c.eq(v))
545
+ return this.unsigned ? b : d;
546
546
  if (this.isNegative())
547
- return l.isNegative() ? this.neg().div(l.neg()) : this.neg().div(l).neg();
548
- if (l.isNegative())
549
- return this.div(l.neg()).neg();
550
- O = d;
547
+ return c.isNegative() ? this.neg().div(c.neg()) : this.neg().div(c).neg();
548
+ if (c.isNegative())
549
+ return this.div(c.neg()).neg();
550
+ R = d;
551
551
  }
552
- for (_ = this; _.gte(l); ) {
553
- T = Math.max(1, Math.floor(_.toNumber() / l.toNumber()));
554
- for (var G = Math.ceil(Math.log(T) / Math.LN2), Z = G <= 48 ? 1 : a(2, G - 48), P = i(T), y = P.mul(l); y.isNegative() || y.gt(_); )
555
- T -= Z, P = i(T, this.unsigned), y = P.mul(l);
556
- P.isZero() && (P = R), O = O.add(P), _ = _.sub(y);
552
+ for (q = this; q.gte(c); ) {
553
+ N = Math.max(1, Math.floor(q.toNumber() / c.toNumber()));
554
+ for (var $ = Math.ceil(Math.log(N) / Math.LN2), G = $ <= 48 ? 1 : l(2, $ - 48), _ = r(N), U = _.mul(c); U.isNegative() || U.gt(q); )
555
+ N -= G, _ = r(N, this.unsigned), U = _.mul(c);
556
+ _.isZero() && (_ = k), R = R.add(_), q = q.sub(U);
557
557
  }
558
- return O;
559
- }, S.div = S.divide, S.modulo = function(l) {
560
- if (n(l) || (l = c(l)), e) {
561
- var F = (this.unsigned ? e.rem_u : e.rem_s)(
558
+ return R;
559
+ }, x.div = x.divide, x.modulo = function(c) {
560
+ if (n(c) || (c = h(c)), e) {
561
+ var E = (this.unsigned ? e.rem_u : e.rem_s)(
562
562
  this.low,
563
563
  this.high,
564
- l.low,
565
- l.high
564
+ c.low,
565
+ c.high
566
566
  );
567
- return u(F, e.get_high(), this.unsigned);
567
+ return i(E, e.get_high(), this.unsigned);
568
568
  }
569
- return this.sub(this.div(l).mul(l));
570
- }, S.mod = S.modulo, S.rem = S.modulo, S.not = function() {
571
- return u(~this.low, ~this.high, this.unsigned);
572
- }, S.and = function(l) {
573
- return n(l) || (l = c(l)), u(this.low & l.low, this.high & l.high, this.unsigned);
574
- }, S.or = function(l) {
575
- return n(l) || (l = c(l)), u(this.low | l.low, this.high | l.high, this.unsigned);
576
- }, S.xor = function(l) {
577
- return n(l) || (l = c(l)), u(this.low ^ l.low, this.high ^ l.high, this.unsigned);
578
- }, S.shiftLeft = function(l) {
579
- return n(l) && (l = l.toInt()), (l &= 63) === 0 ? this : l < 32 ? u(this.low << l, this.high << l | this.low >>> 32 - l, this.unsigned) : u(0, this.low << l - 32, this.unsigned);
580
- }, S.shl = S.shiftLeft, S.shiftRight = function(l) {
581
- return n(l) && (l = l.toInt()), (l &= 63) === 0 ? this : l < 32 ? u(this.low >>> l | this.high << 32 - l, this.high >> l, this.unsigned) : u(this.high >> l - 32, this.high >= 0 ? 0 : -1, this.unsigned);
582
- }, S.shr = S.shiftRight, S.shiftRightUnsigned = function(l) {
583
- if (n(l) && (l = l.toInt()), l &= 63, l === 0)
569
+ return this.sub(this.div(c).mul(c));
570
+ }, x.mod = x.modulo, x.rem = x.modulo, x.not = function() {
571
+ return i(~this.low, ~this.high, this.unsigned);
572
+ }, x.and = function(c) {
573
+ return n(c) || (c = h(c)), i(this.low & c.low, this.high & c.high, this.unsigned);
574
+ }, x.or = function(c) {
575
+ return n(c) || (c = h(c)), i(this.low | c.low, this.high | c.high, this.unsigned);
576
+ }, x.xor = function(c) {
577
+ return n(c) || (c = h(c)), i(this.low ^ c.low, this.high ^ c.high, this.unsigned);
578
+ }, x.shiftLeft = function(c) {
579
+ return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low << c, this.high << c | this.low >>> 32 - c, this.unsigned) : i(0, this.low << c - 32, this.unsigned);
580
+ }, x.shl = x.shiftLeft, x.shiftRight = function(c) {
581
+ return n(c) && (c = c.toInt()), (c &= 63) === 0 ? this : c < 32 ? i(this.low >>> c | this.high << 32 - c, this.high >> c, this.unsigned) : i(this.high >> c - 32, this.high >= 0 ? 0 : -1, this.unsigned);
582
+ }, x.shr = x.shiftRight, x.shiftRightUnsigned = function(c) {
583
+ if (n(c) && (c = c.toInt()), c &= 63, c === 0)
584
584
  return this;
585
- var F = this.high;
586
- if (l < 32) {
587
- var T = this.low;
588
- return u(T >>> l | F << 32 - l, F >>> l, this.unsigned);
589
- } else return l === 32 ? u(F, 0, this.unsigned) : u(F >>> l - 32, 0, this.unsigned);
590
- }, S.shru = S.shiftRightUnsigned, S.shr_u = S.shiftRightUnsigned, S.toSigned = function() {
591
- return this.unsigned ? u(this.low, this.high, !1) : this;
592
- }, S.toUnsigned = function() {
593
- return this.unsigned ? this : u(this.low, this.high, !0);
594
- }, S.toBytes = function(l) {
595
- return l ? this.toBytesLE() : this.toBytesBE();
596
- }, S.toBytesLE = function() {
597
- var l = this.high, F = this.low;
585
+ var E = this.high;
586
+ if (c < 32) {
587
+ var N = this.low;
588
+ return i(N >>> c | E << 32 - c, E >>> c, this.unsigned);
589
+ } else return c === 32 ? i(E, 0, this.unsigned) : i(E >>> c - 32, 0, this.unsigned);
590
+ }, x.shru = x.shiftRightUnsigned, x.shr_u = x.shiftRightUnsigned, x.toSigned = function() {
591
+ return this.unsigned ? i(this.low, this.high, !1) : this;
592
+ }, x.toUnsigned = function() {
593
+ return this.unsigned ? this : i(this.low, this.high, !0);
594
+ }, x.toBytes = function(c) {
595
+ return c ? this.toBytesLE() : this.toBytesBE();
596
+ }, x.toBytesLE = function() {
597
+ var c = this.high, E = this.low;
598
598
  return [
599
- F & 255,
600
- F >>> 8 & 255,
601
- F >>> 16 & 255,
602
- F >>> 24,
603
- l & 255,
604
- l >>> 8 & 255,
605
- l >>> 16 & 255,
606
- l >>> 24
599
+ E & 255,
600
+ E >>> 8 & 255,
601
+ E >>> 16 & 255,
602
+ E >>> 24,
603
+ c & 255,
604
+ c >>> 8 & 255,
605
+ c >>> 16 & 255,
606
+ c >>> 24
607
607
  ];
608
- }, S.toBytesBE = function() {
609
- var l = this.high, F = this.low;
608
+ }, x.toBytesBE = function() {
609
+ var c = this.high, E = this.low;
610
610
  return [
611
- l >>> 24,
612
- l >>> 16 & 255,
613
- l >>> 8 & 255,
614
- l & 255,
615
- F >>> 24,
616
- F >>> 16 & 255,
617
- F >>> 8 & 255,
618
- F & 255
611
+ c >>> 24,
612
+ c >>> 16 & 255,
613
+ c >>> 8 & 255,
614
+ c & 255,
615
+ E >>> 24,
616
+ E >>> 16 & 255,
617
+ E >>> 8 & 255,
618
+ E & 255
619
619
  ];
620
- }, t.fromBytes = function(l, F, T) {
621
- return T ? t.fromBytesLE(l, F) : t.fromBytesBE(l, F);
622
- }, t.fromBytesLE = function(l, F) {
620
+ }, t.fromBytes = function(c, E, N) {
621
+ return N ? t.fromBytesLE(c, E) : t.fromBytesBE(c, E);
622
+ }, t.fromBytesLE = function(c, E) {
623
623
  return new t(
624
- l[0] | l[1] << 8 | l[2] << 16 | l[3] << 24,
625
- l[4] | l[5] << 8 | l[6] << 16 | l[7] << 24,
626
- F
624
+ c[0] | c[1] << 8 | c[2] << 16 | c[3] << 24,
625
+ c[4] | c[5] << 8 | c[6] << 16 | c[7] << 24,
626
+ E
627
627
  );
628
- }, t.fromBytesBE = function(l, F) {
628
+ }, t.fromBytesBE = function(c, E) {
629
629
  return new t(
630
- l[4] << 24 | l[5] << 16 | l[6] << 8 | l[7],
631
- l[0] << 24 | l[1] << 16 | l[2] << 8 | l[3],
632
- F
630
+ c[4] << 24 | c[5] << 16 | c[6] << 8 | c[7],
631
+ c[0] << 24 | c[1] << 16 | c[2] << 8 | c[3],
632
+ E
633
633
  );
634
- }, at;
634
+ }, It;
635
635
  }
636
- var xt = Zt();
637
- const Rt = /* @__PURE__ */ Gt(xt), Ct = /* @__PURE__ */ jt({
636
+ var oe = Tn();
637
+ const re = /* @__PURE__ */ Sn(oe), Rn = /* @__PURE__ */ vn({
638
638
  __proto__: null,
639
- default: Rt
640
- }, [xt]);
639
+ default: re
640
+ }, [oe]);
641
641
  /**
642
642
  * @license
643
643
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -654,86 +654,86 @@ const Rt = /* @__PURE__ */ Gt(xt), Ct = /* @__PURE__ */ jt({
654
654
  * limitations under the License.
655
655
  * =============================================================================
656
656
  */
657
- const J = (
657
+ const tt = (
658
658
  // tslint:disable-next-line
659
- Rt || Ct
659
+ re || Rn
660
660
  );
661
- function lt(e) {
662
- return J.fromString(e, !0, 16);
661
+ function dt(e) {
662
+ return tt.fromString(e, !0, 16);
663
663
  }
664
- const Tt = lt("c3a5c85c97cb3127"), Q = lt("b492b66fbe98f273"), W = lt("9ae16a3b2f90404f");
665
- function ft(e) {
664
+ const ae = dt("c3a5c85c97cb3127"), Q = dt("b492b66fbe98f273"), V = dt("9ae16a3b2f90404f");
665
+ function bt(e) {
666
666
  return e.xor(e.shru(47));
667
667
  }
668
- function vt(e, t, n) {
669
- const r = e.slice(t, t + n);
670
- return J.fromBytes(Array.from(r), !0, !0);
668
+ function ie(e, t, n) {
669
+ const s = e.slice(t, t + n);
670
+ return tt.fromBytes(Array.from(s), !0, !0);
671
671
  }
672
- function v(e, t) {
673
- return vt(e, t, 8);
672
+ function T(e, t) {
673
+ return ie(e, t, 8);
674
674
  }
675
- function wt(e, t) {
676
- return vt(e, t, 4);
675
+ function vt(e, t) {
676
+ return ie(e, t, 4);
677
677
  }
678
- function N(e, t) {
678
+ function O(e, t) {
679
679
  return t === 0 ? e : e.shru(t).or(e.shl(64 - t));
680
680
  }
681
- function X(e, t, n = lt("9ddfea08eb382d69")) {
682
- let r = e.xor(t).mul(n);
683
- r = r.xor(r.shru(47));
684
- let o = t.xor(r).mul(n);
681
+ function Y(e, t, n = dt("9ddfea08eb382d69")) {
682
+ let s = e.xor(t).mul(n);
683
+ s = s.xor(s.shru(47));
684
+ let o = t.xor(s).mul(n);
685
685
  return o = o.xor(o.shru(47)), o = o.mul(n), o;
686
686
  }
687
- function Bt(e, t, n, r, o, s) {
688
- o = o.add(e), s = N(s.add(o).add(r), 21);
689
- const i = o;
690
- return o = o.add(t), o = o.add(n), s = s.add(N(o, 44)), [o.add(r), s.add(i)];
687
+ function Pn(e, t, n, s, o, a) {
688
+ o = o.add(e), a = O(a.add(o).add(s), 21);
689
+ const r = o;
690
+ return o = o.add(t), o = o.add(n), a = a.add(O(o, 44)), [o.add(s), a.add(r)];
691
691
  }
692
- function st(e, t, n, r) {
693
- return Bt(v(e, t), v(e, t + 8), v(e, t + 16), v(e, t + 24), n, r);
692
+ function ut(e, t, n, s) {
693
+ return Pn(T(e, t), T(e, t + 8), T(e, t + 16), T(e, t + 24), n, s);
694
694
  }
695
- function kt(e, t = e.length) {
695
+ function Cn(e, t = e.length) {
696
696
  if (t >= 8) {
697
- const n = W.add(t * 2), r = v(e, 0).add(W), o = v(e, t - 8), s = N(o, 37).mul(n).add(r), i = N(r, 25).add(o).mul(n);
698
- return X(s, i, n);
697
+ const n = V.add(t * 2), s = T(e, 0).add(V), o = T(e, t - 8), a = O(o, 37).mul(n).add(s), r = O(s, 25).add(o).mul(n);
698
+ return Y(a, r, n);
699
699
  }
700
700
  if (t >= 4) {
701
- const n = W.add(t * 2), r = wt(e, 0);
702
- return X(r.shl(3).add(t), wt(e, t - 4), n);
701
+ const n = V.add(t * 2), s = vt(e, 0);
702
+ return Y(s.shl(3).add(t), vt(e, t - 4), n);
703
703
  }
704
704
  if (t > 0) {
705
- const n = e[0], r = e[t >> 1], o = e[t - 1], s = n + (r << 8), i = t + (o << 2);
706
- return ft(W.mul(s).xor(Tt.mul(i))).mul(W);
705
+ const n = e[0], s = e[t >> 1], o = e[t - 1], a = n + (s << 8), r = t + (o << 2);
706
+ return bt(V.mul(a).xor(ae.mul(r))).mul(V);
707
707
  }
708
- return W;
708
+ return V;
709
709
  }
710
- function Ht(e, t = e.length) {
711
- const n = W.add(t * 2), r = v(e, 0).mul(Q), o = v(e, 8), s = v(e, t - 8).mul(n), i = v(e, t - 16).mul(W);
712
- return X(N(r.add(o), 43).add(N(s, 30)).add(i), r.add(N(o.add(W), 18)).add(s), n);
710
+ function qn(e, t = e.length) {
711
+ const n = V.add(t * 2), s = T(e, 0).mul(Q), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(V);
712
+ return Y(O(s.add(o), 43).add(O(a, 30)).add(r), s.add(O(o.add(V), 18)).add(a), n);
713
713
  }
714
- function Kt(e, t = e.length) {
715
- const n = W.add(t * 2), r = v(e, 0).mul(W), o = v(e, 8), s = v(e, t - 8).mul(n), i = v(e, t - 16).mul(W), u = N(r.add(o), 43).add(N(s, 30)).add(i), a = X(u, r.add(N(o.add(W), 18)).add(s), n), h = v(e, 16).mul(n), c = v(e, 24), f = u.add(v(e, t - 32)).mul(n), p = a.add(v(e, t - 24)).mul(n);
716
- return X(N(h.add(c), 43).add(N(f, 30)).add(p), h.add(N(c.add(r), 18)).add(f), n);
714
+ function Un(e, t = e.length) {
715
+ const n = V.add(t * 2), s = T(e, 0).mul(V), o = T(e, 8), a = T(e, t - 8).mul(n), r = T(e, t - 16).mul(V), i = O(s.add(o), 43).add(O(a, 30)).add(r), l = Y(i, s.add(O(o.add(V), 18)).add(a), n), u = T(e, 16).mul(n), h = T(e, 24), f = i.add(T(e, t - 32)).mul(n), p = l.add(T(e, t - 24)).mul(n);
716
+ return Y(O(u.add(h), 43).add(O(f, 30)).add(p), u.add(O(h.add(s), 18)).add(f), n);
717
717
  }
718
- function Xt(e, t = e.length) {
719
- const n = J.fromNumber(81, !0);
718
+ function Mn(e, t = e.length) {
719
+ const n = tt.fromNumber(81, !0);
720
720
  if (t <= 32)
721
- return t <= 16 ? kt(e, t) : Ht(e, t);
721
+ return t <= 16 ? Cn(e, t) : qn(e, t);
722
722
  if (t <= 64)
723
- return Kt(e, t);
724
- let r = n, o = n.mul(Q).add(113), s = ft(o.mul(W).add(113)).mul(W), i = [J.UZERO, J.UZERO], u = [J.UZERO, J.UZERO];
725
- r = r.mul(W).add(v(e, 0));
726
- let a = 0;
727
- const h = (t - 1 >> 6) * 64, c = h + (t - 1 & 63) - 63;
723
+ return Un(e, t);
724
+ let s = n, o = n.mul(Q).add(113), a = bt(o.mul(V).add(113)).mul(V), r = [tt.UZERO, tt.UZERO], i = [tt.UZERO, tt.UZERO];
725
+ s = s.mul(V).add(T(e, 0));
726
+ let l = 0;
727
+ const u = (t - 1 >> 6) * 64, h = u + (t - 1 & 63) - 63;
728
728
  do
729
- r = N(r.add(o).add(i[0]).add(v(e, a + 8)), 37).mul(Q), o = N(o.add(i[1]).add(v(e, a + 48)), 42).mul(Q), r = r.xor(u[1]), o = o.add(i[0]).add(v(e, a + 40)), s = N(s.add(u[0]), 33).mul(Q), i = st(e, a, i[1].mul(Q), r.add(u[0])), u = st(e, a + 32, s.add(u[1]), o.add(v(e, a + 16))), [s, r] = [r, s], a += 64;
730
- while (a !== h);
731
- const f = Q.add(s.and(255).shl(1));
732
- return a = c, u[0] = u[0].add(t - 1 & 63), i[0] = i[0].add(u[0]), u[0] = u[0].add(i[0]), r = N(r.add(o).add(i[0]).add(v(e, a + 8)), 37).mul(f), o = N(o.add(i[1]).add(v(e, a + 48)), 42).mul(f), r = r.xor(u[1].mul(9)), o = o.add(i[0].mul(9).add(v(e, a + 40))), s = N(s.add(u[0]), 33).mul(f), i = st(e, a, i[1].mul(f), r.add(u[0])), u = st(e, a + 32, s.add(u[1]), o.add(v(e, a + 16))), [s, r] = [r, s], X(X(i[0], u[0], f).add(ft(o).mul(Tt)).add(s), X(i[1], u[1], f).add(r), f);
729
+ s = O(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(Q), o = O(o.add(r[1]).add(T(e, l + 48)), 42).mul(Q), s = s.xor(i[1]), o = o.add(r[0]).add(T(e, l + 40)), a = O(a.add(i[0]), 33).mul(Q), r = ut(e, l, r[1].mul(Q), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], l += 64;
730
+ while (l !== u);
731
+ const f = Q.add(a.and(255).shl(1));
732
+ return l = h, i[0] = i[0].add(t - 1 & 63), r[0] = r[0].add(i[0]), i[0] = i[0].add(r[0]), s = O(s.add(o).add(r[0]).add(T(e, l + 8)), 37).mul(f), o = O(o.add(r[1]).add(T(e, l + 48)), 42).mul(f), s = s.xor(i[1].mul(9)), o = o.add(r[0].mul(9).add(T(e, l + 40))), a = O(a.add(i[0]), 33).mul(f), r = ut(e, l, r[1].mul(f), s.add(i[0])), i = ut(e, l + 32, a.add(i[1]), o.add(T(e, l + 16))), [a, s] = [s, a], Y(Y(r[0], i[0], f).add(bt(o).mul(ae)).add(a), Y(r[1], i[1], f).add(s), f);
733
733
  }
734
734
  /**
735
735
  * @license
736
- * Copyright 2022 Google LLC. All Rights Reserved.
736
+ * Copyright 2019 Google LLC. All Rights Reserved.
737
737
  * Licensed under the Apache License, Version 2.0 (the "License");
738
738
  * you may not use this file except in compliance with the License.
739
739
  * You may obtain a copy of the License at
@@ -747,68 +747,47 @@ function Xt(e, t = e.length) {
747
747
  * limitations under the License.
748
748
  * =============================================================================
749
749
  */
750
- var H;
751
- (function(e) {
752
- e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS";
753
- })(H || (H = {}));
754
- function Qt(e, t, n) {
755
- let r = new Array();
756
- if (n == null && t == null)
757
- return r;
758
- if (t == null)
759
- for (; r.length < e + n.length; )
760
- r.push(-1);
761
- else
762
- r = t.slice();
763
- if (n == null)
764
- return r;
765
- if (e + n.length !== r.length)
766
- throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e + n.length}, but shape.rank = ${r.length}`);
767
- for (let o = 1; o < n.length; ++o) {
768
- const s = n[o], i = r[r.length - n.length + o], u = r[i];
769
- if (s >= 0)
770
- if (u >= 0) {
771
- if (u !== s)
772
- throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${o + e}] = ${s} but shape[${o + e}] = ${u}`);
773
- } else
774
- r[i] = s;
775
- }
776
- return r;
777
- }
778
- function Jt(e) {
779
- const t = {
780
- FIRST_DIM_SIZE: H.FIRST_DIM_SIZE,
781
- VALUE_ROWIDS: H.VALUE_ROWIDS,
782
- ROW_LENGTHS: H.ROW_LENGTHS,
783
- ROW_SPLITS: H.ROW_SPLITS,
784
- ROW_LIMITS: H.ROW_LIMITS,
785
- ROW_STARTS: H.ROW_STARTS
786
- }, n = [];
787
- for (const r of e)
788
- if (r in t)
789
- n.push(t[r]);
790
- else
791
- break;
792
- return n;
793
- }
794
- function Yt(e) {
795
- return e.length === 0 ? 0 : e[0] === H.FIRST_DIM_SIZE ? e.length - 1 : e.length;
750
+ function nt(e, t) {
751
+ Array.isArray(e) || (e = [e]), e.forEach((n) => {
752
+ n != null && qt(n.dtype !== "complex64", () => `${t} does not support complex64 tensors in the CPU backend.`);
753
+ });
796
754
  }
797
- function te(e, t) {
798
- if (e == null || t == null)
799
- return;
800
- const n = e.length, r = t.length;
801
- if (n >= r)
802
- throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`);
803
- for (let o = 0; o < Math.min(n, r - 1); ++o) {
804
- const s = e[o], i = t[o + 1];
805
- if (s >= 0 && i >= 0 && s !== 1 && s !== i)
806
- throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${o - e.length}] = ${s} but ragged tensor input.flatValues.shape[${o - e.length}] = ${i}`);
807
- }
755
+ /**
756
+ * @license
757
+ * Copyright 2020 Google LLC. All Rights Reserved.
758
+ * Licensed under the Apache License, Version 2.0 (the License);
759
+ * you may not use this file except in compliance with the License.
760
+ * You may obtain a copy of the License at
761
+ *
762
+ * http://www.apache.org/licenses/LICENSE-2.0
763
+ *
764
+ * Unless required by applicable law or agreed to in writing, software
765
+ * distributed under the License is distributed on an AS IS BASIS,
766
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
767
+ * See the License for the specific language governing permissions and
768
+ * limitations under the License.
769
+ * =============================================================================
770
+ */
771
+ function le(e) {
772
+ const t = new Float32Array(e.length);
773
+ for (let n = 0; n < e.length; ++n)
774
+ t[n] = Math.abs(e[n]);
775
+ return t;
808
776
  }
777
+ const On = (e) => {
778
+ const { x: t } = e.inputs, n = e.backend;
779
+ nt(t, "abs");
780
+ let s = new Float32Array(A(t.shape));
781
+ const o = n.data.get(t.dataId).values;
782
+ return s = le(o), n.makeOutput(s, t.shape, t.dtype);
783
+ }, Ys = {
784
+ kernelName: _e,
785
+ backendName: "cpu",
786
+ kernelFunc: On
787
+ };
809
788
  /**
810
789
  * @license
811
- * Copyright 2021 Google LLC. All Rights Reserved.
790
+ * Copyright 2020 Google LLC. All Rights Reserved.
812
791
  * Licensed under the Apache License, Version 2.0 (the "License");
813
792
  * you may not use this file except in compliance with the License.
814
793
  * You may obtain a copy of the License at
@@ -822,19 +801,27 @@ function te(e, t) {
822
801
  * limitations under the License.
823
802
  * =============================================================================
824
803
  */
825
- function ee(e) {
826
- return `Received SparseTensor with denseShape[0] = 0 but
827
- indices.shape[0] = ${e}`;
828
- }
829
- function ne(e, t) {
830
- return `indices(${e}, 0) is invalid: ${t} < 0`;
831
- }
832
- function re(e, t, n) {
833
- return `indices(${e}, 0) is invalid: ${t} >= ${n}`;
804
+ function W(e) {
805
+ return (t, n, s, o, a) => {
806
+ const r = Ut(t, n), i = r.length, l = K(r), u = A(r), h = et(a, u), f = t.length, p = n.length, I = K(t), m = K(n), F = ht(t, r), g = ht(n, r);
807
+ if (F.length + g.length === 0)
808
+ for (let d = 0; d < h.length; ++d)
809
+ h[d] = e(s[d % s.length], o[d % o.length]);
810
+ else
811
+ for (let d = 0; d < h.length; ++d) {
812
+ const b = gt(d, i, l), k = b.slice(-f);
813
+ F.forEach((C) => k[C] = 0);
814
+ const y = at(k, f, I), S = b.slice(-p);
815
+ g.forEach((C) => S[C] = 0);
816
+ const P = at(S, p, m);
817
+ h[d] = e(s[y], o[P]);
818
+ }
819
+ return [h, r];
820
+ };
834
821
  }
835
822
  /**
836
823
  * @license
837
- * Copyright 2021 Google LLC. All Rights Reserved.
824
+ * Copyright 2020 Google LLC. All Rights Reserved.
838
825
  * Licensed under the Apache License, Version 2.0 (the "License");
839
826
  * you may not use this file except in compliance with the License.
840
827
  * You may obtain a copy of the License at
@@ -848,27 +835,21 @@ function re(e, t, n) {
848
835
  * limitations under the License.
849
836
  * =============================================================================
850
837
  */
851
- function oe(e, t) {
852
- return `only one output dimension may be -1, not both ${e} and ${t}`;
853
- }
854
- function se(e, t) {
855
- return `size ${e} must be non-negative, not ${t}`;
856
- }
857
- function ie() {
858
- return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
859
- }
860
- function le(e, t) {
861
- const n = $(e), r = $(t);
862
- return `Input to reshape is a SparseTensor with ${n}
863
- dense values, but the requested shape requires a multiple of ${r}. inputShape=${e} outputShape= ${t}`;
864
- }
865
- function ue(e, t) {
866
- const n = $(e), r = $(t);
867
- return `Input to reshape is a tensor with ${n} dense values, but the requested shape has ${r}. inputShape=${e} outputShape=${t}`;
868
- }
838
+ function mt(e) {
839
+ const { inputs: t, backend: n } = e, { real: s, imag: o } = t, a = n.data.get(s.dataId).values, r = n.data.get(o.dataId).values, i = n.makeTensorInfo(s.shape, "complex64"), l = n.data.get(i.dataId);
840
+ return l.complexTensorInfos = {
841
+ real: n.makeTensorInfo(s.shape, "float32", a),
842
+ imag: n.makeTensorInfo(o.shape, "float32", r)
843
+ }, i;
844
+ }
845
+ const Js = {
846
+ kernelName: Ve,
847
+ backendName: "cpu",
848
+ kernelFunc: mt
849
+ };
869
850
  /**
870
851
  * @license
871
- * Copyright 2021 Google LLC. All Rights Reserved.
852
+ * Copyright 2020 Google LLC. All Rights Reserved.
872
853
  * Licensed under the Apache License, Version 2.0 (the "License");
873
854
  * you may not use this file except in compliance with the License.
874
855
  * You may obtain a copy of the License at
@@ -882,40 +863,39 @@ function ue(e, t) {
882
863
  * limitations under the License.
883
864
  * =============================================================================
884
865
  */
885
- function pt() {
886
- return "segment ids must be >= 0";
887
- }
888
- function ae() {
889
- return "segment ids are not increasing";
890
- }
891
- function he(e, t) {
892
- return `Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.`;
893
- }
894
- function ce(e, t, n) {
895
- return `Bad: indices[${e}] == ${t} out of range [0, ${n})`;
866
+ function xt(e, t, n = "float32") {
867
+ if (n === "complex64") {
868
+ const o = xt(e, t, "float32"), a = xt(e, t, "float32");
869
+ return mt({ inputs: { real: o, imag: a }, backend: e });
870
+ }
871
+ const s = st(A(t), n);
872
+ return e.makeTensorInfo(t, n, s);
896
873
  }
897
874
  /**
898
875
  * @license
899
876
  * Copyright 2020 Google LLC. All Rights Reserved.
900
- * Licensed under the Apache License, Version 2.0 (the License);
877
+ * Licensed under the Apache License, Version 2.0 (the "License");
901
878
  * you may not use this file except in compliance with the License.
902
879
  * You may obtain a copy of the License at
903
880
  *
904
881
  * http://www.apache.org/licenses/LICENSE-2.0
905
882
  *
906
883
  * Unless required by applicable law or agreed to in writing, software
907
- * distributed under the License is distributed on an AS IS BASIS,
884
+ * distributed under the License is distributed on an "AS IS" BASIS,
908
885
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
909
886
  * See the License for the specific language governing permissions and
910
887
  * limitations under the License.
911
888
  * =============================================================================
912
889
  */
913
- function fe(e) {
914
- const t = new Float32Array(e.length);
915
- for (let n = 0; n < e.length; ++n)
916
- t[n] = Math.abs(e[n]);
917
- return t;
918
- }
890
+ function Et(e) {
891
+ const { inputs: t, backend: n } = e, { x: s } = t;
892
+ return n.incRef(s.dataId), { dataId: s.dataId, shape: s.shape, dtype: s.dtype };
893
+ }
894
+ const Qs = {
895
+ kernelName: De,
896
+ backendName: "cpu",
897
+ kernelFunc: Et
898
+ };
919
899
  /**
920
900
  * @license
921
901
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -932,24 +912,15 @@ function fe(e) {
932
912
  * limitations under the License.
933
913
  * =============================================================================
934
914
  */
935
- function U(e) {
936
- return (t, n, r, o, s) => {
937
- const i = yt(t, n), u = i.length, a = Y(i), h = $(i), c = nt(s, h), f = t.length, p = n.length, I = Y(t), m = Y(n), b = dt(t, i), g = dt(n, i);
938
- if (b.length + g.length === 0)
939
- for (let d = 0; d < c.length; ++d)
940
- c[d] = e(r[d % r.length], o[d % o.length]);
941
- else
942
- for (let d = 0; d < c.length; ++d) {
943
- const E = gt(d, u, a), R = E.slice(-f);
944
- b.forEach((z) => R[z] = 0);
945
- const x = ht(R, f, I), D = E.slice(-p);
946
- g.forEach((z) => D[z] = 0);
947
- const V = ht(D, p, m);
948
- c[d] = e(r[x], o[V]);
949
- }
950
- return [c, i];
951
- };
952
- }
915
+ function ce(e) {
916
+ const { inputs: t, backend: n } = e, { input: s } = t, o = n.data.get(s.dataId).complexTensorInfos.real, a = n.data.get(o.dataId).values;
917
+ return n.makeTensorInfo(o.shape, o.dtype, a);
918
+ }
919
+ const to = {
920
+ kernelName: We,
921
+ backendName: "cpu",
922
+ kernelFunc: ce
923
+ };
953
924
  /**
954
925
  * @license
955
926
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -966,17 +937,41 @@ function U(e) {
966
937
  * limitations under the License.
967
938
  * =============================================================================
968
939
  */
969
- function ge(e, t, n, r) {
970
- if (r === "int32") {
940
+ function ue(e, t, n, s) {
941
+ if (s === "int32") {
971
942
  const o = Int32Array.from(e);
972
943
  return [t, "int32", o];
973
944
  }
974
- if (r === "bool") {
975
- const o = Lt([0], n), [s, i] = U((u, a) => u !== a ? 1 : 0)(t, [], e, o, "bool");
976
- return [i, "bool", s];
945
+ if (s === "bool") {
946
+ const o = Be([0], n), [a, r] = W((i, l) => i !== l ? 1 : 0)(t, [], e, o, "bool");
947
+ return [r, "bool", a];
977
948
  }
978
- throw new Error(`Error in Cast: failed to cast ${n} to ${r}`);
949
+ throw new Error(`Error in Cast: failed to cast ${n} to ${s}`);
979
950
  }
951
+ function lt(e) {
952
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { dtype: a } = s;
953
+ if (a === "complex64") {
954
+ if (o.dtype === "complex64")
955
+ return Et({ inputs: { x: o }, backend: n });
956
+ const h = xt(n, o.shape, o.dtype), f = lt({ inputs: { x: o }, backend: n, attrs: { dtype: "float32" } }), p = mt({ inputs: { real: f, imag: h }, backend: n });
957
+ return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(f), p;
958
+ }
959
+ if (o.dtype === "complex64") {
960
+ const h = ce({ inputs: { input: o }, backend: n }), f = lt({ inputs: { x: h }, backend: n, attrs: { dtype: a } });
961
+ return n.disposeIntermediateTensorInfo(h), f;
962
+ }
963
+ if (!ze(o.dtype, a)) {
964
+ const h = Et({ inputs: { x: o }, backend: n });
965
+ return { dataId: h.dataId, shape: h.shape, dtype: a };
966
+ }
967
+ const r = n.data.get(o.dataId).values, [i, l, u] = ue(r, o.shape, o.dtype, a);
968
+ return n.makeTensorInfo(i, l, u);
969
+ }
970
+ const eo = {
971
+ kernelName: $e,
972
+ backendName: "cpu",
973
+ kernelFunc: lt
974
+ };
980
975
  /**
981
976
  * @license
982
977
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -993,7 +988,49 @@ function ge(e, t, n, r) {
993
988
  * limitations under the License.
994
989
  * =============================================================================
995
990
  */
996
- const de = U((e, t) => e + t);
991
+ function z(e, t, n, s) {
992
+ return n == null ? ({ inputs: o, backend: a }) => {
993
+ const { a: r, b: i } = o, l = a;
994
+ nt([r, i], e);
995
+ const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = r.dtype === "string" ? (
996
+ // tslint:disable-next-line: no-any
997
+ it(u)
998
+ ) : u, p = r.dtype === "string" ? (
999
+ // tslint:disable-next-line: no-any
1000
+ it(h)
1001
+ ) : h, I = s || r.dtype, [m, F] = t(r.shape, i.shape, f, p, I);
1002
+ return l.makeTensorInfo(F, I, m);
1003
+ } : ({ inputs: o, backend: a }) => {
1004
+ const { a: r, b: i } = o, l = a;
1005
+ if (r.dtype === "complex64" || i.dtype === "complex64") {
1006
+ const u = lt({ inputs: { x: r }, backend: l, attrs: { dtype: "complex64" } }), h = l.data.get(u.dataId), f = h.complexTensorInfos.real, p = h.complexTensorInfos.imag, I = l.data.get(f.dataId).values, m = l.data.get(p.dataId).values, F = lt({ inputs: { x: i }, backend: l, attrs: { dtype: "complex64" } }), g = l.data.get(F.dataId), d = g.complexTensorInfos.real, b = g.complexTensorInfos.imag, k = l.data.get(d.dataId).values, y = l.data.get(b.dataId).values, [S, P, C] = n(r.shape, i.shape, I, m, k, y), v = l.makeTensorInfo(C, "float32", S), x = l.makeTensorInfo(C, "float32", P), w = mt({ inputs: { real: v, imag: x }, backend: l });
1007
+ return l.disposeIntermediateTensorInfo(u), l.disposeIntermediateTensorInfo(F), l.disposeIntermediateTensorInfo(v), l.disposeIntermediateTensorInfo(x), w;
1008
+ } else {
1009
+ const u = l.data.get(r.dataId).values, h = l.data.get(i.dataId).values, f = s || r.dtype, [p, I] = t(r.shape, i.shape, u, h, f);
1010
+ return l.makeTensorInfo(I, f, p);
1011
+ }
1012
+ };
1013
+ }
1014
+ function Ft(e) {
1015
+ return (t, n, s, o, a, r) => {
1016
+ const i = Ut(t, n), l = A(i), u = i.length, h = K(i), f = et("float32", l), p = et("float32", l), I = ht(t, i), m = ht(n, i), F = kt(s, o), g = kt(a, r), d = t.length, b = K(t), k = n.length, y = K(n);
1017
+ if (I.length + m.length === 0)
1018
+ for (let S = 0; S < f.length; S++) {
1019
+ const P = S % F.length, C = S % g.length, v = e(F[P * 2], F[P * 2 + 1], g[C * 2], g[C * 2 + 1]);
1020
+ f[S] = v.real, p[S] = v.imag;
1021
+ }
1022
+ else
1023
+ for (let S = 0; S < f.length; S++) {
1024
+ const P = gt(S, u, h), C = P.slice(-d);
1025
+ I.forEach((E) => C[E] = 0);
1026
+ const v = at(C, d, b), x = P.slice(-k);
1027
+ m.forEach((E) => x[E] = 0);
1028
+ const w = at(x, k, y), c = e(F[v * 2], F[v * 2 + 1], g[w * 2], g[w * 2 + 1]);
1029
+ f[S] = c.real, p[S] = c.imag;
1030
+ }
1031
+ return [f, p, i];
1032
+ };
1033
+ }
997
1034
  /**
998
1035
  * @license
999
1036
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1010,26 +1047,47 @@ const de = U((e, t) => e + t);
1010
1047
  * limitations under the License.
1011
1048
  * =============================================================================
1012
1049
  */
1013
- function me(e, t, n, r, o) {
1014
- const s = $(r), i = rt(o, n);
1015
- for (let u = 0; u < e.length; u++) {
1016
- const a = e[u];
1017
- if (a < 0)
1050
+ const he = W((e, t) => e + t), Ln = Ft((e, t, n, s) => ({ real: e + n, imag: t + s })), An = z(Mt, he, Ln), no = {
1051
+ kernelName: Mt,
1052
+ backendName: "cpu",
1053
+ kernelFunc: An
1054
+ };
1055
+ /**
1056
+ * @license
1057
+ * Copyright 2020 Google LLC. All Rights Reserved.
1058
+ * Licensed under the Apache License, Version 2.0 (the "License");
1059
+ * you may not use this file except in compliance with the License.
1060
+ * You may obtain a copy of the License at
1061
+ *
1062
+ * http://www.apache.org/licenses/LICENSE-2.0
1063
+ *
1064
+ * Unless required by applicable law or agreed to in writing, software
1065
+ * distributed under the License is distributed on an "AS IS" BASIS,
1066
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1067
+ * See the License for the specific language governing permissions and
1068
+ * limitations under the License.
1069
+ * =============================================================================
1070
+ */
1071
+ function _n(e, t, n, s, o) {
1072
+ const a = A(s), r = st(o, n);
1073
+ for (let i = 0; i < e.length; i++) {
1074
+ const l = e[i];
1075
+ if (l < 0)
1018
1076
  throw new Error("Input x must be non-negative!");
1019
- a >= o || (s > 0 ? i[a] += t[u] : i[a] += 1);
1077
+ l >= o || (a > 0 ? r[l] += t[i] : r[l] += 1);
1020
1078
  }
1021
- return i;
1079
+ return r;
1022
1080
  }
1023
- function we(e, t, n, r = !1) {
1024
- const o = e.shape[0], s = e.shape[1], i = k([o, n], t.dtype);
1025
- for (let u = 0; u < o; u++)
1026
- for (let a = 0; a < s; a++) {
1027
- const h = e.get(u, a);
1028
- if (h < 0)
1081
+ function Vn(e, t, n, s = !1) {
1082
+ const o = e.shape[0], a = e.shape[1], r = H([o, n], t.dtype);
1083
+ for (let i = 0; i < o; i++)
1084
+ for (let l = 0; l < a; l++) {
1085
+ const u = e.get(i, l);
1086
+ if (u < 0)
1029
1087
  throw new Error("Input x must be non-negative!");
1030
- h >= n || (r ? i.set(1, u, h) : t.size > 0 ? i.set(i.get(u, h) + t.get(u, a), u, h) : i.set(i.get(u, h) + 1, u, h));
1088
+ u >= n || (s ? r.set(1, i, u) : t.size > 0 ? r.set(r.get(i, u) + t.get(i, l), i, u) : r.set(r.get(i, u) + 1, i, u));
1031
1089
  }
1032
- return i;
1090
+ return r;
1033
1091
  }
1034
1092
  /**
1035
1093
  * @license
@@ -1047,7 +1105,11 @@ function we(e, t, n, r = !1) {
1047
1105
  * limitations under the License.
1048
1106
  * =============================================================================
1049
1107
  */
1050
- const pe = U((e, t) => e & t);
1108
+ const fe = W((e, t) => e & t), Dn = z(Ot, fe), so = {
1109
+ kernelName: Ot,
1110
+ backendName: "cpu",
1111
+ kernelFunc: Dn
1112
+ };
1051
1113
  /**
1052
1114
  * @license
1053
1115
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1064,14 +1126,50 @@ const pe = U((e, t) => e & t);
1064
1126
  * limitations under the License.
1065
1127
  * =============================================================================
1066
1128
  */
1067
- function K(e) {
1068
- return (t, n, r) => {
1069
- const o = q(n, t.length);
1070
- for (let s = 0; s < t.length; ++s)
1071
- o[s] = e(t[s], r);
1129
+ function X(e) {
1130
+ return (t, n, s) => {
1131
+ const o = D(n, t.length);
1132
+ for (let a = 0; a < t.length; ++a)
1133
+ o[a] = e(t[a], s);
1072
1134
  return o;
1073
1135
  };
1074
1136
  }
1137
+ /**
1138
+ * @license
1139
+ * Copyright 2020 Google LLC. All Rights Reserved.
1140
+ * Licensed under the Apache License, Version 2.0 (the "License");
1141
+ * you may not use this file except in compliance with the License.
1142
+ * You may obtain a copy of the License at
1143
+ *
1144
+ * http://www.apache.org/licenses/LICENSE-2.0
1145
+ *
1146
+ * Unless required by applicable law or agreed to in writing, software
1147
+ * distributed under the License is distributed on an "AS IS" BASIS,
1148
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1149
+ * See the License for the specific language governing permissions and
1150
+ * limitations under the License.
1151
+ * =============================================================================
1152
+ */
1153
+ function ge(e, t, n) {
1154
+ const s = X(t);
1155
+ return J(e, s, n);
1156
+ }
1157
+ function J(e, t, n) {
1158
+ return ({ inputs: s, attrs: o, backend: a }) => {
1159
+ const { x: r } = s;
1160
+ nt(r, e);
1161
+ const i = a, l = i.data.get(r.dataId).values;
1162
+ let u;
1163
+ if (r.dtype === "string") {
1164
+ if (!Array.isArray(l))
1165
+ throw new Error("String tensor's value was not an instance of Array");
1166
+ u = it(l);
1167
+ } else
1168
+ u = l;
1169
+ const h = n || r.dtype, f = t(u, h, o);
1170
+ return i.makeTensorInfo(r.shape, h, f);
1171
+ };
1172
+ }
1075
1173
  /**
1076
1174
  * @license
1077
1175
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1088,7 +1186,11 @@ function K(e) {
1088
1186
  * limitations under the License.
1089
1187
  * =============================================================================
1090
1188
  */
1091
- const Ie = K((e) => Math.ceil(e));
1189
+ const de = X((e) => Math.ceil(e)), Wn = J(Lt, de), oo = {
1190
+ kernelName: Lt,
1191
+ backendName: "cpu",
1192
+ kernelFunc: Wn
1193
+ };
1092
1194
  /**
1093
1195
  * @license
1094
1196
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1105,25 +1207,25 @@ const Ie = K((e) => Math.ceil(e));
1105
1207
  * limitations under the License.
1106
1208
  * =============================================================================
1107
1209
  */
1108
- function Ee(e, t, n, r) {
1109
- const o = q(n, $(t));
1110
- if (r && n !== "string") {
1111
- let s = 0;
1112
- e.forEach((i) => {
1113
- const u = $(i.shape);
1114
- o.set(i.vals, s), s += u;
1210
+ function $n(e, t, n, s) {
1211
+ const o = D(n, A(t));
1212
+ if (s && n !== "string") {
1213
+ let a = 0;
1214
+ e.forEach((r) => {
1215
+ const i = A(r.shape);
1216
+ o.set(r.vals, a), a += i;
1115
1217
  });
1116
1218
  } else {
1117
- let s = 0;
1118
- e.forEach((i) => {
1119
- const u = n === "string" ? bt(i.vals) : i.vals;
1120
- let a = 0;
1121
- for (let h = 0; h < i.shape[0]; ++h) {
1122
- const c = h * t[1] + s;
1123
- for (let f = 0; f < i.shape[1]; ++f)
1124
- o[c + f] = u[a++];
1219
+ let a = 0;
1220
+ e.forEach((r) => {
1221
+ const i = n === "string" ? it(r.vals) : r.vals;
1222
+ let l = 0;
1223
+ for (let u = 0; u < r.shape[0]; ++u) {
1224
+ const h = u * t[1] + a;
1225
+ for (let f = 0; f < r.shape[1]; ++f)
1226
+ o[h + f] = i[l++];
1125
1227
  }
1126
- s += i.shape[1];
1228
+ a += r.shape[1];
1127
1229
  });
1128
1230
  }
1129
1231
  return o;
@@ -1144,7 +1246,11 @@ function Ee(e, t, n, r) {
1144
1246
  * limitations under the License.
1145
1247
  * =============================================================================
1146
1248
  */
1147
- const Se = U((e, t) => e === t ? 1 : 0);
1249
+ const me = W((e, t) => e === t ? 1 : 0), zn = z(At, me, null, "bool"), ro = {
1250
+ kernelName: At,
1251
+ backendName: "cpu",
1252
+ kernelFunc: zn
1253
+ };
1148
1254
  /**
1149
1255
  * @license
1150
1256
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1161,7 +1267,11 @@ const Se = U((e, t) => e === t ? 1 : 0);
1161
1267
  * limitations under the License.
1162
1268
  * =============================================================================
1163
1269
  */
1164
- const Fe = K((e) => Math.exp(e));
1270
+ const pe = X((e) => Math.exp(e)), Bn = J(_t, pe, "float32"), ao = {
1271
+ kernelName: _t,
1272
+ backendName: "cpu",
1273
+ kernelFunc: Bn
1274
+ };
1165
1275
  /**
1166
1276
  * @license
1167
1277
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1178,7 +1288,11 @@ const Fe = K((e) => Math.exp(e));
1178
1288
  * limitations under the License.
1179
1289
  * =============================================================================
1180
1290
  */
1181
- const be = K((e) => Math.expm1(e));
1291
+ const Ie = X((e) => Math.expm1(e)), Gn = J(Vt, Ie), io = {
1292
+ kernelName: Vt,
1293
+ backendName: "cpu",
1294
+ kernelFunc: Gn
1295
+ };
1182
1296
  /**
1183
1297
  * @license
1184
1298
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1195,7 +1309,11 @@ const be = K((e) => Math.expm1(e));
1195
1309
  * limitations under the License.
1196
1310
  * =============================================================================
1197
1311
  */
1198
- const xe = K((e) => Math.floor(e));
1312
+ const we = X((e) => Math.floor(e)), jn = J(Dt, we), lo = {
1313
+ kernelName: Dt,
1314
+ backendName: "cpu",
1315
+ kernelFunc: jn
1316
+ };
1199
1317
  /**
1200
1318
  * @license
1201
1319
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1212,7 +1330,11 @@ const xe = K((e) => Math.floor(e));
1212
1330
  * limitations under the License.
1213
1331
  * =============================================================================
1214
1332
  */
1215
- const Re = U((e, t) => Math.floor(e / t));
1333
+ const be = W((e, t) => Math.floor(e / t)), Zn = z(Wt, be, null, "int32"), co = {
1334
+ kernelName: Wt,
1335
+ backendName: "cpu",
1336
+ kernelFunc: Zn
1337
+ };
1216
1338
  /**
1217
1339
  * @license
1218
1340
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1229,21 +1351,21 @@ const Re = U((e, t) => Math.floor(e / t));
1229
1351
  * limitations under the License.
1230
1352
  * =============================================================================
1231
1353
  */
1232
- function Te(e, t, n, r, o, s, i, u, a) {
1233
- const h = k([r, s], n);
1234
- for (let c = 0; c < r; c++) {
1354
+ function Hn(e, t, n, s, o, a, r, i, l) {
1355
+ const u = H([s, a], n);
1356
+ for (let h = 0; h < s; h++) {
1235
1357
  const f = [];
1236
1358
  let p = 0;
1237
1359
  for (let I = 0; I < o; I++) {
1238
- const m = e[c * o + I];
1239
- p += m * i[I], f.push(m);
1360
+ const m = e[h * o + I];
1361
+ p += m * r[I], f.push(m);
1240
1362
  }
1241
- if (p < 0 || p >= a / s)
1242
- throw new Error(`Invalid indices: ${f} does not index into ${u}`);
1243
- for (let I = 0; I < s; I++)
1244
- h.values[c * s + I] = t.get(...t.indexToLoc(p * s + I));
1363
+ if (p < 0 || p >= l / a)
1364
+ throw new Error(`Invalid indices: ${f} does not index into ${i}`);
1365
+ for (let I = 0; I < a; I++)
1366
+ u.values[h * a + I] = t.get(...t.indexToLoc(p * a + I));
1245
1367
  }
1246
- return h;
1368
+ return u;
1247
1369
  }
1248
1370
  /**
1249
1371
  * @license
@@ -1261,15 +1383,15 @@ function Te(e, t, n, r, o, s, i, u, a) {
1261
1383
  * limitations under the License.
1262
1384
  * =============================================================================
1263
1385
  */
1264
- function ve(e, t, n) {
1265
- const r = k(n, e.dtype);
1266
- for (let o = 0; o < r.size; ++o) {
1267
- const i = r.indexToLoc(o).slice(), u = i[0], a = i[2], h = t.locToIndex([u, a]);
1268
- i[2] = t.values[h];
1269
- const c = e.locToIndex(i);
1270
- 0 <= c && c < e.values.length && (r.values[o] = e.values[c]);
1386
+ function Kn(e, t, n) {
1387
+ const s = H(n, e.dtype);
1388
+ for (let o = 0; o < s.size; ++o) {
1389
+ const r = s.indexToLoc(o).slice(), i = r[0], l = r[2], u = t.locToIndex([i, l]);
1390
+ r[2] = t.values[u];
1391
+ const h = e.locToIndex(r);
1392
+ 0 <= h && h < e.values.length && (s.values[o] = e.values[h]);
1271
1393
  }
1272
- return r;
1394
+ return s;
1273
1395
  }
1274
1396
  /**
1275
1397
  * @license
@@ -1287,7 +1409,11 @@ function ve(e, t, n) {
1287
1409
  * limitations under the License.
1288
1410
  * =============================================================================
1289
1411
  */
1290
- const Oe = U((e, t) => e > t ? 1 : 0);
1412
+ const xe = W((e, t) => e > t ? 1 : 0), Xn = z($t, xe, null, "bool"), uo = {
1413
+ kernelName: $t,
1414
+ backendName: "cpu",
1415
+ kernelFunc: Xn
1416
+ };
1291
1417
  /**
1292
1418
  * @license
1293
1419
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1304,7 +1430,11 @@ const Oe = U((e, t) => e > t ? 1 : 0);
1304
1430
  * limitations under the License.
1305
1431
  * =============================================================================
1306
1432
  */
1307
- const _e = U((e, t) => e >= t ? 1 : 0);
1433
+ const Ee = W((e, t) => e >= t ? 1 : 0), Yn = z(zt, Ee, null, "bool"), ho = {
1434
+ kernelName: zt,
1435
+ backendName: "cpu",
1436
+ kernelFunc: Yn
1437
+ };
1308
1438
  /**
1309
1439
  * @license
1310
1440
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1321,7 +1451,11 @@ const _e = U((e, t) => e >= t ? 1 : 0);
1321
1451
  * limitations under the License.
1322
1452
  * =============================================================================
1323
1453
  */
1324
- const ye = U((e, t) => e < t ? 1 : 0);
1454
+ const Fe = W((e, t) => e < t ? 1 : 0), Jn = z(Bt, Fe, null, "bool"), fo = {
1455
+ kernelName: Bt,
1456
+ backendName: "cpu",
1457
+ kernelFunc: Jn
1458
+ };
1325
1459
  /**
1326
1460
  * @license
1327
1461
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1338,7 +1472,11 @@ const ye = U((e, t) => e < t ? 1 : 0);
1338
1472
  * limitations under the License.
1339
1473
  * =============================================================================
1340
1474
  */
1341
- const Le = U((e, t) => e <= t ? 1 : 0);
1475
+ const ye = W((e, t) => e <= t ? 1 : 0), Qn = z(Gt, ye, null, "bool"), go = {
1476
+ kernelName: Gt,
1477
+ backendName: "cpu",
1478
+ kernelFunc: Qn
1479
+ };
1342
1480
  /**
1343
1481
  * @license
1344
1482
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1355,11 +1493,11 @@ const Le = U((e, t) => e <= t ? 1 : 0);
1355
1493
  * limitations under the License.
1356
1494
  * =============================================================================
1357
1495
  */
1358
- function Me(e, t, n) {
1359
- const r = (t - e) / (n - 1), o = rt(n, "float32");
1496
+ function ts(e, t, n) {
1497
+ const s = (t - e) / (n - 1), o = st(n, "float32");
1360
1498
  o[0] = e;
1361
- for (let s = 1; s < o.length; s++)
1362
- o[s] = o[s - 1] + r;
1499
+ for (let a = 1; a < o.length; a++)
1500
+ o[a] = o[a - 1] + s;
1363
1501
  return o;
1364
1502
  }
1365
1503
  /**
@@ -1378,7 +1516,11 @@ function Me(e, t, n) {
1378
1516
  * limitations under the License.
1379
1517
  * =============================================================================
1380
1518
  */
1381
- const Ne = K((e) => Math.log(e));
1519
+ const ke = X((e) => Math.log(e)), es = J(jt, ke), mo = {
1520
+ kernelName: jt,
1521
+ backendName: "cpu",
1522
+ kernelFunc: es
1523
+ };
1382
1524
  /**
1383
1525
  * @license
1384
1526
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1395,16 +1537,16 @@ const Ne = K((e) => Math.log(e));
1395
1537
  * limitations under the License.
1396
1538
  * =============================================================================
1397
1539
  */
1398
- function $e(e, t, n, r) {
1399
- const o = nt(r, $(n));
1400
- for (let s = 0; s < o.length; ++s) {
1401
- const i = s * t;
1402
- let u = e[i];
1403
- for (let a = 0; a < t; ++a) {
1404
- const h = e[i + a];
1405
- (Number.isNaN(h) || h > u) && (u = h);
1540
+ function ns(e, t, n, s) {
1541
+ const o = et(s, A(n));
1542
+ for (let a = 0; a < o.length; ++a) {
1543
+ const r = a * t;
1544
+ let i = e[r];
1545
+ for (let l = 0; l < t; ++l) {
1546
+ const u = e[r + l];
1547
+ (Number.isNaN(u) || u > i) && (i = u);
1406
1548
  }
1407
- o[s] = u;
1549
+ o[a] = i;
1408
1550
  }
1409
1551
  return o;
1410
1552
  }
@@ -1424,7 +1566,11 @@ function $e(e, t, n, r) {
1424
1566
  * limitations under the License.
1425
1567
  * =============================================================================
1426
1568
  */
1427
- const Ae = U((e, t) => Math.max(e, t));
1569
+ const Ne = W((e, t) => Math.max(e, t)), ss = z(Zt, Ne), po = {
1570
+ kernelName: Zt,
1571
+ backendName: "cpu",
1572
+ kernelFunc: ss
1573
+ };
1428
1574
  /**
1429
1575
  * @license
1430
1576
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1441,7 +1587,11 @@ const Ae = U((e, t) => Math.max(e, t));
1441
1587
  * limitations under the License.
1442
1588
  * =============================================================================
1443
1589
  */
1444
- const De = U((e, t) => Math.min(e, t));
1590
+ const Se = W((e, t) => Math.min(e, t)), os = z(Ht, Se), Io = {
1591
+ kernelName: Ht,
1592
+ backendName: "cpu",
1593
+ kernelFunc: os
1594
+ };
1445
1595
  /**
1446
1596
  * @license
1447
1597
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1458,7 +1608,14 @@ const De = U((e, t) => Math.min(e, t));
1458
1608
  * limitations under the License.
1459
1609
  * =============================================================================
1460
1610
  */
1461
- const Ot = U((e, t) => e * t);
1611
+ const yt = W((e, t) => e * t), rs = Ft((e, t, n, s) => ({
1612
+ real: e * n - t * s,
1613
+ imag: e * s + t * n
1614
+ })), as = z(Kt, yt, rs), wo = {
1615
+ kernelName: Kt,
1616
+ backendName: "cpu",
1617
+ kernelFunc: as
1618
+ };
1462
1619
  /**
1463
1620
  * @license
1464
1621
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1475,10 +1632,21 @@ const Ot = U((e, t) => e * t);
1475
1632
  * limitations under the License.
1476
1633
  * =============================================================================
1477
1634
  */
1478
- function Pe(e, t, n) {
1479
- const r = Mt(-1, n);
1480
- return Ot([], t, r, e, n);
1481
- }
1635
+ function ve(e, t, n) {
1636
+ const s = je(-1, n);
1637
+ return yt([], t, s, e, n);
1638
+ }
1639
+ function is(e) {
1640
+ const { inputs: t, backend: n } = e, { x: s } = t;
1641
+ nt(s, "neg");
1642
+ const o = n.data.get(s.dataId).values, [a, r] = ve(o, s.shape, s.dtype);
1643
+ return n.makeTensorInfo(r, s.dtype, a);
1644
+ }
1645
+ const bo = {
1646
+ kernelName: Ge,
1647
+ backendName: "cpu",
1648
+ kernelFunc: is
1649
+ };
1482
1650
  /**
1483
1651
  * @license
1484
1652
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1495,7 +1663,11 @@ function Pe(e, t, n) {
1495
1663
  * limitations under the License.
1496
1664
  * =============================================================================
1497
1665
  */
1498
- const We = U((e, t) => e !== t ? 1 : 0);
1666
+ const Te = W((e, t) => e !== t ? 1 : 0), ls = z(Xt, Te, null, "bool"), xo = {
1667
+ kernelName: Xt,
1668
+ backendName: "cpu",
1669
+ kernelFunc: ls
1670
+ };
1499
1671
  /**
1500
1672
  * @license
1501
1673
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1512,16 +1684,16 @@ const We = U((e, t) => e !== t ? 1 : 0);
1512
1684
  * limitations under the License.
1513
1685
  * =============================================================================
1514
1686
  */
1515
- function qe(e, t, n, r, o) {
1516
- const s = t.length, i = $(t), u = Y(t), a = Y(o), h = nt(n, $(o));
1517
- for (let c = 0; c < i; ++c) {
1518
- const f = gt(c, s, u), p = new Array(f.length);
1687
+ function Re(e, t, n, s, o) {
1688
+ const a = t.length, r = A(t), i = K(t), l = K(o), u = et(n, A(o));
1689
+ for (let h = 0; h < r; ++h) {
1690
+ const f = gt(h, a, i), p = new Array(f.length);
1519
1691
  for (let m = 0; m < p.length; m++)
1520
- p[m] = f[r[m]];
1521
- const I = ht(p, s, a);
1522
- h[I] = e[c];
1692
+ p[m] = f[s[m]];
1693
+ const I = at(p, a, l);
1694
+ u[I] = e[h];
1523
1695
  }
1524
- return h;
1696
+ return u;
1525
1697
  }
1526
1698
  /**
1527
1699
  * @license
@@ -1539,17 +1711,63 @@ function qe(e, t, n, r, o) {
1539
1711
  * limitations under the License.
1540
1712
  * =============================================================================
1541
1713
  */
1542
- function Ve(e, t, n, r) {
1543
- const [o, s] = Wt(e, r), i = Nt(t, "int32"), u = rt($(o), i), a = $(s);
1544
- for (let h = 0; h < u.length; ++h) {
1545
- const c = h * a;
1714
+ function Pe(e) {
1715
+ const { inputs: t, attrs: n, backend: s } = e, { x: o } = t, { perm: a } = n;
1716
+ nt(o, "transpose");
1717
+ const r = o.shape.length, i = new Array(r);
1718
+ for (let f = 0; f < i.length; f++)
1719
+ i[f] = o.shape[a[f]];
1720
+ const l = s.data.get(o.dataId).values, u = Re(l, o.shape, o.dtype, a, i);
1721
+ return { dataId: s.write(u, i, o.dtype), shape: i, dtype: o.dtype };
1722
+ }
1723
+ const Eo = {
1724
+ kernelName: Ze,
1725
+ backendName: "cpu",
1726
+ kernelFunc: Pe
1727
+ };
1728
+ /**
1729
+ * @license
1730
+ * Copyright 2020 Google LLC. All Rights Reserved.
1731
+ * Licensed under the Apache License, Version 2.0 (the "License");
1732
+ * you may not use this file except in compliance with the License.
1733
+ * You may obtain a copy of the License at
1734
+ *
1735
+ * http://www.apache.org/licenses/LICENSE-2.0
1736
+ *
1737
+ * Unless required by applicable law or agreed to in writing, software
1738
+ * distributed under the License is distributed on an "AS IS" BASIS,
1739
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1740
+ * See the License for the specific language governing permissions and
1741
+ * limitations under the License.
1742
+ * =============================================================================
1743
+ */
1744
+ function Ce(e, t, n, s) {
1745
+ const [o, a] = bn(e, s), r = Ke(t, "int32"), i = st(A(o), r), l = A(a);
1746
+ for (let u = 0; u < i.length; ++u) {
1747
+ const h = u * l;
1546
1748
  let f = 1;
1547
- for (let p = 0; p < a; ++p)
1548
- f *= n[c + p];
1549
- u[h] = f;
1550
- }
1551
- return { outVals: u, outShape: o, outDtype: i };
1552
- }
1749
+ for (let p = 0; p < l; ++p)
1750
+ f *= n[h + p];
1751
+ i[u] = f;
1752
+ }
1753
+ return { outVals: i, outShape: o, outDtype: r };
1754
+ }
1755
+ function cs(e) {
1756
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { axis: a, keepDims: r } = s;
1757
+ nt(o, "prod");
1758
+ const i = o.shape.length, l = Yt(a, o.shape), u = pn(l, i);
1759
+ let h = l, f = o;
1760
+ const p = [];
1761
+ u != null && (f = Pe({ inputs: { x: o }, backend: n, attrs: { perm: u } }), p.push(f), h = In(h.length, i));
1762
+ const I = n.data.get(f.dataId).values, { outVals: m, outShape: F, outDtype: g } = Ce(f.shape, f.dtype, I, h);
1763
+ let d = F;
1764
+ return r && (d = wn(F, l)), p.forEach((b) => n.disposeIntermediateTensorInfo(b)), n.makeTensorInfo(d, g, m);
1765
+ }
1766
+ const Fo = {
1767
+ kernelName: He,
1768
+ backendName: "cpu",
1769
+ kernelFunc: cs
1770
+ };
1553
1771
  /**
1554
1772
  * @license
1555
1773
  * Copyright 2022 Google LLC. All Rights Reserved.
@@ -1566,96 +1784,96 @@ function Ve(e, t, n, r) {
1566
1784
  * limitations under the License.
1567
1785
  * =============================================================================
1568
1786
  */
1569
- function Ue(e, t, n) {
1570
- e.forEach((r, o) => {
1571
- if (r < 0 || r >= n) {
1572
- const s = gt(o, t.length, Y(t)).join(",");
1573
- throw new Error(`indices[${s}] = ${r} is not in [0, ${n})`);
1787
+ function us(e, t, n) {
1788
+ e.forEach((s, o) => {
1789
+ if (s < 0 || s >= n) {
1790
+ const a = gt(o, t.length, K(t)).join(",");
1791
+ throw new Error(`indices[${a}] = ${s} is not in [0, ${n})`);
1574
1792
  }
1575
1793
  });
1576
1794
  }
1577
- function ze(e, t) {
1795
+ function hs(e, t) {
1578
1796
  for (let n = 0; n < e.length; ++n) {
1579
- const r = e[n], o = n === e.length - 1 ? t : e[n + 1].length;
1580
- if (r.length === 0)
1797
+ const s = e[n], o = n === e.length - 1 ? t : e[n + 1].length;
1798
+ if (s.length === 0)
1581
1799
  throw new Error("Ragged splits may not be empty");
1582
- if (r[0] < 0)
1800
+ if (s[0] < 0)
1583
1801
  throw new Error("Ragged splits must be non-negative");
1584
- if (r[r.length - 1] > o)
1802
+ if (s[s.length - 1] > o)
1585
1803
  throw new Error("Ragged splits must not point past values");
1586
- for (let s = 1; s < r.length; ++s)
1587
- if (r[s - 1] > r[s])
1804
+ for (let a = 1; a < s.length; ++a)
1805
+ if (s[a - 1] > s[a])
1588
1806
  throw new Error("Ragged splits must be sorted in ascending order");
1589
1807
  }
1590
1808
  }
1591
- function Ge(e, t, n, r) {
1809
+ function fs(e, t, n, s) {
1592
1810
  const o = [];
1593
- let s = 0;
1594
- const i = t.length - 1 + n.length, u = new Array(i).fill(null).map(() => [0]);
1595
- ze(n, r);
1596
- let a = 1;
1597
- for (let h = 0; h < t.length - 1; ++h) {
1598
- a *= t[h];
1599
- const c = t[h + 1];
1600
- for (let f = 1; f < a + 1; ++f)
1601
- u[h].push(f * c);
1602
- }
1603
- for (let h = 0; h < e.length; ++h) {
1604
- let c = e[h], f = e[h] + 1;
1811
+ let a = 0;
1812
+ const r = t.length - 1 + n.length, i = new Array(r).fill(null).map(() => [0]);
1813
+ hs(n, s);
1814
+ let l = 1;
1815
+ for (let u = 0; u < t.length - 1; ++u) {
1816
+ l *= t[u];
1817
+ const h = t[u + 1];
1818
+ for (let f = 1; f < l + 1; ++f)
1819
+ i[u].push(f * h);
1820
+ }
1821
+ for (let u = 0; u < e.length; ++u) {
1822
+ let h = e[u], f = e[u] + 1;
1605
1823
  for (let p = 0; p < n.length; ++p) {
1606
1824
  const I = n[p], m = p + t.length - 1;
1607
1825
  if (m >= 0) {
1608
- const b = u[m], g = b[b.length - 1] - I[c];
1609
- for (let d = c; d < f; ++d)
1610
- u[m].push(I[d + 1] + g);
1826
+ const F = i[m], g = F[F.length - 1] - I[h];
1827
+ for (let d = h; d < f; ++d)
1828
+ i[m].push(I[d + 1] + g);
1611
1829
  }
1612
- c = I[c], f = I[f];
1830
+ h = I[h], f = I[f];
1613
1831
  }
1614
- f !== c && (o.push([c, f]), s += f - c);
1832
+ f !== h && (o.push([h, f]), a += f - h);
1615
1833
  }
1616
- return { outSplits: u, valueSlices: o, numValues: s };
1834
+ return { outSplits: i, valueSlices: o, numValues: a };
1617
1835
  }
1618
- function je(e) {
1836
+ function gs(e) {
1619
1837
  const t = [];
1620
1838
  for (let n = 0; n < e.length; ++n) {
1621
- const r = e[n].length, o = q("int32", r);
1622
- t.push(o), e[n].forEach((s, i) => o[i] = s);
1839
+ const s = e[n].length, o = D("int32", s);
1840
+ t.push(o), e[n].forEach((a, r) => o[r] = a);
1623
1841
  }
1624
1842
  return t;
1625
1843
  }
1626
- function It(e, t) {
1844
+ function Tt(e, t) {
1627
1845
  const n = e.slice(0, t);
1628
1846
  for (; n.length < t; )
1629
1847
  n.push(1);
1630
- for (let r = t; r < e.length; r++)
1631
- n[t - 1] *= e[r];
1848
+ for (let s = t; s < e.length; s++)
1849
+ n[t - 1] *= e[s];
1632
1850
  return n;
1633
1851
  }
1634
- function Ze(e, t, n, r, o, s) {
1635
- const i = It(t, 2)[1], u = It(s, 2)[1];
1636
- let a = 0;
1637
- for (const h of n)
1638
- for (let c = h[0]; c < h[1]; ++c) {
1639
- for (let f = 0; f < r; ++f)
1640
- o[a * u + f] = e[c * i + f];
1641
- ++a;
1852
+ function ds(e, t, n, s, o, a) {
1853
+ const r = Tt(t, 2)[1], i = Tt(a, 2)[1];
1854
+ let l = 0;
1855
+ for (const u of n)
1856
+ for (let h = u[0]; h < u[1]; ++h) {
1857
+ for (let f = 0; f < s; ++f)
1858
+ o[l * i + f] = e[h * r + f];
1859
+ ++l;
1642
1860
  }
1643
1861
  }
1644
- function Ce(e, t, n, r, o) {
1645
- const s = t.slice();
1646
- s[0] = o;
1647
- const i = q(n, $(s)), u = e.length, a = u === 0 ? 0 : u / t[0];
1648
- return Ze(e, t, r, a, i, s), [i, s];
1862
+ function ms(e, t, n, s, o) {
1863
+ const a = t.slice();
1864
+ a[0] = o;
1865
+ const r = D(n, A(a)), i = e.length, l = i === 0 ? 0 : i / t[0];
1866
+ return ds(e, t, s, l, r, a), [r, a];
1649
1867
  }
1650
- function Be(e, t, n, r, o, s, i, u) {
1868
+ function ps(e, t, n, s, o, a, r, i) {
1651
1869
  if (e.length === 0)
1652
1870
  throw new Error("paramsNestedSplits must be non empty");
1653
1871
  if (t[0].length === 0)
1654
1872
  throw new Error("Split tensors must not be scalars");
1655
- const a = t[0][0] - 1;
1656
- if (Ue(s, i, a), r.length === 0)
1873
+ const l = t[0][0] - 1;
1874
+ if (us(a, r, l), s.length === 0)
1657
1875
  throw new Error("params.rank must be nonzero");
1658
- const h = r[0], { outSplits: c, valueSlices: f, numValues: p } = Ge(s, i, e, h), I = je(c), m = Ce(n, r, o, f, p);
1876
+ const u = s[0], { outSplits: h, valueSlices: f, numValues: p } = fs(a, r, e, u), I = gs(h), m = ms(n, s, o, f, p);
1659
1877
  return [I, m[0], m[1]];
1660
1878
  }
1661
1879
  /**
@@ -1674,40 +1892,40 @@ function Be(e, t, n, r, o, s, i, u) {
1674
1892
  * limitations under the License.
1675
1893
  * =============================================================================
1676
1894
  */
1677
- const Et = 2147483647;
1678
- function ke(e, t, n, r, o, s, i) {
1895
+ const Rt = 2147483647;
1896
+ function Is(e, t, n, s, o, a, r) {
1679
1897
  if (t.length > 1)
1680
1898
  throw new Error("starts must be a scalar or vector");
1681
1899
  if (o.length > 1)
1682
1900
  throw new Error("limits must be a scalar or vector");
1683
- if (i.length > 1)
1901
+ if (r.length > 1)
1684
1902
  throw new Error("deltas must be a scalar or vector");
1685
- const u = t.length === 0, a = o.length === 0, h = i.length === 0, c = [];
1686
- u || c.push(t[0]), a || c.push(o[0]), h || c.push(i[0]);
1687
- for (let g = 1; g < c.length; ++g)
1688
- if (c[g] !== c[g - 1])
1903
+ const i = t.length === 0, l = o.length === 0, u = r.length === 0, h = [];
1904
+ i || h.push(t[0]), l || h.push(o[0]), u || h.push(r[0]);
1905
+ for (let g = 1; g < h.length; ++g)
1906
+ if (h[g] !== h[g - 1])
1689
1907
  throw new Error("starts, limits, and deltas must have the same shape");
1690
- const f = c.length === 0 ? 1 : c[0], p = q("int32", f + 1);
1908
+ const f = h.length === 0 ? 1 : h[0], p = D("int32", f + 1);
1691
1909
  p[0] = 0;
1692
1910
  for (let g = 0; g < f; ++g) {
1693
- const d = u ? e[0] : e[g], E = a ? r[0] : r[g], R = h ? s[0] : s[g];
1694
- if (R === 0)
1911
+ const d = i ? e[0] : e[g], b = l ? s[0] : s[g], k = u ? a[0] : a[g];
1912
+ if (k === 0)
1695
1913
  throw new Error("Requires delta != 0");
1696
- let x;
1697
- if (R > 0 && E < d || R < 0 && E > d)
1698
- x = 0;
1699
- else if (x = Math.ceil(Math.abs((E - d) / R)), x > Et)
1700
- throw new Error(`Requires ((limit - start) / delta) <= ${Et}`);
1701
- p[g + 1] = p[g] + x;
1702
- }
1703
- const I = p[f], m = q(n, I);
1704
- let b = 0;
1914
+ let y;
1915
+ if (k > 0 && b < d || k < 0 && b > d)
1916
+ y = 0;
1917
+ else if (y = Math.ceil(Math.abs((b - d) / k)), y > Rt)
1918
+ throw new Error(`Requires ((limit - start) / delta) <= ${Rt}`);
1919
+ p[g + 1] = p[g] + y;
1920
+ }
1921
+ const I = p[f], m = D(n, I);
1922
+ let F = 0;
1705
1923
  for (let g = 0; g < f; ++g) {
1706
1924
  const d = p[g + 1] - p[g];
1707
- let E = u ? e[0] : e[g];
1708
- const R = h ? s[0] : s[g];
1709
- for (let x = 0; x < d; ++x)
1710
- m[b++] = E, E += R;
1925
+ let b = i ? e[0] : e[g];
1926
+ const k = u ? a[0] : a[g];
1927
+ for (let y = 0; y < d; ++y)
1928
+ m[F++] = b, b += k;
1711
1929
  }
1712
1930
  return [p, m];
1713
1931
  }
@@ -1727,67 +1945,67 @@ function ke(e, t, n, r, o, s, i) {
1727
1945
  * limitations under the License.
1728
1946
  * =============================================================================
1729
1947
  */
1730
- var B = H;
1731
- class it {
1732
- constructor(t, n, r, o, s, i, u, a, h, c) {
1733
- this.shape = t, this.shapeShape = n, this.values = r, this.valuesShape = o, this.valuesDType = s, this.defaultValue = i, this.defaultValueShape = u, this.rowPartitionValues = a, this.rowPartitionValuesShapes = h, this.rowPartitionTypes = Jt(c), this.raggedRank = Yt(this.rowPartitionTypes);
1948
+ var Z = tn;
1949
+ class ft {
1950
+ constructor(t, n, s, o, a, r, i, l, u, h) {
1951
+ this.shape = t, this.shapeShape = n, this.values = s, this.valuesShape = o, this.valuesDType = a, this.defaultValue = r, this.defaultValueShape = i, this.rowPartitionValues = l, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = Je(h), this.raggedRank = Qe(this.rowPartitionTypes);
1734
1952
  }
1735
1953
  getRowPartitionTypeByDimension(t) {
1736
- return this.rowPartitionTypes[0] === B.FIRST_DIM_SIZE ? this.rowPartitionTypes[t + 1] : this.rowPartitionTypes[t];
1954
+ return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionTypes[t + 1] : this.rowPartitionTypes[t];
1737
1955
  }
1738
1956
  // Returns the relationship between dimension and dimension + 1.
1739
1957
  getRowPartitionTensor(t) {
1740
- return this.rowPartitionTypes[0] === B.FIRST_DIM_SIZE ? this.rowPartitionValues[t + 1] : this.rowPartitionValues[t];
1958
+ return this.rowPartitionTypes[0] === Z.FIRST_DIM_SIZE ? this.rowPartitionValues[t + 1] : this.rowPartitionValues[t];
1741
1959
  }
1742
1960
  getMaxWidth(t) {
1743
1961
  const n = this.getRowPartitionTensor(t - 1);
1744
1962
  switch (this.getRowPartitionTypeByDimension(t - 1)) {
1745
- case B.VALUE_ROWIDS:
1746
- return it.getMaxWidthValueRowID(n);
1747
- case B.ROW_SPLITS:
1748
- return it.getMaxWidthRowSplit(n);
1963
+ case Z.VALUE_ROWIDS:
1964
+ return ft.getMaxWidthValueRowID(n);
1965
+ case Z.ROW_SPLITS:
1966
+ return ft.getMaxWidthRowSplit(n);
1749
1967
  default:
1750
- throw new Error(`Cannot handle partition type ${B[this.getRowPartitionTypeByDimension(t - 1)]}`);
1968
+ throw new Error(`Cannot handle partition type ${Z[this.getRowPartitionTypeByDimension(t - 1)]}`);
1751
1969
  }
1752
1970
  }
1753
1971
  static getMaxWidthRowSplit(t) {
1754
1972
  const n = t.length;
1755
1973
  if (n === 0 || n === 1)
1756
1974
  return 0;
1757
- let r = 0;
1975
+ let s = 0;
1758
1976
  for (let o = 0; o < n - 1; ++o) {
1759
- const s = t[o + 1] - t[o];
1760
- s > r && (r = s);
1977
+ const a = t[o + 1] - t[o];
1978
+ a > s && (s = a);
1761
1979
  }
1762
- return r;
1980
+ return s;
1763
1981
  }
1764
1982
  static getMaxWidthValueRowID(t) {
1765
1983
  const n = t.length;
1766
1984
  if (n === 0)
1767
1985
  return 0;
1768
- let r = 0, o = t[0], s = 0;
1769
- for (let i = 1; i < n; ++i) {
1770
- const u = t[i];
1771
- u !== o && (o = u, s = Math.max(i - r, s), r = i);
1986
+ let s = 0, o = t[0], a = 0;
1987
+ for (let r = 1; r < n; ++r) {
1988
+ const i = t[r];
1989
+ i !== o && (o = i, a = Math.max(r - s, a), s = r);
1772
1990
  }
1773
- return Math.max(n - r, s);
1991
+ return Math.max(n - s, a);
1774
1992
  }
1775
- tensorShapeFromTensor(t, n, r = !0) {
1993
+ tensorShapeFromTensor(t, n, s = !0) {
1776
1994
  if (n.length === 0) {
1777
1995
  if (t[0] === -1)
1778
1996
  return [];
1779
1997
  throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
1780
1998
  }
1781
- return Ft(t, r);
1999
+ return Ct(t, s);
1782
2000
  }
1783
2001
  calculateOutputSize(t) {
1784
- const n = this.valuesShape, r = this.defaultValueShape;
1785
- te(r, n);
1786
- const o = this.tensorShapeFromTensor(this.shape, this.shapeShape), i = Qt(this.raggedRank, o, n);
1787
- i[0] < 0 && (i[0] = t);
1788
- for (let u = 1; u <= this.raggedRank; ++u)
1789
- i[u] < 0 && (i[u] = this.getMaxWidth(u));
1790
- return i;
2002
+ const n = this.valuesShape, s = this.defaultValueShape;
2003
+ en(s, n);
2004
+ const o = this.tensorShapeFromTensor(this.shape, this.shapeShape), r = nn(this.raggedRank, o, n);
2005
+ r[0] < 0 && (r[0] = t);
2006
+ for (let i = 1; i <= this.raggedRank; ++i)
2007
+ r[i] < 0 && (r[i] = this.getMaxWidth(i));
2008
+ return r;
1791
2009
  }
1792
2010
  /**
1793
2011
  * The outputIndex represents the index in the output tensor
@@ -1799,29 +2017,29 @@ class it {
1799
2017
  * If firstDimensionOutput = 11 instead, then:
1800
2018
  * result = [0 100 200 300 400 500 600 700 800 900]
1801
2019
  */
1802
- calculateFirstParentOutputIndex(t, n, r) {
1803
- const o = Math.min(t, r), s = [];
1804
- let i = 0;
1805
- for (let u = 0; u < o; ++u, i += n)
1806
- s.push(i);
1807
- for (let u = o; u < t; ++u)
1808
- s.push(-1);
1809
- return $t(s.length === t, () => "Final length of result must be equal to firstDimension."), s;
1810
- }
1811
- calculateOutputIndexRowSplit(t, n, r, o) {
1812
- const s = t.length, i = [];
1813
- for (let u = 0; u < s - 1; ++u) {
1814
- const a = t[u + 1] - t[u];
1815
- let h = Math.min(o, a), c = n[u];
1816
- c === -1 && (h = 0);
1817
- for (let f = 0; f < h; ++f)
1818
- i.push(c), c += r;
1819
- for (let f = 0; f < a - h; ++f)
1820
- i.push(-1);
2020
+ calculateFirstParentOutputIndex(t, n, s) {
2021
+ const o = Math.min(t, s), a = [];
2022
+ let r = 0;
2023
+ for (let i = 0; i < o; ++i, r += n)
2024
+ a.push(r);
2025
+ for (let i = o; i < t; ++i)
2026
+ a.push(-1);
2027
+ return qt(a.length === t, () => "Final length of result must be equal to firstDimension."), a;
2028
+ }
2029
+ calculateOutputIndexRowSplit(t, n, s, o) {
2030
+ const a = t.length, r = [];
2031
+ for (let i = 0; i < a - 1; ++i) {
2032
+ const l = t[i + 1] - t[i];
2033
+ let u = Math.min(o, l), h = n[i];
2034
+ h === -1 && (u = 0);
2035
+ for (let f = 0; f < u; ++f)
2036
+ r.push(h), h += s;
2037
+ for (let f = 0; f < l - u; ++f)
2038
+ r.push(-1);
1821
2039
  }
1822
- if (s > 0 && i.length !== t[s - 1])
2040
+ if (a > 0 && r.length !== t[a - 1])
1823
2041
  throw new Error("Invalid row split size.");
1824
- return i;
2042
+ return r;
1825
2043
  }
1826
2044
  // Calculate the output index of the first element of a list.
1827
2045
  // The parentOutputIndex is the same computation for the previous list.
@@ -1844,41 +2062,41 @@ class it {
1844
2062
  // result[6] = -1 because parentOutputIndex[valueRowIds[6]] == -1
1845
2063
  // result[7] = -1 because parentOutputIndex[valueRowIds[6]] == -1
1846
2064
  // result[8] = parentOutputIndex[valueRowIds[7]]
1847
- calculateOutputIndexValueRowID(t, n, r, o) {
1848
- const s = t.length, i = [];
1849
- if (s === 0)
2065
+ calculateOutputIndexValueRowID(t, n, s, o) {
2066
+ const a = t.length, r = [];
2067
+ if (a === 0)
1850
2068
  return [];
1851
- let u = 0, a = t[0];
1852
- if (a >= n.length)
1853
- throw new Error(`Got currentValueRowId=${a}, which is not less than ${n.length}`);
1854
- let h = n[a];
1855
- i.push(h);
1856
- for (let c = 1; c < s; ++c) {
1857
- const f = t[c];
1858
- if (f === a)
1859
- h >= 0 && (++u, u < o ? h += r : h = -1);
2069
+ let i = 0, l = t[0];
2070
+ if (l >= n.length)
2071
+ throw new Error(`Got currentValueRowId=${l}, which is not less than ${n.length}`);
2072
+ let u = n[l];
2073
+ r.push(u);
2074
+ for (let h = 1; h < a; ++h) {
2075
+ const f = t[h];
2076
+ if (f === l)
2077
+ u >= 0 && (++i, i < o ? u += s : u = -1);
1860
2078
  else {
1861
- if (u = 0, a = f, f >= n.length)
2079
+ if (i = 0, l = f, f >= n.length)
1862
2080
  throw new Error(`Got nextValueRowId=${f} which is not less than ${n.length}`);
1863
- h = n[f];
2081
+ u = n[f];
1864
2082
  }
1865
- i.push(h);
2083
+ r.push(u);
1866
2084
  }
1867
- if (i.length !== t.length)
2085
+ if (r.length !== t.length)
1868
2086
  throw new Error("Invalid row ids.");
1869
- return i;
1870
- }
1871
- calculateOutputIndex(t, n, r, o) {
1872
- const s = this.getRowPartitionTensor(t), i = this.getRowPartitionTypeByDimension(t);
1873
- switch (i) {
1874
- case B.VALUE_ROWIDS:
1875
- return this.calculateOutputIndexValueRowID(s, n, r, o);
1876
- case B.ROW_SPLITS:
1877
- if (s.length - 1 > n.length)
1878
- throw new Error(`Row partition size is greater than output size: ${s.length - 1} > ${n.length}`);
1879
- return this.calculateOutputIndexRowSplit(s, n, r, o);
2087
+ return r;
2088
+ }
2089
+ calculateOutputIndex(t, n, s, o) {
2090
+ const a = this.getRowPartitionTensor(t), r = this.getRowPartitionTypeByDimension(t);
2091
+ switch (r) {
2092
+ case Z.VALUE_ROWIDS:
2093
+ return this.calculateOutputIndexValueRowID(a, n, s, o);
2094
+ case Z.ROW_SPLITS:
2095
+ if (a.length - 1 > n.length)
2096
+ throw new Error(`Row partition size is greater than output size: ${a.length - 1} > ${n.length}`);
2097
+ return this.calculateOutputIndexRowSplit(a, n, s, o);
1880
2098
  default:
1881
- throw new Error(`Unsupported partition type: ${B[i]}`);
2099
+ throw new Error(`Unsupported partition type: ${Z[r]}`);
1882
2100
  }
1883
2101
  }
1884
2102
  getFirstDimensionSize() {
@@ -1887,94 +2105,94 @@ class it {
1887
2105
  throw new Error("No row_partition_types given.");
1888
2106
  const n = this.rowPartitionTypes[0];
1889
2107
  switch (n) {
1890
- case B.FIRST_DIM_SIZE:
2108
+ case Z.FIRST_DIM_SIZE:
1891
2109
  return t[0];
1892
- case B.VALUE_ROWIDS:
2110
+ case Z.VALUE_ROWIDS:
1893
2111
  throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
1894
- case B.ROW_SPLITS:
2112
+ case Z.ROW_SPLITS:
1895
2113
  return this.rowPartitionValuesShapes[0][0] - 1;
1896
2114
  default:
1897
- throw new Error(`Cannot handle type ${B[n]}`);
2115
+ throw new Error(`Cannot handle type ${Z[n]}`);
1898
2116
  }
1899
2117
  }
1900
2118
  compute() {
1901
2119
  if (this.rowPartitionValues[0].length <= 0)
1902
2120
  throw new Error("Invalid first partition input. Tensor requires at least one element.");
1903
- const n = this.getFirstDimensionSize(), r = this.calculateOutputSize(n), o = new Array(this.raggedRank + 1);
2121
+ const n = this.getFirstDimensionSize(), s = this.calculateOutputSize(n), o = new Array(this.raggedRank + 1);
1904
2122
  o[o.length - 1] = 1;
1905
- for (let a = o.length - 2; a >= 0; --a)
1906
- o[a] = o[a + 1] * r[a + 1];
1907
- const s = Ft(r, !1), i = q(this.valuesDType, $(s));
1908
- if (o[0] * r[0] > 0) {
1909
- let a = this.calculateFirstParentOutputIndex(n, o[0], r[0]);
1910
- for (let h = 1; h <= this.raggedRank; ++h)
1911
- a = this.calculateOutputIndex(h - 1, a, o[h], r[h]);
1912
- this.setOutput(this.raggedRank, a, i, s);
2123
+ for (let l = o.length - 2; l >= 0; --l)
2124
+ o[l] = o[l + 1] * s[l + 1];
2125
+ const a = Ct(s, !1), r = D(this.valuesDType, A(a));
2126
+ if (o[0] * s[0] > 0) {
2127
+ let l = this.calculateFirstParentOutputIndex(n, o[0], s[0]);
2128
+ for (let u = 1; u <= this.raggedRank; ++u)
2129
+ l = this.calculateOutputIndex(u - 1, l, o[u], s[u]);
2130
+ this.setOutput(this.raggedRank, l, r, a);
1913
2131
  }
1914
- return [s, i];
2132
+ return [a, r];
1915
2133
  }
1916
- setOutput(t, n, r, o) {
1917
- if (r.length === 0)
2134
+ setOutput(t, n, s, o) {
2135
+ if (s.length === 0)
1918
2136
  return;
1919
- const s = this.values, i = r;
1920
- let u = o.slice();
1921
- u = u.slice(t + 1);
1922
- const a = $(u), h = n.length;
1923
- let c = this.defaultValue;
1924
- if (c.length !== a && c.length !== 1) {
2137
+ const a = this.values, r = s;
2138
+ let i = o.slice();
2139
+ i = i.slice(t + 1);
2140
+ const l = A(i), u = n.length;
2141
+ let h = this.defaultValue;
2142
+ if (h.length !== l && h.length !== 1) {
1925
2143
  const m = this.defaultValueShape;
1926
- At(() => {
1927
- const b = Vt(c, m);
1928
- c = qt(b, u).dataSync();
2144
+ Xe(() => {
2145
+ const F = En(h, m);
2146
+ h = xn(F, i).dataSync();
1929
2147
  });
1930
2148
  }
1931
2149
  let f = 0, p = 0, I = 0;
1932
- for (let m = 0; m <= h; ++m) {
1933
- let b = m < h ? n[m] : -1;
1934
- if (b === I) {
2150
+ for (let m = 0; m <= u; ++m) {
2151
+ let F = m < u ? n[m] : -1;
2152
+ if (F === I) {
1935
2153
  ++I;
1936
2154
  continue;
1937
2155
  }
1938
2156
  if (p < I) {
1939
- const g = s.subarray(f * a), d = i.subarray(p * a), E = (I - p) * a;
1940
- St(d, g, E);
2157
+ const g = a.subarray(f * l), d = r.subarray(p * l), b = (I - p) * l;
2158
+ Pt(d, g, b);
1941
2159
  }
1942
- if (m >= h) {
1943
- const g = r.length;
1944
- b = Math.floor(g / a);
2160
+ if (m >= u) {
2161
+ const g = s.length;
2162
+ F = Math.floor(g / l);
1945
2163
  }
1946
- if (b > I)
2164
+ if (F > I)
1947
2165
  if (this.defaultValue.length === 1)
1948
- i.subarray(I * a, b * a).fill(this.defaultValue[0]), I = b;
2166
+ r.subarray(I * l, F * l).fill(this.defaultValue[0]), I = F;
1949
2167
  else
1950
- for (; b > I; ) {
1951
- const g = i.slice(I * a);
1952
- St(g, c, a), ++I;
2168
+ for (; F > I; ) {
2169
+ const g = r.slice(I * l);
2170
+ Pt(g, h, l), ++I;
1953
2171
  }
1954
- b < 0 ? (f = m + 1, p = I) : (f = m, p = I, I = p + 1);
2172
+ F < 0 ? (f = m + 1, p = I) : (f = m, p = I, I = p + 1);
1955
2173
  }
1956
2174
  }
1957
2175
  }
1958
- function St(e, t, n) {
1959
- for (let r = 0; r < n; r++)
1960
- e[r] = t[r];
2176
+ function Pt(e, t, n) {
2177
+ for (let s = 0; s < n; s++)
2178
+ e[s] = t[s];
1961
2179
  }
1962
- function Ft(e, t) {
2180
+ function Ct(e, t) {
1963
2181
  const n = [];
1964
- for (let r of e) {
1965
- if (r < 0) {
2182
+ for (let s of e) {
2183
+ if (s < 0) {
1966
2184
  if (!t)
1967
- throw new Error(`Dimension ${r} must be >= 0`);
1968
- if (r < -1)
1969
- throw new Error(`Dimension ${r} must be >= -1`);
1970
- r = -1;
2185
+ throw new Error(`Dimension ${s} must be >= 0`);
2186
+ if (s < -1)
2187
+ throw new Error(`Dimension ${s} must be >= -1`);
2188
+ s = -1;
1971
2189
  }
1972
- n.push(r);
2190
+ n.push(s);
1973
2191
  }
1974
2192
  return n;
1975
2193
  }
1976
- function He(e, t, n, r, o, s, i, u, a, h) {
1977
- return new it(e, t, n, r, o, s, i, u, a, h).compute();
2194
+ function ws(e, t, n, s, o, a, r, i, l, u) {
2195
+ return new ft(e, t, n, s, o, a, r, i, l, u).compute();
1978
2196
  }
1979
2197
  /**
1980
2198
  * @license
@@ -1992,15 +2210,15 @@ function He(e, t, n, r, o, s, i, u, a, h) {
1992
2210
  * limitations under the License.
1993
2211
  * =============================================================================
1994
2212
  */
1995
- function Ke(e, t, n, r) {
1996
- const o = e === t, s = e < t && n < 0, i = t < e && n > 1;
1997
- if (o || s || i)
1998
- return rt(0, r);
1999
- const u = Math.abs(Math.ceil((t - e) / n)), a = rt(u, r);
2000
- t < e && n === 1 && (n = -1), a[0] = e;
2001
- for (let h = 1; h < a.length; h++)
2002
- a[h] = a[h - 1] + n;
2003
- return a;
2213
+ function bs(e, t, n, s) {
2214
+ const o = e === t, a = e < t && n < 0, r = t < e && n > 1;
2215
+ if (o || a || r)
2216
+ return st(0, s);
2217
+ const i = Math.abs(Math.ceil((t - e) / n)), l = st(i, s);
2218
+ t < e && n === 1 && (n = -1), l[0] = e;
2219
+ for (let u = 1; u < l.length; u++)
2220
+ l[u] = l[u - 1] + n;
2221
+ return l;
2004
2222
  }
2005
2223
  /**
2006
2224
  * @license
@@ -2018,7 +2236,11 @@ function Ke(e, t, n, r) {
2018
2236
  * limitations under the License.
2019
2237
  * =============================================================================
2020
2238
  */
2021
- const Xe = K((e) => 1 / Math.sqrt(e));
2239
+ const qe = X((e) => 1 / Math.sqrt(e)), xs = J(Jt, qe), yo = {
2240
+ kernelName: Jt,
2241
+ backendName: "cpu",
2242
+ kernelFunc: xs
2243
+ };
2022
2244
  /**
2023
2245
  * @license
2024
2246
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2035,23 +2257,23 @@ const Xe = K((e) => 1 / Math.sqrt(e));
2035
2257
  * limitations under the License.
2036
2258
  * =============================================================================
2037
2259
  */
2038
- function Qe(e, t, n, r, o, s, i, u, a, h) {
2039
- const c = [r / o, o], f = e.values, p = t.values;
2040
- if (r === 0)
2041
- return k(n, t.dtype);
2042
- const I = a instanceof ct ? a : k(c, t.dtype);
2043
- typeof a == "string" || typeof a == "number" ? I.values.fill(a) : typeof a == "boolean" && I.values.fill(+a);
2044
- for (let m = 0; m < s; m++) {
2045
- const b = [];
2260
+ function Es(e, t, n, s, o, a, r, i, l, u) {
2261
+ const h = [s / o, o], f = e.values, p = t.values;
2262
+ if (s === 0)
2263
+ return H(n, t.dtype);
2264
+ const I = l instanceof wt ? l : H(h, t.dtype);
2265
+ typeof l == "string" || typeof l == "number" ? I.values.fill(l) : typeof l == "boolean" && I.values.fill(+l);
2266
+ for (let m = 0; m < a; m++) {
2267
+ const F = [];
2046
2268
  let g = 0;
2047
- for (let d = 0; d < i; d++) {
2048
- const E = f[m * i + d];
2049
- b.push(E), g += E * u[d];
2269
+ for (let d = 0; d < r; d++) {
2270
+ const b = f[m * r + d];
2271
+ F.push(b), g += b * i[d];
2050
2272
  }
2051
- if (g < 0 || g >= r / o)
2052
- throw new Error(`Invalid indices: ${b} does not index into ${n}`);
2273
+ if (g < 0 || g >= s / o)
2274
+ throw new Error(`Invalid indices: ${F} does not index into ${n}`);
2053
2275
  for (let d = 0; d < o; d++)
2054
- h ? I.values[g * o + d] += p[m * o + d] : I.values[g * o + d] = t.rank === 0 ? p[0] : p[m * o + d];
2276
+ u ? I.values[g * o + d] += p[m * o + d] : I.values[g * o + d] = t.rank === 0 ? p[0] : p[m * o + d];
2055
2277
  }
2056
2278
  return I;
2057
2279
  }
@@ -2071,7 +2293,11 @@ function Qe(e, t, n, r, o, s, i, u, a, h) {
2071
2293
  * limitations under the License.
2072
2294
  * =============================================================================
2073
2295
  */
2074
- const Je = K((e) => 1 / (1 + Math.exp(-e)));
2296
+ const Fs = X((e) => 1 / (1 + Math.exp(-e))), ys = ge(Qt, (e) => 1 / (1 + Math.exp(-e))), ko = {
2297
+ kernelName: Qt,
2298
+ backendName: "cpu",
2299
+ kernelFunc: ys
2300
+ };
2075
2301
  /**
2076
2302
  * @license
2077
2303
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2088,19 +2314,32 @@ const Je = K((e) => 1 / (1 + Math.exp(-e)));
2088
2314
  * limitations under the License.
2089
2315
  * =============================================================================
2090
2316
  */
2091
- function Ye(e, t, n, r, o) {
2092
- const s = Ut(r, t, n), i = $(n), u = Y(r);
2093
- if (s) {
2094
- const f = zt(t, u);
2095
- return o === "string" ? e.slice(f, f + i) : e.subarray(f, f + i);
2096
- }
2097
- const a = o === "string" ? bt(e) : e, h = k(r, o, a), c = k(n, o);
2098
- for (let f = 0; f < c.size; ++f) {
2099
- const p = c.indexToLoc(f), I = p.map((m, b) => m + t[b]);
2100
- c.set(h.get(...I), ...p);
2101
- }
2102
- return o === "string" ? Pt(c.values) : c.values;
2103
- }
2317
+ function Ue(e, t, n, s, o) {
2318
+ const a = kn(s, t, n), r = A(n), i = K(s);
2319
+ if (a) {
2320
+ const f = Nn(t, i);
2321
+ return o === "string" ? e.slice(f, f + r) : e.subarray(f, f + r);
2322
+ }
2323
+ const l = o === "string" ? it(e) : e, u = H(s, o, l), h = H(n, o);
2324
+ for (let f = 0; f < h.size; ++f) {
2325
+ const p = h.indexToLoc(f), I = p.map((m, F) => m + t[F]);
2326
+ h.set(u.get(...I), ...p);
2327
+ }
2328
+ return o === "string" ? sn(h.values) : h.values;
2329
+ }
2330
+ function ks(e) {
2331
+ const { inputs: t, backend: n, attrs: s } = e, { x: o } = t, { begin: a, size: r } = s;
2332
+ nt(o, "slice");
2333
+ const [i, l] = Fn(o, a, r);
2334
+ yn(o, i, l);
2335
+ const u = n.data.get(o.dataId).values, h = Ue(u, i, l, o.shape, o.dtype);
2336
+ return n.makeTensorInfo(l, o.dtype, h);
2337
+ }
2338
+ const No = {
2339
+ kernelName: Ye,
2340
+ backendName: "cpu",
2341
+ kernelFunc: ks
2342
+ };
2104
2343
  /**
2105
2344
  * @license
2106
2345
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -2117,69 +2356,69 @@ function Ye(e, t, n, r, o) {
2117
2356
  * limitations under the License.
2118
2357
  * =============================================================================
2119
2358
  */
2120
- function tn(e, t, n, r, o, s, i) {
2121
- const u = t[0], a = s[0], h = new Array(a), c = new Array(u), f = t[1];
2122
- if (a === 0) {
2123
- if (u !== 0)
2124
- throw new Error(ee(u));
2125
- const g = q(n, 0), d = q(o, 0);
2359
+ function Ns(e, t, n, s, o, a, r) {
2360
+ const i = t[0], l = a[0], u = new Array(l), h = new Array(i), f = t[1];
2361
+ if (l === 0) {
2362
+ if (i !== 0)
2363
+ throw new Error(on(i));
2364
+ const g = D(n, 0), d = D(o, 0);
2126
2365
  return [
2127
2366
  g,
2128
2367
  [0, f],
2129
2368
  d,
2130
- h,
2131
- c
2369
+ u,
2370
+ h
2132
2371
  ];
2133
2372
  }
2134
2373
  let p = !0, I = 0;
2135
- const m = new Array(a).fill(0);
2136
- for (let g = 0; g < u; ++g) {
2374
+ const m = new Array(l).fill(0);
2375
+ for (let g = 0; g < i; ++g) {
2137
2376
  const d = e[g * f];
2138
2377
  if (d < 0)
2139
- throw new Error(ne(g, d));
2140
- if (d >= a)
2141
- throw new Error(re(g, d, a));
2378
+ throw new Error(rn(g, d));
2379
+ if (d >= l)
2380
+ throw new Error(an(g, d, l));
2142
2381
  ++m[d], p = p && d >= I, I = d;
2143
2382
  }
2144
- let b = !0;
2145
- for (let g = 0; g < a; ++g) {
2383
+ let F = !0;
2384
+ for (let g = 0; g < l; ++g) {
2146
2385
  const d = m[g] === 0;
2147
- h[g] = d, b = b && !d, m[g] = Math.max(m[g], 1), g > 0 && (m[g] += m[g - 1]);
2386
+ u[g] = d, F = F && !d, m[g] = Math.max(m[g], 1), g > 0 && (m[g] += m[g - 1]);
2148
2387
  }
2149
- if (b && p) {
2150
- const g = e, d = r;
2151
- for (let E = 0; E < u; ++E)
2152
- c[E] = E;
2388
+ if (F && p) {
2389
+ const g = e, d = s;
2390
+ for (let b = 0; b < i; ++b)
2391
+ h[b] = b;
2153
2392
  return [
2154
2393
  g,
2155
- [u, f],
2394
+ [i, f],
2156
2395
  d,
2157
- h,
2158
- c
2396
+ u,
2397
+ h
2159
2398
  ];
2160
2399
  } else {
2161
- const g = m[a - 1], d = q(n, g * f), E = q(o, g), R = new Array(a).fill(0);
2162
- for (let x = 0; x < u; ++x) {
2163
- const D = e[x * f], V = R[D], z = (D === 0 ? 0 : m[D - 1]) + V;
2164
- R[D]++;
2165
- for (let L = 0; L < f; ++L)
2166
- d[z * f + L] = e[x * f + L];
2167
- E[z] = r[x], c[x] = z;
2400
+ const g = m[l - 1], d = D(n, g * f), b = D(o, g), k = new Array(l).fill(0);
2401
+ for (let y = 0; y < i; ++y) {
2402
+ const S = e[y * f], P = k[S], C = (S === 0 ? 0 : m[S - 1]) + P;
2403
+ k[S]++;
2404
+ for (let v = 0; v < f; ++v)
2405
+ d[C * f + v] = e[y * f + v];
2406
+ b[C] = s[y], h[y] = C;
2168
2407
  }
2169
- for (let x = 0; x < a; ++x)
2170
- if (R[x] === 0) {
2171
- const V = x === 0 ? 0 : m[x - 1];
2172
- d[V * f + 0] = x;
2173
- for (let z = 1; z < f; ++z)
2174
- d[V * f + z] = 0;
2175
- E[V] = i;
2408
+ for (let y = 0; y < l; ++y)
2409
+ if (k[y] === 0) {
2410
+ const P = y === 0 ? 0 : m[y - 1];
2411
+ d[P * f + 0] = y;
2412
+ for (let C = 1; C < f; ++C)
2413
+ d[P * f + C] = 0;
2414
+ b[P] = r;
2176
2415
  }
2177
2416
  return [
2178
2417
  d,
2179
2418
  [g, f],
2180
- E,
2181
- h,
2182
- c
2419
+ b,
2420
+ u,
2421
+ h
2183
2422
  ];
2184
2423
  }
2185
2424
  }
@@ -2199,52 +2438,52 @@ function tn(e, t, n, r, o, s, i) {
2199
2438
  * limitations under the License.
2200
2439
  * =============================================================================
2201
2440
  */
2202
- function en(e, t, n, r, o) {
2203
- const s = $(r), i = t[0], u = o.length, a = [];
2204
- let h = 1, c = -1;
2205
- for (let g = 0; g < u; ++g) {
2441
+ function Ss(e, t, n, s, o) {
2442
+ const a = A(s), r = t[0], i = o.length, l = [];
2443
+ let u = 1, h = -1;
2444
+ for (let g = 0; g < i; ++g) {
2206
2445
  const d = o[g];
2207
2446
  if (d === -1) {
2208
- if (c !== -1)
2209
- throw new Error(oe(c, g));
2210
- c = g, a.push(1);
2447
+ if (h !== -1)
2448
+ throw new Error(ln(h, g));
2449
+ h = g, l.push(1);
2211
2450
  } else {
2212
2451
  if (d < 0)
2213
- throw new Error(se(g, d));
2214
- h *= d, a.push(d);
2452
+ throw new Error(cn(g, d));
2453
+ u *= d, l.push(d);
2215
2454
  }
2216
2455
  }
2217
- if (c !== -1) {
2218
- if (h <= 0)
2219
- throw new Error(ie());
2220
- const g = Math.trunc(s / h);
2221
- if (h * g !== s)
2222
- throw new Error(le(r, a));
2223
- a[c] = g;
2224
- }
2225
- if ($(a) !== s)
2226
- throw new Error(ue(r, a));
2227
- const p = r.length, I = [];
2456
+ if (h !== -1) {
2457
+ if (u <= 0)
2458
+ throw new Error(un());
2459
+ const g = Math.trunc(a / u);
2460
+ if (u * g !== a)
2461
+ throw new Error(hn(s, l));
2462
+ l[h] = g;
2463
+ }
2464
+ if (A(l) !== a)
2465
+ throw new Error(fn(s, l));
2466
+ const p = s.length, I = [];
2228
2467
  if (p > 0) {
2229
2468
  I[p - 1] = 1;
2230
2469
  for (let g = p - 2; g >= 0; --g)
2231
- I[g] = I[g + 1] * r[g + 1];
2470
+ I[g] = I[g + 1] * s[g + 1];
2232
2471
  }
2233
2472
  const m = [];
2234
- if (u > 0) {
2235
- m[u - 1] = 1;
2236
- for (let g = u - 2; g >= 0; --g)
2237
- m[g] = m[g + 1] * a[g + 1];
2473
+ if (i > 0) {
2474
+ m[i - 1] = 1;
2475
+ for (let g = i - 2; g >= 0; --g)
2476
+ m[g] = m[g + 1] * l[g + 1];
2238
2477
  }
2239
- const b = q(n, i * u);
2240
- for (let g = 0; g < i; ++g) {
2478
+ const F = D(n, r * i);
2479
+ for (let g = 0; g < r; ++g) {
2241
2480
  let d = 0;
2242
- for (let E = 0; E < p; ++E)
2243
- d += e[g * p + E] * I[E];
2244
- for (let E = 0; E < u; ++E)
2245
- b[g * u + E] = Math.trunc(d / m[E]), d %= m[E];
2481
+ for (let b = 0; b < p; ++b)
2482
+ d += e[g * p + b] * I[b];
2483
+ for (let b = 0; b < i; ++b)
2484
+ F[g * i + b] = Math.trunc(d / m[b]), d %= m[b];
2246
2485
  }
2247
- return [b, [i, u], a];
2486
+ return [F, [r, i], l];
2248
2487
  }
2249
2488
  /**
2250
2489
  * @license
@@ -2262,45 +2501,45 @@ function en(e, t, n, r, o) {
2262
2501
  * limitations under the License.
2263
2502
  * =============================================================================
2264
2503
  */
2265
- function nn(e, t, n, r, o, s = !1, i = 0) {
2266
- const u = r.length, a = [t[0], e.length / t[0]], h = a[1], f = u > 0 ? o[u - 1] + 1 : 0;
2504
+ function vs(e, t, n, s, o, a = !1, r = 0) {
2505
+ const i = s.length, l = [t[0], e.length / t[0]], u = l[1], f = i > 0 ? o[i - 1] + 1 : 0;
2267
2506
  if (f < 0)
2268
- throw new Error(pt());
2507
+ throw new Error(Nt());
2269
2508
  const p = t.slice();
2270
2509
  p[0] = f;
2271
- const I = p.reduce((R, x) => R * x, 1), m = q(n, I);
2272
- if (u === 0)
2273
- return f > 0 && m.fill(i), [m, p];
2510
+ const I = p.reduce((k, y) => k * y, 1), m = D(n, I);
2511
+ if (i === 0)
2512
+ return f > 0 && m.fill(r), [m, p];
2274
2513
  if (f <= 0)
2275
- throw new Error(pt());
2276
- let b = 0, g = 1, d = 0, E = o[b];
2514
+ throw new Error(Nt());
2515
+ let F = 0, g = 1, d = 0, b = o[F];
2277
2516
  for (; ; ) {
2278
- let R = 0;
2279
- if (g < u) {
2280
- if (R = o[g], E === R) {
2517
+ let k = 0;
2518
+ if (g < i) {
2519
+ if (k = o[g], b === k) {
2281
2520
  ++g;
2282
2521
  continue;
2283
2522
  }
2284
- if (E >= R)
2285
- throw new Error(ae());
2523
+ if (b >= k)
2524
+ throw new Error(gn());
2286
2525
  }
2287
- if (E < 0 || E >= f)
2288
- throw new Error(he(E, f));
2289
- E > d && m.fill(i, d * h, E * h);
2290
- for (let x = b; x < g; ++x) {
2291
- const D = r[x];
2292
- if (D < 0 || D >= a[0])
2293
- throw new Error(ce(x, r[x], a[0]));
2294
- for (let V = 0; V < h; V++)
2295
- m[E * h + V] += e[D * h + V];
2526
+ if (b < 0 || b >= f)
2527
+ throw new Error(dn(b, f));
2528
+ b > d && m.fill(r, d * u, b * u);
2529
+ for (let y = F; y < g; ++y) {
2530
+ const S = s[y];
2531
+ if (S < 0 || S >= l[0])
2532
+ throw new Error(mn(y, s[y], l[0]));
2533
+ for (let P = 0; P < u; P++)
2534
+ m[b * u + P] += e[S * u + P];
2296
2535
  }
2297
- if (s)
2298
- for (let x = 0; x < h; x++)
2299
- m[E * h + x] /= g - b;
2300
- if (b = g, ++g, d = E + 1, E = R, g > u)
2536
+ if (a)
2537
+ for (let y = 0; y < u; y++)
2538
+ m[b * u + y] /= g - F;
2539
+ if (F = g, ++g, d = b + 1, b = k, g > i)
2301
2540
  break;
2302
2541
  }
2303
- return d < f && m.fill(i, d * h, f * h), [m, p];
2542
+ return d < f && m.fill(r, d * u, f * u), [m, p];
2304
2543
  }
2305
2544
  /**
2306
2545
  * @license
@@ -2318,7 +2557,11 @@ function nn(e, t, n, r, o, s = !1, i = 0) {
2318
2557
  * limitations under the License.
2319
2558
  * =============================================================================
2320
2559
  */
2321
- const rn = K((e) => Math.sqrt(e));
2560
+ const Ts = X((e) => Math.sqrt(e)), Rs = ge(te, (e) => Math.sqrt(e)), So = {
2561
+ kernelName: te,
2562
+ backendName: "cpu",
2563
+ kernelFunc: Rs
2564
+ };
2322
2565
  /**
2323
2566
  * @license
2324
2567
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2335,10 +2578,14 @@ const rn = K((e) => Math.sqrt(e));
2335
2578
  * limitations under the License.
2336
2579
  * =============================================================================
2337
2580
  */
2338
- const on = U((e, t) => {
2581
+ const Me = W((e, t) => {
2339
2582
  const n = e - t;
2340
2583
  return n * n;
2341
- });
2584
+ }), Ps = z(ee, Me), vo = {
2585
+ kernelName: ee,
2586
+ backendName: "cpu",
2587
+ kernelFunc: Ps
2588
+ };
2342
2589
  /**
2343
2590
  * @license
2344
2591
  * Copyright 2023 Google LLC.
@@ -2355,10 +2602,14 @@ const on = U((e, t) => {
2355
2602
  * limitations under the License.
2356
2603
  * =============================================================================
2357
2604
  */
2358
- const sn = K((e, t) => {
2359
- const { pattern: n, replaceGlobal: r, rewrite: o } = t;
2360
- return e.replace(new RegExp(n, r ? "g" : ""), o);
2361
- });
2605
+ const Oe = X((e, t) => {
2606
+ const { pattern: n, replaceGlobal: s, rewrite: o } = t;
2607
+ return e.replace(new RegExp(n, s ? "g" : ""), o);
2608
+ }), Cs = J(ne, Oe), To = {
2609
+ kernelName: ne,
2610
+ backendName: "cpu",
2611
+ kernelFunc: Cs
2612
+ };
2362
2613
  /**
2363
2614
  * @license
2364
2615
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2375,13 +2626,13 @@ const sn = K((e, t) => {
2375
2626
  * limitations under the License.
2376
2627
  * =============================================================================
2377
2628
  */
2378
- function ln(e, t, n, r) {
2379
- const o = k(e, t.dtype);
2380
- for (let s = 0; s < o.size; s++) {
2381
- const i = o.indexToLoc(s), u = new Array(i.length);
2382
- for (let a = 0; a < u.length; a++)
2383
- u[a] = i[a] * n[a] + r[a];
2384
- o.set(t.get(...u), ...i);
2629
+ function qs(e, t, n, s) {
2630
+ const o = H(e, t.dtype);
2631
+ for (let a = 0; a < o.size; a++) {
2632
+ const r = o.indexToLoc(a), i = new Array(r.length);
2633
+ for (let l = 0; l < i.length; l++)
2634
+ i[l] = r[l] * n[l] + s[l];
2635
+ o.set(t.get(...i), ...r);
2385
2636
  }
2386
2637
  return o;
2387
2638
  }
@@ -2401,40 +2652,40 @@ function ln(e, t, n, r) {
2401
2652
  * limitations under the License.
2402
2653
  * =============================================================================
2403
2654
  */
2404
- class un {
2405
- constructor(t, n, r, o, s, i) {
2406
- this.separator = ut(t), this.nGramWidths = n, this.leftPad = ut(r), this.rightPad = ut(o), this.padWidth = s, this.preserveShort = i;
2655
+ class Us {
2656
+ constructor(t, n, s, o, a, r) {
2657
+ this.separator = pt(t), this.nGramWidths = n, this.leftPad = pt(s), this.rightPad = pt(o), this.padWidth = a, this.preserveShort = r;
2407
2658
  }
2408
2659
  getPadWidth(t) {
2409
2660
  return Math.min(this.padWidth < 0 ? t - 1 : this.padWidth, t - 1);
2410
2661
  }
2411
2662
  getNumNGrams(t, n) {
2412
- const r = this.getPadWidth(n);
2413
- return Math.max(0, t + 2 * r - n + 1);
2663
+ const s = this.getPadWidth(n);
2664
+ return Math.max(0, t + 2 * s - n + 1);
2414
2665
  }
2415
- createNGrams(t, n, r, o, s, i) {
2416
- for (let u = 0; u < s; ++u) {
2417
- const a = this.getPadWidth(i), h = Math.max(0, a - u), c = Math.max(0, a - (s - (u + 1))), f = i - (h + c), p = n + (h > 0 ? 0 : u - a);
2666
+ createNGrams(t, n, s, o, a, r) {
2667
+ for (let i = 0; i < a; ++i) {
2668
+ const l = this.getPadWidth(r), u = Math.max(0, l - i), h = Math.max(0, l - (a - (i + 1))), f = r - (u + h), p = n + (u > 0 ? 0 : i - l);
2418
2669
  let I = 0;
2419
- I += h * this.leftPad.length;
2420
- for (let E = 0; E < f; ++E)
2421
- I += t[p + E].length;
2422
- I += c * this.rightPad.length;
2423
- const m = h + c + f - 1;
2424
- I += m * this.separator.length, r[o + u] = new Uint8Array(I);
2425
- const b = r[o + u];
2670
+ I += u * this.leftPad.length;
2671
+ for (let b = 0; b < f; ++b)
2672
+ I += t[p + b].length;
2673
+ I += h * this.rightPad.length;
2674
+ const m = u + h + f - 1;
2675
+ I += m * this.separator.length, s[o + i] = new Uint8Array(I);
2676
+ const F = s[o + i];
2426
2677
  let g = 0;
2427
- const d = (E) => E.forEach((R) => b[g++] = R);
2428
- for (let E = 0; E < h; ++E)
2678
+ const d = (b) => b.forEach((k) => F[g++] = k);
2679
+ for (let b = 0; b < u; ++b)
2429
2680
  d(this.leftPad), d(this.separator);
2430
- for (let E = 0; E < f - 1; ++E)
2431
- d(t[p + E]), d(this.separator);
2681
+ for (let b = 0; b < f - 1; ++b)
2682
+ d(t[p + b]), d(this.separator);
2432
2683
  if (f > 0) {
2433
2684
  d(t[p + f - 1]);
2434
- for (let E = 0; E < c; ++E)
2685
+ for (let b = 0; b < h; ++b)
2435
2686
  d(this.separator), d(this.rightPad);
2436
2687
  } else {
2437
- for (let E = 0; E < c - 1; ++E)
2688
+ for (let b = 0; b < h - 1; ++b)
2438
2689
  d(this.rightPad), d(this.separator);
2439
2690
  d(this.rightPad);
2440
2691
  }
@@ -2444,55 +2695,55 @@ class un {
2444
2695
  // where data is 1 dimensional and contains the values of the tensor
2445
2696
  // and splits denotes the indices at which each row starts.
2446
2697
  compute(t, n) {
2447
- const r = t.length, o = n.length;
2698
+ const s = t.length, o = n.length;
2448
2699
  if (o > 0) {
2449
- let a = n[0];
2450
- if (a !== 0)
2451
- throw new Error(`First split value must be 0, got ${a}`);
2452
- for (let h = 1; h < o; ++h) {
2453
- let c = n[h] >= a;
2454
- if (c = c && n[h] <= r, !c)
2455
- throw new Error(`Invalid split value ${n[h]}, must be in [${a}, ${r}]`);
2456
- a = n[h];
2700
+ let l = n[0];
2701
+ if (l !== 0)
2702
+ throw new Error(`First split value must be 0, got ${l}`);
2703
+ for (let u = 1; u < o; ++u) {
2704
+ let h = n[u] >= l;
2705
+ if (h = h && n[u] <= s, !h)
2706
+ throw new Error(`Invalid split value ${n[u]}, must be in [${l}, ${s}]`);
2707
+ l = n[u];
2457
2708
  }
2458
- if (a !== r)
2459
- throw new Error(`Last split value must be data size. Expected ${r}, got ${a}`);
2709
+ if (l !== s)
2710
+ throw new Error(`Last split value must be data size. Expected ${s}, got ${l}`);
2460
2711
  }
2461
- const s = o - 1, i = q("int32", o);
2462
- if (r === 0 || o === 0) {
2463
- const a = new Array(r);
2464
- for (let h = 0; h <= s; ++h)
2465
- i[h] = 0;
2466
- return [a, i];
2712
+ const a = o - 1, r = D("int32", o);
2713
+ if (s === 0 || o === 0) {
2714
+ const l = new Array(s);
2715
+ for (let u = 0; u <= a; ++u)
2716
+ r[u] = 0;
2717
+ return [l, r];
2467
2718
  }
2468
- i[0] = 0;
2469
- for (let a = 1; a <= s; ++a) {
2470
- const h = n[a] - n[a - 1];
2471
- let c = 0;
2719
+ r[0] = 0;
2720
+ for (let l = 1; l <= a; ++l) {
2721
+ const u = n[l] - n[l - 1];
2722
+ let h = 0;
2472
2723
  this.nGramWidths.forEach((f) => {
2473
- c += this.getNumNGrams(h, f);
2474
- }), this.preserveShort && h > 0 && c === 0 && (c = 1), i[a] = i[a - 1] + c;
2724
+ h += this.getNumNGrams(u, f);
2725
+ }), this.preserveShort && u > 0 && h === 0 && (h = 1), r[l] = r[l - 1] + h;
2475
2726
  }
2476
- const u = new Array(i[s]);
2477
- for (let a = 0; a < s; ++a) {
2478
- const h = n[a];
2479
- let c = i[a];
2727
+ const i = new Array(r[a]);
2728
+ for (let l = 0; l < a; ++l) {
2729
+ const u = n[l];
2730
+ let h = r[l];
2480
2731
  if (this.nGramWidths.forEach((f) => {
2481
- const p = n[a + 1] - n[a], I = this.getNumNGrams(p, f);
2482
- this.createNGrams(t, h, u, c, I, f), c += I;
2483
- }), this.preserveShort && c === i[a]) {
2484
- const f = n[a + 1] - n[a];
2732
+ const p = n[l + 1] - n[l], I = this.getNumNGrams(p, f);
2733
+ this.createNGrams(t, u, i, h, I, f), h += I;
2734
+ }), this.preserveShort && h === r[l]) {
2735
+ const f = n[l + 1] - n[l];
2485
2736
  if (f === 0)
2486
2737
  continue;
2487
2738
  const p = f + 2 * this.padWidth;
2488
- this.createNGrams(t, h, u, c, 1, p);
2739
+ this.createNGrams(t, u, i, h, 1, p);
2489
2740
  }
2490
2741
  }
2491
- return [u, i];
2742
+ return [i, r];
2492
2743
  }
2493
2744
  }
2494
- function an(e, t, n, r, o, s, i, u) {
2495
- return new un(n, r, o, s, i, u).compute(e, t);
2745
+ function Ms(e, t, n, s, o, a, r, i) {
2746
+ return new Us(n, s, o, a, r, i).compute(e, t);
2496
2747
  }
2497
2748
  /**
2498
2749
  * @license
@@ -2510,47 +2761,47 @@ function an(e, t, n, r, o, s, i, u) {
2510
2761
  * limitations under the License.
2511
2762
  * =============================================================================
2512
2763
  */
2513
- function hn(e, t, n, r) {
2764
+ function Os(e, t, n, s) {
2514
2765
  if (!e.length)
2515
2766
  return;
2516
2767
  if (t.length === 0) {
2517
- for (let s = 0; s < e.length; ++s)
2518
- r.push(e.subarray(s, s + 1));
2768
+ for (let a = 0; a < e.length; ++a)
2769
+ s.push(e.subarray(a, a + 1));
2519
2770
  return;
2520
2771
  }
2521
2772
  if (t.length === 1) {
2522
- const s = t[0];
2523
- let i = e.indexOf(s);
2524
- for (; i !== -1; ) {
2525
- const u = e.subarray(0, i);
2526
- (!n || u.length !== 0) && r.push(u), e = e.subarray(i + 1), i = e.indexOf(s);
2773
+ const a = t[0];
2774
+ let r = e.indexOf(a);
2775
+ for (; r !== -1; ) {
2776
+ const i = e.subarray(0, r);
2777
+ (!n || i.length !== 0) && s.push(i), e = e.subarray(r + 1), r = e.indexOf(a);
2527
2778
  }
2528
- (!n || e.length !== 0) && r.push(e);
2779
+ (!n || e.length !== 0) && s.push(e);
2529
2780
  return;
2530
2781
  }
2531
2782
  let o = 0;
2532
- for (let s = 0; s < e.length + 1; s++)
2533
- if (s === e.length || t.indexOf(e[s]) !== -1) {
2534
- const i = e.subarray(o, s);
2535
- (!n || i.length !== 0) && r.push(i), o = s + 1;
2783
+ for (let a = 0; a < e.length + 1; a++)
2784
+ if (a === e.length || t.indexOf(e[a]) !== -1) {
2785
+ const r = e.subarray(o, a);
2786
+ (!n || r.length !== 0) && s.push(r), o = a + 1;
2536
2787
  }
2537
2788
  }
2538
- function cn(e, t, n) {
2539
- const r = e.length, o = [];
2540
- let s = 0, i = 0;
2541
- const u = new Array(r);
2542
- for (let p = 0; p < r; ++p) {
2789
+ function Ls(e, t, n) {
2790
+ const s = e.length, o = [];
2791
+ let a = 0, r = 0;
2792
+ const i = new Array(s);
2793
+ for (let p = 0; p < s; ++p) {
2543
2794
  const I = o.length;
2544
- hn(e[p], t, n, o);
2795
+ Os(e[p], t, n, o);
2545
2796
  const m = o.length - I;
2546
- u[p] = m, s += m, i = Math.max(i, m);
2797
+ i[p] = m, a += m, r = Math.max(r, m);
2547
2798
  }
2548
- const a = q("int32", s * 2), h = new Array(s), c = [r, i];
2799
+ const l = D("int32", a * 2), u = new Array(a), h = [s, r];
2549
2800
  let f = 0;
2550
- for (let p = 0; p < r; ++p)
2551
- for (let I = 0; I < u[p]; ++I)
2552
- a[f * 2] = p, a[f * 2 + 1] = I, h[f] = o[f], ++f;
2553
- return [a, h, c];
2801
+ for (let p = 0; p < s; ++p)
2802
+ for (let I = 0; I < i[p]; ++I)
2803
+ l[f * 2] = p, l[f * 2 + 1] = I, u[f] = o[f], ++f;
2804
+ return [l, u, h];
2554
2805
  }
2555
2806
  /**
2556
2807
  * @license
@@ -2568,10 +2819,10 @@ function cn(e, t, n) {
2568
2819
  * limitations under the License.
2569
2820
  * =============================================================================
2570
2821
  */
2571
- function fn(e, t) {
2572
- const n = q("int32", e.length);
2573
- for (let r = 0; r < e.length; ++r)
2574
- n[r] = Xt(e[r]).modulo(t).getLowBitsUnsigned();
2822
+ function As(e, t) {
2823
+ const n = D("int32", e.length);
2824
+ for (let s = 0; s < e.length; ++s)
2825
+ n[s] = Mn(e[s]).modulo(t).getLowBitsUnsigned();
2575
2826
  return n;
2576
2827
  }
2577
2828
  /**
@@ -2590,7 +2841,11 @@ function fn(e, t) {
2590
2841
  * limitations under the License.
2591
2842
  * =============================================================================
2592
2843
  */
2593
- const gn = U((e, t) => e - t);
2844
+ const Le = W((e, t) => e - t), _s = Ft((e, t, n, s) => ({ real: e - n, imag: t - s })), Vs = z(se, Le, _s), Ro = {
2845
+ kernelName: se,
2846
+ backendName: "cpu",
2847
+ kernelFunc: Vs
2848
+ };
2594
2849
  /**
2595
2850
  * @license
2596
2851
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -2607,19 +2862,19 @@ const gn = U((e, t) => e - t);
2607
2862
  * limitations under the License.
2608
2863
  * =============================================================================
2609
2864
  */
2610
- function dn(e, t) {
2865
+ function Ds(e, t) {
2611
2866
  const n = new Array(e.rank);
2612
2867
  for (let o = 0; o < n.length; o++)
2613
2868
  n[o] = e.shape[o] * t[o];
2614
- const r = k(n, e.dtype);
2615
- for (let o = 0; o < r.values.length; ++o) {
2616
- const s = r.indexToLoc(o), i = new Array(e.rank);
2617
- for (let a = 0; a < i.length; a++)
2618
- i[a] = s[a] % e.shape[a];
2619
- const u = e.locToIndex(i);
2620
- r.values[o] = e.values[u];
2869
+ const s = H(n, e.dtype);
2870
+ for (let o = 0; o < s.values.length; ++o) {
2871
+ const a = s.indexToLoc(o), r = new Array(e.rank);
2872
+ for (let l = 0; l < r.length; l++)
2873
+ r[l] = a[l] % e.shape[l];
2874
+ const i = e.locToIndex(r);
2875
+ s.values[o] = e.values[i];
2621
2876
  }
2622
- return r;
2877
+ return s;
2623
2878
  }
2624
2879
  /**
2625
2880
  * @license
@@ -2637,41 +2892,41 @@ function dn(e, t) {
2637
2892
  * limitations under the License.
2638
2893
  * =============================================================================
2639
2894
  */
2640
- const et = (e, t) => {
2895
+ const rt = (e, t) => {
2641
2896
  const n = t.value - e.value;
2642
2897
  return n === 0 ? e.index - t.index : n;
2643
2898
  };
2644
- function _t(e, t, n = 0, r = e.length - 1) {
2645
- for (; r > n; ) {
2646
- if (r - n > 600) {
2647
- const u = r - n + 1, a = t - n + 1, h = Math.log(u), c = 0.5 * Math.exp(2 * h / 3), f = 0.5 * Math.sqrt(h * c * (u - c) / u) * Math.sign(a - u / 2), p = Math.max(n, Math.floor(t - a * c / u + f)), I = Math.min(r, Math.floor(t + (u - a) * c / u + f));
2648
- _t(e, t, p, I);
2899
+ function Ae(e, t, n = 0, s = e.length - 1) {
2900
+ for (; s > n; ) {
2901
+ if (s - n > 600) {
2902
+ const i = s - n + 1, l = t - n + 1, u = Math.log(i), h = 0.5 * Math.exp(2 * u / 3), f = 0.5 * Math.sqrt(u * h * (i - h) / i) * Math.sign(l - i / 2), p = Math.max(n, Math.floor(t - l * h / i + f)), I = Math.min(s, Math.floor(t + (i - l) * h / i + f));
2903
+ Ae(e, t, p, I);
2649
2904
  }
2650
2905
  const o = e[t];
2651
- let s = n, i = r;
2652
- for (tt(e, n, t), et(e[r], o) > 0 && tt(e, n, r); s < i; ) {
2653
- for (tt(e, s, i), s++, i--; et(e[s], o) < 0; )
2654
- s = s + 1;
2655
- for (; et(e[i], o) > 0; )
2656
- i = i - 1;
2906
+ let a = n, r = s;
2907
+ for (ot(e, n, t), rt(e[s], o) > 0 && ot(e, n, s); a < r; ) {
2908
+ for (ot(e, a, r), a++, r--; rt(e[a], o) < 0; )
2909
+ a = a + 1;
2910
+ for (; rt(e[r], o) > 0; )
2911
+ r = r - 1;
2657
2912
  }
2658
- et(e[n], o) === 0 ? tt(e, n, i) : (i = i + 1, tt(e, i, r)), i <= t && (n = i + 1), t <= i && (r = i - 1);
2913
+ rt(e[n], o) === 0 ? ot(e, n, r) : (r = r + 1, ot(e, r, s)), r <= t && (n = r + 1), t <= r && (s = r - 1);
2659
2914
  }
2660
2915
  }
2661
- function mn(e, t, n, r, o) {
2662
- const s = t[t.length - 1], [i, u] = [e.length / s, s], a = nt(n, i * r), h = nt("int32", i * r);
2663
- for (let f = 0; f < i; f++) {
2664
- const p = f * u, I = e.subarray(p, p + u);
2916
+ function Ws(e, t, n, s, o) {
2917
+ const a = t[t.length - 1], [r, i] = [e.length / a, a], l = et(n, r * s), u = et("int32", r * s);
2918
+ for (let f = 0; f < r; f++) {
2919
+ const p = f * i, I = e.subarray(p, p + i);
2665
2920
  let m = new Array(I.length);
2666
- I.forEach((E, R) => m[R] = { value: E, index: R }), r < m.length && (_t(m, r), m = m.slice(0, r)), o && m.sort(et);
2667
- const b = f * r, g = a.subarray(b, b + r), d = h.subarray(b, b + r);
2668
- for (let E = 0; E < r; E++)
2669
- g[E] = m[E].value, d[E] = m[E].index;
2670
- }
2671
- const c = t.slice();
2672
- return c[c.length - 1] = r, [
2673
- k(c, n, a),
2674
- k(c, "int32", h)
2921
+ I.forEach((b, k) => m[k] = { value: b, index: k }), s < m.length && (Ae(m, s), m = m.slice(0, s)), o && m.sort(rt);
2922
+ const F = f * s, g = l.subarray(F, F + s), d = u.subarray(F, F + s);
2923
+ for (let b = 0; b < s; b++)
2924
+ g[b] = m[b].value, d[b] = m[b].index;
2925
+ }
2926
+ const h = t.slice();
2927
+ return h[h.length - 1] = s, [
2928
+ H(h, n, l),
2929
+ H(h, "int32", u)
2675
2930
  ];
2676
2931
  }
2677
2932
  /**
@@ -2690,46 +2945,46 @@ function mn(e, t, n, r, o) {
2690
2945
  * limitations under the License.
2691
2946
  * =============================================================================
2692
2947
  */
2693
- function wn(e, t, n, r) {
2694
- const o = Dt(t, n)[0], s = [1, n[0], 1];
2948
+ function $s(e, t, n, s) {
2949
+ const o = Yt(t, n)[0], a = [1, n[0], 1];
2695
2950
  for (let m = 0; m < o; m++)
2696
- s[0] *= n[m];
2697
- s[1] = n[o];
2951
+ a[0] *= n[m];
2952
+ a[1] = n[o];
2698
2953
  for (let m = o + 1; m < n.length; m++)
2699
- s[2] *= n[m];
2700
- const i = /* @__PURE__ */ new Map(), u = new Int32Array(n[o]), a = new ct(s, r, e), h = [], c = s[0] === 1 && s[2] === 1;
2954
+ a[2] *= n[m];
2955
+ const r = /* @__PURE__ */ new Map(), i = new Int32Array(n[o]), l = new wt(a, s, e), u = [], h = a[0] === 1 && a[2] === 1;
2701
2956
  for (let m = 0; m < n[o]; m++) {
2702
- let b;
2703
- if (c)
2704
- b = e[m].toString();
2957
+ let F;
2958
+ if (h)
2959
+ F = e[m].toString();
2705
2960
  else {
2706
2961
  const d = [];
2707
- for (let E = 0; E < s[0]; E++)
2708
- for (let R = 0; R < s[2]; R++)
2709
- d.push(a.get(E, m, R));
2710
- b = d.join(",");
2962
+ for (let b = 0; b < a[0]; b++)
2963
+ for (let k = 0; k < a[2]; k++)
2964
+ d.push(l.get(b, m, k));
2965
+ F = d.join(",");
2711
2966
  }
2712
- const g = i.get(b);
2967
+ const g = r.get(F);
2713
2968
  if (g != null)
2714
- u[m] = g;
2969
+ i[m] = g;
2715
2970
  else {
2716
- const d = i.size;
2717
- i.set(b, d), u[m] = d, h.push(m);
2971
+ const d = r.size;
2972
+ r.set(F, d), i[m] = d, u.push(m);
2718
2973
  }
2719
2974
  }
2720
- const f = s.slice();
2721
- f[1] = i.size;
2722
- const p = new ct(f, r);
2723
- h.forEach((m, b) => {
2724
- for (let g = 0; g < s[0]; g++)
2725
- for (let d = 0; d < s[2]; d++)
2726
- p.set(a.get(g, m, d), g, b, d);
2975
+ const f = a.slice();
2976
+ f[1] = r.size;
2977
+ const p = new wt(f, s);
2978
+ u.forEach((m, F) => {
2979
+ for (let g = 0; g < a[0]; g++)
2980
+ for (let d = 0; d < a[2]; d++)
2981
+ p.set(l.get(g, m, d), g, F, d);
2727
2982
  });
2728
2983
  const I = n.slice();
2729
2984
  return I[o] = f[1], {
2730
2985
  outputValues: p.values,
2731
2986
  outputShape: I,
2732
- indices: u
2987
+ indices: i
2733
2988
  };
2734
2989
  }
2735
2990
  /**
@@ -2748,59 +3003,59 @@ function wn(e, t, n, r) {
2748
3003
  * limitations under the License.
2749
3004
  * =============================================================================
2750
3005
  */
2751
- const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
3006
+ const zs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2752
3007
  __proto__: null,
2753
- addImpl: de,
2754
- bincountImpl: me,
2755
- bincountReduceImpl: we,
2756
- bitwiseAndImpl: pe,
2757
- castImpl: ge,
2758
- ceilImpl: Ie,
2759
- concatImpl: Ee,
2760
- equalImpl: Se,
2761
- expImpl: Fe,
2762
- expm1Impl: be,
2763
- floorDivImpl: Re,
2764
- floorImpl: xe,
2765
- gatherNdImpl: Te,
2766
- gatherV2Impl: ve,
2767
- greaterEqualImpl: _e,
2768
- greaterImpl: Oe,
2769
- lessEqualImpl: Le,
2770
- lessImpl: ye,
2771
- linSpaceImpl: Me,
2772
- logImpl: Ne,
2773
- maxImpl: $e,
2774
- maximumImpl: Ae,
2775
- minimumImpl: De,
2776
- multiplyImpl: Ot,
2777
- negImpl: Pe,
2778
- notEqualImpl: We,
2779
- prodImpl: Ve,
2780
- raggedGatherImpl: Be,
2781
- raggedRangeImpl: ke,
2782
- raggedTensorToTensorImpl: He,
2783
- rangeImpl: Ke,
2784
- rsqrtImpl: Xe,
2785
- scatterImpl: Qe,
2786
- sigmoidImpl: Je,
2787
- simpleAbsImpl: fe,
2788
- sliceImpl: Ye,
2789
- sparseFillEmptyRowsImpl: tn,
2790
- sparseReshapeImpl: en,
2791
- sparseSegmentReductionImpl: nn,
2792
- sqrtImpl: rn,
2793
- squaredDifferenceImpl: on,
2794
- staticRegexReplaceImpl: sn,
2795
- stridedSliceImpl: ln,
2796
- stringNGramsImpl: an,
2797
- stringSplitImpl: cn,
2798
- stringToHashBucketFastImpl: fn,
2799
- subImpl: gn,
2800
- tileImpl: dn,
2801
- topKImpl: mn,
2802
- transposeImpl: qe,
2803
- uniqueImpl: wn
3008
+ addImpl: he,
3009
+ bincountImpl: _n,
3010
+ bincountReduceImpl: Vn,
3011
+ bitwiseAndImpl: fe,
3012
+ castImpl: ue,
3013
+ ceilImpl: de,
3014
+ concatImpl: $n,
3015
+ equalImpl: me,
3016
+ expImpl: pe,
3017
+ expm1Impl: Ie,
3018
+ floorDivImpl: be,
3019
+ floorImpl: we,
3020
+ gatherNdImpl: Hn,
3021
+ gatherV2Impl: Kn,
3022
+ greaterEqualImpl: Ee,
3023
+ greaterImpl: xe,
3024
+ lessEqualImpl: ye,
3025
+ lessImpl: Fe,
3026
+ linSpaceImpl: ts,
3027
+ logImpl: ke,
3028
+ maxImpl: ns,
3029
+ maximumImpl: Ne,
3030
+ minimumImpl: Se,
3031
+ multiplyImpl: yt,
3032
+ negImpl: ve,
3033
+ notEqualImpl: Te,
3034
+ prodImpl: Ce,
3035
+ raggedGatherImpl: ps,
3036
+ raggedRangeImpl: Is,
3037
+ raggedTensorToTensorImpl: ws,
3038
+ rangeImpl: bs,
3039
+ rsqrtImpl: qe,
3040
+ scatterImpl: Es,
3041
+ sigmoidImpl: Fs,
3042
+ simpleAbsImpl: le,
3043
+ sliceImpl: Ue,
3044
+ sparseFillEmptyRowsImpl: Ns,
3045
+ sparseReshapeImpl: Ss,
3046
+ sparseSegmentReductionImpl: vs,
3047
+ sqrtImpl: Ts,
3048
+ squaredDifferenceImpl: Me,
3049
+ staticRegexReplaceImpl: Oe,
3050
+ stridedSliceImpl: qs,
3051
+ stringNGramsImpl: Ms,
3052
+ stringSplitImpl: Ls,
3053
+ stringToHashBucketFastImpl: As,
3054
+ subImpl: Le,
3055
+ tileImpl: Ds,
3056
+ topKImpl: Ws,
3057
+ transposeImpl: Re,
3058
+ uniqueImpl: $s
2804
3059
  }, Symbol.toStringTag, { value: "Module" }));
2805
3060
  /**
2806
3061
  * @license
@@ -2818,9 +3073,127 @@ const pn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2818
3073
  * limitations under the License.
2819
3074
  * =============================================================================
2820
3075
  */
2821
- const { logImpl: Tn, maxImpl: vn, transposeImpl: On } = pn;
3076
+ const { addImpl: Po, bincountImpl: Co, bincountReduceImpl: qo, bitwiseAndImpl: Uo, castImpl: Mo, ceilImpl: Oo, concatImpl: Lo, equalImpl: Ao, expImpl: _o, expm1Impl: Vo, floorImpl: Do, gatherNdImpl: Wo, gatherV2Impl: $o, greaterImpl: zo, greaterEqualImpl: Bo, lessImpl: Go, lessEqualImpl: jo, linSpaceImpl: Zo, logImpl: Ho, maxImpl: Ko, maximumImpl: Xo, minimumImpl: Yo, multiplyImpl: Jo, negImpl: Qo, notEqualImpl: tr, prodImpl: er, raggedGatherImpl: nr, raggedRangeImpl: sr, raggedTensorToTensorImpl: or, rangeImpl: rr, rsqrtImpl: ar, scatterImpl: ir, sigmoidImpl: lr, simpleAbsImpl: cr, sliceImpl: ur, sparseFillEmptyRowsImpl: hr, sparseReshapeImpl: fr, sparseSegmentReductionImpl: gr, sqrtImpl: dr, staticRegexReplaceImpl: mr, stridedSliceImpl: pr, stringNGramsImpl: Ir, stringSplitImpl: wr, stringToHashBucketFastImpl: br, subImpl: xr, tileImpl: Er, topKImpl: Fr, transposeImpl: yr, uniqueImpl: kr } = zs;
2822
3077
  export {
2823
- Tn as l,
2824
- vn as m,
2825
- On as t
3078
+ uo as $,
3079
+ ps as A,
3080
+ Is as B,
3081
+ ws as C,
3082
+ bs as D,
3083
+ Es as E,
3084
+ Ns as F,
3085
+ Ss as G,
3086
+ vs as H,
3087
+ qs as I,
3088
+ Ms as J,
3089
+ Ls as K,
3090
+ As as L,
3091
+ Ds as M,
3092
+ Ws as N,
3093
+ $s as O,
3094
+ zn as P,
3095
+ Ys as Q,
3096
+ no as R,
3097
+ so as S,
3098
+ eo as T,
3099
+ oo as U,
3100
+ Js as V,
3101
+ ro as W,
3102
+ ao as X,
3103
+ io as Y,
3104
+ lo as Z,
3105
+ co as _,
3106
+ nt as a,
3107
+ br as a$,
3108
+ ho as a0,
3109
+ Qs as a1,
3110
+ fo as a2,
3111
+ go as a3,
3112
+ mo as a4,
3113
+ po as a5,
3114
+ Io as a6,
3115
+ wo as a7,
3116
+ bo as a8,
3117
+ xo as a9,
3118
+ $o as aA,
3119
+ zo as aB,
3120
+ Bo as aC,
3121
+ Go as aD,
3122
+ jo as aE,
3123
+ Zo as aF,
3124
+ Ho as aG,
3125
+ Xo as aH,
3126
+ Yo as aI,
3127
+ xr as aJ,
3128
+ Qo as aK,
3129
+ er as aL,
3130
+ nr as aM,
3131
+ sr as aN,
3132
+ or as aO,
3133
+ rr as aP,
3134
+ ar as aQ,
3135
+ lr as aR,
3136
+ hr as aS,
3137
+ fr as aT,
3138
+ gr as aU,
3139
+ ir as aV,
3140
+ dr as aW,
3141
+ mr as aX,
3142
+ pr as aY,
3143
+ Ir as aZ,
3144
+ wr as a_,
3145
+ Fo as aa,
3146
+ to as ab,
3147
+ yo as ac,
3148
+ ko as ad,
3149
+ No as ae,
3150
+ So as af,
3151
+ vo as ag,
3152
+ To as ah,
3153
+ Ro as ai,
3154
+ Eo as aj,
3155
+ cr as ak,
3156
+ Jo as al,
3157
+ Po as am,
3158
+ ur as an,
3159
+ Co as ao,
3160
+ Uo as ap,
3161
+ tr as aq,
3162
+ Mo as ar,
3163
+ Oo as as,
3164
+ Lo as at,
3165
+ qo as au,
3166
+ Ao as av,
3167
+ _o as aw,
3168
+ Vo as ax,
3169
+ Do as ay,
3170
+ Wo as az,
3171
+ An as b,
3172
+ Er as b0,
3173
+ Fr as b1,
3174
+ kr as b2,
3175
+ W as c,
3176
+ Pe as d,
3177
+ z as e,
3178
+ ks as f,
3179
+ _n as g,
3180
+ mt as h,
3181
+ Et as i,
3182
+ $n as j,
3183
+ Vn as k,
3184
+ lt as l,
3185
+ Ko as m,
3186
+ as as n,
3187
+ Vs as o,
3188
+ Hn as p,
3189
+ Kn as q,
3190
+ ce as r,
3191
+ ys as s,
3192
+ yr as t,
3193
+ ge as u,
3194
+ ts as v,
3195
+ Re as w,
3196
+ ns as x,
3197
+ Bn as y,
3198
+ xt as z
2826
3199
  };