UNPKG

mind-ar

Version:

web augmented reality framework

1,030 lines 366 kB
import { Matrix4 as xe, Vector3 as Ne, Quaternion as qt, Scene as kt, WebGLRenderer as oi, sRGBEncoding as ui, PerspectiveCamera as li, Group as $t } from "three"; import { I as pi, g as Ut, c as Gt, b as Dt, e as z, d as mi, f as Kt, h as ci, i as di, j as hi, k as fi, l as yi, m as Jt, n as gi, o as Qt, p as bi, q as Ni, r as wi, s as Ti, t as Si, u as vi, v as Oi, w as _i, x as Ai, y as w, z as y, A as N, B as we, D as Y, E as Qe, F as B, G as O, H as ue, J as le, K as X, L as It, M as de, N as Ei, O as Xt, P as ce, Q as G, R as q, S as M, T as ie, U as Te, V as Zt, W as Yt, X as Mt, Y as es, Z as ts, _ as v, $ as pe, a0 as ss, a1 as as, a2 as me, a3 as Z, a4 as Ct, a5 as rs, a6 as te, a7 as ns, a8 as is, a9 as ki, aa as Xe, ab as Ze, ac as se, ad as ze, ae as Ye, af as Me, ag as os, ah as us, ai as et, aj as tt, ak as $i, al as V, am as oe, an as st, ao as at, ap as Di, aq as ls, ar as ps, as as ms, at as Ii, au as U, av as Ci, aw as rt, ax as xi, ay as zi, az as Li, aA as Fi, aB as Pi, aC as Vi, aD as Le, aE as Fe, aF as Ri, aG as ji, aH as Bi, aI as Hi, aJ as Wi, aK as qi, aL as Ui, aM as Gi, aN as Ki, aO as Ji, aP as Qi, aQ as Xi, aR as Zi, aS as Yi, aT as Mi, aU as eo, aV as to, aW as so, aX as ao, aY as ro, aZ as no, a_ as io, a$ as oo, b0 as uo, b1 as lo, b2 as po, b3 as mo, b4 as co, b5 as ho, b6 as nt, b7 as cs, b8 as fo, b9 as yo, ba as go, bb as bo, bc as No, bd as wo, be as To, bf as So, bg as vo, bh as Oo, bi as _o, bj as Ao, bk as Eo, bl as ko, bm as $o, bn as Do, bo as Io, bp as Co, bq as xo, br as zo, bs as Lo, bt as Fo, bu as Po, bv as Vo, bw as Ro, bx as jo, by as Bo, bz as Ho, bA as Wo, bB as qo, bC as Uo, bD as Go, bE as Ko, bF as Jo, bG as Qo, bH as Xo, bI as Zo, bJ as Yo, bK as Mo, bL as eu, bM as tu, bN as su, bO as au, bP as ru, bQ as nu, bR as iu, bS as ou, bT as uu, bU as lu, bV as pu, bW as mu, bX as cu, bY as du, bZ as hu, b_ as fu, b$ as yu, c0 as it, c1 as gu, c2 as bu, c3 as Nu, c4 as wu, c5 as Tu, c6 as Su, c7 as vu, c8 as Ou, c9 as _u, ca as Au, cb as Eu, cc as ku, cd as $u, ce as Du, cf as Iu, cg as Cu, ch as xu, ci as zu, cj as Lu, ck as ot, cl as ut, cm as Fu, cn as Pu, co as Vu, cp as Ru, cq as ju, cr as Bu, cs as Hu, ct as Wu, cu as lt, cv as F, cw as ds, cx as hs, cy as fs, cz as ys, cA as gs, cB as bs, cC as Ns, cD as ws, cE as Ts, cF as Ss, cG as vs, cH as Os, cI as _s, cJ as As, cK as Es, cL as ks, cM as $s, cN as Ds, cO as Is, cP as Cs, cQ as xs, cR as zs, cS as Ls, cT as Fs, cU as Ps, cV as Vs, cW as Rs, cX as js, cY as Bs, cZ as Hs, c_ as Ws, c$ as qs, d0 as Us, d1 as Gs, d2 as Ks, d3 as Js, d4 as Qs, d5 as Xs, d6 as Zs, d7 as Ys, d8 as Ms, d9 as ea, da as ta, db as sa, dc as aa, dd as ra, de as na, df as ia, dg as oa, dh as ua, di as pt, dj as la, dk as pa, dl as ma, dm as ca, dn as da, dp as ha, dq as fa, dr as ya, ds as ga, dt as ba, du as mt, dv as Na, dw as wa, dx as Ta, dy as Sa, dz as va, dA as Oa, dB as _a, dC as Aa, dD as Ea, dE as ka, dF as $a, dG as Da, dH as Ia, dI as Ca, dJ as xa, dK as za, dL as La, dM as Fa, dN as Pa, dO as Va, dP as Ra, dQ as ja, dR as Ba, dS as Ha, dT as Wa, dU as qa, dV as Ua, dW as Ga, dX as Ka, dY as Ja, dZ as Qa, d_ as Xa, d$ as Za, e0 as Ya, e1 as Ma, e2 as er, e3 as tr, e4 as sr, e5 as ar, e6 as rr, e7 as nr, e8 as ir, e9 as or, ea as ur, eb as lr, ec as pr, ed as mr, ee as cr, ef as dr, eg as hr, eh as fr, ei as yr, ej as gr, ek as br, el as Nr, em as wr, en as Tr, eo as Sr, ep as vr, eq as Or, er as _r, es as Ar, et as Er, eu as kr, ev as $r, ew as ee, ex as Dr, ey as Ir, ez as Cr, eA as xr, eB as zr, eC as ct, eD as Se, eE as Lr, eF as Fr, eG as Pr, eH as Vr, eI as Rr, eJ as jr, eK as ae, eL as Br, eM as Hr, eN as Wr, eO as qr, eP as H, eQ as C, eR as ve, eS as dt, eT as Ee, eU as qu, eV as Ur, eW as Uu, eX as Gr, eY as Kr, eZ as Gu, e_ as Ku, e$ as Jr, f0 as Ju, f1 as Qu, f2 as Xu, f3 as Zu, f4 as Yu, f5 as Mu, f6 as el, f7 as tl, f8 as sl, f9 as al, fa as rl, fb as nl, fc as il, fd as ol, fe as ul, ff as ll, fg as pl, fh as ml, fi as cl, fj as dl, fk as hl, fl, fm as yl, fn as gl, fo as bl, fp as Nl, fq as wl, fr as Tl, fs as Sl, ft as vl, fu as Ol, fv as _l, fw as Al, fx as El, fy as kl, fz as $l, fA as Dl, fB as Il, fC as Cl, fD as xl, fE as zl, fF as Ll, fG as Fl, fH as Pl, fI as Vl, fJ as Rl, fK as jl, fL as Bl, fM as Hl, fN as Wl, fO as ql, fP as Ul, fQ as Gl, fR as Kl, fS as Jl, fT as Ql, fU as Xl, fV as Zl, fW as Yl, fX as Ml, fY as ep, fZ as tp, f_ as sp, f$ as ap, g0 as rp, g1 as np, g2 as ip, g3 as op, g4 as up, g5 as lp, g6 as pp, g7 as mp, g8 as cp, g9 as dp, ga as hp, gb as fp, gc as yp, gd as gp, ge as bp, gf as Np, gg as wp, gh as Tp, gi as Sp, gj as vp, gk as Op, gl as _p, gm as Ap, gn as Ep, go as kp, gp as $p, gq as Dp, gr as Ip, gs as Cp, gt as xp, gu as zp, gv as Lp, gw as Fp, gx as Pp, gy as Vp, gz as Rp, gA as jp, gB as Bp, gC as Hp, gD as Wp, gE as qp, gF as Up, gG as Gp, gH as Kp, gI as Jp, gJ as Qp, gK as Xp, gL as Zp, gM as Yp, gN as Mp, gO as em, gP as tm, gQ as sm, gR as am, gS as rm, gT as nm, gU as im, gV as om, gW as um, gX as lm, gY as pm, gZ as mm, g_ as cm, g$ as dm, h0 as hm, h1 as fm, h2 as ym, h3 as gm, h4 as bm, h5 as Nm, h6 as wm, h7 as Tm, h8 as Sm, h9 as vm, ha as Om, hb as _m, hc as Am, hd as Em, he as km, hf as $m, hg as Dm, hh as Im, hi as Cm, hj as xm, hk as zm, hl as Lm, hm as Fm, hn as Pm, ho as Vm, hp as Rm, hq as jm, hr as Bm, hs as Hm, ht as Wm, hu as qm, hv as Um, hw as Gm, hx as Km, hy as Jm, hz as Qm, hA as Xm, hB as Zm, hC as Ym, hD as Mm, hE as ec, hF as tc, hG as sc, hH as ac, hI as rc, hJ as nc, hK as ic, hL as oc, hM as uc, hN as lc, hO as pc, hP as mc, hQ as cc, hR as dc, hS as hc, hT as fc, hU as yc, hV as gc, hW as bc, hX as Nc, hY as wc, hZ as Tc, h_ as Sc, h$ as vc, i0 as Oc, i1 as _c, i2 as Ac, i3 as Ec, i4 as kc, i5 as $c, i6 as Dc, i7 as Ic, i8 as Cc, i9 as xc, ia as zc, ib as Lc, ic as Fc, id as Pc, ie as Vc, ig as Rc, ih as jc, ii as Bc, ij as Hc, ik as Wc, il as qc, im as Uc, io as Gc, ip as Kc, iq as Jc, ir as Qc, is as Xc, it as Zc, iu as Yc, iv as Mc, iw as ed, ix as td, iy as sd, iz as ad, iA as rd, C as nd } from "./controller-939e6d85.js"; import { CSS3DRenderer as id } from "three/addons/renderers/CSS3DRenderer.js"; import { U as od } from "./ui-56ede774.js"; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const ud = "model", ld = ".json", pd = ".weights.bin"; function xt(s) { return new Promise((e) => setTimeout(e)).then(s); } class K { constructor(e) { if (!z().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(K.URL_SCHEME) && (e = e.slice(K.URL_SCHEME.length)), (e == null || e.length === 0) && (e = ud), this.modelJsonFileName = e + ld, this.weightDataFileName = e + pd; } async save(e) { if (typeof document > "u") throw new Error("Browser downloads are not supported in this environment since `document` is not present"); const t = window.URL.createObjectURL(new Blob([e.weightData], { type: "application/octet-stream" })); if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserDownloads.save() does not support saving model topology in binary formats yet."); { const a = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], r = mi(e, a), n = window.URL.createObjectURL(new Blob([JSON.stringify(r)], { type: "application/json" })), o = this.modelJsonAnchor == null ? document.createElement("a") : this.modelJsonAnchor; if (o.download = this.modelJsonFileName, o.href = n, await xt(() => o.dispatchEvent(new MouseEvent("click"))), e.weightData != null) { const u = this.weightDataAnchor == null ? document.createElement("a") : this.weightDataAnchor; u.download = this.weightDataFileName, u.href = t, await xt(() => u.dispatchEvent(new MouseEvent("click"))); } return { modelArtifactsInfo: Kt(e) }; } } } K.URL_SCHEME = "downloads://"; class md { constructor(e) { if (e == null || e.length < 1) throw new Error(`When calling browserFiles, at least 1 file is required, but received ${e}`); this.jsonFile = e[0], this.weightsFiles = e.slice(1); } async load() { return new Promise((e, t) => { const a = new FileReader(); a.onload = (r) => { const n = JSON.parse(r.target.result), o = n.modelTopology; if (o == null) { t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); return; } if (n.weightsManifest == null) { t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`)); return; } if (this.weightsFiles.length === 0) { e({ modelTopology: o }); return; } const l = Ut(n, (m) => this.loadWeights(m)); e(l); }, a.onerror = (r) => t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), a.readAsText(this.jsonFile); }); } loadWeights(e) { const t = [], a = []; for (const o of e) t.push(...o.weights), a.push(...o.paths); const r = this.checkManifestAndWeightFiles(e), n = a.map((o) => this.loadWeightsFile(o, r[o])); return Promise.all(n).then((o) => [t, Gt(o)]); } loadWeightsFile(e, t) { return new Promise((a, r) => { const n = new FileReader(); n.onload = (o) => { const u = o.target.result; a(u); }, n.onerror = (o) => r(`Failed to weights data from file of path '${e}'.`), n.readAsArrayBuffer(t); }); } /** * Check the compatibility between weights manifest and weight files. */ checkManifestAndWeightFiles(e) { const t = [], a = this.weightsFiles.map((n) => Dt(n.name)), r = {}; for (const n of e) n.paths.forEach((o) => { const u = Dt(o); if (t.indexOf(u) !== -1) throw new Error(`Duplicate file basename found in weights manifest: '${u}'`); if (t.push(u), a.indexOf(u) === -1) throw new Error(`Weight file with basename '${u}' is not provided.`); r[o] = this.weightsFiles[a.indexOf(u)]; }); if (t.length !== this.weightsFiles.length) throw new Error(`Mismatch in the number of files in weights manifest (${t.length}) and the number of weight files provided (${this.weightsFiles.length}).`); return r; } } const cd = (s) => z().getBool("IS_BROWSER") && !Array.isArray(s) && s.startsWith(K.URL_SCHEME) ? dd(s.slice(K.URL_SCHEME.length)) : null; pi.registerSaveRouter(cd); function dd(s = "model") { return new K(s); } function hd(s) { return new md(s); } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ class De { constructor(e) { this.modelArtifacts = e; } load() { return this.modelArtifacts; } } class Qr { constructor(e) { this.saveHandler = e; } save(e) { return this.saveHandler(e); } } class fd { constructor(e) { e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = (t) => Promise.resolve(e.save(t))); } } function yd(s, e, t, a) { const r = arguments; return new fd(Oe(...r)); } function Oe(s, e, t, a) { return arguments.length === 1 ? s.modelTopology != null || s.weightSpecs != null ? new De(s) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new De({ modelTopology: s })) : (console.warn("Please call tf.io.fromMemory() with only one argument. The argument should be of type ModelArtifacts. The multi-argument signature of tf.io.fromMemory() has been deprecated and will be removed in a future release."), new De({ modelTopology: s, weightSpecs: e, weightData: t, trainingConfig: a })); } function gd(s) { return new Qr(s); } function bd(s) { return new Qr(s); } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, browserFiles: hd, browserHTTPRequest: ci, concatenateArrayBuffers: Gt, copyModel: di, decodeWeights: hi, encodeWeights: fi, fromMemory: yd, fromMemorySync: Oe, getLoadHandlers: yi, getModelArtifactsForJSON: Ut, getModelArtifactsForJSONSync: Jt, getModelArtifactsInfoForJSON: Kt, getSaveHandlers: gi, getWeightSpecs: Qt, http: bi, isHTTPScheme: Ni, listModels: wi, loadWeights: Ti, moveModel: Si, registerLoadRouter: vi, registerSaveRouter: Oi, removeModel: _i, weightsLoaderFactory: Ai, withSaveHandler: gd, withSaveHandlerSync: bd }, Symbol.toStringTag, { value: "Module" })); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Nd(s, e, t) { const a = y(s, "labels", "confusionMatrix"), r = y(e, "predictions", "confusionMatrix"); N(t == null || t > 0 && Number.isInteger(t), () => `If provided, numClasses must be a positive integer, but got ${t}`), N(a.rank === 1, () => `Expected the rank of labels to be 1, but got ${a.rank}`), N(r.rank === 1, () => `Expected the rank of predictions to be 1, but got ${r.rank}`), N(a.shape[0] === r.shape[0], () => `Mismatch in the number of examples: ${a.shape[0]} vs. ${r.shape[0]}. Labels and predictions should have the same number of elements.`), N(t > 0 && Number.isInteger(t), () => `numClasses is required to be a positive integer, but got ${t}`); const n = we(Y(a, "int32"), t), o = we(Y(r, "int32"), t), u = Qe(n), l = B(u, o); return Y(l, "int32"); } const wd = w({ confusionMatrix_: Nd }); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Td = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, confusionMatrix: wd }, Symbol.toStringTag, { value: "Module" })); /** * @license * Copyright 2017 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const Sd = 1e-3, Xr = 0.1; function vd(s, e, t) { return t == null && (t = ft()), Pe(s, e, (a, r) => yt(a, r, t)); } function ft() { return O.backend.floatPrecision() === 32 ? Sd : Xr; } function Pe(s, e, t) { let a = !0; if ((X(s) || X(e)) && (a = !1), X(s) && X(e) && (a = !0), a) { const o = s.constructor.name, u = e.constructor.name; if (o !== u) throw new Error(`Arrays are of different type. Actual: ${o}. Expected: ${u}`); } if (Array.isArray(s) && Array.isArray(e)) { const o = ue(s), u = ue(e); if (!le(o, u)) throw new Error(`Arrays have different shapes. Actual: [${o}]. Expected: [${u}]`); } const r = X(s) ? s : It(s), n = X(e) ? e : It(e); if (r.length !== n.length) throw new Error(`Arrays have different lengths actual: ${r.length} vs expected: ${n.length}. Actual: ${r}. Expected: ${n}.`); for (let o = 0; o < n.length; ++o) { const u = r[o], l = n[o]; if (!t(u, l)) throw new Error(`Arrays differ: actual[${o}] = ${u}, expected[${o}] = ${l}. Actual: ${r}. Expected: ${n}.`); } typeof expect < "u" && expect().nothing(); } function Od(s, e) { s().then(() => e.fail(), () => e()), typeof expect < "u" && expect().nothing(); } function _d(s, e) { const t = typeof e == "string" || typeof e == "number" || typeof e == "boolean" ? [e] : e; return de(s) || de(s[0]) || de(e) || de(e[0]) ? Pe(s, t, (a, r) => a == r) : Pe(s, e, (a, r) => yt(a, r, 0)); } function Ad(s, e, t) { if (t == null && (t = ft()), !yt(s, e, t)) throw new Error(`Numbers differ: actual === ${s}, expected === ${e}`); typeof expect < "u" && expect().nothing(); } function yt(s, e, t) { return !isFinite(s) && !isFinite(e) ? !0 : !(isNaN(s) || isNaN(e) || Math.abs(s - e) > t); } function Ed(s, e, t) { for (let a = 0; a < s.length; a++) if (s[a] < e || s[a] > t) throw new Error(`Value out of range:${s[a]} low: ${e}, high: ${t}`); } function kd(s, e) { const t = new Float32Array(s), a = new Float32Array(e); if (t.length !== a.length) throw new Error(`Expected ArrayBuffer to be of length ${a.length}, but it was ${t.length}`); for (let r = 0; r < a.length; r++) if (t[r] !== a[r]) throw new Error(`Expected ArrayBuffer value at ${r} to be ${a[r]} but got ${t[r]} instead`); } function Zr(s) { for (let e = 0; e < s.length; e++) { const t = s[e]; Array.isArray(t) ? Zr(t) : s[e] = Ei(t); } return s; } function $d(s) { const e = document.createElement("video"); return "playsInline" in e && (e.playsInline = !0), e.muted = !0, e.loop = !0, e.style.position = "fixed", e.style.left = "0px", e.style.top = "0px", e.preload = "auto", e.appendChild(s), new Promise((t) => { e.addEventListener("loadeddata", (a) => t(e)), e.load(); }); } async function Dd(s) { await s.play(), "requestVideoFrameCallback" in s && await new Promise((e) => { s.requestVideoFrameCallback(e); }); } const Id = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, TEST_EPSILON_FLOAT16: Xr, createVideoElement: $d, encodeStrings: Zr, expectArrayBuffersEqual: kd, expectArraysClose: vd, expectArraysEqual: _d, expectNumbersClose: Ad, expectPromiseToFail: Od, expectValuesInRange: Ed, play: Dd, testEpsilon: ft }, Symbol.toStringTag, { value: "Module" })); /** @license See the LICENSE file. */ const Yr = "3.21.0"; /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Cd(s) { N(Array.isArray(s), () => "The argument passed to tf.addN() must be a list of tensors"), N(s.length >= 1, () => `Must pass at least one tensor to tf.addN(), but got ${s.length}`); const e = s.map((r, n) => y(r, `tensors${n}`, "addN")), t = e[0]; e.forEach((r) => { if (r.dtype !== t.dtype) throw new Error("All tensors passed to tf.addN() must have the same dtype"); }), e.forEach((r) => { if (!le(r.shape, t.shape)) throw new Error("All tensors passed to tf.addN() must have the same shape"); }); const a = e; return O.runKernel(Xt, a); } const Mr = w({ addN_: Cd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function xd(s, e, t, a, r, n) { const o = y(s, "forgetBias", "basicLSTMCell"), u = y(e, "lstmKernel", "basicLSTMCell"), l = y(t, "lstmBias", "basicLSTMCell"), m = y(a, "data", "basicLSTMCell"), p = y(r, "c", "basicLSTMCell"), c = y(n, "h", "basicLSTMCell"), d = ce([m, c], 1), h = B(d, u), b = G(h, l), f = b.shape[0], g = b.shape[1] / 4, S = [f, g], k = q(b, [0, 0], S), T = q(b, [0, g], S), W = q(b, [0, g * 2], S), A = q(b, [0, g * 3], S), $ = G(M(ie(k), Te(T)), M(p, ie(G(o, W)))), L = M(Te($), ie(A)); return [$, L]; } const en = w({ basicLSTMCell_: xd }); /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function zd(s, e) { const t = y(s, "s0", "broadcastArgs", "int32"), a = y(e, "s1", "broadcastArgs", "int32"); if (t.rank !== 1) throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${t.rank}`); if (a.rank !== 1) throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${a.rank}`); const r = { s0: t, s1: a }; return O.runKernel(Zt, r); } const tn = w({ broadcastArgs_: zd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Ld(s, e, t, a = !1) { const r = y(s, "x", "denseBincount"), n = y(e, "weights", "denseBincount"); N(r.dtype === "int32", () => `Error in denseBincount: input dtype must be int32, but got ${r.dtype}`), N(r.rank <= 2, () => `Error in denseBincount: input must be at most rank 2, but got rank ${r.rank}.`), N(t >= 0, () => `size must be non-negative, but got ${t}.`), N(n.size === r.size || n.size === 0, () => `Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${r.shape}, weights shape: ${n.shape}.`); const o = { x: r, weights: n }, u = { size: t, binaryOutput: a }; return O.runKernel(Yt, o, u); } const sn = w({ denseBincount_: Ld }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Fd(s) { const t = { x: y(s, "x", "diag") }; return O.runKernel(Mt, t); } const an = w({ diag_: Fd }); /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Pd(s, ...e) { const t = e.map((r, n) => y(r, `tensors${n}`, "einsum")), a = { equation: s }; return O.runKernel(es, t, a); } const rn = w({ einsum_: Pd }); /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function nn(s, e, t) { if (t <= 0) throw new Error("The number of values should be positive."); const a = { start: s, stop: e, num: t }; return O.runKernel(ts, {}, a); } /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ const he = 2147483648; function Vd(s, e, t = "left") { const a = y(s, "sortedSequence", "searchSorted"), r = y(e, "values", "searchSorted"), n = a.shape[a.shape.length - 1], o = r.shape[r.shape.length - 1], u = v(a, [-1, n]), l = v(r, [-1, o]); if (u.rank < 2) throw new Error("Sorted input argument must be at least 2-dimensional"); if (u.shape[0] !== l.shape[0]) throw new Error("Leading dimension of 'sortedSequence' and 'values' must match."); if (pe(l.shape) >= he) throw new Error(`values tensor size must less than ${he}`); if (u.shape[1] >= he) throw new Error(`trailing dim_size must less than ${he} for int32 output type, was ${u.shape[1]}`); const m = { sortedSequence: u, values: l }, p = { side: t }; return O.runKernel(ss, m, p); } const ke = w({ searchSorted_: Vd }); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function on(s, e) { return ke(s, e, "left"); } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Rd(s, e, t, a, r = !1) { const o = { x: y(s, "x", "maxPoolWithArgmax") }, u = { filterSize: e, strides: t, pad: a, includeBatchInIndex: r }, l = O.runKernel(as, o, u); return { result: l[0], indexes: l[1] }; } const un = w({ maxPoolWithArgmax_: Rd }); /** * @license * Copyright 2021 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function ln(s, e, { indexing: t = "xy" } = {}) { if (t !== "xy" && t !== "ij") throw new TypeError(`${t} is not a valid third argument to meshgrid`); if (s === void 0) return []; let a = y(s, "x", "meshgrid", s instanceof me ? s.dtype : "float32"); if (e === void 0) return [a]; let r = y(e, "y", "meshgrid", e instanceof me ? e.dtype : "float32"); const n = pe(a.shape), o = pe(r.shape); return t === "xy" ? (a = v(a, [1, -1]), r = v(r, [-1, 1]), [ B(Z([o, 1], a.dtype), a), B(r, Z([1, n], r.dtype)) ]) : (a = v(a, [-1, 1]), r = v(r, [1, -1]), [ B(a, Z([1, o], a.dtype)), B(Z([n, 1], r.dtype), r) ]); } function jd(s, e, t, a) { const r = y(e, "data", "multiRNNCell"), n = Ct(t, "c", "multiRNNCell"), o = Ct(a, "h", "multiRNNCell"); let u = r; const l = []; for (let c = 0; c < s.length; c++) { const d = s[c](u, n[c], o[c]); l.push(d[0]), l.push(d[1]), u = d[1]; } const m = [], p = []; for (let c = 0; c < l.length; c += 2) m.push(l[c]), p.push(l[c + 1]); return [m, p]; } const pn = w({ multiRNNCell_: jd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Bd(s, e, t, a = !1) { const r = y(s, "logits", "multinomial"), n = r.size, o = r.rank; if (n < 2) throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${n}.`); if (o > 2) throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`); t = t || Math.random(); const l = { logits: o === 1 ? v(r, [1, -1]) : r }, m = { numSamples: e, seed: t, normalized: a }, p = O.runKernel(rs, l, m); return o === 1 ? v(p, [p.size]) : p; } const mn = w({ multinomial_: Bd }); function Hd(s, e) { const t = y(s, "v1", "outerProduct"), a = y(e, "v2", "outerProduct"); N(t.rank === 1 && a.rank === 1, () => `Error in outerProduct: inputs must be rank 1, but got ranks ${t.rank} and ${a.rank}.`); const r = v(t, [-1, 1]), n = v(a, [1, -1]); return B(r, n); } const cn = w({ outerProduct_: Hd }); function Wd(s, e, t = 0) { return N(e.length === 2, () => "Invalid number of paddings. Must be length of 2."), te(s, [e], t); } const dn = w({ pad1d_: Wd }); function qd(s, e, t = 0) { return N(e.length === 2 && e[0].length === 2 && e[1].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), te(s, e, t); } const hn = w({ pad2d_: qd }); function Ud(s, e, t = 0) { return N(e.length === 3 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), te(s, e, t); } const fn = w({ pad3d_: Ud }); function Gd(s, e, t = 0) { return N(e.length === 4 && e[0].length === 2 && e[1].length === 2 && e[2].length === 2 && e[3].length === 2, () => "Invalid number of paddings. Must be length of 2 each."), te(s, e, t); } const yn = w({ pad4d_: Gd }); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Kd(s, e, t, a) { const r = s.map((p, c) => y(p, `tensors${c}`, "raggedGather", "int32")), n = y(e, "paramsDenseValues", "raggedGather"), o = y(t, "indices", "raggedGather", "int32"), u = { paramsNestedSplits: r, paramsDenseValues: n, indices: o }, l = { outputRaggedRank: a }, m = O.runKernel(ns, u, l); return { outputNestedSplits: m.slice(0, m.length - 1), outputDenseValues: m[m.length - 1] }; } const gn = w({ raggedGather_: Kd }); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Jd(s, e, t, a, r) { const n = y(s, "shape", "raggedTensorToTensor", "int32"), o = y(e, "values", "raggedTensorToTensor"), u = y(t, "defaultValue", "raggedTensorToTensor", o.dtype), l = a.map((c, d) => y(c, `tensors${d}`, "raggedTensorToTensor", "int32")), m = { shape: n, values: o, defaultValue: u, rowPartitionTensors: l }, p = { rowPartitionTypes: r }; return O.runKernel(is, m, p); } const bn = w({ raggedTensorToTensor_: Jd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Qd(s, e, t) { const a = pe(s); let r = null; if (t == null || t === "float32") r = new Float32Array(a); else if (t === "int32") r = new Int32Array(a); else if (t === "bool") r = new Uint8Array(a); else throw new Error(`Unknown data type ${t}`); for (let n = 0; n < a; n++) r[n] = e(); return O.makeTensor(r, s, t); } const Nn = w({ rand_: Qd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Xd(s, e, t = 1, a = "float32", r) { if (t == null && (t = 1), a == null && (a = "float32"), a !== "float32" && a !== "int32") throw new Error(`Unsupported data type ${a}`); const n = new ki(e, t, a, r), o = Xe(s, a); for (let u = 0; u < o.values.length; u++) o.values[u] = n.nextValue(); return o.toTensor(); } const wn = w({ randomGamma_: Xd }); /** * @license * Copyright 2022 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Zd(s, e, t) { if (e != null && e === "bool") throw new Error(`Unsupported data type ${e}`); return Ze(s, 0, 1, e, t); } const Tn = w({ randomStandardNormal_: Zd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Yd(s) { const e = y(s, "x", "reverse"); return N(e.rank === 1, () => `Error in reverse1D: x must be rank 1 but got rank ${e.rank}.`), se(e, 0); } const Sn = w({ reverse1d_: Yd }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function Md(s, e) { const t = y(s, "x", "reverse"); return N(t.rank === 2, () => `Error in reverse2D: x must be rank 2 but got rank ${t.rank}.`), se(t, e); } const vn = w({ reverse2d_: Md }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function eh(s, e) { const t = y(s, "x", "reverse"); return N(t.rank === 3, () => `Error in reverse3D: x must be rank 3 but got rank ${t.rank}.`), se(t, e); } const On = w({ reverse3d_: eh }); /** * @license * Copyright 2020 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function th(s, e) { const t = y(s, "x", "reverse"); return N(t.rank === 4, () => `Error in reverse4D: x must be rank 4 but got rank ${t.rank}.`), se(t, e); } const _n = w({ reverse4d_: th }); /** * @license * Copyright 2020 Google Inc. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ async function sh(s, e) { const t = y(s, "x", "setdiff1d"), a = y(e, "y", "setdiff1d"); N(t.dtype === a.dtype, () => `x and y should have the same dtype, but got x (${t.dtype}) and y (${a.dtype}).`), N(t.rank === 1, () => `x should be 1D tensor, but got x (${t.shape}).`), N(a.rank === 1, () => `y should be 1D tensor, but got y (${a.shape}).`); const r = await t.data(), n = await a.data(), o = new Set(n); let u = 0; for (let p = 0; p < r.length; p++) o.has(r[p]) || u++; const l = new ze([u], t.dtype), m = new ze([u], "int32"); for (let p = 0, c = 0; p < r.length; p++) o.has(r[p]) || (l.values[c] = r[p], m.values[c] = p, c++); return [l.toTensor(), m.toTensor()]; } const An = sh; /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function En(s, e, t) { if (Ye(s), e != null && e.length !== 4) throw new Error("tensor4d() requires shape to have four numbers"); const a = ue(s, t); if (a.length !== 4 && a.length !== 1) throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray"); if (a.length === 1 && e == null) throw new Error("tensor4d() requires shape to be provided when `values` are a flat array"); return Me(s, e, a, t); } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function kn(s, e, t) { if (Ye(s), e != null && e.length !== 5) throw new Error("tensor5d() requires shape to have five numbers"); const a = ue(s, t); if (a.length !== 5 && a.length !== 1) throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray"); if (a.length === 1 && e == null) throw new Error("tensor5d() requires shape to be provided when `values` are a flat array"); return Me(s, e, a, t); } /** * @license * Copyright 2018 Google LLC. All Rights Reserved. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============================================================================= */ function $n(s, e, t) { if (Ye(s), e != null && e.length !== 6) throw new Error("tensor6d() requires shape to have six numbers"); const a = ue(s, t); if (a.length !== 6 && a.length !== 1) throw new Error("