@genai-fi/nanogpt 0.16.1 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Generator.js CHANGED
@@ -1,23 +1,23 @@
1
1
  import { E as Ui } from "./index-DvYrXKkX.js";
2
- import { o as Hi, q as Xi, E as Ki, dl as Ss, a5 as pe, ab as _, as as oo, at as ao, h as Oe, aY as Dt, ay as ro, az as io, au as ji, av as Ft, aD as Ge, ae as co, aG as ws, aH as qi, U as G, af as _e, aI as Yi, H as Ns, aJ as Rs, R as Qi, aj as Zi, x as te, D as lo, _ as Ne, a9 as ee, bb as uo, c7 as Ts, c8 as Es, cO as po, bm as ho, ah as ue, Q as Ye, bn as fo, bo as mo, c9 as go, ca as Ds, cb as Fs, cc as Ps, cd as Os, ce as As, bp as xo, ac as nt, cy as Co, cP as bo, cQ as Io, bs as yo, br as ko, bd as $o, de as vo, C as _s, cS as So, ao as wo, z as No, bt as Ro, c2 as $e, cD as To, bu as Eo, cz as Do, cT as Fo, cA as Po, bv as Ls, bw as Vs, bf as Oo, bx as Ao, am as Qe, V as Ji, by as _o, cB as Lo, cf as Vo, bz as Wo, cF as Mo, cG as Bo, df as Go, cg as zo, bX as ns, bR as St, bU as Ws, cU as yn, dt as ut, du as Uo, cV as kn, dg as ec, N as tc, be as Ho, cW as Xo, bB as Ms, A as Ko, aX as jo, aV as mt, cp as qo, dc as Yo, dd as Qo, bg as Zo, cE as Jo, di as ea, al as ta, G as sa, cq as na, ch as Bs, ci as Gs, cj as zs, dj as oa, b3 as Us, b4 as Hs, bD as Xs, cl as Ks, ck as aa, cY as ra, aM as sc, bE as ia, cC as ca, cZ as la, c_ as ua, dk as da, aP as pa, aZ as ha, cm as fa, bQ as ma, M as js, I as ga, bi as xa, bk as Ca, bj as ba, bF as Ia, d3 as ya, bG as ka, P as $a, a6 as va, bH as Sa, c$ as qs, dv as wa, dw as Na, dx as Ra, Z as Ta, cn as Ys, b9 as Ea, d0 as Da, ba as Fa, d1 as Pa, bJ as Oa, bh as Aa, b6 as Qs, ak as _a, dm as La, aL as Va, bL as Zs, co as Js, bM as en, bN as tn, bC as sn, bI as Wa, dy as Ma, dz as Ba, dn as Ga, dp as za, dq as Ua, J as Ha, d2 as Xa, aK as nn, cr as Ka, dr as ja, dA as qa, dB as Ya, cs as on, bq as an, ds as Qa, T as Za, ct as Ja, bl as er, dC as rn, cu as tr, b8 as sr, bO as nr, c as or, dD as ar, dE as $n, aw as vn, ax as nc, t as rr, a as oc, dF as ac, dG as rc, c0 as ic, ar as cc, bP as lc, bV as uc, S as dc, bW as pc, aQ as hc, aq as fc, bS as mc, bT as gc, bY as xc, aS as ir, bA as Cc, aN as bc, bZ as Ic, F as yc, b_ as kc, dh as $c, a$ as vc, b0 as Sc, b1 as wc, b2 as Nc, aO as Rc, b$ as Tc, b5 as Ec, c5 as Dc, ap as Fc, c1 as Pc, aW as cr, bK as Oc, aF as Ac, c3 as _c, b7 as Lc, c4 as Vc, k as Wc } from "./index-CUXkjxiT.js";
2
+ import { o as Hi, q as Xi, E as Ki, dl as Ss, a5 as pe, ab as _, as as oo, at as ao, h as Oe, aY as Dt, ay as ro, az as io, au as ji, av as Ft, aD as Ge, ae as co, aG as ws, aH as qi, U as G, af as _e, aI as Yi, H as Ns, aJ as Rs, R as Qi, aj as Ji, x as te, D as lo, _ as Ne, a9 as ee, bb as uo, c7 as Ts, c8 as Es, cO as po, bm as ho, ah as ue, Q as Ye, bn as fo, bo as mo, c9 as go, ca as Ds, cb as Fs, cc as Ps, cd as Os, ce as As, bp as xo, ac as nt, cy as Co, cP as bo, cQ as Io, bs as yo, br as ko, bd as $o, de as vo, C as _s, cS as So, ao as wo, z as No, bt as Ro, c2 as $e, cD as To, bu as Eo, cz as Do, cT as Fo, cA as Po, bv as Ls, bw as Vs, bf as Oo, bx as Ao, am as Qe, V as Zi, by as _o, cB as Lo, cf as Vo, bz as Wo, cF as Mo, cG as Bo, df as Go, cg as zo, bX as ns, bR as St, bU as Ws, cU as yn, dt as ut, du as Uo, cV as kn, dg as ec, N as tc, be as Ho, cW as Xo, bB as Ms, A as Ko, aX as jo, aV as mt, cp as qo, dc as Yo, dd as Qo, bg as Jo, cE as Zo, di as ea, al as ta, G as sa, cq as na, ch as Bs, ci as Gs, cj as zs, dj as oa, b3 as Us, b4 as Hs, bD as Xs, cl as Ks, ck as aa, cY as ra, aM as sc, bE as ia, cC as ca, cZ as la, c_ as ua, dk as da, aP as pa, aZ as ha, cm as fa, bQ as ma, M as js, I as ga, bi as xa, bk as Ca, bj as ba, bF as Ia, d3 as ya, bG as ka, P as $a, a6 as va, bH as Sa, c$ as qs, dv as wa, dw as Na, dx as Ra, Z as Ta, cn as Ys, b9 as Ea, d0 as Da, ba as Fa, d1 as Pa, bJ as Oa, bh as Aa, b6 as Qs, ak as _a, dm as La, aL as Va, bL as Js, co as Zs, bM as en, bN as tn, bC as sn, bI as Wa, dy as Ma, dz as Ba, dn as Ga, dp as za, dq as Ua, J as Ha, d2 as Xa, aK as nn, cr as Ka, dr as ja, dA as qa, dB as Ya, cs as on, bq as an, ds as Qa, T as Ja, ct as Za, bl as er, dC as rn, cu as tr, b8 as sr, bO as nr, c as or, dD as ar, dE as $n, aw as vn, ax as nc, t as rr, a as oc, dF as ac, dG as rc, c0 as ic, ar as cc, bP as lc, bV as uc, S as dc, bW as pc, aQ as hc, aq as fc, bS as mc, bT as gc, bY as xc, aS as ir, bA as Cc, aN as bc, bZ as Ic, F as yc, b_ as kc, dh as $c, a$ as vc, b0 as Sc, b1 as wc, b2 as Nc, aO as Rc, b$ as Tc, b5 as Ec, c5 as Dc, ap as Fc, c1 as Pc, aW as cr, bK as Oc, aF as Ac, c3 as _c, b7 as Lc, c4 as Vc, k as Wc } from "./index-CUXkjxiT.js";
3
3
  import { n as Mc } from "./random_width-DN5ZtQkM.js";
4
4
  import { t as Bc } from "./zeros_like-CWjDdwr-.js";
5
5
  import "./index-Cp39cXWe.js";
6
6
  import "./dataset-CGGp1z9P.js";
7
- import { a as j, u as ae, c as ot, i as at, b as Gc, d as wt, t as Re, e as gt, f as dt, g as lr, r as Nt, h as Ae, j as zc, k as Uc, l as cn, z as Hc, m as ln, n as ur, o as Xc, p as Kc, q as jc, v as qc, w as Yc, x as Qc, y as Zc, A as Jc, B as el, C as tl, D as lt, E as sl, F as nl, G as dr, H as ol, I as al, J as rl, K as il, L as cl, M as ll, N as ul, O as dl, P as pl, Q as hl, R as fl, S as ml, T as gl, U as xl, V as Cl, W as bl, X as Il, Y as yl, Z as kl, _ as $l, $ as vl, a0 as Sl, a1 as wl, a2 as Nl, a3 as Rl, a4 as Tl, a5 as El, a6 as Dl, a7 as Fl, a8 as Pl, a9 as Ol, aa as Al, ab as _l, ac as Ll, ad as Vl, ae as Wl, af as Ml, ag as Bl, ah as Gl, ai as zl } from "./shared-CagdqkLh.js";
7
+ import { a as j, u as ae, c as ot, i as at, b as Gc, d as wt, t as Re, e as gt, f as dt, g as lr, r as Nt, h as Ae, j as zc, k as Uc, l as cn, z as Hc, m as ln, n as ur, o as Xc, p as Kc, q as jc, v as qc, w as Yc, x as Qc, y as Jc, A as Zc, B as el, C as tl, D as lt, E as sl, F as nl, G as dr, H as ol, I as al, J as rl, K as il, L as cl, M as ll, N as ul, O as dl, P as pl, Q as hl, R as fl, S as ml, T as gl, U as xl, V as Cl, W as bl, X as Il, Y as yl, Z as kl, _ as $l, $ as vl, a0 as Sl, a1 as wl, a2 as Nl, a3 as Rl, a4 as Tl, a5 as El, a6 as Dl, a7 as Fl, a8 as Pl, a9 as Ol, aa as Al, ab as _l, ac as Ll, ad as Vl, ae as Wl, af as Ml, ag as Bl, ah as Gl, ai as zl } from "./shared-CagdqkLh.js";
8
8
  import { m as pt, g as pr, s as Ul, c as Hl, b as Xl, d as Kl, a as jl, e as ql } from "./complex_util-Yc1A_gV1.js";
9
9
  import { a as ge, b as xe, d as ke, c as ve, e as Te, g as os } from "./axis_util-GTVlo58H.js";
10
- import { k as Ze, h as Le, i as Je, j as rt, b as Se, d as xt, g as as } from "./step-BTxPtq1r.js";
10
+ import { k as Je, h as Le, i as Ze, j as rt, b as Se, d as xt, g as as } from "./step-BTxPtq1r.js";
11
11
  import { z as rs, A as is, B as cs, C as hr, D as fr, F as mr, G as gr, H as xr, I as Cr, J as br, y as Ir, x as yr, w as kr, u as $r, t as vr, E as Sr, K as wr, L as Nr, M as Rr, c as Tr, f as Yl } from "./backend_util-GaFarB78.js";
12
12
  import { a as Er, c as Ue } from "./concat_util-D18dJ4fD.js";
13
- import { c as Dr, a as Ql, s as Zl } from "./segment_util-Dasb2Zaf.js";
14
- import { s as Jl } from "./index-CieiGp4Y.js";
13
+ import { c as Dr, a as Ql, s as Jl } from "./segment_util-Dasb2Zaf.js";
14
+ import { s as Zl } from "./index-CieiGp4Y.js";
15
15
  import { n as Fr, b as Pr, a as Or } from "./non_max_suppression_impl-B2W7YjZB.js";
16
16
  import { c as Ct } from "./scatter_nd_util-ByNJaL6I.js";
17
17
  import { S as Ar, a as _r } from "./selu_util-BLhIqRkw.js";
18
18
  import { s as Lr, b as Vr, p as eu, a as tu, i as su, c as nu } from "./slice_util-CC35pLmT.js";
19
19
  import { h as Sn, j as ou, k as au, l as ru, m as iu, n as cu, o as lu, P as un, p as Ve, u as Pe, q as Wr, c as Mr, T as De, E as Br, g as Gr, a as zr, r as uu, s as du, t as Y, v as pu, w as wn, x as hu, y as fu, z as Pt, A as Ot, B as mu, C as gu, D as bs, F as Gt, G as zt, H as xu, I as Cu, J as Nn, K as bu, L as Iu, M as fs, N as yu, O as ku, Q as $u, R as Ut, S as ms, U as vu, f as he, V as be, W as Ht, X as Xt, Y as Su, d as Rn, e as Tn, i as Ur, Z as wu, _ as Nu, $ as Ru, a0 as Tu, a1 as Eu, a2 as Du, a3 as At } from "./gpgpu_math-BwvV12df.js";
20
- import { s as Hr, a as Fu, t as Xr, b as Pu, c as Ou, d as Kr, e as Au, n as _u, f as Lu, g as Vu, h as Wu, i as Mu, j as Bu, k as Gu, l as zu, o as Uu, p as Hu, q as Xu, r as Ku, u as ju, v as qu, w as Yu, x as Qu, y as Zu, z as Ju, A as ed, B as td, C as sd, D as nd, E as od, F as ad, G as rd, H as id, I as cd, J as ld, K as ud, L as dd, M as jr, N as pd, O as hd, P as fd, Q as md, R as gd, S as xd, T as Cd, U as bd, V as Id, W as yd } from "./shared-3agzAqQ_.js";
20
+ import { s as Hr, a as Fu, t as Xr, b as Pu, c as Ou, d as Kr, e as Au, n as _u, f as Lu, g as Vu, h as Wu, i as Mu, j as Bu, k as Gu, l as zu, o as Uu, p as Hu, q as Xu, r as Ku, u as ju, v as qu, w as Yu, x as Qu, y as Ju, z as Zu, A as ed, B as td, C as sd, D as nd, E as od, F as ad, G as rd, H as id, I as cd, J as ld, K as ud, L as dd, M as jr, N as pd, O as hd, P as fd, Q as md, R as gd, S as xd, T as Cd, U as bd, V as Id, W as yd } from "./shared-3agzAqQ_.js";
21
21
  import { a as ye, c as kd, U as st, d as qe, e as ze, A as En, f as bt, B as dn, h as pn, m as Rt, u as se, C as We, b as Ce, i as Fe, j as hn, k as it, l as It, n as $d, o as vd, p as Sd, q as wd } from "./kernel_funcs_utils-pq0CK9co.js";
22
22
  import { R as Nd, r as U, a as Rd } from "./Reshape-BW__R4mZ.js";
23
23
  import { M as qr } from "./matMulGelu-JNLZqKQp.js";
@@ -242,12 +242,12 @@ co(
242
242
  1
243
243
  /* priority */
244
244
  );
245
- const Zr = ae(ws, (a) => a >= 0 ? a : Math.exp(a) - 1), Xd = {
245
+ const Jr = ae(ws, (a) => a >= 0 ? a : Math.exp(a) - 1), Xd = {
246
246
  kernelName: ws,
247
247
  backendName: "cpu",
248
- kernelFunc: Zr
248
+ kernelFunc: Jr
249
249
  };
250
- function Jr(a) {
250
+ function Zr(a) {
251
251
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { alpha: o } = n;
252
252
  j([s], "leakyRelu");
253
253
  const r = G(s.shape), c = e.data.get(s.dataId).values, i = _e("float32", r);
@@ -258,7 +258,7 @@ function Jr(a) {
258
258
  const Kd = {
259
259
  kernelName: qi,
260
260
  backendName: "cpu",
261
- kernelFunc: Jr
261
+ kernelFunc: Zr
262
262
  };
263
263
  const jd = ot((a, t) => a < 0 ? t * a : a);
264
264
  function ei(a) {
@@ -288,19 +288,19 @@ function Qt(a, t, e, n, s) {
288
288
  if (e === "relu")
289
289
  return ti({ inputs: { x: t }, backend: a });
290
290
  if (e === "elu")
291
- return Zr({ inputs: { x: t }, backend: a });
291
+ return Jr({ inputs: { x: t }, backend: a });
292
292
  if (e === "relu6")
293
293
  return si({ inputs: { x: t }, backend: a });
294
294
  if (e === "prelu")
295
295
  return ei({ inputs: { x: t, alpha: n }, backend: a });
296
296
  if (e === "leakyrelu")
297
- return Jr({ inputs: { x: t }, backend: a, attrs: { alpha: s } });
297
+ return Zr({ inputs: { x: t }, backend: a, attrs: { alpha: s } });
298
298
  if (e === "sigmoid")
299
299
  return Gc({ inputs: { x: t }, backend: a });
300
300
  throw new Error(`Activation ${e} has not been implemented for the CPU backend.`);
301
301
  }
302
302
  function ce(a) {
303
- const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { shape: o } = n, r = G(s.shape), c = Zi(o, r), i = G(c);
303
+ const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { shape: o } = n, r = G(s.shape), c = Ji(o, r), i = G(c);
304
304
  te(r === i, () => `The new shape (${c}) has ${i} elements and the old shape (${s.shape}) has ${r} elements. The new shape and old shape must have the same number of elements.`), e.incRef(s.dataId);
305
305
  const l = e.data.get(s.dataId);
306
306
  if (l.complexTensorInfos != null) {
@@ -309,7 +309,7 @@ function ce(a) {
309
309
  }
310
310
  return { dataId: s.dataId, shape: c, dtype: s.dtype };
311
311
  }
312
- const Zd = {
312
+ const Jd = {
313
313
  kernelName: Qi,
314
314
  backendName: "cpu",
315
315
  kernelFunc: ce
@@ -323,13 +323,13 @@ function ni(a) {
323
323
  for (let H = 0; H < R; H++) {
324
324
  const K = H % x, Q = H % g;
325
325
  for (let q = 0; q < w; q += M) {
326
- const Z = Math.min(q + M, w);
327
- for (let J = 0; J < S; J += M) {
328
- const ne = Math.min(J + M, S);
326
+ const J = Math.min(q + M, w);
327
+ for (let Z = 0; Z < S; Z += M) {
328
+ const ne = Math.min(Z + M, S);
329
329
  for (let re = 0; re < v; re += M) {
330
330
  const fe = Math.min(re + M, v);
331
- for (let ie = q; ie < Z; ie++)
332
- for (let oe = J; oe < ne; oe++) {
331
+ for (let ie = q; ie < J; ie++)
332
+ for (let oe = Z; oe < ne; oe++) {
333
333
  let de = 0;
334
334
  for (let le = re; le < fe; le++) {
335
335
  const Me = (
@@ -349,7 +349,7 @@ function ni(a) {
349
349
  }
350
350
  return e.disposeIntermediateTensorInfo(k), e.disposeIntermediateTensorInfo($), e.makeTensorInfo(I, W.dtype, W.values);
351
351
  }
352
- const Jd = {
352
+ const Zd = {
353
353
  kernelName: lo,
354
354
  backendName: "cpu",
355
355
  kernelFunc: ni
@@ -609,14 +609,14 @@ function ai(a, t, e, n, s, o) {
609
609
  for (; M < 0; )
610
610
  M += p;
611
611
  const H = Math.min(s.inWidth, f + z), K = B + W * v;
612
- let Q = C, q = 0, Z = 0;
612
+ let Q = C, q = 0, J = 0;
613
613
  for (let ne = T; ne < E; ne += l) {
614
614
  const re = R + ne * n[1];
615
615
  for (let fe = V; fe < L; fe += u) {
616
616
  const ie = re + fe * n[2];
617
617
  for (let oe = M; oe < H; oe += p) {
618
618
  const de = ie + oe * n[3], le = a[de + P];
619
- if (o === "max" && le > Q ? Q = le : o === "avg" && (q += le, Z++), isNaN(Q))
619
+ if (o === "max" && le > Q ? Q = le : o === "avg" && (q += le, J++), isNaN(Q))
620
620
  break;
621
621
  }
622
622
  if (isNaN(Q))
@@ -625,8 +625,8 @@ function ai(a, t, e, n, s, o) {
625
625
  if (isNaN(Q))
626
626
  break;
627
627
  }
628
- const J = K + P;
629
- b[J] = o === "avg" ? q / Math.max(Z, 1) : Q;
628
+ const Z = K + P;
629
+ b[Z] = o === "avg" ? q / Math.max(J, 1) : Q;
630
630
  }
631
631
  }
632
632
  }
@@ -676,7 +676,7 @@ function Rp(a) {
676
676
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t;
677
677
  j(s, "avgPool");
678
678
  const { filterSize: o, strides: r, pad: c, dimRoundingMode: i } = n, l = 1;
679
- te(Ze(r, l), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
679
+ te(Je(r, l), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
680
680
  const u = Le(s.shape, o, r, l, c, i);
681
681
  let p;
682
682
  if (u.filterWidth === 1 && u.filterHeight === 1 && nt(u.inShape, u.outShape))
@@ -695,7 +695,7 @@ const Tp = {
695
695
  function Ep(a) {
696
696
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dimRoundingMode: i, dataFormat: l } = n;
697
697
  j(s, "avgPool3d");
698
- const u = Je(s.shape, o, r, 1, c, i, l), p = e.data.get(s.dataId).values, d = ai(p, s.shape, s.dtype, ee(s.shape), u, "avg");
698
+ const u = Ze(s.shape, o, r, 1, c, i, l), p = e.data.get(s.dataId).values, d = ai(p, s.shape, s.dtype, ee(s.shape), u, "avg");
699
699
  return e.makeTensorInfo(d.shape, "float32", d.values);
700
700
  }
701
701
  const Dp = {
@@ -706,7 +706,7 @@ const Dp = {
706
706
  function Fp(a) {
707
707
  const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, { filterSize: r, strides: c, pad: i, dimRoundingMode: l } = n;
708
708
  j([s, o], "avgPool3DGrad");
709
- const u = Je(o.shape, r, c, 1, i, l), p = u.strideDepth, d = u.strideHeight, h = u.strideWidth, f = u.filterDepth, m = u.filterHeight, x = u.filterWidth, g = u.dilationDepth, C = u.dilationHeight, I = u.dilationWidth, b = u.effectiveFilterDepth, y = u.effectiveFilterHeight, k = u.effectiveFilterWidth, $ = b - 1 - u.padInfo.front, v = k - 1 - u.padInfo.left, w = y - 1 - u.padInfo.top, S = pe(o.shape, "float32"), R = 1 / (f * m * x), P = e.bufferSync(s);
709
+ const u = Ze(o.shape, r, c, 1, i, l), p = u.strideDepth, d = u.strideHeight, h = u.strideWidth, f = u.filterDepth, m = u.filterHeight, x = u.filterWidth, g = u.dilationDepth, C = u.dilationHeight, I = u.dilationWidth, b = u.effectiveFilterDepth, y = u.effectiveFilterHeight, k = u.effectiveFilterWidth, $ = b - 1 - u.padInfo.front, v = k - 1 - u.padInfo.left, w = y - 1 - u.padInfo.top, S = pe(o.shape, "float32"), R = 1 / (f * m * x), P = e.bufferSync(s);
710
710
  for (let D = 0; D < u.batchSize; ++D)
711
711
  for (let F = 0; F < u.inChannels; ++F)
712
712
  for (let T = 0; T < u.inDepth; ++T)
@@ -890,12 +890,12 @@ function ri(a) {
890
890
  continue;
891
891
  const H = z * k[0], K = O + M * v;
892
892
  for (let Q = 0; Q < d.outWidth; ++Q) {
893
- const q = B + Q * D, Z = Q * d.strideWidth - g;
894
- for (let J = 0; J < f; ++J) {
895
- const ne = Z + J * x;
893
+ const q = B + Q * D, J = Q * d.strideWidth - g;
894
+ for (let Z = 0; Z < f; ++Z) {
895
+ const ne = J + Z * x;
896
896
  if (ne < 0 || ne >= d.inWidth)
897
897
  continue;
898
- const re = H + J * k[1], fe = K + ne * w;
898
+ const re = H + Z * k[1], fe = K + ne * w;
899
899
  let ie = re;
900
900
  for (let oe = 0; oe < d.inChannels; ++oe) {
901
901
  const de = T[fe + oe * S];
@@ -940,12 +940,12 @@ function Qp(a) {
940
940
  }
941
941
  return e.makeTensorInfo(C.shape, C.dtype, C.values);
942
942
  }
943
- const Zp = {
943
+ const Jp = {
944
944
  kernelName: To,
945
945
  backendName: "cpu",
946
946
  kernelFunc: Qp
947
947
  };
948
- function Jp(a) {
948
+ function Zp(a) {
949
949
  const { inputs: t, backend: e, attrs: n } = a, { dy: s, filter: o } = t, { inputShape: r, strides: c, pad: i, dataFormat: l, dimRoundingMode: u } = n;
950
950
  j([s, o], "conv2dBackpropInput");
951
951
  const p = ee(o.shape), d = ee(s.shape);
@@ -955,13 +955,13 @@ function Jp(a) {
955
955
  const A = $ - 1 - f.padInfo.top, N = v - 1 - f.padInfo.left, O = h === "channelsLast", V = m.strides[0], L = O ? m.strides[1] : m.strides[2], B = O ? m.strides[2] : 1, W = O ? 1 : m.strides[1], z = d[0], M = O ? d[1] : d[2], H = O ? d[2] : 1, K = O ? 1 : d[1];
956
956
  for (let Q = 0; Q < k; ++Q)
957
957
  for (let q = 0; q < w; ++q)
958
- for (let Z = 0; Z < S; ++Z) {
959
- const J = Z - A, ne = Math.max(0, Math.ceil(J / T)), re = Math.min(D, ($ + J) / T);
958
+ for (let J = 0; J < S; ++J) {
959
+ const Z = J - A, ne = Math.max(0, Math.ceil(Z / T)), re = Math.min(D, ($ + Z) / T);
960
960
  for (let fe = 0; fe < R; ++fe) {
961
961
  const ie = fe - N, oe = Math.max(0, Math.ceil(ie / E)), de = Math.min(F, (v + ie) / E);
962
962
  let le = 0;
963
963
  for (let me = ne; me < re; ++me) {
964
- const He = me * T - J;
964
+ const He = me * T - Z;
965
965
  for (let we = oe; we < de; ++we) {
966
966
  const et = we * E - ie, Ee = z * Q + M * me + H * we, Be = I * ($ - 1 - He) + b * (v - 1 - et) + y * q;
967
967
  for (let Xe = 0; Xe < P; ++Xe) {
@@ -970,7 +970,7 @@ function Jp(a) {
970
970
  }
971
971
  }
972
972
  }
973
- const Me = V * Q + L * Z + B * fe + W * q;
973
+ const Me = V * Q + L * J + B * fe + W * q;
974
974
  x[Me] = le;
975
975
  }
976
976
  }
@@ -979,7 +979,7 @@ function Jp(a) {
979
979
  const eh = {
980
980
  kernelName: Eo,
981
981
  backendName: "cpu",
982
- kernelFunc: Jp
982
+ kernelFunc: Zp
983
983
  };
984
984
  function th(a) {
985
985
  const { inputs: t, backend: e, attrs: n } = a, { x: s, filter: o } = t, { strides: r, pad: c, dilations: i } = n;
@@ -1003,11 +1003,11 @@ function th(a) {
1003
1003
  const M = N + W * w[1], H = O + z * v[2];
1004
1004
  for (let K = 0; K < l.outWidth; ++K) {
1005
1005
  const Q = L + K * l.outChannels, q = K * l.strideWidth - C;
1006
- for (let Z = 0; Z < d; ++Z) {
1007
- const J = q + Z * m;
1008
- if (J < 0 || J >= l.inWidth)
1006
+ for (let J = 0; J < d; ++J) {
1007
+ const Z = q + J * m;
1008
+ if (Z < 0 || Z >= l.inWidth)
1009
1009
  continue;
1010
- const ne = M + Z * w[2], re = H + J * l.inChannels;
1010
+ const ne = M + J * w[2], re = H + Z * l.inChannels;
1011
1011
  let fe = ne;
1012
1012
  for (let ie = 0; ie < l.inChannels; ++ie) {
1013
1013
  const oe = y[re + ie];
@@ -1038,7 +1038,7 @@ function nh(a) {
1038
1038
  for (let M = 0; M < x; ++M) {
1039
1039
  const H = Math.max(0, Math.ceil((V - M) / h)), K = Math.min(p.outHeight, (p.inHeight + V - M) / h), Q = M * y + z;
1040
1040
  for (let q = 0; q < g; ++q) {
1041
- const Z = Math.max(0, Math.ceil((O - q) / f)), J = Math.min(p.outWidth, (p.inWidth + O - q) / f), ne = q * k + Q;
1041
+ const J = Math.max(0, Math.ceil((O - q) / f)), Z = Math.min(p.outWidth, (p.inWidth + O - q) / f), ne = q * k + Q;
1042
1042
  for (let re = 0; re < p.inChannels; ++re) {
1043
1043
  const fe = re * $ + ne;
1044
1044
  for (let ie = 0; ie < p.outChannels; ++ie) {
@@ -1049,7 +1049,7 @@ function nh(a) {
1049
1049
  const we = (L + me * d - N) * T + le, et = me * S + Me;
1050
1050
  for (let Ee = H; Ee < K; ++Ee) {
1051
1051
  const Xe = (M + Ee * h - V) * E + we, Ke = Ee * R + et;
1052
- for (let je = Z; je < J; ++je) {
1052
+ for (let je = J; je < Z; ++je) {
1053
1053
  const ps = (q + je * f - O) * A + Xe, hs = je * P + Ke;
1054
1054
  oe += D[ps + re] * v[hs + ie];
1055
1055
  }
@@ -1073,8 +1073,8 @@ function ah(a) {
1073
1073
  const { inputs: t, backend: e, attrs: n } = a, { dy: s, filter: o } = t, { pad: r, strides: c, inputShape: i } = n;
1074
1074
  j([s], "conv3dBackpropInputV2");
1075
1075
  const l = ee(s.shape), u = ee(o.shape), p = xt(i, o.shape, c, 1, r), d = new $e(p.inShape, "float32"), h = d.values, [f, m, x, g] = d.strides, C = e.data.get(s.dataId).values, [I, b, y, k] = l, $ = e.data.get(o.dataId).values, [v, w, S, R] = u, { batchSize: P, filterDepth: D, filterHeight: F, filterWidth: T, inChannels: E, inDepth: A, inHeight: N, inWidth: O, outChannels: V, outDepth: L, outHeight: B, outWidth: W, strideDepth: z, strideHeight: M, strideWidth: H } = p, K = D - 1 - p.padInfo.front, Q = F - 1 - p.padInfo.top, q = T - 1 - p.padInfo.left;
1076
- for (let Z = 0; Z < P; ++Z)
1077
- for (let J = 0; J < E; ++J)
1076
+ for (let J = 0; J < P; ++J)
1077
+ for (let Z = 0; Z < E; ++Z)
1078
1078
  for (let ne = 0; ne < A; ++ne) {
1079
1079
  const re = ne - K, fe = Math.max(0, Math.ceil(re / z)), ie = Math.min(L, (D + re) / z);
1080
1080
  for (let oe = 0; oe < N; ++oe) {
@@ -1087,7 +1087,7 @@ function ah(a) {
1087
1087
  for (let Ke = le; Ke < Me; ++Ke) {
1088
1088
  const je = Ke * M - de;
1089
1089
  for (let kt = we; kt < et; ++kt) {
1090
- const ps = kt * H - He, hs = I * Z + b * Be + y * Ke + k * kt, Bi = v * (D - 1 - Xe) + w * (F - 1 - je) + S * (T - 1 - ps) + R * J;
1090
+ const ps = kt * H - He, hs = I * J + b * Be + y * Ke + k * kt, Bi = v * (D - 1 - Xe) + w * (F - 1 - je) + S * (T - 1 - ps) + R * Z;
1091
1091
  for (let Bt = 0; Bt < V; ++Bt) {
1092
1092
  const Gi = C[hs + Bt], zi = $[Bi + Bt];
1093
1093
  Ee += Gi * zi;
@@ -1095,7 +1095,7 @@ function ah(a) {
1095
1095
  }
1096
1096
  }
1097
1097
  }
1098
- h[f * Z + m * ne + x * oe + g * me + J] = Ee;
1098
+ h[f * J + m * ne + x * oe + g * me + Z] = Ee;
1099
1099
  }
1100
1100
  }
1101
1101
  }
@@ -1151,9 +1151,9 @@ function dh(a) {
1151
1151
  K = H + z * y[2] + N * y[1] + D * y[0];
1152
1152
  const q = b[K];
1153
1153
  K = H + W * y[2] + O * y[1] + D * y[0];
1154
- const Z = b[K];
1154
+ const J = b[K];
1155
1155
  K = H + z * y[2] + O * y[1] + D * y[0];
1156
- const J = b[K], ne = Q + (q - Q) * M, re = Z + (J - Z) * M;
1156
+ const Z = b[K], ne = Q + (q - Q) * M, re = J + (Z - J) * M;
1157
1157
  K = H + L * k[2] + E * k[1] + $ * k[0], g.values[K] = ne + (re - ne) * V;
1158
1158
  }
1159
1159
  }
@@ -1191,7 +1191,7 @@ function hh(a) {
1191
1191
  const u = xe(1, s.shape.length)[0];
1192
1192
  if (u !== l.shape.length - 1)
1193
1193
  throw new Error(`backend.cumprod in CPU expects an inner-most axis=${l.shape.length - 1} but got axis=${u}`);
1194
- const p = Qe(l.dtype, "int32"), d = Ji(G(l.shape), p), h = e.data.get(l.dataId).values, f = l.shape[l.shape.length - 1], m = c ? (g, C) => g + f - C - 1 : (g, C) => g + C;
1194
+ const p = Qe(l.dtype, "int32"), d = Zi(G(l.shape), p), h = e.data.get(l.dataId).values, f = l.shape[l.shape.length - 1], m = c ? (g, C) => g + f - C - 1 : (g, C) => g + C;
1195
1195
  for (let g = 0; g < h.length; g += f)
1196
1196
  for (let C = 0; C < f; C++) {
1197
1197
  const I = m(g, C);
@@ -1290,7 +1290,7 @@ function ii(a) {
1290
1290
  j([s, o], "depthwiseConv2DNative");
1291
1291
  const u = ee(s.shape), p = ee(o.shape);
1292
1292
  let d = i;
1293
- d == null && (d = [1, 1]), te(Ze(r, d), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${d}'`);
1293
+ d == null && (d = [1, 1]), te(Je(r, d), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${d}'`);
1294
1294
  const h = Se(
1295
1295
  s.shape,
1296
1296
  o.shape,
@@ -1319,9 +1319,9 @@ function ii(a) {
1319
1319
  const M = N + W * p[1], H = O + z * h.inChannels;
1320
1320
  let K = L, Q = M;
1321
1321
  for (let q = 0; q < h.inChannels; ++q) {
1322
- const Z = $[H + q];
1323
- for (let J = 0; J < y; ++J)
1324
- w[K + J] += Z * v[Q + J];
1322
+ const J = $[H + q];
1323
+ for (let Z = 0; Z < y; ++Z)
1324
+ w[K + Z] += J * v[Q + Z];
1325
1325
  K += y, Q += y;
1326
1326
  }
1327
1327
  }
@@ -1391,11 +1391,11 @@ function vh(a) {
1391
1391
  for (let M = 0; M < R; ++M)
1392
1392
  for (let H = 0; H < F; ++H)
1393
1393
  for (let K = 0; K < T; ++K) {
1394
- const Q = K - B, q = Math.max(0, Math.ceil(Q / V)), Z = Math.min(N, (P + Q) / V);
1395
- for (let J = 0; J < E; ++J) {
1396
- const ne = J - W, re = Math.max(0, Math.ceil(ne / L)), fe = Math.min(O, (D + ne) / L);
1394
+ const Q = K - B, q = Math.max(0, Math.ceil(Q / V)), J = Math.min(N, (P + Q) / V);
1395
+ for (let Z = 0; Z < E; ++Z) {
1396
+ const ne = Z - W, re = Math.max(0, Math.ceil(ne / L)), fe = Math.min(O, (D + ne) / L);
1397
1397
  let ie = 0;
1398
- for (let oe = q; oe < Z; ++oe) {
1398
+ for (let oe = q; oe < J; ++oe) {
1399
1399
  const de = oe * V - Q;
1400
1400
  for (let le = re; le < fe; ++le) {
1401
1401
  const Me = le * L - ne, me = b * M + y * oe + k * le, He = v * (P - 1 - de) + w * (D - 1 - Me) + S * H;
@@ -1405,7 +1405,7 @@ function vh(a) {
1405
1405
  }
1406
1406
  }
1407
1407
  }
1408
- m[x * M + g * K + C * J + H] = ie;
1408
+ m[x * M + g * K + C * Z + H] = ie;
1409
1409
  }
1410
1410
  }
1411
1411
  return e.makeTensorInfo(f.shape, f.dtype, f.values);
@@ -1639,7 +1639,7 @@ const Vh = Sr, Wh = vr, Mh = $r, Bh = kr, Gh = yr, zh = Ir, Uh = ae(Ms, (a) => {
1639
1639
  backendName: "cpu",
1640
1640
  kernelFunc: Uh
1641
1641
  };
1642
- function Zt(a) {
1642
+ function Jt(a) {
1643
1643
  const { inputs: t, backend: e, attrs: n } = a, { input: s } = t, { dim: o } = n, r = s.shape.length, c = s.shape.slice();
1644
1644
  let i = o;
1645
1645
  return o < 0 && (te(-(r + 1) <= o, () => `Axis must be in the interval [${-(r + 1)}, ${r}]`), i = r + o + 1), c.splice(i, 0, 1), ce({ inputs: { x: s }, backend: e, attrs: { shape: c } });
@@ -1647,7 +1647,7 @@ function Zt(a) {
1647
1647
  const Xh = {
1648
1648
  kernelName: Ko,
1649
1649
  backendName: "cpu",
1650
- kernelFunc: Zt
1650
+ kernelFunc: Jt
1651
1651
  };
1652
1652
  const Kh = ot((a, t) => a / t), gn = gt(jo, Kh), Is = {
1653
1653
  kernelName: jo,
@@ -1704,16 +1704,16 @@ function ys(a, t, e, n, s) {
1704
1704
  }), H = ur({
1705
1705
  inputs: { a: R, b: z },
1706
1706
  backend: s
1707
- }), K = Nt({ inputs: { input: M }, backend: s }), Q = Nt({ inputs: { input: H }, backend: s }), q = ht({ inputs: { input: M }, backend: s }), Z = ht({ inputs: { input: H }, backend: s }), J = ft({
1707
+ }), K = Nt({ inputs: { input: M }, backend: s }), Q = Nt({ inputs: { input: H }, backend: s }), q = ht({ inputs: { input: M }, backend: s }), J = ht({ inputs: { input: H }, backend: s }), Z = ft({
1708
1708
  inputs: [K, Q],
1709
1709
  backend: s,
1710
1710
  attrs: { axis: 0 }
1711
1711
  }), ne = ft({
1712
- inputs: [q, Z],
1712
+ inputs: [q, J],
1713
1713
  backend: s,
1714
1714
  attrs: { axis: 0 }
1715
- }), re = s.data.get(J.dataId).values, fe = s.data.get(ne.dataId).values;
1716
- return s.disposeIntermediateTensorInfo(p), s.disposeIntermediateTensorInfo(d), s.disposeIntermediateTensorInfo(h), s.disposeIntermediateTensorInfo(C), s.disposeIntermediateTensorInfo(I), s.disposeIntermediateTensorInfo(b), s.disposeIntermediateTensorInfo(w), s.disposeIntermediateTensorInfo(S), s.disposeIntermediateTensorInfo(R), s.disposeIntermediateTensorInfo(E), s.disposeIntermediateTensorInfo(A), s.disposeIntermediateTensorInfo(N), s.disposeIntermediateTensorInfo(L), s.disposeIntermediateTensorInfo(B), s.disposeIntermediateTensorInfo(W), s.disposeIntermediateTensorInfo(z), s.disposeIntermediateTensorInfo(M), s.disposeIntermediateTensorInfo(H), s.disposeIntermediateTensorInfo(K), s.disposeIntermediateTensorInfo(q), s.disposeIntermediateTensorInfo(Q), s.disposeIntermediateTensorInfo(Z), s.disposeIntermediateTensorInfo(J), s.disposeIntermediateTensorInfo(ne), { real: re, imag: fe };
1715
+ }), re = s.data.get(Z.dataId).values, fe = s.data.get(ne.dataId).values;
1716
+ return s.disposeIntermediateTensorInfo(p), s.disposeIntermediateTensorInfo(d), s.disposeIntermediateTensorInfo(h), s.disposeIntermediateTensorInfo(C), s.disposeIntermediateTensorInfo(I), s.disposeIntermediateTensorInfo(b), s.disposeIntermediateTensorInfo(w), s.disposeIntermediateTensorInfo(S), s.disposeIntermediateTensorInfo(R), s.disposeIntermediateTensorInfo(E), s.disposeIntermediateTensorInfo(A), s.disposeIntermediateTensorInfo(N), s.disposeIntermediateTensorInfo(L), s.disposeIntermediateTensorInfo(B), s.disposeIntermediateTensorInfo(W), s.disposeIntermediateTensorInfo(z), s.disposeIntermediateTensorInfo(M), s.disposeIntermediateTensorInfo(H), s.disposeIntermediateTensorInfo(K), s.disposeIntermediateTensorInfo(q), s.disposeIntermediateTensorInfo(Q), s.disposeIntermediateTensorInfo(J), s.disposeIntermediateTensorInfo(Z), s.disposeIntermediateTensorInfo(ne), { real: re, imag: fe };
1717
1717
  }
1718
1718
  function Yh(a, t, e) {
1719
1719
  const n = new Float32Array(t * 2);
@@ -1735,7 +1735,7 @@ function Qh(a) {
1735
1735
  }), i = ci(c, !1, e), l = ce({ inputs: { x: i }, backend: e, attrs: { shape: n.shape } });
1736
1736
  return e.disposeIntermediateTensorInfo(c), e.disposeIntermediateTensorInfo(i), l;
1737
1737
  }
1738
- const Zh = {
1738
+ const Jh = {
1739
1739
  kernelName: qo,
1740
1740
  backendName: "cpu",
1741
1741
  kernelFunc: Qh
@@ -1744,7 +1744,7 @@ function xn(a) {
1744
1744
  const { backend: t, attrs: e } = a, { shape: n, value: s, dtype: o } = e, r = o || Qo(s), c = ns(r, G(n));
1745
1745
  return ef(c, s, r), t.makeTensorInfo(n, r, c);
1746
1746
  }
1747
- const Jh = {
1747
+ const Zh = {
1748
1748
  kernelName: Yo,
1749
1749
  backendName: "cpu",
1750
1750
  kernelFunc: xn
@@ -1753,7 +1753,7 @@ function ef(a, t, e) {
1753
1753
  a.fill(t);
1754
1754
  }
1755
1755
  const tf = {
1756
- kernelName: Zo,
1756
+ kernelName: Jo,
1757
1757
  backendName: "cpu",
1758
1758
  kernelFunc: ({ inputs: a, attrs: t, backend: e }) => {
1759
1759
  const { image: n } = a, s = e, o = _e(n.dtype, G(n.shape)), [r, c, i, l] = n.shape, u = s.data.get(n.dataId).values;
@@ -1810,7 +1810,7 @@ function sf(a) {
1810
1810
  return m;
1811
1811
  }
1812
1812
  const nf = {
1813
- kernelName: Jo,
1813
+ kernelName: Zo,
1814
1814
  backendName: "cpu",
1815
1815
  kernelFunc: sf
1816
1816
  };
@@ -2018,7 +2018,7 @@ function _f(a) {
2018
2018
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t;
2019
2019
  j(s, "maxPool");
2020
2020
  const { filterSize: o, strides: r, pad: c, dimRoundingMode: i } = n, l = 1;
2021
- te(Ze(r, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
2021
+ te(Je(r, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
2022
2022
  const u = Le(s.shape, o, r, l, c, i);
2023
2023
  let p;
2024
2024
  if (u.filterWidth === 1 && u.filterHeight === 1 && nt(u.inShape, u.outShape))
@@ -2037,7 +2037,7 @@ const Lf = {
2037
2037
  function Vf(a) {
2038
2038
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dimRoundingMode: i, dataFormat: l } = n;
2039
2039
  j(s, "maxPool3d");
2040
- const u = Je(s.shape, o, r, 1, c, i, l), p = e.data.get(s.dataId).values, d = ai(p, s.shape, s.dtype, ee(s.shape), u, "max");
2040
+ const u = Ze(s.shape, o, r, 1, c, i, l), p = e.data.get(s.dataId).values, d = ai(p, s.shape, s.dtype, ee(s.shape), u, "max");
2041
2041
  return e.makeTensorInfo(d.shape, "float32", d.values);
2042
2042
  }
2043
2043
  const Wf = {
@@ -2048,7 +2048,7 @@ const Wf = {
2048
2048
  function Mf(a) {
2049
2049
  const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, { filterSize: r, strides: c, pad: i, dimRoundingMode: l } = n;
2050
2050
  j([s, o], "maxPool3DGrad");
2051
- const u = Je(o.shape, r, c, 1, i, l), p = e.bufferSync(o), d = Np(p, u), h = u.strideDepth, f = u.strideHeight, m = u.strideWidth, x = u.dilationDepth, g = u.dilationHeight, C = u.dilationWidth, I = u.effectiveFilterDepth, b = u.effectiveFilterHeight, y = u.effectiveFilterWidth, k = I - 1 - u.padInfo.front, $ = y - 1 - u.padInfo.left, v = b - 1 - u.padInfo.top, w = pe(o.shape, "float32"), S = e.bufferSync(s);
2051
+ const u = Ze(o.shape, r, c, 1, i, l), p = e.bufferSync(o), d = Np(p, u), h = u.strideDepth, f = u.strideHeight, m = u.strideWidth, x = u.dilationDepth, g = u.dilationHeight, C = u.dilationWidth, I = u.effectiveFilterDepth, b = u.effectiveFilterHeight, y = u.effectiveFilterWidth, k = I - 1 - u.padInfo.front, $ = y - 1 - u.padInfo.left, v = b - 1 - u.padInfo.top, w = pe(o.shape, "float32"), S = e.bufferSync(s);
2052
2052
  for (let R = 0; R < u.batchSize; ++R)
2053
2053
  for (let P = 0; P < u.inChannels; ++P)
2054
2054
  for (let D = 0; D < u.inDepth; ++D)
@@ -2201,13 +2201,13 @@ const Qf = {
2201
2201
  backendName: "cpu",
2202
2202
  kernelFunc: Yf
2203
2203
  };
2204
- const Zf = ot(((a, t) => {
2204
+ const Jf = ot(((a, t) => {
2205
2205
  const e = a % t;
2206
2206
  return a < 0 && t < 0 || a >= 0 && t >= 0 ? e : (e + t) % t;
2207
- })), Jf = gt(js, Zf), em = {
2207
+ })), Zf = gt(js, Jf), em = {
2208
2208
  kernelName: js,
2209
2209
  backendName: "cpu",
2210
- kernelFunc: Jf
2210
+ kernelFunc: Zf
2211
2211
  };
2212
2212
  function ui(a) {
2213
2213
  const { inputs: t, backend: e, attrs: n } = a, { logits: s } = t, { dim: o } = n, r = s.shape.length;
@@ -2235,7 +2235,7 @@ function sm(a) {
2235
2235
  x[0] = p[m];
2236
2236
  for (let I = 1; I < x.length; ++I)
2237
2237
  x[I] = x[I - 1] + p[m + I];
2238
- const g = Jl.alea(r.toString()), C = f * o;
2238
+ const g = Zl.alea(r.toString()), C = f * o;
2239
2239
  for (let I = 0; I < o; ++I) {
2240
2240
  const b = g();
2241
2241
  h[C + I] = x.length;
@@ -2310,12 +2310,12 @@ const fm = {
2310
2310
  backendName: "cpu",
2311
2311
  kernelFunc: hm
2312
2312
  };
2313
- function Jt(a) {
2313
+ function Zt(a) {
2314
2314
  const { inputs: t, backend: e } = a, { x: n } = t;
2315
2315
  if (n.dtype === "string")
2316
2316
  throw new Error("zerosLike is not supported for string tensors");
2317
2317
  if (n.dtype === "complex64") {
2318
- const s = Nt({ inputs: { input: n }, backend: e }), o = Jt({ inputs: { x: s }, backend: e }), r = ht({ inputs: { input: n }, backend: e }), c = Jt({ inputs: { x: r }, backend: e }), i = Ae({ inputs: { real: o, imag: c }, backend: e });
2318
+ const s = Nt({ inputs: { input: n }, backend: e }), o = Zt({ inputs: { x: s }, backend: e }), r = ht({ inputs: { input: n }, backend: e }), c = Zt({ inputs: { x: r }, backend: e }), i = Ae({ inputs: { real: o, imag: c }, backend: e });
2319
2319
  return e.disposeIntermediateTensorInfo(s), e.disposeIntermediateTensorInfo(o), e.disposeIntermediateTensorInfo(r), e.disposeIntermediateTensorInfo(c), i;
2320
2320
  } else
2321
2321
  return xn({ backend: e, attrs: { shape: n.shape, value: 0, dtype: n.dtype } });
@@ -2323,14 +2323,14 @@ function Jt(a) {
2323
2323
  const mm = {
2324
2324
  kernelName: ya,
2325
2325
  backendName: "cpu",
2326
- kernelFunc: Jt
2326
+ kernelFunc: Zt
2327
2327
  };
2328
2328
  function di(a) {
2329
2329
  const { inputs: t, backend: e } = a, { x: n } = t;
2330
2330
  if (n.dtype === "string")
2331
2331
  throw new Error("onesLike is not supported for string tensors");
2332
2332
  if (n.dtype === "complex64") {
2333
- const s = Nt({ inputs: { input: n }, backend: e }), o = di({ inputs: { x: s }, backend: e }), r = ht({ inputs: { input: n }, backend: e }), c = Jt({ inputs: { x: r }, backend: e }), i = Ae({ inputs: { real: o, imag: c }, backend: e });
2333
+ const s = Nt({ inputs: { input: n }, backend: e }), o = di({ inputs: { x: s }, backend: e }), r = ht({ inputs: { input: n }, backend: e }), c = Zt({ inputs: { x: r }, backend: e }), i = Ae({ inputs: { real: o, imag: c }, backend: e });
2334
2334
  return e.disposeIntermediateTensorInfo(s), e.disposeIntermediateTensorInfo(o), e.disposeIntermediateTensorInfo(r), e.disposeIntermediateTensorInfo(c), i;
2335
2335
  } else
2336
2336
  return xn({ backend: e, attrs: { shape: n.shape, value: 1, dtype: n.dtype } });
@@ -2343,13 +2343,13 @@ const gm = {
2343
2343
  function pi(a) {
2344
2344
  const { inputs: t, backend: e, attrs: n } = a, { axis: s } = n;
2345
2345
  if (t.length === 1)
2346
- return Zt({ inputs: { input: t[0] }, backend: e, attrs: { dim: s } });
2346
+ return Jt({ inputs: { input: t[0] }, backend: e, attrs: { dim: s } });
2347
2347
  const o = t[0].shape, r = t[0].dtype;
2348
2348
  t.forEach((u) => {
2349
2349
  va(o, u.shape, "All tensors passed to stack must have matching shapes"), te(r === u.dtype, () => "All tensors passed to stack must have matching dtypes");
2350
2350
  });
2351
2351
  const c = [], i = t.map((u) => {
2352
- const p = Zt({ inputs: { input: u }, backend: e, attrs: { dim: s } });
2352
+ const p = Jt({ inputs: { input: u }, backend: e, attrs: { dim: s } });
2353
2353
  return c.push(p), p;
2354
2354
  }), l = ft({ inputs: i, backend: e, attrs: { axis: s } });
2355
2355
  return c.forEach((u) => e.disposeIntermediateTensorInfo(u)), l;
@@ -2384,7 +2384,7 @@ const bm = ot((a, t) => Math.pow(a, t)), Im = gt(qs, bm), ym = {
2384
2384
  kernelFunc: Im
2385
2385
  };
2386
2386
  function km(a) {
2387
- const { inputs: t, backend: e, attrs: n } = a, { paramsNestedSplits: s, paramsDenseValues: o, indices: r } = t, { outputRaggedRank: c } = n, i = s.map((g) => e.data.get(g.dataId).values), l = s.map((g) => g.shape), u = e.data.get(o.dataId).values, p = e.data.get(r.dataId).values, [d, h, f] = Zc(i, l, u, o.shape, o.dtype, p, r.shape), m = d.map((g) => e.makeTensorInfo([g.length], "int32", g)), x = e.makeTensorInfo(f, o.dtype, h);
2387
+ const { inputs: t, backend: e, attrs: n } = a, { paramsNestedSplits: s, paramsDenseValues: o, indices: r } = t, { outputRaggedRank: c } = n, i = s.map((g) => e.data.get(g.dataId).values), l = s.map((g) => g.shape), u = e.data.get(o.dataId).values, p = e.data.get(r.dataId).values, [d, h, f] = Jc(i, l, u, o.shape, o.dtype, p, r.shape), m = d.map((g) => e.makeTensorInfo([g.length], "int32", g)), x = e.makeTensorInfo(f, o.dtype, h);
2388
2388
  return m.concat([x]);
2389
2389
  }
2390
2390
  const $m = {
@@ -2393,7 +2393,7 @@ const $m = {
2393
2393
  kernelFunc: km
2394
2394
  };
2395
2395
  function vm(a) {
2396
- const { inputs: t, backend: e } = a, { starts: n, limits: s, deltas: o } = t, r = e.data.get(n.dataId).values, c = e.data.get(s.dataId).values, i = e.data.get(o.dataId).values, [l, u] = Jc(r, n.shape, n.dtype, c, s.shape, i, o.shape), p = e.makeTensorInfo([l.length], "int32", l), d = e.makeTensorInfo([u.length], n.dtype, u);
2396
+ const { inputs: t, backend: e } = a, { starts: n, limits: s, deltas: o } = t, r = e.data.get(n.dataId).values, c = e.data.get(s.dataId).values, i = e.data.get(o.dataId).values, [l, u] = Zc(r, n.shape, n.dtype, c, s.shape, i, o.shape), p = e.makeTensorInfo([l.length], "int32", l), d = e.makeTensorInfo([u.length], n.dtype, u);
2397
2397
  return [p, d];
2398
2398
  }
2399
2399
  const Sm = {
@@ -2446,8 +2446,8 @@ function Fm(a) {
2446
2446
  r ? T = y * (F + 0.5) - 0.5 : T = y * F;
2447
2447
  const E = Math.max(0, Math.floor(T)), A = T - E, N = Math.min(h - 1, Math.ceil(T)), O = P + E * i[2], V = D + E * i[2], L = P + N * i[2], B = D + N * i[2];
2448
2448
  for (let W = 0; W < f; W++) {
2449
- const z = m[O + W], M = m[V + W], H = m[L + W], K = m[B + W], Q = z + (H - z) * A, q = M + (K - M) * A, Z = Q + (q - Q) * S;
2450
- x[I++] = Z;
2449
+ const z = m[O + W], M = m[V + W], H = m[L + W], K = m[B + W], Q = z + (H - z) * A, q = M + (K - M) * A, J = Q + (q - Q) * S;
2450
+ x[I++] = J;
2451
2451
  }
2452
2452
  }
2453
2453
  }
@@ -2476,8 +2476,8 @@ function Om(a) {
2476
2476
  for (let T = 0; T < h; T++) {
2477
2477
  const E = T * C, A = Math.floor(E), N = Math.min(Math.ceil(E), u - 1), O = E - A, V = 1 - O, L = R + A * c[2], B = R + N * c[2], W = P + A * c[2], z = P + N * c[2], M = F * V, H = F * O, K = D * V, Q = D * O;
2478
2478
  for (let q = 0; q < p; q++) {
2479
- const Z = I[b++];
2480
- f[L + q] += Z * M, f[B + q] += Z * H, f[W + q] += Z * K, f[z + q] += Z * Q;
2479
+ const J = I[b++];
2480
+ f[L + q] += J * M, f[B + q] += J * H, f[W + q] += J * K, f[z + q] += J * Q;
2481
2481
  }
2482
2482
  }
2483
2483
  }
@@ -2554,8 +2554,8 @@ function Vm(a) {
2554
2554
  const K = H + N;
2555
2555
  if (K < 0 || K >= f)
2556
2556
  continue;
2557
- const Q = W + K * i[2], q = K * b, Z = Math.min(p - 1, r ? Math.round(q) : Math.floor(q));
2558
- T === Z && (V += x[Q + O]);
2557
+ const Q = W + K * i[2], q = K * b, J = Math.min(p - 1, r ? Math.round(q) : Math.floor(q));
2558
+ T === J && (V += x[Q + O]);
2559
2559
  }
2560
2560
  }
2561
2561
  m[E + O] = V;
@@ -2664,7 +2664,7 @@ const Qm = {
2664
2664
  backendName: "cpu",
2665
2665
  kernelFunc: Ym
2666
2666
  };
2667
- function Zm(a) {
2667
+ function Jm(a) {
2668
2668
  const { inputs: t, backend: e } = a, { condition: n, t: s, e: o } = t;
2669
2669
  j([n, s, o], "select");
2670
2670
  const r = n.shape.length, c = e.data.get(n.dataId).values, i = e.data.get(s.dataId).values, l = e.data.get(o.dataId).values, u = Qe(s.dtype, o.dtype), p = Ye(G(s.shape), u);
@@ -2675,18 +2675,18 @@ function Zm(a) {
2675
2675
  c[f] === 1 ? p[d++] = i[f] : p[d++] = l[f];
2676
2676
  return e.makeTensorInfo(s.shape, u, p);
2677
2677
  }
2678
- const Jm = {
2678
+ const Zm = {
2679
2679
  kernelName: Va,
2680
2680
  backendName: "cpu",
2681
- kernelFunc: Zm
2681
+ kernelFunc: Jm
2682
2682
  };
2683
- const eg = _r, tg = Ar, sg = ae(Zs, (a) => a >= 0 ? tg * a : eg * (Math.exp(a) - 1)), ng = {
2684
- kernelName: Zs,
2683
+ const eg = _r, tg = Ar, sg = ae(Js, (a) => a >= 0 ? tg * a : eg * (Math.exp(a) - 1)), ng = {
2684
+ kernelName: Js,
2685
2685
  backendName: "cpu",
2686
2686
  kernelFunc: sg
2687
2687
  };
2688
- const og = ae(Js, (a) => a < 0 ? -1 : a > 0 ? 1 : 0), ag = {
2689
- kernelName: Js,
2688
+ const og = ae(Zs, (a) => a < 0 ? -1 : a > 0 ? 1 : 0), ag = {
2689
+ kernelName: Zs,
2690
2690
  backendName: "cpu",
2691
2691
  kernelFunc: og
2692
2692
  };
@@ -2980,7 +2980,7 @@ function Ug(a) {
2980
2980
  return e.makeTensorInfo(r.shape, r.dtype, r.values);
2981
2981
  }
2982
2982
  const Hg = {
2983
- kernelName: Za,
2983
+ kernelName: Ja,
2984
2984
  backendName: "cpu",
2985
2985
  kernelFunc: Ug
2986
2986
  };
@@ -2994,7 +2994,7 @@ function Xg(a) {
2994
2994
  ];
2995
2995
  }
2996
2996
  const Kg = {
2997
- kernelName: Ja,
2997
+ kernelName: Za,
2998
2998
  backendName: "cpu",
2999
2999
  kernelFunc: Xg
3000
3000
  };
@@ -3041,9 +3041,9 @@ function _n(a, t, e) {
3041
3041
  case "wrap":
3042
3042
  return Qg(a, t);
3043
3043
  case "nearest":
3044
- return Jg(a, t);
3044
+ return Zg(a, t);
3045
3045
  default:
3046
- return Zg(a);
3046
+ return Jg(a);
3047
3047
  }
3048
3048
  }
3049
3049
  function Yg(a, t) {
@@ -3082,10 +3082,10 @@ function Qg(a, t) {
3082
3082
  }
3083
3083
  return rn(0, e, t - 1);
3084
3084
  }
3085
- function Zg(a, t) {
3085
+ function Jg(a, t) {
3086
3086
  return a;
3087
3087
  }
3088
- function Jg(a, t) {
3088
+ function Zg(a, t) {
3089
3089
  return rn(0, a, t - 1);
3090
3090
  }
3091
3091
  function $t(a, t, e, n, s, o, r, c, i, l, u) {
@@ -3143,7 +3143,7 @@ function rx(a) {
3143
3143
  const c = s.shape.length, i = o.shape.length, l = [], u = [], p = c - i;
3144
3144
  let d = o;
3145
3145
  for (let f = 0; f < p; ++f) {
3146
- const m = Zt({ inputs: { input: d }, backend: e, attrs: { dim: f + 1 } });
3146
+ const m = Jt({ inputs: { input: d }, backend: e, attrs: { dim: f + 1 } });
3147
3147
  d = m, u.push(m);
3148
3148
  }
3149
3149
  for (let f = 0; f < r; ++f) {
@@ -3178,7 +3178,7 @@ const cx = [
3178
3178
  Dp,
3179
3179
  Pp,
3180
3180
  Ap,
3181
- Jd,
3181
+ Zd,
3182
3182
  Lp,
3183
3183
  Wp,
3184
3184
  Bp,
@@ -3191,7 +3191,7 @@ const cx = [
3191
3191
  Kp,
3192
3192
  qp,
3193
3193
  Yp,
3194
- Zp,
3194
+ Jp,
3195
3195
  eh,
3196
3196
  sh,
3197
3197
  oh,
@@ -3219,8 +3219,8 @@ const cx = [
3219
3219
  bl,
3220
3220
  Xh,
3221
3221
  Il,
3222
- Zh,
3223
3222
  Jh,
3223
+ Zh,
3224
3224
  tf,
3225
3225
  yl,
3226
3226
  kl,
@@ -3282,7 +3282,7 @@ const cx = [
3282
3282
  Dm,
3283
3283
  Yd,
3284
3284
  Qd,
3285
- Zd,
3285
+ Jd,
3286
3286
  Pm,
3287
3287
  Am,
3288
3288
  Lm,
@@ -3293,7 +3293,7 @@ const cx = [
3293
3293
  _l,
3294
3294
  Xm,
3295
3295
  Qm,
3296
- Jm,
3296
+ Zm,
3297
3297
  ng,
3298
3298
  Ll,
3299
3299
  ag,
@@ -4825,15 +4825,15 @@ const Qx = {
4825
4825
  backendName: "webgl",
4826
4826
  kernelFunc: Yx
4827
4827
  };
4828
- const Zx = We + `
4828
+ const Jx = We + `
4829
4829
  if (abs(x) > 1.) {
4830
4830
  return NAN;
4831
4831
  }
4832
4832
  return acos(x);
4833
- `, Jx = se({ opSnippet: Zx }), eC = {
4833
+ `, Zx = se({ opSnippet: Jx }), eC = {
4834
4834
  kernelName: Ts,
4835
4835
  backendName: "webgl",
4836
- kernelFunc: Jx
4836
+ kernelFunc: Zx
4837
4837
  };
4838
4838
  const tC = We + `
4839
4839
  if (x < 1.0) return NAN;
@@ -5507,7 +5507,7 @@ function AC(a) {
5507
5507
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t;
5508
5508
  At(s, "avgPool");
5509
5509
  const { filterSize: o, strides: r, pad: c, dimRoundingMode: i } = n, l = 1;
5510
- te(Ze(r, l), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
5510
+ te(Je(r, l), () => `Error in avgPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
5511
5511
  const u = Le(s.shape, o, r, l, c, i);
5512
5512
  if (u.filterWidth === 1 && u.filterHeight === 1 && nt(u.inShape, u.outShape))
5513
5513
  return Fe({ inputs: { x: s }, backend: e });
@@ -5520,7 +5520,7 @@ const _C = {
5520
5520
  kernelFunc: AC
5521
5521
  };
5522
5522
  function LC(a) {
5523
- const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dimRoundingMode: i, dataFormat: l } = n, u = [1, 1, 1], p = Je(s.shape, o, r, u, c, i, l), d = new bn(p, "avg", !1);
5523
+ const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dimRoundingMode: i, dataFormat: l } = n, u = [1, 1, 1], p = Ze(s.shape, o, r, u, c, i, l), d = new bn(p, "avg", !1);
5524
5524
  return e.runWebGLProgram(d, [s], "float32");
5525
5525
  }
5526
5526
  const VC = {
@@ -5641,7 +5641,7 @@ class MC {
5641
5641
  }
5642
5642
  }
5643
5643
  function BC(a) {
5644
- const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, r = o, { filterSize: c, strides: i, pad: l, dimRoundingMode: u } = n, p = [1, 1, 1], d = Je(r.shape, c, i, p, l, u), h = new MC(d);
5644
+ const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, r = o, { filterSize: c, strides: i, pad: l, dimRoundingMode: u } = n, p = [1, 1, 1], d = Ze(r.shape, c, i, p, l, u), h = new MC(d);
5645
5645
  return e.runWebGLProgram(h, [s], r.dtype);
5646
5646
  }
5647
5647
  const GC = {
@@ -5732,7 +5732,7 @@ class QC {
5732
5732
  this.variableNames = ["source"], this.outputShape = t, this.rank = t.length;
5733
5733
  const e = he(this.rank);
5734
5734
  this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }];
5735
- const n = ZC(this.rank);
5735
+ const n = JC(this.rank);
5736
5736
  let s;
5737
5737
  const o = t.map((r, c) => `sourceLoc.${ks[c]} = start[${c}] + coords.${ks[c]};`);
5738
5738
  s = `
@@ -5749,14 +5749,14 @@ class QC {
5749
5749
  }
5750
5750
  }
5751
5751
  const ks = ["x", "y", "z", "w", "u", "v"];
5752
- function ZC(a) {
5752
+ function JC(a) {
5753
5753
  if (a === 1)
5754
5754
  return "sourceLoc";
5755
5755
  if (a <= 6)
5756
5756
  return ks.slice(0, a).map((t) => "sourceLoc." + t).join(",");
5757
5757
  throw Error(`Slicing for rank ${a} is not yet supported`);
5758
5758
  }
5759
- class JC {
5759
+ class ZC {
5760
5760
  constructor(t) {
5761
5761
  this.variableNames = ["source"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t, this.rank = t.length, this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }];
5762
5762
  const e = he(this.rank), n = ye("coords", this.rank), s = ye("sourceLoc", this.rank), o = this.rank === 1 ? "sourceLoc" : `vec2(${s.slice(-2).join()})`, r = `getChannel(getSource(${s.join()}), ${o})`, c = `
@@ -5814,7 +5814,7 @@ function yt(a) {
5814
5814
  }
5815
5815
  const { isPacked: l } = e.texData.get(s.dataId), u = su(s.shape, c, i);
5816
5816
  if (l || !u) {
5817
- const p = _().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new JC(i) : new QC(i), d = [c];
5817
+ const p = _().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new ZC(i) : new QC(i), d = [c];
5818
5818
  return e.runWebGLProgram(p, [s], s.dtype, d);
5819
5819
  }
5820
5820
  return e.uploadToGPU(s.dataId), eb(s, c, i, e);
@@ -7233,15 +7233,15 @@ const Yb = {
7233
7233
  };
7234
7234
  const Qb = It + `
7235
7235
  return cos(x);
7236
- `, Zb = `
7236
+ `, Jb = `
7237
7237
  vec4 result = cos(x);
7238
7238
  bvec4 isNaN = isnan(x);
7239
7239
  ${it}
7240
7240
  return result;
7241
- `, Jb = se({ opSnippet: Qb, packedOpSnippet: Zb }), e1 = {
7241
+ `, Zb = se({ opSnippet: Qb, packedOpSnippet: Jb }), e1 = {
7242
7242
  kernelName: Ls,
7243
7243
  backendName: "webgl",
7244
- kernelFunc: Jb
7244
+ kernelFunc: Zb
7245
7245
  };
7246
7246
  const t1 = `
7247
7247
  float e2x = exp(-x);
@@ -7791,7 +7791,7 @@ class Di {
7791
7791
  function g1(a) {
7792
7792
  const { inputs: t, backend: e, attrs: n } = a, { x: s, filter: o } = t, { strides: r, pad: c, dilations: i, dimRoundingMode: l } = n;
7793
7793
  let u = i;
7794
- u == null && (u = [1, 1]), te(Ze(r, u), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${u}'`);
7794
+ u == null && (u = [1, 1]), te(Je(r, u), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${r} and dilations '${u}'`);
7795
7795
  const p = Se(
7796
7796
  s.shape,
7797
7797
  o.shape,
@@ -8147,12 +8147,12 @@ const Y1 = {
8147
8147
  backendName: "webgl",
8148
8148
  kernelFunc: vs
8149
8149
  };
8150
- const Qn = "return exp(x) - 1.0;", Q1 = se({ opSnippet: Qn, packedOpSnippet: Qn, cpuKernelImpl: zu }), Z1 = {
8150
+ const Qn = "return exp(x) - 1.0;", Q1 = se({ opSnippet: Qn, packedOpSnippet: Qn, cpuKernelImpl: zu }), J1 = {
8151
8151
  kernelName: Ic,
8152
8152
  backendName: "webgl",
8153
8153
  kernelFunc: Q1
8154
8154
  };
8155
- class Zn {
8155
+ class Jn {
8156
8156
  constructor(t, e, n) {
8157
8157
  this.variableNames = ["real", "imag"];
8158
8158
  const s = e[1];
@@ -8202,7 +8202,7 @@ class Zn {
8202
8202
  }
8203
8203
  }
8204
8204
  function Pi(a, t, e) {
8205
- const n = e.texData.get(a.dataId), s = G(a.shape), o = a.shape[a.shape.length - 1], r = s / o, c = U({ inputs: { x: a }, backend: e, attrs: { shape: [r, o] } }), i = c.shape, l = new Zn("real", i, t), u = new Zn("imag", i, t), p = [
8205
+ const n = e.texData.get(a.dataId), s = G(a.shape), o = a.shape[a.shape.length - 1], r = s / o, c = U({ inputs: { x: a }, backend: e, attrs: { shape: [r, o] } }), i = c.shape, l = new Jn("real", i, t), u = new Jn("imag", i, t), p = [
8206
8206
  {
8207
8207
  dataId: n.complexTensorInfos.real.dataId,
8208
8208
  dtype: n.complexTensorInfos.real.dtype,
@@ -8218,14 +8218,14 @@ function Pi(a, t, e) {
8218
8218
  const m = U({ inputs: { x: f }, backend: e, attrs: { shape: a.shape } });
8219
8219
  return e.disposeIntermediateTensorInfo(c), e.disposeIntermediateTensorInfo(f), m;
8220
8220
  }
8221
- function J1(a) {
8221
+ function Z1(a) {
8222
8222
  const { inputs: t, backend: e } = a, { input: n } = t;
8223
8223
  return Pi(n, !1, e);
8224
8224
  }
8225
8225
  const e0 = {
8226
8226
  kernelName: qo,
8227
8227
  backendName: "webgl",
8228
- kernelFunc: J1
8228
+ kernelFunc: Z1
8229
8229
  };
8230
8230
  class t0 {
8231
8231
  constructor(t, e) {
@@ -8275,14 +8275,14 @@ class n0 {
8275
8275
  }
8276
8276
  }
8277
8277
  const o0 = {
8278
- kernelName: Zo,
8278
+ kernelName: Jo,
8279
8279
  backendName: "webgl",
8280
8280
  kernelFunc: ({ inputs: a, backend: t }) => {
8281
8281
  const { image: e } = a, n = t, s = new n0(e.shape);
8282
8282
  return n.runWebGLProgram(s, [e], e.dtype);
8283
8283
  }
8284
8284
  };
8285
- const Jn = "return floor(x);", a0 = se({ opSnippet: Jn, packedOpSnippet: Jn, cpuKernelImpl: Uu }), r0 = {
8285
+ const Zn = "return floor(x);", a0 = se({ opSnippet: Zn, packedOpSnippet: Zn, cpuKernelImpl: Uu }), r0 = {
8286
8286
  kernelName: yc,
8287
8287
  backendName: "webgl",
8288
8288
  kernelFunc: a0
@@ -8474,14 +8474,14 @@ function m0(a) {
8474
8474
  return C.push(g), C.forEach((v) => e.disposeIntermediateTensorInfo(v)), $;
8475
8475
  }
8476
8476
  const g0 = {
8477
- kernelName: Jo,
8477
+ kernelName: Zo,
8478
8478
  backendName: "webgl",
8479
8479
  kernelFunc: m0
8480
8480
  };
8481
8481
  function x0(a) {
8482
8482
  const { inputs: t, backend: e, attrs: n } = a, { x: s, filter: o, bias: r, preluActivationWeights: c } = t, { strides: i, pad: l, dilations: u, dimRoundingMode: p, activation: d, leakyreluAlpha: h } = n, f = [];
8483
8483
  let m = u;
8484
- m == null && (m = [1, 1]), te(Ze(i, m), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${m}'`);
8484
+ m == null && (m = [1, 1]), te(Je(i, m), () => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${m}'`);
8485
8485
  const x = Se(
8486
8486
  s.shape,
8487
8487
  o.shape,
@@ -8692,14 +8692,14 @@ const j0 = "return float(a <= b);", q0 = `
8692
8692
  backendName: "webgl",
8693
8693
  kernelFunc: Y0
8694
8694
  };
8695
- function Z0(a) {
8695
+ function J0(a) {
8696
8696
  const { backend: t, attrs: e } = a, { start: n, stop: s, num: o } = e, r = Qu(n, s, o);
8697
8697
  return t.makeTensorInfo([r.length], "float32", r);
8698
8698
  }
8699
- const J0 = {
8699
+ const Z0 = {
8700
8700
  kernelName: oa,
8701
8701
  backendName: "webgl",
8702
- kernelFunc: Z0
8702
+ kernelFunc: J0
8703
8703
  };
8704
8704
  const eI = It + `
8705
8705
  return x < 0.0 ? 0./0. : log(x);
@@ -8711,7 +8711,7 @@ const eI = It + `
8711
8711
  result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);
8712
8712
  result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);
8713
8713
  return result;
8714
- `, sI = se({ opSnippet: eI, packedOpSnippet: tI, cpuKernelImpl: Zu }), nI = {
8714
+ `, sI = se({ opSnippet: eI, packedOpSnippet: tI, cpuKernelImpl: Ju }), nI = {
8715
8715
  kernelName: Rc,
8716
8716
  backendName: "webgl",
8717
8717
  kernelFunc: sI
@@ -8940,7 +8940,7 @@ const SI = hn + `
8940
8940
  `, NI = Ce({
8941
8941
  opSnippet: SI,
8942
8942
  packedOpSnippet: wI,
8943
- cpuKernelImpl: Ju
8943
+ cpuKernelImpl: Zu
8944
8944
  }), RI = {
8945
8945
  kernelName: Tc,
8946
8946
  backendName: "webgl",
@@ -8950,7 +8950,7 @@ function TI(a) {
8950
8950
  const { inputs: t, backend: e, attrs: n } = a, { x: s } = t;
8951
8951
  At(s, "maxPool");
8952
8952
  const { filterSize: o, strides: r, pad: c, dimRoundingMode: i } = n, l = 1;
8953
- te(Ze(r, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
8953
+ te(Je(r, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${r} and dilations '${l}'`);
8954
8954
  const u = Le(s.shape, o, r, l, c, i);
8955
8955
  if (u.filterWidth === 1 && u.filterHeight === 1 && nt(u.inShape, u.outShape))
8956
8956
  return Fe({ inputs: { x: s }, backend: e });
@@ -8963,7 +8963,7 @@ const EI = {
8963
8963
  kernelFunc: TI
8964
8964
  };
8965
8965
  function DI(a) {
8966
- const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dataFormat: i, dimRoundingMode: l } = n, u = [1, 1, 1], p = Je(s.shape, o, r, u, c, l, i), d = new bn(p, "max", !1);
8966
+ const { inputs: t, backend: e, attrs: n } = a, { x: s } = t, { filterSize: o, strides: r, pad: c, dataFormat: i, dimRoundingMode: l } = n, u = [1, 1, 1], p = Ze(s.shape, o, r, u, c, l, i), d = new bn(p, "max", !1);
8967
8967
  return e.runWebGLProgram(d, [s], s.dtype);
8968
8968
  }
8969
8969
  const FI = {
@@ -9096,7 +9096,7 @@ class OI {
9096
9096
  }
9097
9097
  }
9098
9098
  function AI(a) {
9099
- const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, r = o, { filterSize: c, strides: i, pad: l, dimRoundingMode: u } = n, p = [1, 1, 1], d = Je(r.shape, c, i, p, l, u), h = new bn(
9099
+ const { inputs: t, backend: e, attrs: n } = a, { dy: s, input: o } = t, r = o, { filterSize: c, strides: i, pad: l, dimRoundingMode: u } = n, p = [1, 1, 1], d = Ze(r.shape, c, i, p, l, u), h = new bn(
9100
9100
  d,
9101
9101
  "max",
9102
9102
  !0
@@ -9134,7 +9134,7 @@ const MI = {
9134
9134
  const { x: n } = a, { filterSize: s, strides: o, pad: r, includeBatchInIndex: c } = t, i = e;
9135
9135
  te(n.shape.length === 4, () => `Error in maxPool: input must be rank 4 but got rank ${n.shape.length}.`);
9136
9136
  const l = [1, 1];
9137
- te(Ze(o, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);
9137
+ te(Je(o, l), () => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '${l}'`);
9138
9138
  const u = Le(n.shape, s, o, l, r), [p, d] = WI(n, c, u, i);
9139
9139
  return [p, d];
9140
9140
  }
@@ -9332,19 +9332,19 @@ class YI {
9332
9332
  const QI = ({ inputs: a, backend: t, attrs: e }) => {
9333
9333
  const { x: n } = a, { paddings: s, mode: o } = e, r = _().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new YI(n.shape, s, o) : new qI(n.shape, s, o);
9334
9334
  return t.runWebGLProgram(r, [n], n.dtype);
9335
- }, ZI = {
9335
+ }, JI = {
9336
9336
  kernelName: fa,
9337
9337
  backendName: "webgl",
9338
9338
  kernelFunc: QI
9339
9339
  };
9340
- const JI = `if (b == 0.0) return NAN;
9340
+ const ZI = `if (b == 0.0) return NAN;
9341
9341
  return mod(a, b);`, ey = `
9342
9342
  vec4 result = mod(a, b);
9343
9343
  bvec4 isNaN = equal(b, vec4(0.0));
9344
9344
  ` + it + `
9345
9345
  return result;
9346
9346
  `, ty = Ce({
9347
- opSnippet: JI,
9347
+ opSnippet: ZI,
9348
9348
  packedOpSnippet: ey
9349
9349
  }), sy = {
9350
9350
  kernelName: js,
@@ -9767,7 +9767,7 @@ const Ky = We + `
9767
9767
  };
9768
9768
  const Qy = We + `
9769
9769
  return (x < 0.0) ? 0.0 : min(6.0, x);
9770
- `, Zy = `
9770
+ `, Jy = `
9771
9771
  vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));
9772
9772
  bvec4 isNaN = isnan(x);
9773
9773
 
@@ -9777,10 +9777,10 @@ const Qy = We + `
9777
9777
  result.a = isNaN.a ? x.a : result.a;
9778
9778
 
9779
9779
  return result;
9780
- `, Jy = se({ opSnippet: Qy, packedOpSnippet: Zy }), ek = {
9780
+ `, Zy = se({ opSnippet: Qy, packedOpSnippet: Jy }), ek = {
9781
9781
  kernelName: Rs,
9782
9782
  backendName: "webgl",
9783
- kernelFunc: Jy
9783
+ kernelFunc: Zy
9784
9784
  };
9785
9785
  class tk {
9786
9786
  constructor(t, e, n, s, o) {
@@ -10576,7 +10576,7 @@ const _k = `
10576
10576
  float scale = ${Ar};
10577
10577
  return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);
10578
10578
  `, Lk = se({ opSnippet: _k }), Vk = {
10579
- kernelName: Zs,
10579
+ kernelName: Js,
10580
10580
  backendName: "webgl",
10581
10581
  kernelFunc: Lk
10582
10582
  };
@@ -10605,7 +10605,7 @@ const zk = `
10605
10605
  if (isnan(x)) { return 0.0; }
10606
10606
  return sign(x);
10607
10607
  `, Uk = se({ opSnippet: zk }), Hk = {
10608
- kernelName: Js,
10608
+ kernelName: Zs,
10609
10609
  backendName: "webgl",
10610
10610
  kernelFunc: Uk
10611
10611
  };
@@ -10624,12 +10624,12 @@ const Xk = It + `
10624
10624
  const Yk = `
10625
10625
  float e2x = exp(x);
10626
10626
  return (e2x - 1.0 / e2x) / 2.0;
10627
- `, Qk = se({ opSnippet: Yk }), Zk = {
10627
+ `, Qk = se({ opSnippet: Yk }), Jk = {
10628
10628
  kernelName: tn,
10629
10629
  backendName: "webgl",
10630
10630
  kernelFunc: Qk
10631
10631
  };
10632
- const Jk = `
10632
+ const Zk = `
10633
10633
  float epsilon = 1.1920928955078125e-7;
10634
10634
  float threshold = log(epsilon) + 2.0;
10635
10635
 
@@ -10649,7 +10649,7 @@ const Jk = `
10649
10649
  result = log(exp_x + 1.0);
10650
10650
  }
10651
10651
  return result;
10652
- `, e$ = se({ opSnippet: Jk }), t$ = {
10652
+ `, e$ = se({ opSnippet: Zk }), t$ = {
10653
10653
  kernelName: sn,
10654
10654
  backendName: "webgl",
10655
10655
  kernelFunc: e$
@@ -10978,7 +10978,7 @@ function Mi(a) {
10978
10978
  return e.runWebGLProgram(r, [s], s.dtype);
10979
10979
  }
10980
10980
  const X$ = {
10981
- kernelName: Za,
10981
+ kernelName: Ja,
10982
10982
  backendName: "webgl",
10983
10983
  kernelFunc: Mi
10984
10984
  };
@@ -11141,7 +11141,7 @@ function q$(a) {
11141
11141
  return $ = U({ inputs: { x: $ }, attrs: { shape: v }, backend: e }), tt(e, w), [$, I];
11142
11142
  }
11143
11143
  const Y$ = {
11144
- kernelName: Ja,
11144
+ kernelName: Za,
11145
11145
  backendName: "webgl",
11146
11146
  kernelFunc: q$
11147
11147
  };
@@ -11282,7 +11282,7 @@ class Q$ {
11282
11282
  `;
11283
11283
  }
11284
11284
  }
11285
- function Z$(a) {
11285
+ function J$(a) {
11286
11286
  const { inputs: t, backend: e, attrs: n } = a, { image: s, transforms: o } = t, { interpolation: r, fillMode: c, fillValue: i, outputShape: l } = n, [u, p, d, h] = s.shape, [f, m] = l ?? [p, d], x = [
11287
11287
  u,
11288
11288
  f,
@@ -11291,10 +11291,10 @@ function Z$(a) {
11291
11291
  ], g = new Q$(p, d, r, c, i, x);
11292
11292
  return e.runWebGLProgram(g, [s, o], "float32");
11293
11293
  }
11294
- const J$ = {
11294
+ const Z$ = {
11295
11295
  kernelName: er,
11296
11296
  backendName: "webgl",
11297
- kernelFunc: Z$
11297
+ kernelFunc: J$
11298
11298
  };
11299
11299
  function ev(a) {
11300
11300
  const { inputs: t, attrs: e, backend: n } = a, { axis: s } = e, { x: o } = t;
@@ -11460,7 +11460,7 @@ function av(a) {
11460
11460
  const d = Ql(p.shape, l, r), h = G([p.shape[l]]), f = U({ inputs: { x: p }, backend: e, attrs: { shape: [-1, h] } });
11461
11461
  i.push(f);
11462
11462
  const m = cr(s.dtype), x = (b, y, k, $, v) => {
11463
- const w = b.shape[0], S = b.shape[1], R = Zl(S, v), P = { windowSize: R, inSize: S, batchSize: w, numSegments: v }, D = new ov(P, y), F = e.compileAndRun(D, [b, k], $);
11463
+ const w = b.shape[0], S = b.shape[1], R = Jl(S, v), P = { windowSize: R, inSize: S, batchSize: w, numSegments: v }, D = new ov(P, y), F = e.compileAndRun(D, [b, k], $);
11464
11464
  if (i.push(F), F.shape[1] === v)
11465
11465
  return F;
11466
11466
  const T = Wi({
@@ -11543,7 +11543,7 @@ const iv = [
11543
11543
  X1,
11544
11544
  q1,
11545
11545
  Y1,
11546
- Z1,
11546
+ J1,
11547
11547
  e0,
11548
11548
  s0,
11549
11549
  o0,
@@ -11565,7 +11565,7 @@ const iv = [
11565
11565
  Sd,
11566
11566
  K0,
11567
11567
  Q0,
11568
- J0,
11568
+ Z0,
11569
11569
  nI,
11570
11570
  rI,
11571
11571
  uI,
@@ -11583,7 +11583,7 @@ const iv = [
11583
11583
  GI,
11584
11584
  UI,
11585
11585
  jI,
11586
- ZI,
11586
+ JI,
11587
11587
  sy,
11588
11588
  iy,
11589
11589
  Xx,
@@ -11624,7 +11624,7 @@ const iv = [
11624
11624
  Gk,
11625
11625
  Hk,
11626
11626
  qk,
11627
- Zk,
11627
+ Jk,
11628
11628
  tb,
11629
11629
  ay,
11630
11630
  t$,
@@ -11651,7 +11651,7 @@ const iv = [
11651
11651
  z$,
11652
11652
  X$,
11653
11653
  Y$,
11654
- J$,
11654
+ Z$,
11655
11655
  Kx,
11656
11656
  tv,
11657
11657
  nv,
@@ -11695,6 +11695,8 @@ class AS extends Ui {
11695
11695
  tokens = [];
11696
11696
  lastLoss = null;
11697
11697
  lastMultinomialRand = null;
11698
+ jobQueue = [];
11699
+ processingJob = !1;
11698
11700
  async tokenisePrompt(t, e, n) {
11699
11701
  if (e) {
11700
11702
  const s = e.length > 0 && e[e.length - 1].role === "assistant";
@@ -11856,7 +11858,7 @@ class AS extends Ui {
11856
11858
  this.cache = s, this.lastToken = -1;
11857
11859
  }
11858
11860
  const n = this.tokeniser.trained ? this.tokeniser : new Ad(uv(lv, this.tokeniser.vocabSize));
11859
- this.actualTokeniser = n;
11861
+ this.actualTokeniser = n, e?.loraName ? this.model.attachLoRA(e.loraName) : this.model.hasLoRA() && this.model.detachLoRA();
11860
11862
  }
11861
11863
  async step(t, e) {
11862
11864
  const n = { ...e, maxLength: 1 };
@@ -11864,9 +11866,32 @@ class AS extends Ui {
11864
11866
  }
11865
11867
  async generate(t, e) {
11866
11868
  let n;
11867
- Array.isArray(t) ? n = t : typeof t == "object" && (e = t), this.initialise(n, e), this.active = !0, e?.maxLength !== 1 && this.emit("start");
11868
- const o = await this._generate(e);
11869
- return this.active = !1, this.emit("stop"), o;
11869
+ if (Array.isArray(t) ? n = t : typeof t == "object" && (e = t), this.processingJob) {
11870
+ if (this.jobQueue.length > 10)
11871
+ throw new Error("Job queue is too long, rejecting new job");
11872
+ return new Promise((s, o) => {
11873
+ this.jobQueue.push({ prompt: n, options: e, resolve: s, reject: o });
11874
+ });
11875
+ }
11876
+ this.processingJob = !0;
11877
+ try {
11878
+ const s = await this.startJob(n, e);
11879
+ if (this.processingJob = !1, this.jobQueue.length > 0) {
11880
+ const o = this.jobQueue.shift();
11881
+ this.generate(o.prompt || [], o.options).then(o.resolve).catch(o.reject);
11882
+ }
11883
+ return s;
11884
+ } catch (s) {
11885
+ throw this.processingJob = !1, s;
11886
+ }
11887
+ }
11888
+ async startJob(t, e) {
11889
+ this.initialise(t, e), this.active = !0, e?.maxLength !== 1 && this.emit("start");
11890
+ const s = await this._generate(e);
11891
+ return this.active = !1, this.emit("stop"), s;
11892
+ }
11893
+ getQueueLength() {
11894
+ return this.jobQueue.length;
11870
11895
  }
11871
11896
  stop() {
11872
11897
  this.active = !1;