@genai-fi/nanogpt 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/Generator.js +3 -3
  2. package/dist/NanoGPTModel.js +83 -70
  3. package/dist/TeachableLLM.js +1 -1
  4. package/dist/{random_width-CMHmdbSu.js → TiedEmbedding-CnJ1bx4q.js} +760 -719
  5. package/dist/{axis_util-DeydwOoC.js → axis_util-BgTGy5w8.js} +1 -1
  6. package/dist/{concat-DS_qH7MI.js → concat-CuRsVY-K.js} +1 -1
  7. package/dist/dropout-DfDdklfL.js +193 -0
  8. package/dist/{gather-BUmJIS8n.js → gather-ZYRWhmXR.js} +1 -1
  9. package/dist/gelu-CnCt17Lk.js +26 -0
  10. package/dist/{index-XjBAhiFO.js → index-C4JCoBvj.js} +61 -61
  11. package/dist/kernel_funcs_utils-CAd1h9X1.js +388 -0
  12. package/dist/layers/CausalSelfAttention.js +71 -70
  13. package/dist/layers/MLP.d.ts +3 -1
  14. package/dist/layers/MLP.js +93 -5
  15. package/dist/layers/RMSNorm.js +3 -3
  16. package/dist/layers/RoPECache.js +3 -3
  17. package/dist/layers/TiedEmbedding.js +6 -46
  18. package/dist/layers/TransformerBlock.js +2 -2
  19. package/dist/{log_sum_exp-DJPkVZZn.js → log_sum_exp-BswFnwOb.js} +5 -5
  20. package/dist/main.js +1 -1
  21. package/dist/{mat_mul-CKwFEV1Q.js → mat_mul-415y5Qn2.js} +1 -1
  22. package/dist/{max-DJvEiCAJ.js → max-CP_9O2Yd.js} +1 -1
  23. package/dist/{moments-CrWRPcR3.js → moments-CjeIaVdp.js} +3 -3
  24. package/dist/{norm-BzY929B_.js → norm-CZM380I3.js} +5 -5
  25. package/dist/{ones-BO01zpJG.js → ones-Bf3YR48P.js} +2 -2
  26. package/dist/ops/appendCache.js +1 -1
  27. package/dist/ops/attentionMask.d.ts +1 -1
  28. package/dist/ops/attentionMask.js +4 -4
  29. package/dist/ops/cpu/appendCache.js +2 -2
  30. package/dist/ops/cpu/attentionMask.js +13 -9
  31. package/dist/ops/cpu/fusedSoftmax.js +2 -2
  32. package/dist/ops/cpu/gatherSub.js +3 -3
  33. package/dist/ops/cpu/gelu.d.ts +1 -0
  34. package/dist/ops/cpu/gelu.js +40 -0
  35. package/dist/ops/cpu/mulDropout.js +1 -1
  36. package/dist/ops/cpu/qkv.js +3 -3
  37. package/dist/ops/cpu/rope.js +5 -5
  38. package/dist/ops/cpu/scatterSub.js +4 -4
  39. package/dist/ops/fusedSoftmax.js +1 -1
  40. package/dist/ops/gatherSub.js +1 -1
  41. package/dist/ops/gelu.d.ts +3 -0
  42. package/dist/ops/gelu.js +8 -0
  43. package/dist/ops/grads/attentionMask.js +1 -1
  44. package/dist/ops/grads/fusedSoftmax.js +2 -2
  45. package/dist/ops/grads/gelu.d.ts +2 -0
  46. package/dist/ops/grads/gelu.js +5 -0
  47. package/dist/ops/grads/qkv.js +1 -1
  48. package/dist/ops/grads/rope.js +1 -1
  49. package/dist/ops/mulDrop.js +1 -1
  50. package/dist/ops/node/sparseCrossEntropy.js +1 -1
  51. package/dist/ops/qkv.js +1 -1
  52. package/dist/ops/scatterSub.js +1 -1
  53. package/dist/ops/webgl/appendCache.js +1 -1
  54. package/dist/ops/webgl/attentionMask.js +19 -18
  55. package/dist/ops/webgl/fusedSoftmax.js +483 -782
  56. package/dist/ops/webgl/gatherSub.js +1 -1
  57. package/dist/ops/webgl/gelu.d.ts +2 -0
  58. package/dist/ops/webgl/gelu.js +50 -0
  59. package/dist/ops/webgl/mulDropout.js +1 -1
  60. package/dist/ops/webgl/qkv.js +1 -1
  61. package/dist/ops/webgl/rope.js +1 -1
  62. package/dist/ops/webgl/scatterSub.js +1 -1
  63. package/dist/{range-DQMNzBWs.js → range-9AzeApCc.js} +1 -1
  64. package/dist/{reshape-DFzh97Sc.js → reshape-Boe4DuIO.js} +1 -1
  65. package/dist/{sin-BYM-U4Ut.js → sin-KmhiDuMa.js} +1 -1
  66. package/dist/{slice_util-CnVNPQI-.js → slice_util-19zDNNSn.js} +2 -2
  67. package/dist/{softmax-4DOn6cPq.js → softmax-Cujsg4ay.js} +1 -1
  68. package/dist/{split-CkbeVdF8.js → split-DbcNm1-i.js} +1 -1
  69. package/dist/{stack-DaIMO5iX.js → stack-D1YjmgKN.js} +1 -1
  70. package/dist/{sum-C6u3xMi3.js → sum-R28pucR5.js} +1 -1
  71. package/dist/{tensor-Cu1fU7H7.js → tensor-BVeHdl7V.js} +1 -1
  72. package/dist/{tensor2d-D0CKdG6B.js → tensor2d-DqFGNs_K.js} +1 -1
  73. package/dist/{tfjs_backend-Bzl2SrRo.js → tfjs_backend-Cug-PH75.js} +826 -1015
  74. package/dist/training/AdamExt.js +1 -1
  75. package/dist/training/DatasetBuilder.js +3 -3
  76. package/dist/training/FullTrainer.js +1 -1
  77. package/dist/training/Trainer.js +5 -5
  78. package/dist/training/sparseCrossEntropy.js +4 -4
  79. package/dist/utilities/dummy.js +2 -2
  80. package/dist/utilities/generate.js +3 -3
  81. package/dist/utilities/load.js +1 -1
  82. package/dist/utilities/profile.js +1 -1
  83. package/dist/utilities/weights.js +2 -2
  84. package/dist/{variable-BS4AKqNU.js → variable-LJT9Ld63.js} +1 -1
  85. package/dist/{zeros-CmJFiC84.js → zeros-dnQxFgAD.js} +1 -1
  86. package/package.json +1 -1
  87. package/dist/MLP-KHhikThU.js +0 -83
@@ -1,9 +1,10 @@
1
- import { aW as Jt, n as y, aX as Qt, aY as ut, aj as It, aZ as K, a_ as nt, a$ as Ot, b0 as xt, b1 as gt, b2 as te, W as ot, ao as Z, b3 as W, b4 as ee, b5 as pt, j as zt, t as ne, b6 as mt, b7 as tt, Y as ht, b8 as oe, aI as se, ab as St, b9 as re, ba as ie, r as ae } from "../../index-XjBAhiFO.js";
2
- import { c as bt, g as Wt, a as kt, b as Ut, e as vt } from "../../axis_util-DeydwOoC.js";
3
- import { b as ue, i as le, c as ce } from "../../slice_util-CnVNPQI-.js";
4
- import { r as he } from "../../reshape-DFzh97Sc.js";
5
- import { g as fe } from "../../_commonjsHelpers-ByX85dGu.js";
6
- function de(t, e) {
1
+ import { aZ as jt, n as O, al as Bt, a_ as K, a$ as nt, b0 as xt, b1 as mt, b2 as dt, b3 as Zt, W as ot, aa as Z, b4 as W, b5 as Ht, am as Kt, j as Lt, t as Xt, b6 as gt, ak as ht, b7 as tt, Y as lt, b8 as Yt, ab as Jt, b9 as Qt, af as te, ba as ee, r as ne } from "../../index-C4JCoBvj.js";
2
+ import { f as Mt, a as oe, b as se, g as _t, c as re, d as ie } from "../../kernel_funcs_utils-CAd1h9X1.js";
3
+ import { c as wt, g as At, a as Nt, b as Dt, e as It } from "../../axis_util-BgTGy5w8.js";
4
+ import { b as ae, i as ue, c as le } from "../../slice_util-19zDNNSn.js";
5
+ import { r as ce } from "../../reshape-Boe4DuIO.js";
6
+ import { g as he } from "../../_commonjsHelpers-ByX85dGu.js";
7
+ function fe(t, e) {
7
8
  for (var n = 0; n < e.length; n++) {
8
9
  const o = e[n];
9
10
  if (typeof o != "string" && !Array.isArray(o)) {
@@ -19,10 +20,10 @@ function de(t, e) {
19
20
  }
20
21
  return Object.freeze(Object.defineProperty(t, Symbol.toStringTag, { value: "Module" }));
21
22
  }
22
- var dt, yt;
23
- function ge() {
24
- if (yt) return dt;
25
- yt = 1, dt = e;
23
+ var ft, St;
24
+ function de() {
25
+ if (St) return ft;
26
+ St = 1, ft = e;
26
27
  var t = null;
27
28
  try {
28
29
  t = new WebAssembly.Instance(new WebAssembly.Module(new Uint8Array([
@@ -315,85 +316,85 @@ function ge() {
315
316
  ])), {}).exports;
316
317
  } catch {
317
318
  }
318
- function e(x, l, v) {
319
- this.low = x | 0, this.high = l | 0, this.unsigned = !!v;
319
+ function e(I, l, v) {
320
+ this.low = I | 0, this.high = l | 0, this.unsigned = !!v;
320
321
  }
321
322
  e.prototype.__isLong__, Object.defineProperty(e.prototype, "__isLong__", { value: !0 });
322
- function n(x) {
323
- return (x && x.__isLong__) === !0;
323
+ function n(I) {
324
+ return (I && I.__isLong__) === !0;
324
325
  }
325
326
  e.isLong = n;
326
327
  var o = {}, s = {};
327
- function r(x, l) {
328
- var v, O, V;
329
- return l ? (x >>>= 0, (V = 0 <= x && x < 256) && (O = s[x], O) ? O : (v = a(x, (x | 0) < 0 ? -1 : 0, !0), V && (s[x] = v), v)) : (x |= 0, (V = -128 <= x && x < 128) && (O = o[x], O) ? O : (v = a(x, x < 0 ? -1 : 0, !1), V && (o[x] = v), v));
328
+ function r(I, l) {
329
+ var v, R, T;
330
+ return l ? (I >>>= 0, (T = 0 <= I && I < 256) && (R = s[I], R) ? R : (v = a(I, (I | 0) < 0 ? -1 : 0, !0), T && (s[I] = v), v)) : (I |= 0, (T = -128 <= I && I < 128) && (R = o[I], R) ? R : (v = a(I, I < 0 ? -1 : 0, !1), T && (o[I] = v), v));
330
331
  }
331
332
  e.fromInt = r;
332
- function i(x, l) {
333
- if (isNaN(x))
334
- return l ? I : g;
333
+ function i(I, l) {
334
+ if (isNaN(I))
335
+ return l ? x : g;
335
336
  if (l) {
336
- if (x < 0)
337
- return I;
338
- if (x >= m)
339
- return A;
340
- } else {
341
- if (x <= -b)
342
- return L;
343
- if (x + 1 >= b)
337
+ if (I < 0)
338
+ return x;
339
+ if (I >= m)
344
340
  return M;
341
+ } else {
342
+ if (I <= -b)
343
+ return _;
344
+ if (I + 1 >= b)
345
+ return z;
345
346
  }
346
- return x < 0 ? i(-x, l).neg() : a(x % p | 0, x / p | 0, l);
347
+ return I < 0 ? i(-I, l).neg() : a(I % p | 0, I / p | 0, l);
347
348
  }
348
349
  e.fromNumber = i;
349
- function a(x, l, v) {
350
- return new e(x, l, v);
350
+ function a(I, l, v) {
351
+ return new e(I, l, v);
351
352
  }
352
353
  e.fromBits = a;
353
354
  var u = Math.pow;
354
- function c(x, l, v) {
355
- if (x.length === 0)
355
+ function c(I, l, v) {
356
+ if (I.length === 0)
356
357
  throw Error("empty string");
357
- if (x === "NaN" || x === "Infinity" || x === "+Infinity" || x === "-Infinity")
358
+ if (I === "NaN" || I === "Infinity" || I === "+Infinity" || I === "-Infinity")
358
359
  return g;
359
360
  if (typeof l == "number" ? (v = l, l = !1) : l = !!l, v = v || 10, v < 2 || 36 < v)
360
361
  throw RangeError("radix");
361
- var O;
362
- if ((O = x.indexOf("-")) > 0)
362
+ var R;
363
+ if ((R = I.indexOf("-")) > 0)
363
364
  throw Error("interior hyphen");
364
- if (O === 0)
365
- return c(x.substring(1), l, v).neg();
366
- for (var V = i(u(v, 8)), T = g, N = 0; N < x.length; N += 8) {
367
- var U = Math.min(8, x.length - N), B = parseInt(x.substring(N, N + U), v);
368
- if (U < 8) {
369
- var C = i(u(v, U));
370
- T = T.mul(C).add(i(B));
365
+ if (R === 0)
366
+ return c(I.substring(1), l, v).neg();
367
+ for (var T = i(u(v, 8)), y = g, A = 0; A < I.length; A += 8) {
368
+ var q = Math.min(8, I.length - A), G = parseInt(I.substring(A, A + q), v);
369
+ if (q < 8) {
370
+ var P = i(u(v, q));
371
+ y = y.mul(P).add(i(G));
371
372
  } else
372
- T = T.mul(V), T = T.add(i(B));
373
+ y = y.mul(T), y = y.add(i(G));
373
374
  }
374
- return T.unsigned = l, T;
375
+ return y.unsigned = l, y;
375
376
  }
376
377
  e.fromString = c;
377
- function h(x, l) {
378
- return typeof x == "number" ? i(x, l) : typeof x == "string" ? c(x, l) : a(x.low, x.high, typeof l == "boolean" ? l : x.unsigned);
378
+ function h(I, l) {
379
+ return typeof I == "number" ? i(I, l) : typeof I == "string" ? c(I, l) : a(I.low, I.high, typeof l == "boolean" ? l : I.unsigned);
379
380
  }
380
381
  e.fromValue = h;
381
382
  var f = 65536, w = 1 << 24, p = f * f, m = p * p, b = m / 2, d = r(w), g = r(0);
382
383
  e.ZERO = g;
383
- var I = r(0, !0);
384
- e.UZERO = I;
384
+ var x = r(0, !0);
385
+ e.UZERO = x;
385
386
  var $ = r(1);
386
387
  e.ONE = $;
387
388
  var E = r(1, !0);
388
389
  e.UONE = E;
389
- var F = r(-1);
390
- e.NEG_ONE = F;
391
- var M = a(-1, 2147483647, !1);
392
- e.MAX_VALUE = M;
393
- var A = a(-1, -1, !0);
394
- e.MAX_UNSIGNED_VALUE = A;
395
- var L = a(0, -2147483648, !1);
396
- e.MIN_VALUE = L;
390
+ var V = r(-1);
391
+ e.NEG_ONE = V;
392
+ var z = a(-1, 2147483647, !1);
393
+ e.MAX_VALUE = z;
394
+ var M = a(-1, -1, !0);
395
+ e.MAX_UNSIGNED_VALUE = M;
396
+ var _ = a(0, -2147483648, !1);
397
+ e.MIN_VALUE = _;
397
398
  var S = e.prototype;
398
399
  return S.toInt = function() {
399
400
  return this.unsigned ? this.low >>> 0 : this.low;
@@ -405,18 +406,18 @@ function ge() {
405
406
  if (this.isZero())
406
407
  return "0";
407
408
  if (this.isNegative())
408
- if (this.eq(L)) {
409
- var v = i(l), O = this.div(v), V = O.mul(v).sub(this);
410
- return O.toString(l) + V.toInt().toString(l);
409
+ if (this.eq(_)) {
410
+ var v = i(l), R = this.div(v), T = R.mul(v).sub(this);
411
+ return R.toString(l) + T.toInt().toString(l);
411
412
  } else
412
413
  return "-" + this.neg().toString(l);
413
- for (var T = i(u(l, 6), this.unsigned), N = this, U = ""; ; ) {
414
- var B = N.div(T), C = N.sub(B.mul(T)).toInt() >>> 0, _ = C.toString(l);
415
- if (N = B, N.isZero())
416
- return _ + U;
417
- for (; _.length < 6; )
418
- _ = "0" + _;
419
- U = "" + _ + U;
414
+ for (var y = i(u(l, 6), this.unsigned), A = this, q = ""; ; ) {
415
+ var G = A.div(y), P = A.sub(G.mul(y)).toInt() >>> 0, L = P.toString(l);
416
+ if (A = G, A.isZero())
417
+ return L + q;
418
+ for (; L.length < 6; )
419
+ L = "0" + L;
420
+ q = "" + L + q;
420
421
  }
421
422
  }, S.getHighBits = function() {
422
423
  return this.high;
@@ -428,7 +429,7 @@ function ge() {
428
429
  return this.low >>> 0;
429
430
  }, S.getNumBitsAbs = function() {
430
431
  if (this.isNegative())
431
- return this.eq(L) ? 64 : this.neg().getNumBitsAbs();
432
+ return this.eq(_) ? 64 : this.neg().getNumBitsAbs();
432
433
  for (var l = this.high != 0 ? this.high : this.low, v = 31; v > 0 && (l & 1 << v) == 0; v--)
433
434
  ;
434
435
  return this.high != 0 ? v + 33 : v + 1;
@@ -472,14 +473,14 @@ function ge() {
472
473
  }, S.gte = S.greaterThanOrEqual, S.ge = S.greaterThanOrEqual, S.compare = function(l) {
473
474
  if (n(l) || (l = h(l)), this.eq(l))
474
475
  return 0;
475
- var v = this.isNegative(), O = l.isNegative();
476
- return v && !O ? -1 : !v && O ? 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;
476
+ var v = this.isNegative(), R = l.isNegative();
477
+ return v && !R ? -1 : !v && R ? 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;
477
478
  }, S.comp = S.compare, S.negate = function() {
478
- return !this.unsigned && this.eq(L) ? L : this.not().add($);
479
+ return !this.unsigned && this.eq(_) ? _ : this.not().add($);
479
480
  }, S.neg = S.negate, S.add = function(l) {
480
481
  n(l) || (l = h(l));
481
- var v = this.high >>> 16, O = this.high & 65535, V = this.low >>> 16, T = this.low & 65535, N = l.high >>> 16, U = l.high & 65535, B = l.low >>> 16, C = l.low & 65535, _ = 0, G = 0, P = 0, q = 0;
482
- return q += T + C, P += q >>> 16, q &= 65535, P += V + B, G += P >>> 16, P &= 65535, G += O + U, _ += G >>> 16, G &= 65535, _ += v + N, _ &= 65535, a(P << 16 | q, _ << 16 | G, this.unsigned);
482
+ var v = this.high >>> 16, R = this.high & 65535, T = this.low >>> 16, y = this.low & 65535, A = l.high >>> 16, q = l.high & 65535, G = l.low >>> 16, P = l.low & 65535, L = 0, j = 0, D = 0, U = 0;
483
+ return U += y + P, D += U >>> 16, U &= 65535, D += T + G, j += D >>> 16, D &= 65535, j += R + q, L += j >>> 16, j &= 65535, L += v + A, L &= 65535, a(D << 16 | U, L << 16 | j, this.unsigned);
483
484
  }, S.subtract = function(l) {
484
485
  return n(l) || (l = h(l)), this.add(l.neg());
485
486
  }, S.sub = S.subtract, S.multiply = function(l) {
@@ -496,18 +497,18 @@ function ge() {
496
497
  }
497
498
  if (l.isZero())
498
499
  return g;
499
- if (this.eq(L))
500
- return l.isOdd() ? L : g;
501
- if (l.eq(L))
502
- return this.isOdd() ? L : g;
500
+ if (this.eq(_))
501
+ return l.isOdd() ? _ : g;
502
+ if (l.eq(_))
503
+ return this.isOdd() ? _ : g;
503
504
  if (this.isNegative())
504
505
  return l.isNegative() ? this.neg().mul(l.neg()) : this.neg().mul(l).neg();
505
506
  if (l.isNegative())
506
507
  return this.mul(l.neg()).neg();
507
508
  if (this.lt(d) && l.lt(d))
508
509
  return i(this.toNumber() * l.toNumber(), this.unsigned);
509
- var O = this.high >>> 16, V = this.high & 65535, T = this.low >>> 16, N = this.low & 65535, U = l.high >>> 16, B = l.high & 65535, C = l.low >>> 16, _ = l.low & 65535, G = 0, P = 0, q = 0, rt = 0;
510
- return rt += N * _, q += rt >>> 16, rt &= 65535, q += T * _, P += q >>> 16, q &= 65535, q += N * C, P += q >>> 16, q &= 65535, P += V * _, G += P >>> 16, P &= 65535, P += T * C, G += P >>> 16, P &= 65535, P += N * B, G += P >>> 16, P &= 65535, G += O * _ + V * C + T * B + N * U, G &= 65535, a(q << 16 | rt, G << 16 | P, this.unsigned);
510
+ var R = this.high >>> 16, T = this.high & 65535, y = this.low >>> 16, A = this.low & 65535, q = l.high >>> 16, G = l.high & 65535, P = l.low >>> 16, L = l.low & 65535, j = 0, D = 0, U = 0, rt = 0;
511
+ return rt += A * L, U += rt >>> 16, rt &= 65535, U += y * L, D += U >>> 16, U &= 65535, U += A * P, D += U >>> 16, U &= 65535, D += T * L, j += D >>> 16, D &= 65535, D += y * P, j += D >>> 16, D &= 65535, D += A * G, j += D >>> 16, D &= 65535, j += R * L + T * P + y * G + A * q, j &= 65535, a(U << 16 | rt, j << 16 | D, this.unsigned);
511
512
  }, S.mul = S.multiply, S.divide = function(l) {
512
513
  if (n(l) || (l = h(l)), l.isZero())
513
514
  throw Error("division by zero");
@@ -523,37 +524,37 @@ function ge() {
523
524
  return a(v, t.get_high(), this.unsigned);
524
525
  }
525
526
  if (this.isZero())
526
- return this.unsigned ? I : g;
527
- var O, V, T;
527
+ return this.unsigned ? x : g;
528
+ var R, T, y;
528
529
  if (this.unsigned) {
529
530
  if (l.unsigned || (l = l.toUnsigned()), l.gt(this))
530
- return I;
531
+ return x;
531
532
  if (l.gt(this.shru(1)))
532
533
  return E;
533
- T = I;
534
+ y = x;
534
535
  } else {
535
- if (this.eq(L)) {
536
- if (l.eq($) || l.eq(F))
537
- return L;
538
- if (l.eq(L))
536
+ if (this.eq(_)) {
537
+ if (l.eq($) || l.eq(V))
538
+ return _;
539
+ if (l.eq(_))
539
540
  return $;
540
- var N = this.shr(1);
541
- return O = N.div(l).shl(1), O.eq(g) ? l.isNegative() ? $ : F : (V = this.sub(l.mul(O)), T = O.add(V.div(l)), T);
542
- } else if (l.eq(L))
543
- return this.unsigned ? I : g;
541
+ var A = this.shr(1);
542
+ return R = A.div(l).shl(1), R.eq(g) ? l.isNegative() ? $ : V : (T = this.sub(l.mul(R)), y = R.add(T.div(l)), y);
543
+ } else if (l.eq(_))
544
+ return this.unsigned ? x : g;
544
545
  if (this.isNegative())
545
546
  return l.isNegative() ? this.neg().div(l.neg()) : this.neg().div(l).neg();
546
547
  if (l.isNegative())
547
548
  return this.div(l.neg()).neg();
548
- T = g;
549
+ y = g;
549
550
  }
550
- for (V = this; V.gte(l); ) {
551
- O = Math.max(1, Math.floor(V.toNumber() / l.toNumber()));
552
- for (var U = Math.ceil(Math.log(O) / Math.LN2), B = U <= 48 ? 1 : u(2, U - 48), C = i(O), _ = C.mul(l); _.isNegative() || _.gt(V); )
553
- O -= B, C = i(O, this.unsigned), _ = C.mul(l);
554
- C.isZero() && (C = $), T = T.add(C), V = V.sub(_);
551
+ for (T = this; T.gte(l); ) {
552
+ R = Math.max(1, Math.floor(T.toNumber() / l.toNumber()));
553
+ for (var q = Math.ceil(Math.log(R) / Math.LN2), G = q <= 48 ? 1 : u(2, q - 48), P = i(R), L = P.mul(l); L.isNegative() || L.gt(T); )
554
+ R -= G, P = i(R, this.unsigned), L = P.mul(l);
555
+ P.isZero() && (P = $), y = y.add(P), T = T.sub(L);
555
556
  }
556
- return T;
557
+ return y;
557
558
  }, S.div = S.divide, S.modulo = function(l) {
558
559
  if (n(l) || (l = h(l)), t) {
559
560
  var v = (this.unsigned ? t.rem_u : t.rem_s)(
@@ -582,8 +583,8 @@ function ge() {
582
583
  return this;
583
584
  var v = this.high;
584
585
  if (l < 32) {
585
- var O = this.low;
586
- return a(O >>> l | v << 32 - l, v >>> l, this.unsigned);
586
+ var R = this.low;
587
+ return a(R >>> l | v << 32 - l, v >>> l, this.unsigned);
587
588
  } else return l === 32 ? a(v, 0, this.unsigned) : a(v >>> l - 32, 0, this.unsigned);
588
589
  }, S.shru = S.shiftRightUnsigned, S.shr_u = S.shiftRightUnsigned, S.toSigned = function() {
589
590
  return this.unsigned ? a(this.low, this.high, !1) : this;
@@ -615,8 +616,8 @@ function ge() {
615
616
  v >>> 8 & 255,
616
617
  v & 255
617
618
  ];
618
- }, e.fromBytes = function(l, v, O) {
619
- return O ? e.fromBytesLE(l, v) : e.fromBytesBE(l, v);
619
+ }, e.fromBytes = function(l, v, R) {
620
+ return R ? e.fromBytesLE(l, v) : e.fromBytesBE(l, v);
620
621
  }, e.fromBytesLE = function(l, v) {
621
622
  return new e(
622
623
  l[0] | l[1] << 8 | l[2] << 16 | l[3] << 24,
@@ -629,13 +630,13 @@ function ge() {
629
630
  l[0] << 24 | l[1] << 16 | l[2] << 8 | l[3],
630
631
  v
631
632
  );
632
- }, dt;
633
+ }, ft;
633
634
  }
634
- var qt = ge();
635
- const Bt = /* @__PURE__ */ fe(qt), pe = /* @__PURE__ */ de({
635
+ var zt = de();
636
+ const Pt = /* @__PURE__ */ he(zt), ge = /* @__PURE__ */ fe({
636
637
  __proto__: null,
637
- default: Bt
638
- }, [qt]);
638
+ default: Pt
639
+ }, [zt]);
639
640
  /**
640
641
  * @license
641
642
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -654,80 +655,80 @@ const Bt = /* @__PURE__ */ fe(qt), pe = /* @__PURE__ */ de({
654
655
  */
655
656
  const Q = (
656
657
  // tslint:disable-next-line
657
- Bt || pe
658
+ Pt || ge
658
659
  );
659
- function ft(t) {
660
+ function ct(t) {
660
661
  return Q.fromString(t, !0, 16);
661
662
  }
662
- const Gt = ft("c3a5c85c97cb3127"), J = ft("b492b66fbe98f273"), z = ft("9ae16a3b2f90404f");
663
- function wt(t) {
663
+ const Ct = ct("c3a5c85c97cb3127"), J = ct("b492b66fbe98f273"), C = ct("9ae16a3b2f90404f");
664
+ function pt(t) {
664
665
  return t.xor(t.shru(47));
665
666
  }
666
- function jt(t, e, n) {
667
+ function Wt(t, e, n) {
667
668
  const o = t.slice(e, e + n);
668
669
  return Q.fromBytes(Array.from(o), !0, !0);
669
670
  }
670
- function R(t, e) {
671
- return jt(t, e, 8);
671
+ function F(t, e) {
672
+ return Wt(t, e, 8);
672
673
  }
673
- function Rt(t, e) {
674
- return jt(t, e, 4);
674
+ function vt(t, e) {
675
+ return Wt(t, e, 4);
675
676
  }
676
- function D(t, e) {
677
+ function N(t, e) {
677
678
  return e === 0 ? t : t.shru(e).or(t.shl(64 - e));
678
679
  }
679
- function Y(t, e, n = ft("9ddfea08eb382d69")) {
680
+ function Y(t, e, n = ct("9ddfea08eb382d69")) {
680
681
  let o = t.xor(e).mul(n);
681
682
  o = o.xor(o.shru(47));
682
683
  let s = e.xor(o).mul(n);
683
684
  return s = s.xor(s.shru(47)), s = s.mul(n), s;
684
685
  }
685
- function me(t, e, n, o, s, r) {
686
- s = s.add(t), r = D(r.add(s).add(o), 21);
686
+ function pe(t, e, n, o, s, r) {
687
+ s = s.add(t), r = N(r.add(s).add(o), 21);
687
688
  const i = s;
688
- return s = s.add(e), s = s.add(n), r = r.add(D(s, 44)), [s.add(o), r.add(i)];
689
+ return s = s.add(e), s = s.add(n), r = r.add(N(s, 44)), [s.add(o), r.add(i)];
689
690
  }
690
691
  function it(t, e, n, o) {
691
- return me(R(t, e), R(t, e + 8), R(t, e + 16), R(t, e + 24), n, o);
692
+ return pe(F(t, e), F(t, e + 8), F(t, e + 16), F(t, e + 24), n, o);
692
693
  }
693
- function we(t, e = t.length) {
694
+ function me(t, e = t.length) {
694
695
  if (e >= 8) {
695
- const n = z.add(e * 2), o = R(t, 0).add(z), s = R(t, e - 8), r = D(s, 37).mul(n).add(o), i = D(o, 25).add(s).mul(n);
696
+ const n = C.add(e * 2), o = F(t, 0).add(C), s = F(t, e - 8), r = N(s, 37).mul(n).add(o), i = N(o, 25).add(s).mul(n);
696
697
  return Y(r, i, n);
697
698
  }
698
699
  if (e >= 4) {
699
- const n = z.add(e * 2), o = Rt(t, 0);
700
- return Y(o.shl(3).add(e), Rt(t, e - 4), n);
700
+ const n = C.add(e * 2), o = vt(t, 0);
701
+ return Y(o.shl(3).add(e), vt(t, e - 4), n);
701
702
  }
702
703
  if (e > 0) {
703
704
  const n = t[0], o = t[e >> 1], s = t[e - 1], r = n + (o << 8), i = e + (s << 2);
704
- return wt(z.mul(r).xor(Gt.mul(i))).mul(z);
705
+ return pt(C.mul(r).xor(Ct.mul(i))).mul(C);
705
706
  }
706
- return z;
707
+ return C;
708
+ }
709
+ function we(t, e = t.length) {
710
+ const n = C.add(e * 2), o = F(t, 0).mul(J), s = F(t, 8), r = F(t, e - 8).mul(n), i = F(t, e - 16).mul(C);
711
+ return Y(N(o.add(s), 43).add(N(r, 30)).add(i), o.add(N(s.add(C), 18)).add(r), n);
707
712
  }
708
713
  function Ie(t, e = t.length) {
709
- const n = z.add(e * 2), o = R(t, 0).mul(J), s = R(t, 8), r = R(t, e - 8).mul(n), i = R(t, e - 16).mul(z);
710
- return Y(D(o.add(s), 43).add(D(r, 30)).add(i), o.add(D(s.add(z), 18)).add(r), n);
714
+ const n = C.add(e * 2), o = F(t, 0).mul(C), s = F(t, 8), r = F(t, e - 8).mul(n), i = F(t, e - 16).mul(C), a = N(o.add(s), 43).add(N(r, 30)).add(i), u = Y(a, o.add(N(s.add(C), 18)).add(r), n), c = F(t, 16).mul(n), h = F(t, 24), f = a.add(F(t, e - 32)).mul(n), w = u.add(F(t, e - 24)).mul(n);
715
+ return Y(N(c.add(h), 43).add(N(f, 30)).add(w), c.add(N(h.add(o), 18)).add(f), n);
711
716
  }
712
717
  function xe(t, e = t.length) {
713
- const n = z.add(e * 2), o = R(t, 0).mul(z), s = R(t, 8), r = R(t, e - 8).mul(n), i = R(t, e - 16).mul(z), a = D(o.add(s), 43).add(D(r, 30)).add(i), u = Y(a, o.add(D(s.add(z), 18)).add(r), n), c = R(t, 16).mul(n), h = R(t, 24), f = a.add(R(t, e - 32)).mul(n), w = u.add(R(t, e - 24)).mul(n);
714
- return Y(D(c.add(h), 43).add(D(f, 30)).add(w), c.add(D(h.add(o), 18)).add(f), n);
715
- }
716
- function Se(t, e = t.length) {
717
718
  const n = Q.fromNumber(81, !0);
718
719
  if (e <= 32)
719
- return e <= 16 ? we(t, e) : Ie(t, e);
720
+ return e <= 16 ? me(t, e) : we(t, e);
720
721
  if (e <= 64)
721
- return xe(t, e);
722
- let o = n, s = n.mul(J).add(113), r = wt(s.mul(z).add(113)).mul(z), i = [Q.UZERO, Q.UZERO], a = [Q.UZERO, Q.UZERO];
723
- o = o.mul(z).add(R(t, 0));
722
+ return Ie(t, e);
723
+ let o = n, s = n.mul(J).add(113), r = pt(s.mul(C).add(113)).mul(C), i = [Q.UZERO, Q.UZERO], a = [Q.UZERO, Q.UZERO];
724
+ o = o.mul(C).add(F(t, 0));
724
725
  let u = 0;
725
726
  const c = (e - 1 >> 6) * 64, h = c + (e - 1 & 63) - 63;
726
727
  do
727
- o = D(o.add(s).add(i[0]).add(R(t, u + 8)), 37).mul(J), s = D(s.add(i[1]).add(R(t, u + 48)), 42).mul(J), o = o.xor(a[1]), s = s.add(i[0]).add(R(t, u + 40)), r = D(r.add(a[0]), 33).mul(J), i = it(t, u, i[1].mul(J), o.add(a[0])), a = it(t, u + 32, r.add(a[1]), s.add(R(t, u + 16))), [r, o] = [o, r], u += 64;
728
+ o = N(o.add(s).add(i[0]).add(F(t, u + 8)), 37).mul(J), s = N(s.add(i[1]).add(F(t, u + 48)), 42).mul(J), o = o.xor(a[1]), s = s.add(i[0]).add(F(t, u + 40)), r = N(r.add(a[0]), 33).mul(J), i = it(t, u, i[1].mul(J), o.add(a[0])), a = it(t, u + 32, r.add(a[1]), s.add(F(t, u + 16))), [r, o] = [o, r], u += 64;
728
729
  while (u !== c);
729
730
  const f = J.add(r.and(255).shl(1));
730
- return u = h, a[0] = a[0].add(e - 1 & 63), i[0] = i[0].add(a[0]), a[0] = a[0].add(i[0]), o = D(o.add(s).add(i[0]).add(R(t, u + 8)), 37).mul(f), s = D(s.add(i[1]).add(R(t, u + 48)), 42).mul(f), o = o.xor(a[1].mul(9)), s = s.add(i[0].mul(9).add(R(t, u + 40))), r = D(r.add(a[0]), 33).mul(f), i = it(t, u, i[1].mul(f), o.add(a[0])), a = it(t, u + 32, r.add(a[1]), s.add(R(t, u + 16))), [r, o] = [o, r], Y(Y(i[0], a[0], f).add(wt(s).mul(Gt)).add(r), Y(i[1], a[1], f).add(o), f);
731
+ return u = h, a[0] = a[0].add(e - 1 & 63), i[0] = i[0].add(a[0]), a[0] = a[0].add(i[0]), o = N(o.add(s).add(i[0]).add(F(t, u + 8)), 37).mul(f), s = N(s.add(i[1]).add(F(t, u + 48)), 42).mul(f), o = o.xor(a[1].mul(9)), s = s.add(i[0].mul(9).add(F(t, u + 40))), r = N(r.add(a[0]), 33).mul(f), i = it(t, u, i[1].mul(f), o.add(a[0])), a = it(t, u + 32, r.add(a[1]), s.add(F(t, u + 16))), [r, o] = [o, r], Y(Y(i[0], a[0], f).add(pt(s).mul(Ct)).add(r), Y(i[1], a[1], f).add(o), f);
731
732
  }
732
733
  /**
733
734
  * @license
@@ -749,7 +750,7 @@ var H;
749
750
  (function(t) {
750
751
  t[t.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", t[t.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", t[t.ROW_LENGTHS = 2] = "ROW_LENGTHS", t[t.ROW_SPLITS = 3] = "ROW_SPLITS", t[t.ROW_LIMITS = 4] = "ROW_LIMITS", t[t.ROW_STARTS = 5] = "ROW_STARTS";
751
752
  })(H || (H = {}));
752
- function be(t, e, n) {
753
+ function Se(t, e, n) {
753
754
  let o = new Array();
754
755
  if (n == null && e == null)
755
756
  return o;
@@ -789,10 +790,10 @@ function ve(t) {
789
790
  break;
790
791
  return n;
791
792
  }
792
- function Ee(t) {
793
+ function be(t) {
793
794
  return t.length === 0 ? 0 : t[0] === H.FIRST_DIM_SIZE ? t.length - 1 : t.length;
794
795
  }
795
- function $e(t, e) {
796
+ function Ee(t, e) {
796
797
  if (t == null || e == null)
797
798
  return;
798
799
  const n = t.length, o = e.length;
@@ -820,9 +821,9 @@ function $e(t, e) {
820
821
  * limitations under the License.
821
822
  * =============================================================================
822
823
  */
823
- const Oe = 30;
824
- function ye(t) {
825
- return t <= Oe ? t : Jt(t, Math.floor(Math.sqrt(t)));
824
+ const $e = 30;
825
+ function Re(t) {
826
+ return t <= $e ? t : jt(t, Math.floor(Math.sqrt(t)));
826
827
  }
827
828
  /**
828
829
  * @license
@@ -840,14 +841,14 @@ function ye(t) {
840
841
  * limitations under the License.
841
842
  * =============================================================================
842
843
  */
843
- function Re(t) {
844
+ function Fe(t) {
844
845
  return `Received SparseTensor with denseShape[0] = 0 but
845
846
  indices.shape[0] = ${t}`;
846
847
  }
847
- function Fe(t, e) {
848
+ function Oe(t, e) {
848
849
  return `indices(${t}, 0) is invalid: ${e} < 0`;
849
850
  }
850
- function Te(t, e, n) {
851
+ function ye(t, e, n) {
851
852
  return `indices(${t}, 0) is invalid: ${e} >= ${n}`;
852
853
  }
853
854
  /**
@@ -866,22 +867,22 @@ function Te(t, e, n) {
866
867
  * limitations under the License.
867
868
  * =============================================================================
868
869
  */
869
- function Ve(t, e) {
870
+ function Te(t, e) {
870
871
  return `only one output dimension may be -1, not both ${t} and ${e}`;
871
872
  }
872
- function Ae(t, e) {
873
+ function Ve(t, e) {
873
874
  return `size ${t} must be non-negative, not ${e}`;
874
875
  }
875
876
  function Le() {
876
877
  return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero";
877
878
  }
878
- function _e(t, e) {
879
- const n = y(t), o = y(e);
879
+ function Me(t, e) {
880
+ const n = O(t), o = O(e);
880
881
  return `Input to reshape is a SparseTensor with ${n}
881
882
  dense values, but the requested shape requires a multiple of ${o}. inputShape=${t} outputShape= ${e}`;
882
883
  }
883
- function Me(t, e) {
884
- const n = y(t), o = y(e);
884
+ function _e(t, e) {
885
+ const n = O(t), o = O(e);
885
886
  return `Input to reshape is a tensor with ${n} dense values, but the requested shape has ${o}. inputShape=${t} outputShape=${e}`;
886
887
  }
887
888
  /**
@@ -900,44 +901,18 @@ function Me(t, e) {
900
901
  * limitations under the License.
901
902
  * =============================================================================
902
903
  */
903
- function Ft() {
904
+ function bt() {
904
905
  return "segment ids must be >= 0";
905
906
  }
906
- function Ne() {
907
+ function Ae() {
907
908
  return "segment ids are not increasing";
908
909
  }
909
- function De(t, e) {
910
+ function Ne(t, e) {
910
911
  return `Segment id ${t} out of range [0, ${e}), possibly because segmentIds input is not sorted.`;
911
912
  }
912
- function Pe(t, e, n) {
913
+ function De(t, e, n) {
913
914
  return `Bad: indices[${t}] == ${e} out of range [0, ${n})`;
914
915
  }
915
- /**
916
- * @license
917
- * Copyright 2018 Google LLC. All Rights Reserved.
918
- * Licensed under the Apache License, Version 2.0 (the "License");
919
- * you may not use this file except in compliance with the License.
920
- * You may obtain a copy of the License at
921
- *
922
- * http://www.apache.org/licenses/LICENSE-2.0
923
- *
924
- * Unless required by applicable law or agreed to in writing, software
925
- * distributed under the License is distributed on an "AS IS" BASIS,
926
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
927
- * See the License for the specific language governing permissions and
928
- * limitations under the License.
929
- * =============================================================================
930
- */
931
- function lt(t) {
932
- try {
933
- return t.map((e) => Qt(e));
934
- } catch (e) {
935
- throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`);
936
- }
937
- }
938
- function Ce(t) {
939
- return t.map((e) => ut(e));
940
- }
941
916
  /**
942
917
  * @license
943
918
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -978,18 +953,18 @@ function ze(t) {
978
953
  */
979
954
  function k(t) {
980
955
  return (e, n, o, s, r) => {
981
- const i = It(e, n), a = i.length, u = K(i), c = y(i), h = nt(r, c), f = e.length, w = n.length, p = K(e), m = K(n), b = Ot(e, i), d = Ot(n, i);
956
+ const i = Bt(e, n), a = i.length, u = K(i), c = O(i), h = nt(r, c), f = e.length, w = n.length, p = K(e), m = K(n), b = xt(e, i), d = xt(n, i);
982
957
  if (b.length + d.length === 0)
983
958
  for (let g = 0; g < h.length; ++g)
984
959
  h[g] = t(o[g % o.length], s[g % s.length]);
985
960
  else
986
961
  for (let g = 0; g < h.length; ++g) {
987
- const I = xt(g, a, u), $ = I.slice(-f);
988
- b.forEach((A) => $[A] = 0);
989
- const E = gt($, f, p), F = I.slice(-w);
990
- d.forEach((A) => F[A] = 0);
991
- const M = gt(F, w, m);
992
- h[g] = t(o[E], s[M]);
962
+ const x = mt(g, a, u), $ = x.slice(-f);
963
+ b.forEach((M) => $[M] = 0);
964
+ const E = dt($, f, p), V = x.slice(-w);
965
+ d.forEach((M) => V[M] = 0);
966
+ const z = dt(V, w, m);
967
+ h[g] = t(o[E], s[z]);
993
968
  }
994
969
  return [h, i];
995
970
  };
@@ -1010,13 +985,13 @@ function k(t) {
1010
985
  * limitations under the License.
1011
986
  * =============================================================================
1012
987
  */
1013
- function We(t, e, n, o) {
988
+ function Pe(t, e, n, o) {
1014
989
  if (o === "int32") {
1015
990
  const s = Int32Array.from(t);
1016
991
  return [e, "int32", s];
1017
992
  }
1018
993
  if (o === "bool") {
1019
- const s = te([0], n), [r, i] = k((a, u) => a !== u ? 1 : 0)(e, [], t, s, "bool");
994
+ const s = Zt([0], n), [r, i] = k((a, u) => a !== u ? 1 : 0)(e, [], t, s, "bool");
1020
995
  return [i, "bool", r];
1021
996
  }
1022
997
  throw new Error(`Error in Cast: failed to cast ${n} to ${o}`);
@@ -1037,7 +1012,7 @@ function We(t, e, n, o) {
1037
1012
  * limitations under the License.
1038
1013
  * =============================================================================
1039
1014
  */
1040
- const ke = k((t, e) => t + e);
1015
+ const Ce = k((t, e) => t + e);
1041
1016
  /**
1042
1017
  * @license
1043
1018
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1054,8 +1029,8 @@ const ke = k((t, e) => t + e);
1054
1029
  * limitations under the License.
1055
1030
  * =============================================================================
1056
1031
  */
1057
- function Ue(t, e, n, o, s) {
1058
- const r = y(o), i = ot(s, n);
1032
+ function We(t, e, n, o, s) {
1033
+ const r = O(o), i = ot(s, n);
1059
1034
  for (let a = 0; a < t.length; a++) {
1060
1035
  const u = t[a];
1061
1036
  if (u < 0)
@@ -1064,7 +1039,7 @@ function Ue(t, e, n, o, s) {
1064
1039
  }
1065
1040
  return i;
1066
1041
  }
1067
- function qe(t, e, n, o = !1) {
1042
+ function ke(t, e, n, o = !1) {
1068
1043
  const s = t.shape[0], r = t.shape[1], i = Z([s, n], e.dtype);
1069
1044
  for (let a = 0; a < s; a++)
1070
1045
  for (let u = 0; u < r; u++) {
@@ -1091,7 +1066,7 @@ function qe(t, e, n, o = !1) {
1091
1066
  * limitations under the License.
1092
1067
  * =============================================================================
1093
1068
  */
1094
- const Be = k((t, e) => t & e);
1069
+ const qe = k((t, e) => t & e);
1095
1070
  /**
1096
1071
  * @license
1097
1072
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1132,7 +1107,7 @@ function X(t) {
1132
1107
  * limitations under the License.
1133
1108
  * =============================================================================
1134
1109
  */
1135
- const Ge = X((t) => Math.ceil(t));
1110
+ const Ue = X((t) => Math.ceil(t));
1136
1111
  /**
1137
1112
  * @license
1138
1113
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1149,18 +1124,18 @@ const Ge = X((t) => Math.ceil(t));
1149
1124
  * limitations under the License.
1150
1125
  * =============================================================================
1151
1126
  */
1152
- function je(t, e, n, o) {
1153
- const s = W(n, y(e));
1127
+ function Ge(t, e, n, o) {
1128
+ const s = W(n, O(e));
1154
1129
  if (o && n !== "string") {
1155
1130
  let r = 0;
1156
1131
  t.forEach((i) => {
1157
- const a = y(i.shape);
1132
+ const a = O(i.shape);
1158
1133
  s.set(i.vals, r), r += a;
1159
1134
  });
1160
1135
  } else {
1161
1136
  let r = 0;
1162
1137
  t.forEach((i) => {
1163
- const a = n === "string" ? lt(i.vals) : i.vals;
1138
+ const a = n === "string" ? Mt(i.vals) : i.vals;
1164
1139
  let u = 0;
1165
1140
  for (let c = 0; c < i.shape[0]; ++c) {
1166
1141
  const h = c * e[1] + r;
@@ -1188,7 +1163,7 @@ function je(t, e, n, o) {
1188
1163
  * limitations under the License.
1189
1164
  * =============================================================================
1190
1165
  */
1191
- const Ze = k((t, e) => t === e ? 1 : 0);
1166
+ const je = k((t, e) => t === e ? 1 : 0);
1192
1167
  /**
1193
1168
  * @license
1194
1169
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1205,7 +1180,7 @@ const Ze = k((t, e) => t === e ? 1 : 0);
1205
1180
  * limitations under the License.
1206
1181
  * =============================================================================
1207
1182
  */
1208
- const He = X((t) => Math.exp(t));
1183
+ const Be = X((t) => Math.exp(t));
1209
1184
  /**
1210
1185
  * @license
1211
1186
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1222,7 +1197,7 @@ const He = X((t) => Math.exp(t));
1222
1197
  * limitations under the License.
1223
1198
  * =============================================================================
1224
1199
  */
1225
- const Ke = X((t) => Math.expm1(t));
1200
+ const Ze = X((t) => Math.expm1(t));
1226
1201
  /**
1227
1202
  * @license
1228
1203
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1239,7 +1214,7 @@ const Ke = X((t) => Math.expm1(t));
1239
1214
  * limitations under the License.
1240
1215
  * =============================================================================
1241
1216
  */
1242
- const Xe = X((t) => Math.floor(t));
1217
+ const He = X((t) => Math.floor(t));
1243
1218
  /**
1244
1219
  * @license
1245
1220
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1256,7 +1231,7 @@ const Xe = X((t) => Math.floor(t));
1256
1231
  * limitations under the License.
1257
1232
  * =============================================================================
1258
1233
  */
1259
- const Ye = k((t, e) => Math.floor(t / e));
1234
+ const Ke = k((t, e) => Math.floor(t / e));
1260
1235
  /**
1261
1236
  * @license
1262
1237
  * Copyright 2021 Google LLC. All Rights Reserved.
@@ -1273,7 +1248,7 @@ const Ye = k((t, e) => Math.floor(t / e));
1273
1248
  * limitations under the License.
1274
1249
  * =============================================================================
1275
1250
  */
1276
- function Je(t, e, n, o, s, r, i, a, u) {
1251
+ function Xe(t, e, n, o, s, r, i, a, u) {
1277
1252
  const c = Z([o, r], n);
1278
1253
  for (let h = 0; h < o; h++) {
1279
1254
  const f = [];
@@ -1305,7 +1280,7 @@ function Je(t, e, n, o, s, r, i, a, u) {
1305
1280
  * limitations under the License.
1306
1281
  * =============================================================================
1307
1282
  */
1308
- function Qe(t, e, n) {
1283
+ function Ye(t, e, n) {
1309
1284
  const o = Z(n, t.dtype);
1310
1285
  for (let s = 0; s < o.size; ++s) {
1311
1286
  const i = o.indexToLoc(s).slice(), a = i[0], u = i[2], c = e.locToIndex([a, u]);
@@ -1331,7 +1306,7 @@ function Qe(t, e, n) {
1331
1306
  * limitations under the License.
1332
1307
  * =============================================================================
1333
1308
  */
1334
- const tn = k((t, e) => t > e ? 1 : 0);
1309
+ const Je = k((t, e) => t > e ? 1 : 0);
1335
1310
  /**
1336
1311
  * @license
1337
1312
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1348,7 +1323,7 @@ const tn = k((t, e) => t > e ? 1 : 0);
1348
1323
  * limitations under the License.
1349
1324
  * =============================================================================
1350
1325
  */
1351
- const en = k((t, e) => t >= e ? 1 : 0);
1326
+ const Qe = k((t, e) => t >= e ? 1 : 0);
1352
1327
  /**
1353
1328
  * @license
1354
1329
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1365,7 +1340,7 @@ const en = k((t, e) => t >= e ? 1 : 0);
1365
1340
  * limitations under the License.
1366
1341
  * =============================================================================
1367
1342
  */
1368
- const nn = k((t, e) => t < e ? 1 : 0);
1343
+ const tn = k((t, e) => t < e ? 1 : 0);
1369
1344
  /**
1370
1345
  * @license
1371
1346
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1382,7 +1357,7 @@ const nn = k((t, e) => t < e ? 1 : 0);
1382
1357
  * limitations under the License.
1383
1358
  * =============================================================================
1384
1359
  */
1385
- const on = k((t, e) => t <= e ? 1 : 0);
1360
+ const en = k((t, e) => t <= e ? 1 : 0);
1386
1361
  /**
1387
1362
  * @license
1388
1363
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1399,7 +1374,7 @@ const on = k((t, e) => t <= e ? 1 : 0);
1399
1374
  * limitations under the License.
1400
1375
  * =============================================================================
1401
1376
  */
1402
- function sn(t, e, n) {
1377
+ function nn(t, e, n) {
1403
1378
  const o = (e - t) / (n - 1), s = ot(n, "float32");
1404
1379
  s[0] = t;
1405
1380
  for (let r = 1; r < s.length; r++)
@@ -1422,7 +1397,7 @@ function sn(t, e, n) {
1422
1397
  * limitations under the License.
1423
1398
  * =============================================================================
1424
1399
  */
1425
- const rn = X((t) => Math.log(t));
1400
+ const on = X((t) => Math.log(t));
1426
1401
  /**
1427
1402
  * @license
1428
1403
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1439,8 +1414,8 @@ const rn = X((t) => Math.log(t));
1439
1414
  * limitations under the License.
1440
1415
  * =============================================================================
1441
1416
  */
1442
- function an(t, e, n, o) {
1443
- const s = nt(o, y(n));
1417
+ function sn(t, e, n, o) {
1418
+ const s = nt(o, O(n));
1444
1419
  for (let r = 0; r < s.length; ++r) {
1445
1420
  const i = r * e;
1446
1421
  let a = t[i];
@@ -1468,7 +1443,7 @@ function an(t, e, n, o) {
1468
1443
  * limitations under the License.
1469
1444
  * =============================================================================
1470
1445
  */
1471
- const un = k((t, e) => Math.max(t, e));
1446
+ const rn = k((t, e) => Math.max(t, e));
1472
1447
  /**
1473
1448
  * @license
1474
1449
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1485,7 +1460,7 @@ const un = k((t, e) => Math.max(t, e));
1485
1460
  * limitations under the License.
1486
1461
  * =============================================================================
1487
1462
  */
1488
- const ln = k((t, e) => Math.min(t, e));
1463
+ const an = k((t, e) => Math.min(t, e));
1489
1464
  /**
1490
1465
  * @license
1491
1466
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1502,7 +1477,7 @@ const ln = k((t, e) => Math.min(t, e));
1502
1477
  * limitations under the License.
1503
1478
  * =============================================================================
1504
1479
  */
1505
- const Zt = k((t, e) => t * e);
1480
+ const kt = k((t, e) => t * e);
1506
1481
  /**
1507
1482
  * @license
1508
1483
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1519,9 +1494,9 @@ const Zt = k((t, e) => t * e);
1519
1494
  * limitations under the License.
1520
1495
  * =============================================================================
1521
1496
  */
1522
- function cn(t, e, n) {
1523
- const o = ee(-1, n);
1524
- return Zt([], e, o, t, n);
1497
+ function un(t, e, n) {
1498
+ const o = Ht(-1, n);
1499
+ return kt([], e, o, t, n);
1525
1500
  }
1526
1501
  /**
1527
1502
  * @license
@@ -1539,7 +1514,7 @@ function cn(t, e, n) {
1539
1514
  * limitations under the License.
1540
1515
  * =============================================================================
1541
1516
  */
1542
- const hn = k((t, e) => t !== e ? 1 : 0);
1517
+ const ln = k((t, e) => t !== e ? 1 : 0);
1543
1518
  /**
1544
1519
  * @license
1545
1520
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -1556,13 +1531,13 @@ const hn = k((t, e) => t !== e ? 1 : 0);
1556
1531
  * limitations under the License.
1557
1532
  * =============================================================================
1558
1533
  */
1559
- function fn(t, e, n, o, s) {
1560
- const r = e.length, i = y(e), a = K(e), u = K(s), c = nt(n, y(s));
1534
+ function cn(t, e, n, o, s) {
1535
+ const r = e.length, i = O(e), a = K(e), u = K(s), c = nt(n, O(s));
1561
1536
  for (let h = 0; h < i; ++h) {
1562
- const f = xt(h, r, a), w = new Array(f.length);
1537
+ const f = mt(h, r, a), w = new Array(f.length);
1563
1538
  for (let m = 0; m < w.length; m++)
1564
1539
  w[m] = f[o[m]];
1565
- const p = gt(w, r, u);
1540
+ const p = dt(w, r, u);
1566
1541
  c[p] = t[h];
1567
1542
  }
1568
1543
  return c;
@@ -1583,8 +1558,8 @@ function fn(t, e, n, o, s) {
1583
1558
  * limitations under the License.
1584
1559
  * =============================================================================
1585
1560
  */
1586
- function dn(t, e, n, o) {
1587
- const [s, r] = bt(t, o), i = pt(e, "int32"), a = ot(y(s), i), u = y(r);
1561
+ function hn(t, e, n, o) {
1562
+ const [s, r] = wt(t, o), i = Kt(e, "int32"), a = ot(O(s), i), u = O(r);
1588
1563
  for (let c = 0; c < a.length; ++c) {
1589
1564
  const h = c * u;
1590
1565
  let f = 1;
@@ -1610,15 +1585,15 @@ function dn(t, e, n, o) {
1610
1585
  * limitations under the License.
1611
1586
  * =============================================================================
1612
1587
  */
1613
- function gn(t, e, n) {
1588
+ function fn(t, e, n) {
1614
1589
  t.forEach((o, s) => {
1615
1590
  if (o < 0 || o >= n) {
1616
- const r = xt(s, e.length, K(e)).join(",");
1591
+ const r = mt(s, e.length, K(e)).join(",");
1617
1592
  throw new Error(`indices[${r}] = ${o} is not in [0, ${n})`);
1618
1593
  }
1619
1594
  });
1620
1595
  }
1621
- function pn(t, e) {
1596
+ function dn(t, e) {
1622
1597
  for (let n = 0; n < t.length; ++n) {
1623
1598
  const o = t[n], s = n === t.length - 1 ? e : t[n + 1].length;
1624
1599
  if (o.length === 0)
@@ -1632,11 +1607,11 @@ function pn(t, e) {
1632
1607
  throw new Error("Ragged splits must be sorted in ascending order");
1633
1608
  }
1634
1609
  }
1635
- function mn(t, e, n, o) {
1610
+ function gn(t, e, n, o) {
1636
1611
  const s = [];
1637
1612
  let r = 0;
1638
1613
  const i = e.length - 1 + n.length, a = new Array(i).fill(null).map(() => [0]);
1639
- pn(n, o);
1614
+ dn(n, o);
1640
1615
  let u = 1;
1641
1616
  for (let c = 0; c < e.length - 1; ++c) {
1642
1617
  u *= e[c];
@@ -1659,7 +1634,7 @@ function mn(t, e, n, o) {
1659
1634
  }
1660
1635
  return { outSplits: a, valueSlices: s, numValues: r };
1661
1636
  }
1662
- function wn(t) {
1637
+ function pn(t) {
1663
1638
  const e = [];
1664
1639
  for (let n = 0; n < t.length; ++n) {
1665
1640
  const o = t[n].length, s = W("int32", o);
@@ -1667,7 +1642,7 @@ function wn(t) {
1667
1642
  }
1668
1643
  return e;
1669
1644
  }
1670
- function Tt(t, e) {
1645
+ function Et(t, e) {
1671
1646
  const n = t.slice(0, e);
1672
1647
  for (; n.length < e; )
1673
1648
  n.push(1);
@@ -1675,8 +1650,8 @@ function Tt(t, e) {
1675
1650
  n[e - 1] *= t[o];
1676
1651
  return n;
1677
1652
  }
1678
- function In(t, e, n, o, s, r) {
1679
- const i = Tt(e, 2)[1], a = Tt(r, 2)[1];
1653
+ function mn(t, e, n, o, s, r) {
1654
+ const i = Et(e, 2)[1], a = Et(r, 2)[1];
1680
1655
  let u = 0;
1681
1656
  for (const c of n)
1682
1657
  for (let h = c[0]; h < c[1]; ++h) {
@@ -1685,21 +1660,21 @@ function In(t, e, n, o, s, r) {
1685
1660
  ++u;
1686
1661
  }
1687
1662
  }
1688
- function xn(t, e, n, o, s) {
1663
+ function wn(t, e, n, o, s) {
1689
1664
  const r = e.slice();
1690
1665
  r[0] = s;
1691
- const i = W(n, y(r)), a = t.length, u = a === 0 ? 0 : a / e[0];
1692
- return In(t, e, o, u, i, r), [i, r];
1666
+ const i = W(n, O(r)), a = t.length, u = a === 0 ? 0 : a / e[0];
1667
+ return mn(t, e, o, u, i, r), [i, r];
1693
1668
  }
1694
- function Sn(t, e, n, o, s, r, i, a) {
1669
+ function In(t, e, n, o, s, r, i, a) {
1695
1670
  if (t.length === 0)
1696
1671
  throw new Error("paramsNestedSplits must be non empty");
1697
1672
  if (e[0].length === 0)
1698
1673
  throw new Error("Split tensors must not be scalars");
1699
1674
  const u = e[0][0] - 1;
1700
- if (gn(r, i, u), o.length === 0)
1675
+ if (fn(r, i, u), o.length === 0)
1701
1676
  throw new Error("params.rank must be nonzero");
1702
- const c = o[0], { outSplits: h, valueSlices: f, numValues: w } = mn(r, i, t, c), p = wn(h), m = xn(n, o, s, f, w);
1677
+ const c = o[0], { outSplits: h, valueSlices: f, numValues: w } = gn(r, i, t, c), p = pn(h), m = wn(n, o, s, f, w);
1703
1678
  return [p, m[0], m[1]];
1704
1679
  }
1705
1680
  /**
@@ -1718,8 +1693,8 @@ function Sn(t, e, n, o, s, r, i, a) {
1718
1693
  * limitations under the License.
1719
1694
  * =============================================================================
1720
1695
  */
1721
- const Vt = 2147483647;
1722
- function bn(t, e, n, o, s, r, i) {
1696
+ const $t = 2147483647;
1697
+ function xn(t, e, n, o, s, r, i) {
1723
1698
  if (e.length > 1)
1724
1699
  throw new Error("starts must be a scalar or vector");
1725
1700
  if (s.length > 1)
@@ -1734,24 +1709,24 @@ function bn(t, e, n, o, s, r, i) {
1734
1709
  const f = h.length === 0 ? 1 : h[0], w = W("int32", f + 1);
1735
1710
  w[0] = 0;
1736
1711
  for (let d = 0; d < f; ++d) {
1737
- const g = a ? t[0] : t[d], I = u ? o[0] : o[d], $ = c ? r[0] : r[d];
1712
+ const g = a ? t[0] : t[d], x = u ? o[0] : o[d], $ = c ? r[0] : r[d];
1738
1713
  if ($ === 0)
1739
1714
  throw new Error("Requires delta != 0");
1740
1715
  let E;
1741
- if ($ > 0 && I < g || $ < 0 && I > g)
1716
+ if ($ > 0 && x < g || $ < 0 && x > g)
1742
1717
  E = 0;
1743
- else if (E = Math.ceil(Math.abs((I - g) / $)), E > Vt)
1744
- throw new Error(`Requires ((limit - start) / delta) <= ${Vt}`);
1718
+ else if (E = Math.ceil(Math.abs((x - g) / $)), E > $t)
1719
+ throw new Error(`Requires ((limit - start) / delta) <= ${$t}`);
1745
1720
  w[d + 1] = w[d] + E;
1746
1721
  }
1747
1722
  const p = w[f], m = W(n, p);
1748
1723
  let b = 0;
1749
1724
  for (let d = 0; d < f; ++d) {
1750
1725
  const g = w[d + 1] - w[d];
1751
- let I = a ? t[0] : t[d];
1726
+ let x = a ? t[0] : t[d];
1752
1727
  const $ = c ? r[0] : r[d];
1753
1728
  for (let E = 0; E < g; ++E)
1754
- m[b++] = I, I += $;
1729
+ m[b++] = x, x += $;
1755
1730
  }
1756
1731
  return [w, m];
1757
1732
  }
@@ -1771,27 +1746,27 @@ function bn(t, e, n, o, s, r, i) {
1771
1746
  * limitations under the License.
1772
1747
  * =============================================================================
1773
1748
  */
1774
- var j = H;
1775
- class ct {
1749
+ var B = H;
1750
+ class ut {
1776
1751
  constructor(e, n, o, s, r, i, a, u, c, h) {
1777
- this.shape = e, this.shapeShape = n, this.values = o, this.valuesShape = s, this.valuesDType = r, this.defaultValue = i, this.defaultValueShape = a, this.rowPartitionValues = u, this.rowPartitionValuesShapes = c, this.rowPartitionTypes = ve(h), this.raggedRank = Ee(this.rowPartitionTypes);
1752
+ this.shape = e, this.shapeShape = n, this.values = o, this.valuesShape = s, this.valuesDType = r, this.defaultValue = i, this.defaultValueShape = a, this.rowPartitionValues = u, this.rowPartitionValuesShapes = c, this.rowPartitionTypes = ve(h), this.raggedRank = be(this.rowPartitionTypes);
1778
1753
  }
1779
1754
  getRowPartitionTypeByDimension(e) {
1780
- return this.rowPartitionTypes[0] === j.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
1755
+ return this.rowPartitionTypes[0] === B.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e];
1781
1756
  }
1782
1757
  // Returns the relationship between dimension and dimension + 1.
1783
1758
  getRowPartitionTensor(e) {
1784
- return this.rowPartitionTypes[0] === j.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
1759
+ return this.rowPartitionTypes[0] === B.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e];
1785
1760
  }
1786
1761
  getMaxWidth(e) {
1787
1762
  const n = this.getRowPartitionTensor(e - 1);
1788
1763
  switch (this.getRowPartitionTypeByDimension(e - 1)) {
1789
- case j.VALUE_ROWIDS:
1790
- return ct.getMaxWidthValueRowID(n);
1791
- case j.ROW_SPLITS:
1792
- return ct.getMaxWidthRowSplit(n);
1764
+ case B.VALUE_ROWIDS:
1765
+ return ut.getMaxWidthValueRowID(n);
1766
+ case B.ROW_SPLITS:
1767
+ return ut.getMaxWidthRowSplit(n);
1793
1768
  default:
1794
- throw new Error(`Cannot handle partition type ${j[this.getRowPartitionTypeByDimension(e - 1)]}`);
1769
+ throw new Error(`Cannot handle partition type ${B[this.getRowPartitionTypeByDimension(e - 1)]}`);
1795
1770
  }
1796
1771
  }
1797
1772
  static getMaxWidthRowSplit(e) {
@@ -1822,12 +1797,12 @@ class ct {
1822
1797
  return [];
1823
1798
  throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.");
1824
1799
  }
1825
- return Lt(e, o);
1800
+ return Ft(e, o);
1826
1801
  }
1827
1802
  calculateOutputSize(e) {
1828
1803
  const n = this.valuesShape, o = this.defaultValueShape;
1829
- $e(o, n);
1830
- const s = this.tensorShapeFromTensor(this.shape, this.shapeShape), i = be(this.raggedRank, s, n);
1804
+ Ee(o, n);
1805
+ const s = this.tensorShapeFromTensor(this.shape, this.shapeShape), i = Se(this.raggedRank, s, n);
1831
1806
  i[0] < 0 && (i[0] = e);
1832
1807
  for (let a = 1; a <= this.raggedRank; ++a)
1833
1808
  i[a] < 0 && (i[a] = this.getMaxWidth(a));
@@ -1850,7 +1825,7 @@ class ct {
1850
1825
  r.push(i);
1851
1826
  for (let a = s; a < e; ++a)
1852
1827
  r.push(-1);
1853
- return zt(r.length === e, () => "Final length of result must be equal to firstDimension."), r;
1828
+ return Lt(r.length === e, () => "Final length of result must be equal to firstDimension."), r;
1854
1829
  }
1855
1830
  calculateOutputIndexRowSplit(e, n, o, s) {
1856
1831
  const r = e.length, i = [];
@@ -1915,14 +1890,14 @@ class ct {
1915
1890
  calculateOutputIndex(e, n, o, s) {
1916
1891
  const r = this.getRowPartitionTensor(e), i = this.getRowPartitionTypeByDimension(e);
1917
1892
  switch (i) {
1918
- case j.VALUE_ROWIDS:
1893
+ case B.VALUE_ROWIDS:
1919
1894
  return this.calculateOutputIndexValueRowID(r, n, o, s);
1920
- case j.ROW_SPLITS:
1895
+ case B.ROW_SPLITS:
1921
1896
  if (r.length - 1 > n.length)
1922
1897
  throw new Error(`Row partition size is greater than output size: ${r.length - 1} > ${n.length}`);
1923
1898
  return this.calculateOutputIndexRowSplit(r, n, o, s);
1924
1899
  default:
1925
- throw new Error(`Unsupported partition type: ${j[i]}`);
1900
+ throw new Error(`Unsupported partition type: ${B[i]}`);
1926
1901
  }
1927
1902
  }
1928
1903
  getFirstDimensionSize() {
@@ -1931,14 +1906,14 @@ class ct {
1931
1906
  throw new Error("No row_partition_types given.");
1932
1907
  const n = this.rowPartitionTypes[0];
1933
1908
  switch (n) {
1934
- case j.FIRST_DIM_SIZE:
1909
+ case B.FIRST_DIM_SIZE:
1935
1910
  return e[0];
1936
- case j.VALUE_ROWIDS:
1911
+ case B.VALUE_ROWIDS:
1937
1912
  throw new Error("Cannot handle VALUE_ROWIDS in first dimension.");
1938
- case j.ROW_SPLITS:
1913
+ case B.ROW_SPLITS:
1939
1914
  return this.rowPartitionValuesShapes[0][0] - 1;
1940
1915
  default:
1941
- throw new Error(`Cannot handle type ${j[n]}`);
1916
+ throw new Error(`Cannot handle type ${B[n]}`);
1942
1917
  }
1943
1918
  }
1944
1919
  compute() {
@@ -1948,7 +1923,7 @@ class ct {
1948
1923
  s[s.length - 1] = 1;
1949
1924
  for (let u = s.length - 2; u >= 0; --u)
1950
1925
  s[u] = s[u + 1] * o[u + 1];
1951
- const r = Lt(o, !1), i = W(this.valuesDType, y(r));
1926
+ const r = Ft(o, !1), i = W(this.valuesDType, O(r));
1952
1927
  if (s[0] * o[0] > 0) {
1953
1928
  let u = this.calculateFirstParentOutputIndex(n, s[0], o[0]);
1954
1929
  for (let c = 1; c <= this.raggedRank; ++c)
@@ -1963,13 +1938,13 @@ class ct {
1963
1938
  const r = this.values, i = o;
1964
1939
  let a = s.slice();
1965
1940
  a = a.slice(e + 1);
1966
- const u = y(a), c = n.length;
1941
+ const u = O(a), c = n.length;
1967
1942
  let h = this.defaultValue;
1968
1943
  if (h.length !== u && h.length !== 1) {
1969
1944
  const m = this.defaultValueShape;
1970
- ne(() => {
1971
- const b = he(h, m);
1972
- h = ue(b, a).dataSync();
1945
+ Xt(() => {
1946
+ const b = ce(h, m);
1947
+ h = ae(b, a).dataSync();
1973
1948
  });
1974
1949
  }
1975
1950
  let f = 0, w = 0, p = 0;
@@ -1980,8 +1955,8 @@ class ct {
1980
1955
  continue;
1981
1956
  }
1982
1957
  if (w < p) {
1983
- const d = r.subarray(f * u), g = i.subarray(w * u), I = (p - w) * u;
1984
- At(g, d, I);
1958
+ const d = r.subarray(f * u), g = i.subarray(w * u), x = (p - w) * u;
1959
+ Rt(g, d, x);
1985
1960
  }
1986
1961
  if (m >= c) {
1987
1962
  const d = o.length;
@@ -1993,17 +1968,17 @@ class ct {
1993
1968
  else
1994
1969
  for (; b > p; ) {
1995
1970
  const d = i.slice(p * u);
1996
- At(d, h, u), ++p;
1971
+ Rt(d, h, u), ++p;
1997
1972
  }
1998
1973
  b < 0 ? (f = m + 1, w = p) : (f = m, w = p, p = w + 1);
1999
1974
  }
2000
1975
  }
2001
1976
  }
2002
- function At(t, e, n) {
1977
+ function Rt(t, e, n) {
2003
1978
  for (let o = 0; o < n; o++)
2004
1979
  t[o] = e[o];
2005
1980
  }
2006
- function Lt(t, e) {
1981
+ function Ft(t, e) {
2007
1982
  const n = [];
2008
1983
  for (let o of t) {
2009
1984
  if (o < 0) {
@@ -2017,8 +1992,8 @@ function Lt(t, e) {
2017
1992
  }
2018
1993
  return n;
2019
1994
  }
2020
- function vn(t, e, n, o, s, r, i, a, u, c) {
2021
- return new ct(t, e, n, o, s, r, i, a, u, c).compute();
1995
+ function Sn(t, e, n, o, s, r, i, a, u, c) {
1996
+ return new ut(t, e, n, o, s, r, i, a, u, c).compute();
2022
1997
  }
2023
1998
  /**
2024
1999
  * @license
@@ -2036,7 +2011,7 @@ function vn(t, e, n, o, s, r, i, a, u, c) {
2036
2011
  * limitations under the License.
2037
2012
  * =============================================================================
2038
2013
  */
2039
- function En(t, e, n, o) {
2014
+ function vn(t, e, n, o) {
2040
2015
  const s = t === e, r = t < e && n < 0, i = e < t && n > 1;
2041
2016
  if (s || r || i)
2042
2017
  return ot(0, o);
@@ -2062,7 +2037,7 @@ function En(t, e, n, o) {
2062
2037
  * limitations under the License.
2063
2038
  * =============================================================================
2064
2039
  */
2065
- const $n = X((t) => 1 / Math.sqrt(t));
2040
+ const bn = X((t) => 1 / Math.sqrt(t));
2066
2041
  /**
2067
2042
  * @license
2068
2043
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2079,18 +2054,18 @@ const $n = X((t) => 1 / Math.sqrt(t));
2079
2054
  * limitations under the License.
2080
2055
  * =============================================================================
2081
2056
  */
2082
- function On(t, e, n, o, s, r, i, a, u, c) {
2057
+ function En(t, e, n, o, s, r, i, a, u, c) {
2083
2058
  const h = [o / s, s], f = t.values, w = e.values;
2084
2059
  if (o === 0)
2085
2060
  return Z(n, e.dtype);
2086
- const p = u instanceof mt ? u : Z(h, e.dtype);
2061
+ const p = u instanceof gt ? u : Z(h, e.dtype);
2087
2062
  typeof u == "string" || typeof u == "number" ? p.values.fill(u) : typeof u == "boolean" && p.values.fill(+u);
2088
2063
  for (let m = 0; m < r; m++) {
2089
2064
  const b = [];
2090
2065
  let d = 0;
2091
2066
  for (let g = 0; g < i; g++) {
2092
- const I = f[m * i + g];
2093
- b.push(I), d += I * a[g];
2067
+ const x = f[m * i + g];
2068
+ b.push(x), d += x * a[g];
2094
2069
  }
2095
2070
  if (d < 0 || d >= o / s)
2096
2071
  throw new Error(`Invalid indices: ${b} does not index into ${n}`);
@@ -2115,7 +2090,7 @@ function On(t, e, n, o, s, r, i, a, u, c) {
2115
2090
  * limitations under the License.
2116
2091
  * =============================================================================
2117
2092
  */
2118
- const yn = X((t) => 1 / (1 + Math.exp(-t)));
2093
+ const $n = X((t) => 1 / (1 + Math.exp(-t)));
2119
2094
  /**
2120
2095
  * @license
2121
2096
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2133,17 +2108,17 @@ const yn = X((t) => 1 / (1 + Math.exp(-t)));
2133
2108
  * =============================================================================
2134
2109
  */
2135
2110
  function Rn(t, e, n, o, s) {
2136
- const r = le(o, e, n), i = y(n), a = K(o);
2111
+ const r = ue(o, e, n), i = O(n), a = K(o);
2137
2112
  if (r) {
2138
- const f = ce(e, a);
2113
+ const f = le(e, a);
2139
2114
  return s === "string" ? t.slice(f, f + i) : t.subarray(f, f + i);
2140
2115
  }
2141
- const u = s === "string" ? lt(t) : t, c = Z(o, s, u), h = Z(n, s);
2116
+ const u = s === "string" ? Mt(t) : t, c = Z(o, s, u), h = Z(n, s);
2142
2117
  for (let f = 0; f < h.size; ++f) {
2143
2118
  const w = h.indexToLoc(f), p = w.map((m, b) => m + e[b]);
2144
2119
  h.set(c.get(...p), ...w);
2145
2120
  }
2146
- return s === "string" ? Ce(h.values) : h.values;
2121
+ return s === "string" ? oe(h.values) : h.values;
2147
2122
  }
2148
2123
  /**
2149
2124
  * @license
@@ -2165,7 +2140,7 @@ function Fn(t, e, n, o, s, r, i) {
2165
2140
  const a = e[0], u = r[0], c = new Array(u), h = new Array(a), f = e[1];
2166
2141
  if (u === 0) {
2167
2142
  if (a !== 0)
2168
- throw new Error(Re(a));
2143
+ throw new Error(Fe(a));
2169
2144
  const d = W(n, 0), g = W(s, 0);
2170
2145
  return [
2171
2146
  d,
@@ -2180,9 +2155,9 @@ function Fn(t, e, n, o, s, r, i) {
2180
2155
  for (let d = 0; d < a; ++d) {
2181
2156
  const g = t[d * f];
2182
2157
  if (g < 0)
2183
- throw new Error(Fe(d, g));
2158
+ throw new Error(Oe(d, g));
2184
2159
  if (g >= u)
2185
- throw new Error(Te(d, g, u));
2160
+ throw new Error(ye(d, g, u));
2186
2161
  ++m[g], w = w && g >= p, p = g;
2187
2162
  }
2188
2163
  let b = !0;
@@ -2192,8 +2167,8 @@ function Fn(t, e, n, o, s, r, i) {
2192
2167
  }
2193
2168
  if (b && w) {
2194
2169
  const d = t, g = o;
2195
- for (let I = 0; I < a; ++I)
2196
- h[I] = I;
2170
+ for (let x = 0; x < a; ++x)
2171
+ h[x] = x;
2197
2172
  return [
2198
2173
  d,
2199
2174
  [a, f],
@@ -2202,26 +2177,26 @@ function Fn(t, e, n, o, s, r, i) {
2202
2177
  h
2203
2178
  ];
2204
2179
  } else {
2205
- const d = m[u - 1], g = W(n, d * f), I = W(s, d), $ = new Array(u).fill(0);
2180
+ const d = m[u - 1], g = W(n, d * f), x = W(s, d), $ = new Array(u).fill(0);
2206
2181
  for (let E = 0; E < a; ++E) {
2207
- const F = t[E * f], M = $[F], A = (F === 0 ? 0 : m[F - 1]) + M;
2208
- $[F]++;
2209
- for (let L = 0; L < f; ++L)
2210
- g[A * f + L] = t[E * f + L];
2211
- I[A] = o[E], h[E] = A;
2182
+ const V = t[E * f], z = $[V], M = (V === 0 ? 0 : m[V - 1]) + z;
2183
+ $[V]++;
2184
+ for (let _ = 0; _ < f; ++_)
2185
+ g[M * f + _] = t[E * f + _];
2186
+ x[M] = o[E], h[E] = M;
2212
2187
  }
2213
2188
  for (let E = 0; E < u; ++E)
2214
2189
  if ($[E] === 0) {
2215
- const M = E === 0 ? 0 : m[E - 1];
2216
- g[M * f + 0] = E;
2217
- for (let A = 1; A < f; ++A)
2218
- g[M * f + A] = 0;
2219
- I[M] = i;
2190
+ const z = E === 0 ? 0 : m[E - 1];
2191
+ g[z * f + 0] = E;
2192
+ for (let M = 1; M < f; ++M)
2193
+ g[z * f + M] = 0;
2194
+ x[z] = i;
2220
2195
  }
2221
2196
  return [
2222
2197
  g,
2223
2198
  [d, f],
2224
- I,
2199
+ x,
2225
2200
  c,
2226
2201
  h
2227
2202
  ];
@@ -2243,18 +2218,18 @@ function Fn(t, e, n, o, s, r, i) {
2243
2218
  * limitations under the License.
2244
2219
  * =============================================================================
2245
2220
  */
2246
- function Tn(t, e, n, o, s) {
2247
- const r = y(o), i = e[0], a = s.length, u = [];
2221
+ function On(t, e, n, o, s) {
2222
+ const r = O(o), i = e[0], a = s.length, u = [];
2248
2223
  let c = 1, h = -1;
2249
2224
  for (let d = 0; d < a; ++d) {
2250
2225
  const g = s[d];
2251
2226
  if (g === -1) {
2252
2227
  if (h !== -1)
2253
- throw new Error(Ve(h, d));
2228
+ throw new Error(Te(h, d));
2254
2229
  h = d, u.push(1);
2255
2230
  } else {
2256
2231
  if (g < 0)
2257
- throw new Error(Ae(d, g));
2232
+ throw new Error(Ve(d, g));
2258
2233
  c *= g, u.push(g);
2259
2234
  }
2260
2235
  }
@@ -2263,11 +2238,11 @@ function Tn(t, e, n, o, s) {
2263
2238
  throw new Error(Le());
2264
2239
  const d = Math.trunc(r / c);
2265
2240
  if (c * d !== r)
2266
- throw new Error(_e(o, u));
2241
+ throw new Error(Me(o, u));
2267
2242
  u[h] = d;
2268
2243
  }
2269
- if (y(u) !== r)
2270
- throw new Error(Me(o, u));
2244
+ if (O(u) !== r)
2245
+ throw new Error(_e(o, u));
2271
2246
  const w = o.length, p = [];
2272
2247
  if (w > 0) {
2273
2248
  p[w - 1] = 1;
@@ -2283,10 +2258,10 @@ function Tn(t, e, n, o, s) {
2283
2258
  const b = W(n, i * a);
2284
2259
  for (let d = 0; d < i; ++d) {
2285
2260
  let g = 0;
2286
- for (let I = 0; I < w; ++I)
2287
- g += t[d * w + I] * p[I];
2288
- for (let I = 0; I < a; ++I)
2289
- b[d * a + I] = Math.trunc(g / m[I]), g %= m[I];
2261
+ for (let x = 0; x < w; ++x)
2262
+ g += t[d * w + x] * p[x];
2263
+ for (let x = 0; x < a; ++x)
2264
+ b[d * a + x] = Math.trunc(g / m[x]), g %= m[x];
2290
2265
  }
2291
2266
  return [b, [i, a], u];
2292
2267
  }
@@ -2306,42 +2281,42 @@ function Tn(t, e, n, o, s) {
2306
2281
  * limitations under the License.
2307
2282
  * =============================================================================
2308
2283
  */
2309
- function Vn(t, e, n, o, s, r = !1, i = 0) {
2284
+ function yn(t, e, n, o, s, r = !1, i = 0) {
2310
2285
  const a = o.length, u = [e[0], t.length / e[0]], c = u[1], f = a > 0 ? s[a - 1] + 1 : 0;
2311
2286
  if (f < 0)
2312
- throw new Error(Ft());
2287
+ throw new Error(bt());
2313
2288
  const w = e.slice();
2314
2289
  w[0] = f;
2315
2290
  const p = w.reduce(($, E) => $ * E, 1), m = W(n, p);
2316
2291
  if (a === 0)
2317
2292
  return f > 0 && m.fill(i), [m, w];
2318
2293
  if (f <= 0)
2319
- throw new Error(Ft());
2320
- let b = 0, d = 1, g = 0, I = s[b];
2294
+ throw new Error(bt());
2295
+ let b = 0, d = 1, g = 0, x = s[b];
2321
2296
  for (; ; ) {
2322
2297
  let $ = 0;
2323
2298
  if (d < a) {
2324
- if ($ = s[d], I === $) {
2299
+ if ($ = s[d], x === $) {
2325
2300
  ++d;
2326
2301
  continue;
2327
2302
  }
2328
- if (I >= $)
2329
- throw new Error(Ne());
2303
+ if (x >= $)
2304
+ throw new Error(Ae());
2330
2305
  }
2331
- if (I < 0 || I >= f)
2332
- throw new Error(De(I, f));
2333
- I > g && m.fill(i, g * c, I * c);
2306
+ if (x < 0 || x >= f)
2307
+ throw new Error(Ne(x, f));
2308
+ x > g && m.fill(i, g * c, x * c);
2334
2309
  for (let E = b; E < d; ++E) {
2335
- const F = o[E];
2336
- if (F < 0 || F >= u[0])
2337
- throw new Error(Pe(E, o[E], u[0]));
2338
- for (let M = 0; M < c; M++)
2339
- m[I * c + M] += t[F * c + M];
2310
+ const V = o[E];
2311
+ if (V < 0 || V >= u[0])
2312
+ throw new Error(De(E, o[E], u[0]));
2313
+ for (let z = 0; z < c; z++)
2314
+ m[x * c + z] += t[V * c + z];
2340
2315
  }
2341
2316
  if (r)
2342
2317
  for (let E = 0; E < c; E++)
2343
- m[I * c + E] /= d - b;
2344
- if (b = d, ++d, g = I + 1, I = $, d > a)
2318
+ m[x * c + E] /= d - b;
2319
+ if (b = d, ++d, g = x + 1, x = $, d > a)
2345
2320
  break;
2346
2321
  }
2347
2322
  return g < f && m.fill(i, g * c, f * c), [m, w];
@@ -2362,7 +2337,7 @@ function Vn(t, e, n, o, s, r = !1, i = 0) {
2362
2337
  * limitations under the License.
2363
2338
  * =============================================================================
2364
2339
  */
2365
- const An = X((t) => Math.sqrt(t));
2340
+ const Tn = X((t) => Math.sqrt(t));
2366
2341
  /**
2367
2342
  * @license
2368
2343
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2379,7 +2354,7 @@ const An = X((t) => Math.sqrt(t));
2379
2354
  * limitations under the License.
2380
2355
  * =============================================================================
2381
2356
  */
2382
- const Ln = k((t, e) => {
2357
+ const Vn = k((t, e) => {
2383
2358
  const n = t - e;
2384
2359
  return n * n;
2385
2360
  });
@@ -2399,7 +2374,7 @@ const Ln = k((t, e) => {
2399
2374
  * limitations under the License.
2400
2375
  * =============================================================================
2401
2376
  */
2402
- const _n = X((t, e) => {
2377
+ const Ln = X((t, e) => {
2403
2378
  const { pattern: n, replaceGlobal: o, rewrite: s } = e;
2404
2379
  return t.replace(new RegExp(n, o ? "g" : ""), s);
2405
2380
  });
@@ -2445,9 +2420,9 @@ function Mn(t, e, n, o) {
2445
2420
  * limitations under the License.
2446
2421
  * =============================================================================
2447
2422
  */
2448
- class Nn {
2423
+ class _n {
2449
2424
  constructor(e, n, o, s, r, i) {
2450
- this.separator = ut(e), this.nGramWidths = n, this.leftPad = ut(o), this.rightPad = ut(s), this.padWidth = r, this.preserveShort = i;
2425
+ this.separator = ht(e), this.nGramWidths = n, this.leftPad = ht(o), this.rightPad = ht(s), this.padWidth = r, this.preserveShort = i;
2451
2426
  }
2452
2427
  getPadWidth(e) {
2453
2428
  return Math.min(this.padWidth < 0 ? e - 1 : this.padWidth, e - 1);
@@ -2461,24 +2436,24 @@ class Nn {
2461
2436
  const u = this.getPadWidth(i), c = Math.max(0, u - a), h = Math.max(0, u - (r - (a + 1))), f = i - (c + h), w = n + (c > 0 ? 0 : a - u);
2462
2437
  let p = 0;
2463
2438
  p += c * this.leftPad.length;
2464
- for (let I = 0; I < f; ++I)
2465
- p += e[w + I].length;
2439
+ for (let x = 0; x < f; ++x)
2440
+ p += e[w + x].length;
2466
2441
  p += h * this.rightPad.length;
2467
2442
  const m = c + h + f - 1;
2468
2443
  p += m * this.separator.length, o[s + a] = new Uint8Array(p);
2469
2444
  const b = o[s + a];
2470
2445
  let d = 0;
2471
- const g = (I) => I.forEach(($) => b[d++] = $);
2472
- for (let I = 0; I < c; ++I)
2446
+ const g = (x) => x.forEach(($) => b[d++] = $);
2447
+ for (let x = 0; x < c; ++x)
2473
2448
  g(this.leftPad), g(this.separator);
2474
- for (let I = 0; I < f - 1; ++I)
2475
- g(e[w + I]), g(this.separator);
2449
+ for (let x = 0; x < f - 1; ++x)
2450
+ g(e[w + x]), g(this.separator);
2476
2451
  if (f > 0) {
2477
2452
  g(e[w + f - 1]);
2478
- for (let I = 0; I < h; ++I)
2453
+ for (let x = 0; x < h; ++x)
2479
2454
  g(this.separator), g(this.rightPad);
2480
2455
  } else {
2481
- for (let I = 0; I < h - 1; ++I)
2456
+ for (let x = 0; x < h - 1; ++x)
2482
2457
  g(this.rightPad), g(this.separator);
2483
2458
  g(this.rightPad);
2484
2459
  }
@@ -2535,8 +2510,8 @@ class Nn {
2535
2510
  return [a, i];
2536
2511
  }
2537
2512
  }
2538
- function Dn(t, e, n, o, s, r, i, a) {
2539
- return new Nn(n, o, s, r, i, a).compute(t, e);
2513
+ function An(t, e, n, o, s, r, i, a) {
2514
+ return new _n(n, o, s, r, i, a).compute(t, e);
2540
2515
  }
2541
2516
  /**
2542
2517
  * @license
@@ -2554,7 +2529,7 @@ function Dn(t, e, n, o, s, r, i, a) {
2554
2529
  * limitations under the License.
2555
2530
  * =============================================================================
2556
2531
  */
2557
- function Pn(t, e, n, o) {
2532
+ function Nn(t, e, n, o) {
2558
2533
  if (!t.length)
2559
2534
  return;
2560
2535
  if (e.length === 0) {
@@ -2579,13 +2554,13 @@ function Pn(t, e, n, o) {
2579
2554
  (!n || i.length !== 0) && o.push(i), s = r + 1;
2580
2555
  }
2581
2556
  }
2582
- function Cn(t, e, n) {
2557
+ function Dn(t, e, n) {
2583
2558
  const o = t.length, s = [];
2584
2559
  let r = 0, i = 0;
2585
2560
  const a = new Array(o);
2586
2561
  for (let w = 0; w < o; ++w) {
2587
2562
  const p = s.length;
2588
- Pn(t[w], e, n, s);
2563
+ Nn(t[w], e, n, s);
2589
2564
  const m = s.length - p;
2590
2565
  a[w] = m, r += m, i = Math.max(i, m);
2591
2566
  }
@@ -2615,7 +2590,7 @@ function Cn(t, e, n) {
2615
2590
  function zn(t, e) {
2616
2591
  const n = W("int32", t.length);
2617
2592
  for (let o = 0; o < t.length; ++o)
2618
- n[o] = Se(t[o]).modulo(e).getLowBitsUnsigned();
2593
+ n[o] = xe(t[o]).modulo(e).getLowBitsUnsigned();
2619
2594
  return n;
2620
2595
  }
2621
2596
  /**
@@ -2634,7 +2609,7 @@ function zn(t, e) {
2634
2609
  * limitations under the License.
2635
2610
  * =============================================================================
2636
2611
  */
2637
- const Wn = k((t, e) => t - e);
2612
+ const Pn = k((t, e) => t - e);
2638
2613
  /**
2639
2614
  * @license
2640
2615
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -2651,7 +2626,7 @@ const Wn = k((t, e) => t - e);
2651
2626
  * limitations under the License.
2652
2627
  * =============================================================================
2653
2628
  */
2654
- function kn(t, e) {
2629
+ function Cn(t, e) {
2655
2630
  const n = new Array(t.rank);
2656
2631
  for (let s = 0; s < n.length; s++)
2657
2632
  n[s] = t.shape[s] * e[s];
@@ -2685,11 +2660,11 @@ const et = (t, e) => {
2685
2660
  const n = e.value - t.value;
2686
2661
  return n === 0 ? t.index - e.index : n;
2687
2662
  };
2688
- function Ht(t, e, n = 0, o = t.length - 1) {
2663
+ function qt(t, e, n = 0, o = t.length - 1) {
2689
2664
  for (; o > n; ) {
2690
2665
  if (o - n > 600) {
2691
2666
  const a = o - n + 1, u = e - n + 1, c = Math.log(a), h = 0.5 * Math.exp(2 * c / 3), f = 0.5 * Math.sqrt(c * h * (a - h) / a) * Math.sign(u - a / 2), w = Math.max(n, Math.floor(e - u * h / a + f)), p = Math.min(o, Math.floor(e + (a - u) * h / a + f));
2692
- Ht(t, e, w, p);
2667
+ qt(t, e, w, p);
2693
2668
  }
2694
2669
  const s = t[e];
2695
2670
  let r = n, i = o;
@@ -2702,15 +2677,15 @@ function Ht(t, e, n = 0, o = t.length - 1) {
2702
2677
  et(t[n], s) === 0 ? tt(t, n, i) : (i = i + 1, tt(t, i, o)), i <= e && (n = i + 1), e <= i && (o = i - 1);
2703
2678
  }
2704
2679
  }
2705
- function Un(t, e, n, o, s) {
2680
+ function Wn(t, e, n, o, s) {
2706
2681
  const r = e[e.length - 1], [i, a] = [t.length / r, r], u = nt(n, i * o), c = nt("int32", i * o);
2707
2682
  for (let f = 0; f < i; f++) {
2708
2683
  const w = f * a, p = t.subarray(w, w + a);
2709
2684
  let m = new Array(p.length);
2710
- p.forEach((I, $) => m[$] = { value: I, index: $ }), o < m.length && (Ht(m, o), m = m.slice(0, o)), s && m.sort(et);
2685
+ p.forEach((x, $) => m[$] = { value: x, index: $ }), o < m.length && (qt(m, o), m = m.slice(0, o)), s && m.sort(et);
2711
2686
  const b = f * o, d = u.subarray(b, b + o), g = c.subarray(b, b + o);
2712
- for (let I = 0; I < o; I++)
2713
- d[I] = m[I].value, g[I] = m[I].index;
2687
+ for (let x = 0; x < o; x++)
2688
+ d[x] = m[x].value, g[x] = m[x].index;
2714
2689
  }
2715
2690
  const h = e.slice();
2716
2691
  return h[h.length - 1] = o, [
@@ -2734,23 +2709,23 @@ function Un(t, e, n, o, s) {
2734
2709
  * limitations under the License.
2735
2710
  * =============================================================================
2736
2711
  */
2737
- function qn(t, e, n, o) {
2738
- const s = ht(e, n)[0], r = [1, n[0], 1];
2712
+ function kn(t, e, n, o) {
2713
+ const s = lt(e, n)[0], r = [1, n[0], 1];
2739
2714
  for (let m = 0; m < s; m++)
2740
2715
  r[0] *= n[m];
2741
2716
  r[1] = n[s];
2742
2717
  for (let m = s + 1; m < n.length; m++)
2743
2718
  r[2] *= n[m];
2744
- const i = /* @__PURE__ */ new Map(), a = new Int32Array(n[s]), u = new mt(r, o, t), c = [], h = r[0] === 1 && r[2] === 1;
2719
+ const i = /* @__PURE__ */ new Map(), a = new Int32Array(n[s]), u = new gt(r, o, t), c = [], h = r[0] === 1 && r[2] === 1;
2745
2720
  for (let m = 0; m < n[s]; m++) {
2746
2721
  let b;
2747
2722
  if (h)
2748
2723
  b = t[m].toString();
2749
2724
  else {
2750
2725
  const g = [];
2751
- for (let I = 0; I < r[0]; I++)
2726
+ for (let x = 0; x < r[0]; x++)
2752
2727
  for (let $ = 0; $ < r[2]; $++)
2753
- g.push(u.get(I, m, $));
2728
+ g.push(u.get(x, m, $));
2754
2729
  b = g.join(",");
2755
2730
  }
2756
2731
  const d = i.get(b);
@@ -2763,7 +2738,7 @@ function qn(t, e, n, o) {
2763
2738
  }
2764
2739
  const f = r.slice();
2765
2740
  f[1] = i.size;
2766
- const w = new mt(f, o);
2741
+ const w = new gt(f, o);
2767
2742
  c.forEach((m, b) => {
2768
2743
  for (let d = 0; d < r[0]; d++)
2769
2744
  for (let g = 0; g < r[2]; g++)
@@ -2792,59 +2767,59 @@ function qn(t, e, n, o) {
2792
2767
  * limitations under the License.
2793
2768
  * =============================================================================
2794
2769
  */
2795
- const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2770
+ const qn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2796
2771
  __proto__: null,
2797
- addImpl: ke,
2798
- bincountImpl: Ue,
2799
- bincountReduceImpl: qe,
2800
- bitwiseAndImpl: Be,
2801
- castImpl: We,
2802
- ceilImpl: Ge,
2803
- concatImpl: je,
2804
- equalImpl: Ze,
2805
- expImpl: He,
2806
- expm1Impl: Ke,
2807
- floorDivImpl: Ye,
2808
- floorImpl: Xe,
2809
- gatherNdImpl: Je,
2810
- gatherV2Impl: Qe,
2811
- greaterEqualImpl: en,
2812
- greaterImpl: tn,
2813
- lessEqualImpl: on,
2814
- lessImpl: nn,
2815
- linSpaceImpl: sn,
2816
- logImpl: rn,
2817
- maxImpl: an,
2818
- maximumImpl: un,
2819
- minimumImpl: ln,
2820
- multiplyImpl: Zt,
2821
- negImpl: cn,
2822
- notEqualImpl: hn,
2823
- prodImpl: dn,
2824
- raggedGatherImpl: Sn,
2825
- raggedRangeImpl: bn,
2826
- raggedTensorToTensorImpl: vn,
2827
- rangeImpl: En,
2828
- rsqrtImpl: $n,
2829
- scatterImpl: On,
2830
- sigmoidImpl: yn,
2772
+ addImpl: Ce,
2773
+ bincountImpl: We,
2774
+ bincountReduceImpl: ke,
2775
+ bitwiseAndImpl: qe,
2776
+ castImpl: Pe,
2777
+ ceilImpl: Ue,
2778
+ concatImpl: Ge,
2779
+ equalImpl: je,
2780
+ expImpl: Be,
2781
+ expm1Impl: Ze,
2782
+ floorDivImpl: Ke,
2783
+ floorImpl: He,
2784
+ gatherNdImpl: Xe,
2785
+ gatherV2Impl: Ye,
2786
+ greaterEqualImpl: Qe,
2787
+ greaterImpl: Je,
2788
+ lessEqualImpl: en,
2789
+ lessImpl: tn,
2790
+ linSpaceImpl: nn,
2791
+ logImpl: on,
2792
+ maxImpl: sn,
2793
+ maximumImpl: rn,
2794
+ minimumImpl: an,
2795
+ multiplyImpl: kt,
2796
+ negImpl: un,
2797
+ notEqualImpl: ln,
2798
+ prodImpl: hn,
2799
+ raggedGatherImpl: In,
2800
+ raggedRangeImpl: xn,
2801
+ raggedTensorToTensorImpl: Sn,
2802
+ rangeImpl: vn,
2803
+ rsqrtImpl: bn,
2804
+ scatterImpl: En,
2805
+ sigmoidImpl: $n,
2831
2806
  simpleAbsImpl: ze,
2832
2807
  sliceImpl: Rn,
2833
2808
  sparseFillEmptyRowsImpl: Fn,
2834
- sparseReshapeImpl: Tn,
2835
- sparseSegmentReductionImpl: Vn,
2836
- sqrtImpl: An,
2837
- squaredDifferenceImpl: Ln,
2838
- staticRegexReplaceImpl: _n,
2809
+ sparseReshapeImpl: On,
2810
+ sparseSegmentReductionImpl: yn,
2811
+ sqrtImpl: Tn,
2812
+ squaredDifferenceImpl: Vn,
2813
+ staticRegexReplaceImpl: Ln,
2839
2814
  stridedSliceImpl: Mn,
2840
- stringNGramsImpl: Dn,
2841
- stringSplitImpl: Cn,
2815
+ stringNGramsImpl: An,
2816
+ stringSplitImpl: Dn,
2842
2817
  stringToHashBucketFastImpl: zn,
2843
- subImpl: Wn,
2844
- tileImpl: kn,
2845
- topKImpl: Un,
2846
- transposeImpl: fn,
2847
- uniqueImpl: qn
2818
+ subImpl: Pn,
2819
+ tileImpl: Cn,
2820
+ topKImpl: Wn,
2821
+ transposeImpl: cn,
2822
+ uniqueImpl: kn
2848
2823
  }, Symbol.toStringTag, { value: "Module" }));
2849
2824
  /**
2850
2825
  * @license
@@ -2862,7 +2837,7 @@ const Bn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
2862
2837
  * limitations under the License.
2863
2838
  * =============================================================================
2864
2839
  */
2865
- const { maxImpl: Gn, transposeImpl: jn } = Bn;
2840
+ const { maxImpl: Un, transposeImpl: Gn } = qn;
2866
2841
  /**
2867
2842
  * @license
2868
2843
  * Copyright 2020 Google LLC. All Rights Reserved.
@@ -2879,7 +2854,7 @@ const { maxImpl: Gn, transposeImpl: jn } = Bn;
2879
2854
  * limitations under the License.
2880
2855
  * =============================================================================
2881
2856
  */
2882
- class _t {
2857
+ class Ot {
2883
2858
  constructor(e, n) {
2884
2859
  this.variableNames = ["x"];
2885
2860
  const { windowSize: o, batchSize: s, inSize: r, outSize: i } = e;
@@ -2888,7 +2863,7 @@ class _t {
2888
2863
  let c = "sumValue += dot(values, ones);";
2889
2864
  if (n != null) {
2890
2865
  const f = 1 / n;
2891
- c = `sumValue += dot(values * ${oe(f) ? f.toPrecision(2) : f}, ones);`;
2866
+ c = `sumValue += dot(values * ${Yt(f) ? f.toPrecision(2) : f}, ones);`;
2892
2867
  }
2893
2868
  let h = "";
2894
2869
  r % o > 0 && (h = `
@@ -2963,7 +2938,7 @@ class _t {
2963
2938
  * limitations under the License.
2964
2939
  * =============================================================================
2965
2940
  */
2966
- class Zn {
2941
+ class jn {
2967
2942
  constructor(e, n) {
2968
2943
  this.variableNames = ["x"];
2969
2944
  const { windowSize: o, batchSize: s, inSize: r, outSize: i } = e;
@@ -3087,10 +3062,10 @@ class Zn {
3087
3062
  * limitations under the License.
3088
3063
  * =============================================================================
3089
3064
  */
3090
- function Hn(t) {
3065
+ function Bn(t) {
3091
3066
  const e = [];
3092
3067
  for (; e.length === 0 || e[e.length - 1].outSize !== 1; ) {
3093
- const n = e.length ? e[e.length - 1].outSize : t[1], o = ye(n);
3068
+ const n = e.length ? e[e.length - 1].outSize : t[1], o = Re(n);
3094
3069
  e.push({
3095
3070
  inSize: n,
3096
3071
  windowSize: o,
@@ -3099,13 +3074,13 @@ function Hn(t) {
3099
3074
  }
3100
3075
  return e;
3101
3076
  }
3102
- function Kt(t, e, n, o) {
3103
- const s = Hn(t.shape);
3077
+ function Ut(t, e, n, o) {
3078
+ const s = Bn(t.shape);
3104
3079
  let r = t;
3105
3080
  for (let i = 0; i < s.length; i++) {
3106
3081
  const { inSize: a, windowSize: u, outSize: c } = s[i];
3107
3082
  let h, f;
3108
- n === "mean" ? h = i === 0 ? new _t({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }, a) : new _t({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }) : h = new Zn({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }, n), f = r, r = o.runWebGLProgram(h, [r], e), f.dataId !== t.dataId && o.disposeIntermediateTensorInfo(f);
3083
+ n === "mean" ? h = i === 0 ? new Ot({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }, a) : new Ot({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }) : h = new jn({ windowSize: u, inSize: a, batchSize: t.shape[0], outSize: c }, n), f = r, r = o.runWebGLProgram(h, [r], e), f.dataId !== t.dataId && o.disposeIntermediateTensorInfo(f);
3109
3084
  }
3110
3085
  return r;
3111
3086
  }
@@ -3125,28 +3100,28 @@ function Kt(t, e, n, o) {
3125
3100
  * limitations under the License.
3126
3101
  * =============================================================================
3127
3102
  */
3128
- function Kn(t, e, n = "index") {
3103
+ function Zn(t, e, n = "index") {
3129
3104
  const o = K(e);
3130
3105
  return o.map((s, r) => {
3131
3106
  const i = `int ${t[r]} = ${n} / ${s}`, a = r === o.length - 1 ? `int ${t[r + 1]} = ${n} - ${t[r]} * ${s}` : `index -= ${t[r]} * ${s}`;
3132
3107
  return `${i}; ${a};`;
3133
3108
  }).join("");
3134
3109
  }
3135
- function Xn(t, e) {
3110
+ function Hn(t, e) {
3136
3111
  const n = t.length, o = t.map((r) => `${e}[${r}]`), s = new Array(n - 1);
3137
3112
  s[n - 2] = o[n - 1];
3138
3113
  for (let r = n - 3; r >= 0; --r)
3139
3114
  s[r] = `(${s[r + 1]} * ${o[r + 1]})`;
3140
3115
  return s;
3141
3116
  }
3142
- function Yn(t, e, n = "index") {
3143
- const o = t.map((r, i) => i), s = Xn(o, e);
3117
+ function Kn(t, e, n = "index") {
3118
+ const o = t.map((r, i) => i), s = Hn(o, e);
3144
3119
  return s.map((r, i) => {
3145
3120
  const a = `int ${t[i]} = ${n} / ${s[i]}`, u = i === s.length - 1 ? `int ${t[i + 1]} = ${n} - ${t[i]} * ${s[i]}` : `index -= ${t[i]} * ${s[i]}`;
3146
3121
  return `${a}; ${u};`;
3147
3122
  }).join("");
3148
3123
  }
3149
- function Jn(t) {
3124
+ function Xn(t) {
3150
3125
  const e = K(t).map((n) => n.toString());
3151
3126
  return `
3152
3127
  int getFlatIndex(ivec3 coords) {
@@ -3154,7 +3129,7 @@ function Jn(t) {
3154
3129
  }
3155
3130
  `;
3156
3131
  }
3157
- function Qn() {
3132
+ function Yn() {
3158
3133
  return `
3159
3134
  int getFlatIndex(ivec3 coords) {
3160
3135
  return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;
@@ -3177,41 +3152,10 @@ function Qn() {
3177
3152
  * limitations under the License.
3178
3153
  * =============================================================================
3179
3154
  */
3180
- function Et(t) {
3181
- if (t <= 1)
3182
- return "int";
3183
- if (t === 2)
3184
- return "ivec2";
3185
- if (t === 3)
3186
- return "ivec3";
3187
- if (t === 4)
3188
- return "ivec4";
3189
- if (t === 5)
3190
- return "ivec5";
3191
- if (t === 6)
3192
- return "ivec6";
3193
- throw Error(`GPU for rank ${t} is not yet supported`);
3155
+ function yt(t, e = 2) {
3156
+ return O(t.slice(0, t.length - e));
3194
3157
  }
3195
- /**
3196
- * @license
3197
- * Copyright 2017 Google LLC. All Rights Reserved.
3198
- * Licensed under the Apache License, Version 2.0 (the "License");
3199
- * you may not use this file except in compliance with the License.
3200
- * You may obtain a copy of the License at
3201
- *
3202
- * http://www.apache.org/licenses/LICENSE-2.0
3203
- *
3204
- * Unless required by applicable law or agreed to in writing, software
3205
- * distributed under the License is distributed on an "AS IS" BASIS,
3206
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3207
- * See the License for the specific language governing permissions and
3208
- * limitations under the License.
3209
- * =============================================================================
3210
- */
3211
- function Mt(t, e = 2) {
3212
- return y(t.slice(0, t.length - e));
3213
- }
3214
- function Nt(t) {
3158
+ function Tt(t) {
3215
3159
  if (t.length === 0)
3216
3160
  throw Error("Cannot get rows and columns of an empty shape array.");
3217
3161
  return [
@@ -3222,8 +3166,8 @@ function Nt(t) {
3222
3166
  function at(t) {
3223
3167
  return t % 2 === 0;
3224
3168
  }
3225
- function Dt(t, e) {
3226
- if (t = t.slice(-2), e = e.slice(-2), se(t, e) || !t.length || !e.length || t[0] === 0 || t[1] === 0 || e[0] === 0 || e[1] === 0)
3169
+ function Vt(t, e) {
3170
+ if (t = t.slice(-2), e = e.slice(-2), Jt(t, e) || !t.length || !e.length || t[0] === 0 || t[1] === 0 || e[0] === 0 || e[1] === 0)
3227
3171
  return !0;
3228
3172
  if (t.length !== e.length) {
3229
3173
  const n = t[t.length - 1], o = e[e.length - 1];
@@ -3232,25 +3176,6 @@ function Dt(t, e) {
3232
3176
  }
3233
3177
  return t[1] === e[1] && at(t[0]) && at(e[0]);
3234
3178
  }
3235
- /**
3236
- * @license
3237
- * Copyright 2017 Google LLC. All Rights Reserved.
3238
- * Licensed under the Apache License, Version 2.0 (the "License");
3239
- * you may not use this file except in compliance with the License.
3240
- * You may obtain a copy of the License at
3241
- *
3242
- * http://www.apache.org/licenses/LICENSE-2.0
3243
- *
3244
- * Unless required by applicable law or agreed to in writing, software
3245
- * distributed under the License is distributed on an "AS IS" BASIS,
3246
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3247
- * See the License for the specific language governing permissions and
3248
- * limitations under the License.
3249
- * =============================================================================
3250
- */
3251
- function $t(t) {
3252
- return St().getBool("WEBGL_USE_SHAPES_UNIFORMS") && t <= 4;
3253
- }
3254
3179
  /**
3255
3180
  * @license
3256
3181
  * Copyright 2018 Google LLC. All Rights Reserved.
@@ -3267,9 +3192,9 @@ function $t(t) {
3267
3192
  * limitations under the License.
3268
3193
  * =============================================================================
3269
3194
  */
3270
- class to {
3195
+ class Jn {
3271
3196
  constructor(e, n) {
3272
- this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = $t(this.outputShape.length);
3197
+ this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = se(this.outputShape.length);
3273
3198
  let o = "";
3274
3199
  for (let s = 0; s < 4; s++) {
3275
3200
  let r = "thisRC = rc;";
@@ -3287,8 +3212,8 @@ class to {
3287
3212
  `;
3288
3213
  }
3289
3214
  this.userCode = `
3290
- ${eo(n, this.enableShapeUniforms)}
3291
- ${this.enableShapeUniforms ? Qn() : Jn(e)}
3215
+ ${Qn(n, this.enableShapeUniforms)}
3216
+ ${this.enableShapeUniforms ? Yn() : Xn(e)}
3292
3217
 
3293
3218
  void main() {
3294
3219
  ivec3 rc = getOutputCoords();
@@ -3306,10 +3231,10 @@ class to {
3306
3231
  `;
3307
3232
  }
3308
3233
  }
3309
- function eo(t, e) {
3234
+ function Qn(t, e) {
3310
3235
  return `
3311
3236
  ivec3 inputCoordsFromReshapedOutCoords(int index) {
3312
- ${e ? Yn(["r", "c", "d"], "inputShape") : Kn(["r", "c", "d"], t)}
3237
+ ${e ? Kn(["r", "c", "d"], "inputShape") : Zn(["r", "c", "d"], t)}
3313
3238
  return ivec3(r, c, d);
3314
3239
  }
3315
3240
  `;
@@ -3330,18 +3255,18 @@ function eo(t, e) {
3330
3255
  * limitations under the License.
3331
3256
  * =============================================================================
3332
3257
  */
3333
- function no(t, e, n) {
3258
+ function to(t, e, n) {
3334
3259
  const o = [
3335
- Mt(t.shape),
3336
- ...Nt(t.shape)
3260
+ yt(t.shape),
3261
+ ...Tt(t.shape)
3337
3262
  ], s = {
3338
3263
  dtype: t.dtype,
3339
3264
  shape: o,
3340
3265
  dataId: t.dataId
3341
3266
  }, r = [
3342
- Mt(e),
3343
- ...Nt(e)
3344
- ], i = new to(r, o), a = !0, u = [o], c = n.runWebGLProgram(i, [s], t.dtype, u, a);
3267
+ yt(e),
3268
+ ...Tt(e)
3269
+ ], i = new Jn(r, o), a = !0, u = [o], c = n.runWebGLProgram(i, [s], t.dtype, u, a);
3345
3270
  return { dataId: c.dataId, shape: e, dtype: c.dtype };
3346
3271
  }
3347
3272
  /**
@@ -3361,10 +3286,10 @@ function no(t, e, n) {
3361
3286
  * =============================================================================
3362
3287
  */
3363
3288
  function st(t) {
3364
- const { inputs: e, backend: n, attrs: o } = t, { x: s } = e, { shape: r } = o, i = n, a = y(s.shape), u = re(r, a), c = y(u);
3365
- zt(a === c, () => `The new shape (${u}) has ${c} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);
3289
+ const { inputs: e, backend: n, attrs: o } = t, { x: s } = e, { shape: r } = o, i = n, a = O(s.shape), u = Qt(r, a), c = O(u);
3290
+ Lt(a === c, () => `The new shape (${u}) has ${c} elements and the old shape (${s.shape}) has ${a} elements. The new shape and old shape must have the same number of elements.`);
3366
3291
  const h = i.texData.get(s.dataId);
3367
- return h.isPacked && !Dt(s.shape, u) && !(h.texture !== null && Dt(h.shape, u)) ? no(s, u, i) : (i.incRef(s.dataId), { dataId: s.dataId, shape: u, dtype: s.dtype });
3292
+ return h.isPacked && !Vt(s.shape, u) && !(h.texture !== null && Vt(h.shape, u)) ? to(s, u, i) : (i.incRef(s.dataId), { dataId: s.dataId, shape: u, dtype: s.dtype });
3368
3293
  }
3369
3294
  /**
3370
3295
  * @license
@@ -3382,8 +3307,8 @@ function st(t) {
3382
3307
  * limitations under the License.
3383
3308
  * =============================================================================
3384
3309
  */
3385
- function oo(t, e, n, o) {
3386
- const s = y(e), i = y(t.shape) / s, a = st({ inputs: { x: t }, attrs: { shape: [i, s] }, backend: o }), u = Kt(a, t.dtype, "max", o), c = st({ inputs: { x: u }, attrs: { shape: n }, backend: o });
3310
+ function eo(t, e, n, o) {
3311
+ const s = O(e), i = O(t.shape) / s, a = st({ inputs: { x: t }, attrs: { shape: [i, s] }, backend: o }), u = Ut(a, t.dtype, "max", o), c = st({ inputs: { x: u }, attrs: { shape: n }, backend: o });
3387
3312
  return o.disposeIntermediateTensorInfo(a), o.disposeIntermediateTensorInfo(u), c;
3388
3313
  }
3389
3314
  /**
@@ -3402,14 +3327,14 @@ function oo(t, e, n, o) {
3402
3327
  * limitations under the License.
3403
3328
  * =============================================================================
3404
3329
  */
3405
- class so {
3330
+ class no {
3406
3331
  constructor(e, n) {
3407
3332
  this.variableNames = ["A"];
3408
3333
  const o = new Array(e.length);
3409
3334
  for (let i = 0; i < o.length; i++)
3410
3335
  o[i] = e[n[i]];
3411
3336
  this.outputShape = o, this.rank = o.length;
3412
- const s = Et(this.rank), r = ro(n);
3337
+ const s = _t(this.rank), r = oo(n);
3413
3338
  this.userCode = `
3414
3339
  void main() {
3415
3340
  ${s} resRC = getOutputCoords();
@@ -3418,7 +3343,7 @@ class so {
3418
3343
  `;
3419
3344
  }
3420
3345
  }
3421
- function ro(t) {
3346
+ function oo(t) {
3422
3347
  const e = t.length;
3423
3348
  if (e > 6)
3424
3349
  throw Error(`Transpose for rank ${e} is not yet supported`);
@@ -3427,28 +3352,6 @@ function ro(t) {
3427
3352
  o[t[s]] = n[s];
3428
3353
  return o.join();
3429
3354
  }
3430
- /**
3431
- * @license
3432
- * Copyright 2018 Google LLC. All Rights Reserved.
3433
- * Licensed under the Apache License, Version 2.0 (the "License");
3434
- * you may not use this file except in compliance with the License.
3435
- * You may obtain a copy of the License at
3436
- *
3437
- * http://www.apache.org/licenses/LICENSE-2.0
3438
- *
3439
- * Unless required by applicable law or agreed to in writing, software
3440
- * distributed under the License is distributed on an "AS IS" BASIS,
3441
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3442
- * See the License for the specific language governing permissions and
3443
- * limitations under the License.
3444
- * =============================================================================
3445
- */
3446
- function Xt(t, e) {
3447
- return ["x", "y", "z", "w", "u", "v"].slice(0, e).map((n) => `${t}.${n}`);
3448
- }
3449
- function io(t, e) {
3450
- return e === 1 ? [t] : Xt(t, e);
3451
- }
3452
3355
  /**
3453
3356
  * @license
3454
3357
  * Copyright 2019 Google LLC. All Rights Reserved.
@@ -3465,7 +3368,7 @@ function io(t, e) {
3465
3368
  * limitations under the License.
3466
3369
  * =============================================================================
3467
3370
  */
3468
- class ao {
3371
+ class so {
3469
3372
  constructor(e, n) {
3470
3373
  this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0;
3471
3374
  const o = new Array(e.length);
@@ -3473,7 +3376,7 @@ class ao {
3473
3376
  o[h] = e[n[h]];
3474
3377
  if (this.outputShape = o, this.rank = o.length, this.rank > 6)
3475
3378
  throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`);
3476
- const s = Et(this.rank), r = Xt("rc", this.rank), i = new Array(this.rank);
3379
+ const s = _t(this.rank), r = re("rc", this.rank), i = new Array(this.rank);
3477
3380
  for (let h = 0; h < n.length; h++)
3478
3381
  i[n[h]] = r[h];
3479
3382
  const a = `vec2(${i.slice(-2).join()})`, u = `++${r[this.rank - 1]} < ${o[this.rank - 1]}`, c = `getChannel(getA(${i.join()}), ${a})`;
@@ -3513,8 +3416,8 @@ class ao {
3513
3416
  * limitations under the License.
3514
3417
  * =============================================================================
3515
3418
  */
3516
- function Yt(t, e, n) {
3517
- const o = St().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new ao(t.shape, e) : new so(t.shape, e);
3419
+ function Gt(t, e, n) {
3420
+ const o = te().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new so(t.shape, e) : new no(t.shape, e);
3518
3421
  return n.runWebGLProgram(o, [t], t.dtype);
3519
3422
  }
3520
3423
  /**
@@ -3533,36 +3436,36 @@ function Yt(t, e, n) {
3533
3436
  * limitations under the License.
3534
3437
  * =============================================================================
3535
3438
  */
3536
- function uo(t) {
3537
- const { inputs: e, backend: n, attrs: o } = t, { x: s } = e, { reductionIndices: r, keepDims: i } = o, a = s.shape.length, u = ht(r, s.shape);
3439
+ function ro(t) {
3440
+ const { inputs: e, backend: n, attrs: o } = t, { x: s } = e, { reductionIndices: r, keepDims: i } = o, a = s.shape.length, u = lt(r, s.shape);
3538
3441
  let c = u;
3539
- const h = Wt(c, a), f = h != null, w = n.shouldExecuteOnCPU([s]);
3442
+ const h = At(c, a), f = h != null, w = n.shouldExecuteOnCPU([s]);
3540
3443
  let p = s;
3541
3444
  if (f) {
3542
3445
  if (w) {
3543
3446
  const $ = n.texData.get(p.dataId).values, E = new Array(a);
3544
- for (let A = 0; A < E.length; A++)
3545
- E[A] = s.shape[h[A]];
3546
- const F = jn($, s.shape, s.dtype, h, E);
3447
+ for (let M = 0; M < E.length; M++)
3448
+ E[M] = s.shape[h[M]];
3449
+ const V = Gn($, s.shape, s.dtype, h, E);
3547
3450
  p = n.makeTensorInfo(E, s.dtype);
3548
- const M = n.texData.get(p.dataId);
3549
- M.values = F;
3451
+ const z = n.texData.get(p.dataId);
3452
+ z.values = V;
3550
3453
  } else
3551
- p = Yt(s, h, n);
3552
- c = kt(c.length, a);
3454
+ p = Gt(s, h, n);
3455
+ c = Nt(c.length, a);
3553
3456
  }
3554
- Ut("max", c, a);
3555
- const [m, b] = bt(p.shape, c);
3457
+ Dt("max", c, a);
3458
+ const [m, b] = wt(p.shape, c);
3556
3459
  let d = m;
3557
- i && (d = vt(m, u));
3460
+ i && (d = It(m, u));
3558
3461
  let g;
3559
3462
  if (w) {
3560
- const $ = n.texData.get(p.dataId).values, E = Gn($, y(b), d, s.dtype);
3463
+ const $ = n.texData.get(p.dataId).values, E = Un($, O(b), d, s.dtype);
3561
3464
  g = n.makeTensorInfo(d, s.dtype);
3562
- const F = n.texData.get(g.dataId);
3563
- F.values = E;
3465
+ const V = n.texData.get(g.dataId);
3466
+ V.values = E;
3564
3467
  } else
3565
- g = oo(p, b, d, n);
3468
+ g = eo(p, b, d, n);
3566
3469
  return f && n.disposeIntermediateTensorInfo(p), g;
3567
3470
  }
3568
3471
  /**
@@ -3581,16 +3484,16 @@ function uo(t) {
3581
3484
  * limitations under the License.
3582
3485
  * =============================================================================
3583
3486
  */
3584
- function lo(t, e, n, o) {
3585
- const s = e, r = t.shape.length, i = ht(s, t.shape);
3487
+ function io(t, e, n, o) {
3488
+ const s = e, r = t.shape.length, i = lt(s, t.shape);
3586
3489
  let a = i;
3587
- const u = Wt(a, r), c = u != null;
3490
+ const u = At(a, r), c = u != null;
3588
3491
  let h = t;
3589
- c && (h = Yt(t, u, o), a = kt(a.length, r)), Ut("sum", a, r);
3590
- const [f, w] = bt(h.shape, a);
3492
+ c && (h = Gt(t, u, o), a = Nt(a.length, r)), Dt("sum", a, r);
3493
+ const [f, w] = wt(h.shape, a);
3591
3494
  let p = f;
3592
- n && (p = vt(f, i));
3593
- const m = y(w), d = y(t.shape) / m, g = st({ inputs: { x: h }, attrs: { shape: [d, m] }, backend: o }), I = ie(t.dtype), $ = Kt(g, I, "sum", o), E = st({ inputs: { x: $ }, attrs: { shape: p }, backend: o });
3495
+ n && (p = It(f, i));
3496
+ const m = O(w), d = O(t.shape) / m, g = st({ inputs: { x: h }, attrs: { shape: [d, m] }, backend: o }), x = ee(t.dtype), $ = Ut(g, x, "sum", o), E = st({ inputs: { x: $ }, attrs: { shape: p }, backend: o });
3594
3497
  return o.disposeIntermediateTensorInfo(g), o.disposeIntermediateTensorInfo($), c && o.disposeIntermediateTensorInfo(h), E;
3595
3498
  }
3596
3499
  /**
@@ -3609,158 +3512,9 @@ function lo(t, e, n, o) {
3609
3512
  * limitations under the License.
3610
3513
  * =============================================================================
3611
3514
  */
3612
- function co(t) {
3515
+ function ao(t) {
3613
3516
  const { inputs: e, backend: n, attrs: o } = t, { x: s } = e, { axis: r, keepDims: i } = o;
3614
- return lo(s, r, i, n);
3615
- }
3616
- /**
3617
- * @license
3618
- * Copyright 2017 Google LLC. All Rights Reserved.
3619
- * Licensed under the Apache License, Version 2.0 (the "License");
3620
- * you may not use this file except in compliance with the License.
3621
- * You may obtain a copy of the License at
3622
- *
3623
- * http://www.apache.org/licenses/LICENSE-2.0
3624
- *
3625
- * Unless required by applicable law or agreed to in writing, software
3626
- * distributed under the License is distributed on an "AS IS" BASIS,
3627
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3628
- * See the License for the specific language governing permissions and
3629
- * limitations under the License.
3630
- * =============================================================================
3631
- */
3632
- class Pt {
3633
- constructor(e, n, o) {
3634
- this.variableNames = ["A", "B"], this.outputShape = It(n, o), this.enableShapeUniforms = $t(this.outputShape.length), this.userCode = `
3635
- float binaryOperation(float a, float b) {
3636
- ${e}
3637
- }
3638
-
3639
- void main() {
3640
- float a = getAAtOutCoords();
3641
- float b = getBAtOutCoords();
3642
- setOutput(binaryOperation(a, b));
3643
- }
3644
- `;
3645
- }
3646
- }
3647
- /**
3648
- * @license
3649
- * Copyright 2018 Google LLC. All Rights Reserved.
3650
- * Licensed under the Apache License, Version 2.0 (the "License");
3651
- * you may not use this file except in compliance with the License.
3652
- * You may obtain a copy of the License at
3653
- *
3654
- * http://www.apache.org/licenses/LICENSE-2.0
3655
- *
3656
- * Unless required by applicable law or agreed to in writing, software
3657
- * distributed under the License is distributed on an "AS IS" BASIS,
3658
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3659
- * See the License for the specific language governing permissions and
3660
- * limitations under the License.
3661
- * =============================================================================
3662
- */
3663
- class ho {
3664
- constructor(e, n, o, s = !1) {
3665
- this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = It(n, o);
3666
- const r = this.outputShape.length;
3667
- this.enableShapeUniforms = $t(r);
3668
- let i = "";
3669
- if (s)
3670
- if (r === 0 || y(this.outputShape) === 1)
3671
- i = `
3672
- result.y = 0.;
3673
- result.z = 0.;
3674
- result.w = 0.;
3675
- `;
3676
- else if (i = `
3677
- ${Et(r)} coords = getOutputCoords();
3678
- `, r === 1)
3679
- this.enableShapeUniforms ? i += `
3680
- result.y = (coords + 1) >= outShape ? 0. : result.y;
3681
- result.z = 0.;
3682
- result.w = 0.;
3683
- ` : i += `
3684
- result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;
3685
- result.z = 0.;
3686
- result.w = 0.;
3687
- `;
3688
- else {
3689
- const u = io("coords", r);
3690
- this.enableShapeUniforms ? i += `
3691
- bool nextRowOutOfBounds =
3692
- (${u[r - 2]} + 1) >= outShape[${r} - 2];
3693
- bool nextColOutOfBounds =
3694
- (${u[r - 1]} + 1) >= outShape[${r} - 1];
3695
- result.y = nextColOutOfBounds ? 0. : result.y;
3696
- result.z = nextRowOutOfBounds ? 0. : result.z;
3697
- result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
3698
- ` : i += `
3699
- bool nextRowOutOfBounds =
3700
- (${u[r - 2]} + 1) >= ${this.outputShape[r - 2]};
3701
- bool nextColOutOfBounds =
3702
- (${u[r - 1]} + 1) >= ${this.outputShape[r - 1]};
3703
- result.y = nextColOutOfBounds ? 0. : result.y;
3704
- result.z = nextRowOutOfBounds ? 0. : result.z;
3705
- result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;
3706
- `;
3707
- }
3708
- this.userCode = `
3709
- vec4 binaryOperation(vec4 a, vec4 b) {
3710
- ${e}
3711
- }
3712
-
3713
- void main() {
3714
- vec4 a = getAAtOutCoords();
3715
- vec4 b = getBAtOutCoords();
3716
-
3717
- vec4 result = binaryOperation(a, b);
3718
- ${i}
3719
-
3720
- setOutput(result);
3721
- }
3722
- `;
3723
- }
3724
- }
3725
- /**
3726
- * @license
3727
- * Copyright 2020 Google LLC. All Rights Reserved.
3728
- * Licensed under the Apache License, Version 2.0 (the "License");
3729
- * you may not use this file except in compliance with the License.
3730
- * You may obtain a copy of the License at
3731
- *
3732
- * http://www.apache.org/licenses/LICENSE-2.0
3733
- *
3734
- * Unless required by applicable law or agreed to in writing, software
3735
- * distributed under the License is distributed on an "AS IS" BASIS,
3736
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3737
- * See the License for the specific language governing permissions and
3738
- * limitations under the License.
3739
- * =============================================================================
3740
- */
3741
- function Ct(t) {
3742
- const { inputs: e, backend: n } = t, { x: o } = e;
3743
- return n.incRef(o.dataId), { dataId: o.dataId, shape: o.shape, dtype: o.dtype };
3744
- }
3745
- /**
3746
- * @license
3747
- * Copyright 2020 Google LLC. All Rights Reserved.
3748
- * Licensed under the Apache License, Version 2.0 (the "License");
3749
- * you may not use this file except in compliance with the License.
3750
- * You may obtain a copy of the License at
3751
- *
3752
- * http://www.apache.org/licenses/LICENSE-2.0
3753
- *
3754
- * Unless required by applicable law or agreed to in writing, software
3755
- * distributed under the License is distributed on an "AS IS" BASIS,
3756
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3757
- * See the License for the specific language governing permissions and
3758
- * limitations under the License.
3759
- * =============================================================================
3760
- */
3761
- function fo(t) {
3762
- const { inputs: e, backend: n } = t, { real: o, imag: s } = e, r = n.makeTensorInfo(o.shape, "complex64"), i = n.texData.get(r.dataId), a = Ct({ inputs: { x: o }, backend: n }), u = Ct({ inputs: { x: s }, backend: n });
3763
- return i.complexTensorInfos = { real: a, imag: u }, r;
3517
+ return io(s, r, i, n);
3764
3518
  }
3765
3519
  /**
3766
3520
  * @license
@@ -3778,64 +3532,11 @@ function fo(t) {
3778
3532
  * limitations under the License.
3779
3533
  * =============================================================================
3780
3534
  */
3781
- function go({ opSnippet: t, packedOpSnippet: e, checkOutOfBounds: n = !1, supportsComplex: o = !1, cpuKernelImpl: s, dtype: r }) {
3782
- return ({ inputs: i, backend: a }) => {
3783
- const { a: u, b: c } = i, h = a;
3784
- if (o && u.dtype === "complex64") {
3785
- const m = h.texData.get(u.dataId), b = h.texData.get(c.dataId), [d, g] = [
3786
- [m.complexTensorInfos.real, b.complexTensorInfos.real],
3787
- [m.complexTensorInfos.imag, b.complexTensorInfos.imag]
3788
- ].map(($) => {
3789
- const [E, F] = $, M = {
3790
- dataId: E.dataId,
3791
- dtype: E.dtype,
3792
- shape: u.shape
3793
- }, A = {
3794
- dataId: F.dataId,
3795
- dtype: F.dtype,
3796
- shape: c.shape
3797
- }, L = new Pt(t, u.shape, c.shape);
3798
- return h.runWebGLProgram(L, [M, A], pt(E.dtype, F.dtype));
3799
- }), I = fo({ inputs: { real: d, imag: g }, backend: h });
3800
- return h.disposeIntermediateTensorInfo(d), h.disposeIntermediateTensorInfo(g), I;
3801
- }
3802
- const f = r || pt(u.dtype, c.dtype);
3803
- if ((u.dtype === "string" || c.dtype === "string" || h.shouldExecuteOnCPU([u, c])) && s != null) {
3804
- const m = h.texData.get(u.dataId).values, b = h.texData.get(c.dataId).values, d = u.dtype === "string" ? (
3805
- // tslint:disable-next-line: no-any
3806
- lt(m)
3807
- ) : m, g = u.dtype === "string" ? (
3808
- // tslint:disable-next-line: no-any
3809
- lt(b)
3810
- ) : b, [I, $] = s(u.shape, c.shape, d, g, f), E = h.makeTensorInfo($, f), F = h.texData.get(E.dataId);
3811
- return F.values = I, E;
3812
- }
3813
- const w = St().getBool("WEBGL_PACK_BINARY_OPERATIONS") && e != null;
3814
- let p;
3815
- return w ? p = new ho(e, u.shape, c.shape, n) : p = new Pt(t, u.shape, c.shape), h.runWebGLProgram(p, [u, c], f);
3816
- };
3817
- }
3818
- /**
3819
- * @license
3820
- * Copyright 2020 Google LLC. All Rights Reserved.
3821
- * Licensed under the Apache License, Version 2.0 (the "License");
3822
- * you may not use this file except in compliance with the License.
3823
- * You may obtain a copy of the License at
3824
- *
3825
- * http://www.apache.org/licenses/LICENSE-2.0
3826
- *
3827
- * Unless required by applicable law or agreed to in writing, software
3828
- * distributed under the License is distributed on an "AS IS" BASIS,
3829
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
3830
- * See the License for the specific language governing permissions and
3831
- * limitations under the License.
3832
- * =============================================================================
3833
- */
3834
- const po = `
3535
+ const uo = `
3835
3536
  if (a == b) {
3836
3537
  return 1.0;
3837
3538
  };
3838
- return a / b;`, mo = `
3539
+ return a / b;`, lo = `
3839
3540
  // vec4 one = vec4(equal(a, b));
3840
3541
  // return one + (vec4(1.0) - one) * a / b;
3841
3542
  vec4 result = a / b;
@@ -3853,8 +3554,8 @@ return a / b;`, mo = `
3853
3554
  }
3854
3555
 
3855
3556
  return result;
3856
- `, wo = go({ opSnippet: po, packedOpSnippet: mo, checkOutOfBounds: !0 });
3857
- class Io {
3557
+ `, co = ie({ opSnippet: uo, packedOpSnippet: lo, checkOutOfBounds: !0 });
3558
+ class ho {
3858
3559
  variableNames = ["logits", "maxLogits"];
3859
3560
  outputShape;
3860
3561
  userCode;
@@ -3873,7 +3574,7 @@ class Io {
3873
3574
  `;
3874
3575
  }
3875
3576
  }
3876
- class xo {
3577
+ class fo {
3877
3578
  variableNames = ["exp", "sum"];
3878
3579
  outputShape;
3879
3580
  userCode;
@@ -3900,31 +3601,31 @@ class xo {
3900
3601
  `;
3901
3602
  }
3902
3603
  }
3903
- function So(t) {
3604
+ function go(t) {
3904
3605
  const { inputs: e, attrs: n } = t, { logits: o } = e, { dim: s, dropoutRate: r, seed: i } = n, a = t.backend;
3905
3606
  if (!o)
3906
3607
  throw new Error("Error in softmax: input logits is null");
3907
- const u = ht([s], o.shape), c = uo({
3608
+ const u = lt([s], o.shape), c = ro({
3908
3609
  inputs: { x: o },
3909
3610
  backend: a,
3910
3611
  attrs: { reductionIndices: u, keepDims: !1 }
3911
- }), h = vt(c.shape, u), f = new Io(o.shape), w = a.runWebGLProgram(f, [o, c], "float32"), p = co({ inputs: { x: w }, backend: a, attrs: { axis: u, keepDims: !1 } }), m = st({ inputs: { x: p }, backend: a, attrs: { shape: h } });
3612
+ }), h = It(c.shape, u), f = new ho(o.shape), w = a.runWebGLProgram(f, [o, c], "float32"), p = ao({ inputs: { x: w }, backend: a, attrs: { axis: u, keepDims: !1 } }), m = st({ inputs: { x: p }, backend: a, attrs: { shape: h } });
3912
3613
  if (r !== void 0 && r > 0) {
3913
- const d = new xo(o.shape), g = a.runWebGLProgram(d, [w, m], "float32", [
3614
+ const d = new fo(o.shape), g = a.runWebGLProgram(d, [w, m], "float32", [
3914
3615
  [r],
3915
3616
  [i ?? Math.random() * 1e4]
3916
3617
  ]);
3917
3618
  return a.disposeIntermediateTensorInfo(c), a.disposeIntermediateTensorInfo(w), a.disposeIntermediateTensorInfo(p), a.disposeIntermediateTensorInfo(m), g;
3918
3619
  }
3919
- const b = wo({ inputs: { a: w, b: m }, backend: a });
3620
+ const b = co({ inputs: { a: w, b: m }, backend: a });
3920
3621
  return a.disposeIntermediateTensorInfo(c), a.disposeIntermediateTensorInfo(w), a.disposeIntermediateTensorInfo(p), a.disposeIntermediateTensorInfo(m), b;
3921
3622
  }
3922
- const bo = {
3623
+ const po = {
3923
3624
  kernelName: "FusedSoftmax",
3924
3625
  backendName: "webgl",
3925
- kernelFunc: So
3626
+ kernelFunc: go
3926
3627
  };
3927
- ae(bo);
3628
+ ne(po);
3928
3629
  export {
3929
- So as softmax
3630
+ go as softmax
3930
3631
  };