UNPKG

bry-biometric-collector

Version:

BRy web-collector component for biometric capture.

1,368 lines 301 kB
import { _ as Sn, a as Nt, s as F, A as Gs, b as Us, c as js, d as qs, e as Mn, I as Xs, t as Ks, T as vn, p as at, g as Qt, f as je, h as An, i as Se, j as Be, k as Te, l as xn, m as Qs, n as Js, o as Ys, q as Zs, r as eu, u as tu, v as nu, w as Dn, x as rt, y as au, z as Ct, B as ru, C as su, R as uu, D as ou, E as ge, F as Nn, S as iu, G as du, H as cu, J as fe, K as pu, L as gn, M as lu, N as Cn, O as Fn, P as Rn, Q as mu, U as fu, V as En, W as hu, X as gu, Y as bu, Z as _u, $ as Pn, a0 as yu, a1 as Iu, a2 as Gt, a3 as wu, a4 as ku, a5 as On, a6 as Wn, a7 as st, a8 as Bn, a9 as Tn, aa as Jt, ab as Hn, ac as Ln, ad as Su, ae as Mu, af as Vn, ag as $n, ah as zn, ai as Gn, aj as vu, ak as Un, al as jn, am as Au, an as qn, ao as Yt, ap as Xn, aq as Kn, ar as xu, as as Qn, at as Du, au as Nu, av as Cu, aw as Fu, ax as Ru, ay as Eu, az as Pu, aA as Jn, aB as Ou, aC as Wu, aD as Yn, aE as Zn, aF as ea, aG as ta, aH as Bu, aI as Tu, aJ as Hu, aK as Lu, aL as Vu, aM as $u, aN as zu, aO as Gu, aP as na, aQ as Uu, aR as ju, aS as aa, aT as qu, aU as Xu, aV as Ku, aW as Qu, aX as Ju, aY as Yu, aZ as ra, a_ as sa, a$ as ua, b0 as Zu, b1 as oa, b2 as eo, b3 as to, b4 as no, b5 as ao, b6 as ro, b7 as ia, b8 as da, b9 as so, ba as ca, bb as pa, bc as la, bd as uo, be as oo, bf as io, bg as ma, bh as fa, bi as ha, bj as co, bk as ga, bl as po, bm as lo, bn as mo, bo as ba, bp as fo, bq as _a, br as ya, bs as ho, bt as go, bu as bo, bv as _o, bw as yo, bx as Io, by as Ia, bz as wa, bA as ka, bB as Sa, bC as Ma, bD as va, bE as wo, bF as ko, bG as So, bH as Aa, bI as Zt, bJ as xa, bK as Mo, bL as vo, bM as Ao, bN as xo, bO as Do, bP as No, bQ as Co, bR as Fo, bS as Ro, bT as Eo, bU as Po, bV as Oo, bW as Da, bX as Wo, bY as Bo, bZ as To, b_ as Ho, b$ as Lo, c0 as bn, c1 as Vo, c2 as $o, c3 as zo, c4 as Go, c5 as Uo, c6 as Na, c7 as jo, c8 as qo, c9 as Xo, ca as Ko, cb as Qo, cc as Ca, cd as Fa, ce as Jo, cf as Yo, cg as Zo, ch as ei, ci as ti, cj as ni, ck as ai, cl as ri, cm as si, cn as Ra, co as ui, cp as oi, cq as Ea, cr as Pa, cs as Oa, ct as Wa, cu as ii, cv as di, cw as ci, cx as pi, cy as li, cz as Ut, cA as Oe, cB as mi, cC as fi, cD as hi, cE as _n, cF as yn, cG as gi, cH as bi } from "./Unique_impl_cbb0d216_3.3.6.js"; import { bz as In, bA as Ba } from "./main_8f1a8854_3.3.6.js"; import "./face_api_d3d25326_3.3.6.js"; function Ta(r, a) { for (var s = 0; s < a.length; s++) { const o = a[s]; if (typeof o != "string" && !Array.isArray(o)) { for (const n in o) if (n !== "default" && !(n in r)) { const t = Object.getOwnPropertyDescriptor(o, n); t && Object.defineProperty(r, n, t.get ? t : { enumerable: !0, get: () => o[n] }); } } } return Object.freeze(Object.defineProperty(r, Symbol.toStringTag, { value: "Module" })); } /** * @license * Copyright 2019 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. * ============================================================================= */ var $; (function(r) { r[r.float32 = 0] = "float32", r[r.int32 = 1] = "int32", r[r.bool = 2] = "bool", r[r.string = 3] = "string", r[r.complex64 = 4] = "complex64"; })($ || ($ = {})); var nt; (function(r) { r[r.linear = 0] = "linear", r[r.relu = 1] = "relu", r[r.relu6 = 2] = "relu6", r[r.prelu = 3] = "prelu", r[r.leakyrelu = 4] = "leakyrelu", r[r.sigmoid = 5] = "sigmoid", r[r.elu = 6] = "elu"; })(nt || (nt = {})); /** * @license * Copyright 2019 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. * ============================================================================= */ let Ha; function _i(r) { Ha = r.wasm.cwrap(Sn, null, [ "number", "array", "number", "number", "array", "number", "number", "number", "number", "number", "number", "number", "number" // out_id ]); } function yi(r) { const { inputs: a, backend: s, attrs: o } = r, { a: n, b: t, bias: i, preluActivationWeights: d } = a; if (n.dtype !== "float32" || t.dtype !== "float32") throw new Error("_FusedMatMul for non non-float32 tensors not yet supported."); const { transposeA: c, transposeB: u, activation: e, leakyreluAlpha: m } = o, b = s.dataIdMap.get(n.dataId).id, l = s.dataIdMap.get(t.dataId).id; let f = 0; if (i != null) { const V = s.dataIdMap.get(i.dataId); if (V.shape.length !== 1) throw new Error(`_FusedMatMul only supports rank-1 bias but got rank ${V.shape.length}.`); f = V.id; } const g = d == null ? 0 : s.dataIdMap.get(d.dataId).id, w = nt[e]; if (w == null) throw new Error(`${e} activation not yet supported for FusedConv2D in the wasm backend.`); const k = c ? n.shape[2] : n.shape[1], y = u ? t.shape[1] : t.shape[2], _ = Nt(n.shape.slice(0, -2), t.shape.slice(0, -2)), v = s.makeOutput([..._, k, y], n.dtype), E = s.dataIdMap.get(v.dataId).id, R = new Uint8Array(new Int32Array(n.shape).buffer), B = new Uint8Array(new Int32Array(t.shape).buffer); return Ha(b, R, n.shape.length, l, B, t.shape.length, c, u, w, f, g, m || 0, E), v; } const Ii = { kernelName: Sn, backendName: "wasm", setupFunc: _i, kernelFunc: yi }; /** * @license * Copyright 2019 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 L(r, a) { let s; function o(t) { s = t.wasm.cwrap(r, null, [ "number", "number", "number" // out_id ]); } function n(t) { const { backend: i, inputs: { x: d } } = t, c = i.dataIdMap.get(d.dataId).id, u = i.makeOutput(d.shape, a || d.dtype), e = i.dataIdMap.get(u.dataId).id; return F(u.shape) === 0 || s(c, $[d.dtype], e), u; } return { kernelName: r, backendName: "wasm", setupFunc: o, kernelFunc: n }; } /** * @license * Copyright 2019 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 wi = L(Gs); /** * @license * Copyright 2023 Google LLC. * 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 ki = L(Us); /** * @license * Copyright 2023 Google LLC. * 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 Si = L(js); /** * @license * Copyright 2019 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 ee(r, a, s) { let o; function n(i) { o = i.wasm.cwrap(r, null, [ "number", "array", "number", "number", "array", "number", "number", "number" // out_id ]); } function t(i) { const { backend: d, inputs: c } = i, { a: u, b: e } = c, m = d.dataIdMap.get(u.dataId).id, b = d.dataIdMap.get(e.dataId).id, l = s ?? u.dtype, f = Nt(u.shape, e.shape), g = d.makeOutput(f, l); if (F(f) === 0) return g; const w = new Uint8Array(new Int32Array(u.shape).buffer), k = new Uint8Array(new Int32Array(e.shape).buffer), y = d.dataIdMap.get(g.dataId).id; return (() => o(m, w, u.shape.length, b, k, e.shape.length, $[u.dtype], y))(), g; } return { kernelName: r, backendName: "wasm", setupFunc: n, kernelFunc: t }; } /** * @license * Copyright 2019 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 Mi = ee(qs); /** * @license * Copyright 2019 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. * ============================================================================= */ let La; function vi(r) { La = r.wasm.cwrap(Mn, null, [ "array", "number", "number", "number" // out_id ]); } function Ai(r) { const { inputs: a, backend: s } = r, o = s.makeOutput(a[0].shape, a[0].dtype); if (F(o.shape) === 0) return o; const n = a.map((d) => s.dataIdMap.get(d.dataId).id), t = new Uint8Array(new Int32Array(n).buffer), i = s.dataIdMap.get(o.dataId).id; return La(t, n.length, $[o.dtype], i), o; } const xi = { kernelName: Mn, backendName: "wasm", setupFunc: vi, kernelFunc: Ai }; /** * @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 Ft(r) { const { inputs: { x: a }, backend: s } = r; if (a.dtype === "string") return Ks(s.readSync(a.dataId), a.shape, a.dtype); const o = s.makeOutput(a.shape, a.dtype), n = s.typedArrayFromHeap(a); return s.typedArrayFromHeap(o).set(n), o; } const Di = { kernelName: Xs, backendName: "wasm", kernelFunc: Ft }; /** * @license * Copyright 2019 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. * ============================================================================= */ let Va; function Ni(r) { Va = r.wasm.cwrap(vn, null, [ "number", "array", "number", "number", "number", "array", "number" // perm.length ]); } function Ae(r) { const { inputs: a, backend: s, attrs: o } = r, [n, t] = Fi(a.x.shape, o.perm); let i = !0; for (let f = 0; f < t.length; f++) t[f] !== f && (i = !1); const d = Ci(a.x.shape, o.perm), c = { dataId: a.x.dataId, shape: n, dtype: a.x.dtype }; if (i) { const f = Ft({ inputs: a, backend: s }); return f.shape = d, f; } const u = s.makeOutput(d, c.dtype), e = s.dataIdMap.get(c.dataId).id, m = s.dataIdMap.get(u.dataId).id, b = new Uint8Array(new Int32Array(t).buffer), l = new Uint8Array(new Int32Array(c.shape).buffer); return Va(e, l, c.shape.length, $[c.dtype], m, b, t.length), u; } function Ci(r, a) { const s = new Array(r.length); for (let o = 0; o < s.length; o++) s[o] = r[a[o]]; return s; } function Fi(r, a) { const s = [], o = []; for (let n = 0; n < r.length; ++n) r[n] !== 1 && s.push(r[n]), r[a[n]] !== 1 && o.push(a[n]); for (let n = 0; n < o.length; ++n) { let t = -1; for (let i = 0; i < o.length; ++i) o[i] >= n && (t === -1 || o[t] > o[i]) && (t = i); o[t] = n; } return [s, o]; } const Ri = { kernelName: vn, backendName: "wasm", kernelFunc: Ae, setupFunc: Ni }; /** * @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. * ============================================================================= */ function xe(r, a, s) { const o = r.shape, n = r.shape.length, t = at(a, o); let i = t; const d = Qt(i, n); let c = null, u = !1; if (d != null) { const e = new Array(n); for (let l = 0; l < e.length; l++) e[l] = o[d[l]]; i = je(i.length, n), c = Ae({ inputs: { x: r }, attrs: { perm: d }, backend: s }); const m = s.dataIdMap.get(r.dataId).id; s.dataIdMap.get(c.dataId).id !== m && (u = !0); } return { transposed: c, originalAxes: t, axes: i, inputWasTransposed: u }; } /** * @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. * ============================================================================= */ let $a; function Ei(r) { $a = r.wasm.cwrap(An, null, ["number, number, number"]); } function Pi(r) { const { backend: a, inputs: s, attrs: o } = r, { axis: n, keepDims: t } = o, { x: i } = s; let c = a.dataIdMap.get(i.dataId).id, u = i; const { transposed: e, axes: m, originalAxes: b, inputWasTransposed: l } = xe(i, n, a); if (l) { const _ = a.dataIdMap.get(e.dataId).id; u = e, c = _; } const f = u.shape.length; Se("all", m, f); const [g, w] = Be(u.shape, m), k = F(w), y = a.makeOutput(g, i.dtype); if (F(u.shape) !== 0) { const _ = a.dataIdMap.get(y.dataId).id; $a(c, k, _); } if (l && a.disposeData(e.dataId), t) { const _ = Te(y.shape, b); y.shape = _; } return y; } const Oi = { kernelName: An, backendName: "wasm", setupFunc: Ei, kernelFunc: Pi }; /** * @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. * ============================================================================= */ let za; function Wi(r) { za = r.wasm.cwrap(xn, null, ["number, number, number"]); } function Bi(r) { const { backend: a, inputs: s, attrs: o } = r, { axis: n, keepDims: t } = o, { x: i } = s; let c = a.dataIdMap.get(i.dataId).id, u = i; const { transposed: e, axes: m, originalAxes: b, inputWasTransposed: l } = xe(i, n, a); if (l) { const _ = a.dataIdMap.get(e.dataId).id; u = e, c = _; } const f = u.shape.length; Se("any", m, f); const [g, w] = Be(u.shape, m), k = F(w), y = a.makeOutput(g, i.dtype); if (F(u.shape) !== 0) { const _ = a.dataIdMap.get(y.dataId).id; za(c, k, _); } if (l && a.disposeData(e.dataId), t) { const _ = Te(y.shape, b); y.shape = _; } return y; } const Ti = { kernelName: xn, backendName: "wasm", setupFunc: Wi, kernelFunc: Bi }; /** * @license * Copyright 2023 Google LLC. * 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 Ga(r) { let a; function s(n) { a = n.wasm.cwrap(r, null, [ "number", "number", "number", "number", "number" // out_id ]); } function o(n) { const { backend: t, inputs: i, attrs: d } = n, { axis: c } = d, { x: u } = i, e = t.dataIdMap.get(u.dataId).id; let m = e, b = u; const { transposed: l, axes: f, inputWasTransposed: g } = xe(u, c, t); if (g) { const E = t.dataIdMap.get(l.dataId).id; E !== e && (b = l, m = E); } const w = b.shape.slice(0, -1), k = t.makeOutput(w, "int32"), y = t.dataIdMap.get(k.dataId).id, _ = F(k.shape), v = b.shape[f[0]]; return a(m, $[b.dtype], _, v, y), g && t.disposeData(l.dataId), k; } return { kernelName: r, backendName: "wasm", setupFunc: s, kernelFunc: o }; } /** * @license * Copyright 2019 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 Hi = Ga(Qs); /** * @license * Copyright 2023 Google LLC. * 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 Li = Ga(Js); /** * @license * Copyright 2023 Google LLC. * 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 Vi = L(Ys); /** * @license * Copyright 2023 Google LLC. * 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 $i = L(Zs); /** * @license * Copyright 2023 Google LLC. * 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 zi = L(eu); /** * @license * Copyright 2023 Google LLC. * 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 Gi = ee(tu); /** * @license * Copyright 2023 Google LLC. * 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 Ui = L(nu); /** * @license * Copyright 2019 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. * ============================================================================= */ let Ua; function ji(r) { Ua = r.wasm.cwrap(Dn, null, [ "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number" // outId ]); } function qi(r) { const { inputs: a, attrs: s, backend: o } = r, n = a.x, t = o.dataIdMap.get(n.dataId).id, { filterSize: i, strides: d, pad: c, dimRoundingMode: u } = s, e = rt(n.shape, i, d, 1, c, u), m = e.filterHeight, b = e.filterWidth, l = e.padInfo.top, f = e.padInfo.right, g = e.padInfo.bottom, w = e.padInfo.left, k = e.strideHeight, y = e.strideWidth, _ = e.inChannels; if (e.dataFormat !== "channelsLast") throw new Error(`wasm backend does not support dataFormat:'${e.dataFormat}'. Please use 'channelsLast'.`); if (e.dilationWidth !== 1 || e.dilationHeight !== 1) throw new Error(`was backend only supports average pooling with dilation = [1, 1], got [${e.dilationHeight}, ${e.dilationWidth}].`); const v = o.makeOutput(e.outShape, "float32"), E = o.dataIdMap.get(v.dataId).id; return Ua(t, n.shape[0], n.shape[1], n.shape[2], m, b, l, f, g, w, k, y, _, E), v; } const Xi = { kernelName: Dn, backendName: "wasm", setupFunc: ji, kernelFunc: qi }; /** * @license * Copyright 2023 Google LLC. * 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. * ============================================================================= */ let ja; function Ki(r) { ja = r.wasm.cwrap("AvgPool3D", null, [ "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number" // padLeft ]); } function Qi(r) { const { inputs: a, backend: s, attrs: o } = r, { x: n } = a, { filterSize: t, strides: i, pad: d, dimRoundingMode: c, dataFormat: u } = o, e = Ct( n.shape, t, i, /*dilations=*/ 1, d, c, u ), m = s.makeOutput(e.outShape, n.dtype); return ja( s.dataIdMap.get(n.dataId).id, s.dataIdMap.get(m.dataId).id, e.batchSize, // Since Pool3D ops (AvgPool3D and MaxPool3D) support 3D filter only, in // channels should always equal to out channels. /*channelSize=*/ e.inChannels, e.inDepth, e.inHeight, e.inWidth, e.outDepth, e.outHeight, e.outWidth, e.strideDepth, e.strideHeight, e.strideWidth, e.dilationDepth, e.dilationHeight, e.dilationWidth, e.effectiveFilterDepth, e.effectiveFilterHeight, e.effectiveFilterWidth, e.padInfo.front, e.padInfo.top, e.padInfo.left ), m; } const Ji = { kernelName: au, backendName: "wasm", setupFunc: Ki, kernelFunc: Qi }; /** * @license * Copyright 2023 Google LLC. * 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. * ============================================================================= */ let qa; function Yi(r) { qa = r.wasm.cwrap("AvgPool3DGrad", null, [ "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number" // filterWidth ]); } function Zi(r) { const { inputs: a, backend: s, attrs: o } = r, { dy: n, input: t } = a, { filterSize: i, strides: d, pad: c, dimRoundingMode: u } = o, e = Ct( t.shape, i, d, /*dilations=*/ 1, c, u ), m = s.makeOutput(t.shape, t.dtype); return qa( s.dataIdMap.get(n.dataId).id, s.dataIdMap.get(m.dataId).id, e.batchSize, // Since Pool3D ops (AvgPool3D and MaxPool3D) support 3D filter only, in // channels should always equal to out channels. /*channelSize=*/ e.inChannels, e.inDepth, e.inHeight, e.inWidth, e.outDepth, e.outHeight, e.outWidth, e.strideDepth, e.strideHeight, e.strideWidth, e.dilationDepth, e.dilationHeight, e.dilationWidth, e.effectiveFilterDepth, e.effectiveFilterHeight, e.effectiveFilterWidth, e.padInfo.front, e.padInfo.top, e.padInfo.left, e.filterDepth, e.filterHeight, e.filterWidth ), m; } const ed = { kernelName: ru, backendName: "wasm", setupFunc: Yi, kernelFunc: Zi }; /** * @license * Copyright 2023 Google LLC. * 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. * ============================================================================= */ let Xa; function td(r) { Xa = r.wasm.cwrap("AvgPoolGrad", null, [ "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number", "number" // filterWidth ]); } function nd(r) { const { inputs: a, backend: s, attrs: o } = r, { dy: n, input: t } = a, { filterSize: i, strides: d, pad: c } = o, u = rt( t.shape, i, d, /*dilations=*/ 1, c ), e = s.makeOutput(t.shape, t.dtype); return Xa( s.dataIdMap.get(n.dataId).id, s.dataIdMap.get(e.dataId).id, u.batchSize, // Since Pool ops (AvgPool and MaxPool) support 2D filter only, in // channels should always equal to out channels. /*channelSize=*/ u.inChannels, u.inHeight, u.inWidth, u.outHeight, u.outWidth, u.strideHeight, u.strideWidth, u.dilationHeight, u.dilationWidth, u.effectiveFilterHeight, u.effectiveFilterWidth, u.padInfo.top, u.padInfo.left, u.filterHeight, u.filterWidth ), e; } const ad = { kernelName: su, backendName: "wasm", setupFunc: td, kernelFunc: nd }; /** * @license * Copyright 2019 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 oe(r) { const { inputs: a, attrs: s } = r, { x: o } = a, { shape: n } = s, t = F(o.shape), i = ou(n, t); return ge(t === F(i), () => `new shape: ${i}, old shape: ${o.shape}. New shape and old shape must have the same number of elements.`), r.backend.incRef(o.dataId), { dataId: o.dataId, shape: i, dtype: o.dtype }; } const rd = { kernelName: uu, backendName: "wasm", kernelFunc: oe }; /** * @license * Copyright 2019 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. * ============================================================================= */ let Ka; function sd(r) { Ka = r.wasm.cwrap(Nn, null, [ "number", "array", "number", "number", "array", "number", "number", "number", "number" // out_id ]); } function ud(r) { const { inputs: a, backend: s, attrs: o } = r, { a: n, b: t } = a, { transposeA: i, transposeB: d } = o; if (n.dtype !== "float32" || t.dtype !== "float32") throw new Error("BatchMatMul for non non-float32 tensors not yet supported."); const c = n.shape.length, u = t.shape.length, e = i ? n.shape[c - 2] : n.shape[c - 1], m = d ? t.shape[u - 1] : t.shape[u - 2], b = i ? n.shape[c - 1] : n.shape[c - 2], l = d ? t.shape[u - 2] : t.shape[u - 1], f = n.shape.slice(0, -2), g = t.shape.slice(0, -2), w = F(f), k = F(g), _ = Nt(n.shape.slice(0, -2), t.shape.slice(0, -2)).concat([b, l]); ge(e === m, () => `Error in matMul: inner shapes (${e}) and (${m}) of Tensors with shapes ${n.shape} and ${t.shape} and transposeA=${i} and transposeB=${d} must match.`); const v = i ? [w, e, b] : [w, b, e], E = d ? [k, l, m] : [k, m, l], R = oe({ inputs: { x: n }, backend: s, attrs: { shape: v } }), B = oe({ inputs: { x: t }, backend: s, attrs: { shape: E } }), V = s.dataIdMap.get(R.dataId).id, z = s.dataIdMap.get(B.dataId).id, H = i ? R.shape[2] : R.shape[1], U = d ? B.shape[1] : B.shape[2], q = Math.max(w, k), J = s.makeOutput([q, H, U], R.dtype), ue = s.dataIdMap.get(J.dataId).id, X = new Uint8Array(new Int32Array(R.shape).buffer), te = new Uint8Array(new Int32Array(B.shape).buffer); return Ka(V, X, R.shape.length, z, te, B.shape.length, i, d, ue), s.disposeData(R.dataId), s.disposeData(B.dataId), J.shape = _, J; } const od = { kernelName: Nn, backendName: "wasm", setupFunc: sd, kernelFunc: ud }; /** * @license * Copyright 2019 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 We(r) { const { inputs: { x: a }, attrs: { begin: s, size: o }, backend: n } = r, [t, i] = du(a, s, o), d = cu(a.shape, t, i), c = n.readSync(a.dataId), u = n.makeOutput(i, a.dtype), e = fe(a.shape), m = n.dataIdMap.get(u.dataId); if (d) { const f = pu(t, e); return a.dtype === "string" ? m.stringBytes = c.slice(f, f + F(i)) : n.typedArrayFromHeap(u).set(c.subarray(f, f + F(i))), u; } if (a.dtype === "string") { const f = gn(c, t, i, a.shape, a.dtype); return m.stringBytes = f, u; } const b = n.typedArrayFromHeap(u), l = a.shape.length; if (l === 2) id(c, e[0], b, t, i); else if (l === 3) dd(c, e[0], e[1], b, t, i); else if (l === 4) cd(c, e[0], e[1], e[2], b, t, i); else { const f = gn(c, t, i, a.shape, a.dtype); b.set(f); } return u; } function id(r, a, s, o, n) { let t = 0; const i = o[0], d = o[1], c = i + n[0]; for (let u = i; u < c; u++) { const e = u * a + d; s.set(r.subarray(e, e + n[1]), t), t += n[1]; } } function dd(r, a, s, o, n, t) { let i = 0; const d = n[0], c = n[1], u = n[2], e = d + t[0], m = c + t[1]; for (let b = d; b < e; b++) for (let l = c; l < m; l++) { const f = b * a + l * s + u; o.set(r.subarray(f, f + t[2]), i), i += t[2]; } } function cd(r, a, s, o, n, t, i) { let d = 0; const c = t[0], u = t[1], e = t[2], m = c + i[0], b = u + i[1], l = e + i[2], f = t[3]; for (let g = c; g < m; g++) for (let w = u; w < b; w++) for (let k = e; k < l; k++) { const y = g * a + w * s + k * o + f; n.set(r.subarray(y, y + i[3]), d), d += i[3]; } } const pd = { kernelName: iu, backendName: "wasm", kernelFunc: We }; /** * @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 ld(r) { const { inputs: a, backend: s, attrs: o } = r, { x: n } = a, { blockShape: t, crops: i } = o, d = t.reduce((k, y) => k * y), c = Cn(n.shape, t, d), u = Fn(c.length, t.length), e = Rn(n.shape, t, d), m = mu(i, t.length), b = fu(e, i, t.length), l = oe({ inputs: { x: n }, backend: s, attrs: { shape: c } }), f = Ae({ inputs: { x: l }, backend: s, attrs: { perm: u } }), g = oe({ inputs: { x: f }, backend: s, attrs: { shape: e } }), w = We({ inputs: { x: g }, backend: s, attrs: { begin: m, size: b } }); return s.disposeData(l.dataId), s.disposeData(f.dataId), s.disposeData(g.dataId), w; } const md = { kernelName: lu, backendName: "wasm", kernelFunc: ld }; /** * @license * Copyright 2023 Google LLC. * 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. * ============================================================================= */ let Qa; function fd(r) { Qa = r.wasm.cwrap(En, null, [ "number", "number", "boolean", "number", "number", "number" // outId ]); } function hd(r) { const { backend: a, inputs: s, attrs: o } = r, { x: n, weights: t } = s, { size: i } = o, d = t.shape.reduce((m, b) => m * b, 1) !== 0, c = n.shape.length === 1 ? [i] : [n.shape[0], i], u = a.makeOutput(c, t.dtype); function e(m) { return a.dataIdMap.get(m.dataId).id; } return Qa(e(n), i, d, e(t), $[t.dtype], e(u)), u; } const gd = { kernelName: En, backendName: "wasm", setupFunc: fd, kernelFunc: hd }; /** * @license * Copyright 2023 Google LLC. * 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 bd = ee(hu); /** * @license * Copyright 2023 Google LLC. * 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 _d(r) { const { inputs: a, backend: s } = r, { s0: o, s1: n } = a, t = s.typedArrayFromHeap(o), i = s.typedArrayFromHeap(n), d = Nt(Array.from(t), Array.from(i)); return s.makeOutput( [d.length], "int32", /*memoryOffset=*/ void 0, /*values=*/ new Int32Array(d) ); } const yd = { kernelName: gu, backendName: "wasm", kernelFunc: _d }; /** * @license * Copyright 2019 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 De(r) { const { inputs: { x: a }, attrs: { dtype: s }, backend: o } = r, n = o.makeOutput(a.shape, s), t = o.typedArrayFromHeap(a); return o.typedArrayFromHeap(n).set(t), n; } const Id = { kernelName: bu, backendName: "wasm", kernelFunc: De }; /** * @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. * ============================================================================= */ const wd = L(_u); /** * @license * Copyright 2019 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. * ============================================================================= */ let Ja; function kd(r) { Ja = r.wasm.cwrap(Pn, null, [ "number", "number", "number", "number" // out_id ]); } function Sd(r) { const { inputs: a, backend: s, attrs: o } = r, { x: n } = a, { clipValueMin: t, clipValueMax: i } = o, d = s.dataIdMap.get(n.dataId).id, c = s.makeOutput(n.shape, n.dtype), u = s.dataIdMap.get(c.dataId).id; return Ja(d, t, i, u), c; } const Md = { kernelName: Pn, backendName: "wasm", setupFunc: kd, kernelFunc: Sd }; /** * @license * Copyright 2019 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 Ya(r) { const { inputs: a, backend: s } = r, o = at(r.attrs.axis, a[0].shape)[0], n = a.map((l) => l.shape); Iu(n, o); let t = Gt(a.map((l) => l.shape), o); const i = a.filter((l) => F(l.shape) > 0); if (i.length === 1) return Ft({ inputs: { x: i[0] }, backend: s }); const d = s.makeOutput(t, a[0].dtype); if (F(t) === 0) return d; if (i[0].dtype === "string") { const l = i.map((_) => { const E = [-1, F(_.shape.slice(o))]; return oe({ inputs: { x: _ }, backend: s, attrs: { shape: E } }); }), f = l.map((_) => ({ vals: s.readSync(_.dataId), shape: _.shape })); t = Gt( l.map((_) => _.shape), 1 /* axis */ ); const g = l[0].shape[0] === 1, w = wu(f, t, a[0].dtype, g), k = Gt(i.map((_) => _.shape), o); d.shape = k; const y = s.dataIdMap.get(d.dataId); return y.stringBytes = ku(w), l.forEach((_) => s.disposeData(_.dataId)), d; } const c = F(i[0].shape.slice(0, o)); let u = 0; const e = i.map((l) => { const f = F(l.shape.slice(o)); return u += f, f; }), m =