!function (e, t) { "object" == typeof exports && "object" == typeof module ? module.exports = t() : "function" == typeof define && define.amd ? define([], t) : "object" == typeof exports ? exports.ml5 = t() : e.ml5 = t() }(self, (() => (() => { var e = { 2726: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.g = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.g }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l, c = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) l = Object.setPrototypeOf; else { var h; e: { var d = {}; try { d.__proto__ = { a: !0 }, h = d.a; break e } catch (e) { } h = !1 } l = h ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var f = l; function p(e, t) { if (e.prototype = c(t.prototype), e.prototype.constructor = e, f) f(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.ea = t.prototype } function m() { this.l = !1, this.i = null, this.h = void 0, this.g = 1, this.s = this.m = 0, this.j = null } function g(e) { if (e.l) throw new TypeError("Generator is already running"); e.l = !0 } function y(e, t) { e.j = { U: t, V: !0 }, e.g = e.m || e.s } function b(e, t, n) { return e.g = n, { value: t } } function v(e) { this.g = new m, this.h = e } function x(e, t, n, r) { try { var i = t.call(e.g.i, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.g.l = !1, i; var a = i.value } catch (t) { return e.g.i = null, y(e.g, t), w(e) } return e.g.i = null, r.call(e.g, a), w(e) } function w(e) { for (; e.g.g;)try { var t = e.h(e.g); if (t) return e.g.l = !1, { value: t.value, done: !1 } } catch (t) { e.g.h = void 0, y(e.g, t) } if (e.g.l = !1, e.g.j) { if (t = e.g.j, e.g.j = null, t.V) throw t.U; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function k(e) { this.next = function (t) { return g(e.g), e.g.i ? t = x(e, e.g.i.next, t, e.g.o) : (e.g.o(t), t = w(e)), t }, this.throw = function (t) { return g(e.g), e.g.i ? t = x(e, e.g.i.throw, t, e.g.o) : (y(e.g, t), t = w(e)), t }, this.return = function (t) { return function (e, t) { g(e.g); var n = e.g.i; return n ? x(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.g.return) : (e.g.return(t), w(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function S(e, t) { return t = new k(new v(t)), f && e.prototype && f(t, e.prototype), t } m.prototype.o = function (e) { this.h = e }, m.prototype.return = function (e) { this.j = { return: e }, this.g = this.s }; var _ = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || _ })), a("Promise", (function (e) { function t(e) { this.h = 0, this.i = void 0, this.g = [], this.o = !1; var t = this.j(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.g = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.h = function (e) { if (null == this.g) { this.g = []; var t = this; this.i((function () { t.l() })) } this.g.push(e) }; var a = i.setTimeout; n.prototype.i = function (e) { a(e, 0) }, n.prototype.l = function () { for (; this.g && this.g.length;) { var e = this.g; this.g = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.j(e) } } } this.g = null }, n.prototype.j = function (e) { this.i((function () { throw e })) }, t.prototype.j = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.C), reject: e(this.l) } }, t.prototype.C = function (e) { if (e === this) this.l(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.F(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.u(e) : this.m(e) } }, t.prototype.u = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.l(e) } "function" == typeof t ? this.G(t, e) : this.m(e) }, t.prototype.l = function (e) { this.s(2, e) }, t.prototype.m = function (e) { this.s(1, e) }, t.prototype.s = function (e, t) { if (0 != this.h) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.h); this.h = e, this.i = t, 2 === this.h && this.D(), this.A() }, t.prototype.D = function () { var e = this; a((function () { if (e.B()) { var t = i.console; void 0 !== t && t.error(e.i) } }), 1) }, t.prototype.B = function () { if (this.o) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.i, n(e)) }, t.prototype.A = function () { if (null != this.g) { for (var e = 0; e < this.g.length; ++e)o.h(this.g[e]); this.g = null } }; var o = new n; return t.prototype.F = function (e) { var t = this.j(); e.J(t.resolve, t.reject) }, t.prototype.G = function (e, t) { var n = this.j(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.J(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.J = function (e, t) { function n() { switch (r.h) { case 1: e(r.i); break; case 2: t(r.i); break; default: throw Error("Unexpected state: " + r.h) } } var r = this; null == this.g ? o.h(n) : this.g.push(n), this.o = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).J(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).J(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })); var C = this || self; function A(e, t) { e = e.split("."); var n, r = C; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function T(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var E, N, I = "undefined" != typeof TextDecoder, M = "undefined" != typeof TextEncoder; function F(e) { if (M) e = (N || (N = new TextEncoder)).encode(e); else { var t = void 0; t = void 0 !== t && t; for (var n = 0, r = new Uint8Array(3 * e.length), i = 0; i < e.length; i++) { var a = e.charCodeAt(i); if (128 > a) r[n++] = a; else { if (2048 > a) r[n++] = a >> 6 | 192; else { if (55296 <= a && 57343 >= a) { if (56319 >= a && i < e.length) { var o = e.charCodeAt(++i); if (56320 <= o && 57343 >= o) { a = 1024 * (a - 55296) + o - 56320 + 65536, r[n++] = a >> 18 | 240, r[n++] = a >> 12 & 63 | 128, r[n++] = a >> 6 & 63 | 128, r[n++] = 63 & a | 128; continue } i-- } if (t) throw Error("Found an unpaired surrogate"); a = 65533 } r[n++] = a >> 12 | 224, r[n++] = a >> 6 & 63 | 128 } r[n++] = 63 & a | 128 } } e = r.subarray(0, n) } return e } var D = {}, $ = null; function R(e, t) { void 0 === t && (t = 0), z(), t = D[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } function O(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = $[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } z(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), r.subarray(0, i) } function z() { if (!$) { $ = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); D[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === $[a] && ($[a] = i) } } } } var P, B = "function" == typeof Uint8Array.prototype.slice; function L(e, t, n) { return t === n ? P || (P = new Uint8Array(0)) : B ? e.slice(t, n) : new Uint8Array(e.subarray(t, n)) } var j = 0; function U(e, t) { t = void 0 !== (t = void 0 === t ? {} : t).v && t.v, this.h = null, this.g = this.j = this.l = 0, this.m = !1, this.v = t, e && W(this, e) } function W(e, t) { t = t.constructor === Uint8Array ? t : t.constructor === ArrayBuffer || t.constructor === Array ? new Uint8Array(t) : t.constructor === String ? O(t) : t instanceof Uint8Array ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(0), e.h = t, e.l = 0, e.j = e.h.length, e.g = e.l } function V(e) { for (var t = 128, n = 0, r = 0, i = 0; 4 > i && 128 <= t; i++)n |= (127 & (t = e.h[e.g++])) << 7 * i; if (128 <= t && (n |= (127 & (t = e.h[e.g++])) << 28, r |= (127 & t) >> 4), 128 <= t) for (i = 0; 5 > i && 128 <= t; i++)r |= (127 & (t = e.h[e.g++])) << 7 * i + 3; if (128 > t) return e = n >>> 0, (r = 2147483648 & (t = r >>> 0)) && (t = ~t >>> 0, 0 == (e = 1 + ~e >>> 0) && (t = t + 1 >>> 0)), e = 4294967296 * t + (e >>> 0), r ? -e : e; e.m = !0 } U.prototype.reset = function () { this.g = this.l }, U.prototype.i = function () { var e = this.h, t = e[this.g], n = 127 & t; return 128 > t ? (this.g += 1, n) : (n |= (127 & (t = e[this.g + 1])) << 7, 128 > t ? (this.g += 2, n) : (n |= (127 & (t = e[this.g + 2])) << 14, 128 > t ? (this.g += 3, n) : (n |= (127 & (t = e[this.g + 3])) << 21, 128 > t ? (this.g += 4, n) : (n |= (15 & (t = e[this.g + 4])) << 28, 128 > t ? (this.g += 5, n >>> 0) : (this.g += 5, 128 <= e[this.g++] && 128 <= e[this.g++] && 128 <= e[this.g++] && 128 <= e[this.g++] && this.g++, n))))) }, U.prototype.o = function () { var e = this.h[this.g], t = this.h[this.g + 1], n = this.h[this.g + 2], r = this.h[this.g + 3]; return this.g += 4, e = 2 * ((n = (e | t << 8 | n << 16 | r << 24) >>> 0) >> 31) + 1, t = n >>> 23 & 255, n &= 8388607, 255 == t ? n ? NaN : 1 / 0 * e : 0 == t ? e * Math.pow(2, -149) * n : e * Math.pow(2, t - 150) * (n + Math.pow(2, 23)) }; var G = []; function H() { this.g = new Uint8Array(64), this.h = 0 } function q(e, t) { for (; 127 < t;)e.push(127 & t | 128), t >>>= 7; e.push(t) } function Y(e) { var t = {}, n = void 0 !== t.N && t.N; this.o = { v: void 0 !== t.v && t.v }, this.N = n, t = this.o, G.length ? (n = G.pop(), t && (n.v = t.v), e && W(n, e), e = n) : e = new U(e, t), this.g = e, this.m = this.g.g, this.h = this.i = this.l = -1, this.j = !1 } function X(e) { var t = e.g; if ((t = t.g == t.j) || (t = e.j) || (t = (t = e.g).m || 0 > t.g || t.g > t.j), t) return !1; e.m = e.g.g; var n = 7 & (t = e.g.i()); return 0 != n && 5 != n && 1 != n && 2 != n && 3 != n && 4 != n ? (e.j = !0, !1) : (e.i = t, e.l = t >>> 3, e.h = n, !0) } function K(e) { switch (e.h) { case 0: if (0 != e.h) K(e); else { for (e = e.g; 128 & e.h[e.g];)e.g++; e.g++ } break; case 1: 1 != e.h ? K(e) : (e = e.g).g += 8; break; case 2: if (2 != e.h) K(e); else { var t = e.g.i(); (e = e.g).g += t } break; case 5: 5 != e.h ? K(e) : (e = e.g).g += 4; break; case 3: for (t = e.l; ;) { if (!X(e)) { e.j = !0; break } if (4 == e.h) { e.l != t && (e.j = !0); break } K(e) } break; default: e.j = !0 } } function Z(e, t, n) { var r = e.g.j, i = e.g.i(), a = e.g.g + i; if (e.g.j = a, n(t, e), 0 !== (n = a - e.g.g)) throw Error("Message parsing ended unexpectedly. Expected to read " + i + " bytes, instead read " + (i - n) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.g.g = a, e.g.j = r, t } function J(e) { return e.g.o() } function Q(e) { var t, n = e.g.i(), r = (e = e.g).g; if (e.g += n, e = e.h, I) (t = E) || (t = E = new TextDecoder("utf-8", { fatal: !1 })), t = t.decode(e.subarray(r, r + n)); else { n = r + n; for (var i, a, o, s = [], u = null; r < n;)128 > (i = e[r++]) ? s.push(i) : 224 > i ? r >= n ? s.push(65533) : (a = e[r++], 194 > i || 128 != (192 & a) ? (r--, s.push(65533)) : s.push((31 & i) << 6 | 63 & a)) : 240 > i ? r >= n - 1 ? s.push(65533) : 128 != (192 & (a = e[r++])) || 224 === i && 160 > a || 237 === i && 160 <= a || 128 != (192 & (t = e[r++])) ? (r--, s.push(65533)) : s.push((15 & i) << 12 | (63 & a) << 6 | 63 & t) : 244 >= i ? r >= n - 2 ? s.push(65533) : 128 != (192 & (a = e[r++])) || a - 144 + (i << 28) >> 30 || 128 != (192 & (t = e[r++])) || 128 != (192 & (o = e[r++])) ? (r--, s.push(65533)) : (i = (7 & i) << 18 | (63 & a) << 12 | (63 & t) << 6 | 63 & o, i -= 65536, s.push(55296 + (i >> 10 & 1023), 56320 + (1023 & i))) : s.push(65533), 8192 <= s.length && (u = T(u, s), s.length = 0); t = T(u, s) } return t } function ee(e, t, n) { var r = e.g.i(); for (r = e.g.g + r; e.g.g < r;)n.push(t.call(e.g)) } function te(e, t) { 2 == e.h ? ee(e, U.prototype.o, t) : t.push(J(e)) } function ne() { this.h = [], this.i = 0, this.g = new H } function re(e, t) { 0 !== t.length && (e.h.push(t), e.i += t.length) } function ie(e) { var t = e.i + e.g.length(); if (0 === t) return new Uint8Array(0); t = new Uint8Array(t); for (var n = e.h, r = n.length, i = 0, a = 0; a < r; a++) { var o = n[a]; 0 !== o.length && (t.set(o, i), i += o.length) } return 0 !== (r = (n = e.g).h) && (t.set(n.g.subarray(0, r), i), n.h = 0), e.h = [t], t } function ae(e, t, n) { if (null != n) { q(e.g, 8 * t + 5), e = e.g; var r = n; 0 === (r = (n = 0 > r ? 1 : 0) ? -r : r) ? 0 < 1 / r ? j = 0 : j = 2147483648 : isNaN(r) ? j = 2147483647 : 34028234663852886e22 < r ? j = (n << 31 | 2139095040) >>> 0 : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), j = (n << 31 | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, j = (n << 31 | t + 127 << 23 | 8388607 & r) >>> 0), n = j, e.push(n >>> 0 & 255), e.push(n >>> 8 & 255), e.push(n >>> 16 & 255), e.push(n >>> 24 & 255) } } H.prototype.push = function (e) { if (!(this.h + 1 < this.g.length)) { var t = this.g; this.g = new Uint8Array(Math.ceil(1 + 2 * this.g.length)), this.g.set(t) } this.g[this.h++] = e }, H.prototype.length = function () { return this.h }, H.prototype.end = function () { var e = this.g, t = this.h; return this.h = 0, L(e, 0, t) }, Y.prototype.reset = function () { this.g.reset(), this.h = this.l = -1 }; var oe = "function" == typeof Uint8Array; function se(e, t, n) { if (null != e) return "object" == typeof e ? oe && e instanceof Uint8Array ? n(e) : ue(e, t, n) : t(e) } function ue(e, t, n) { if (Array.isArray(e)) { for (var r = Array(e.length), i = 0; i < e.length; i++)r[i] = se(e[i], t, n); return Array.isArray(e) && e.W && de(r), r } for (i in r = {}, e) r[i] = se(e[i], t, n); return r } function le(e) { return "number" == typeof e ? isFinite(e) ? e : String(e) : e } var ce, he = { W: { value: !0, configurable: !0 } }; function de(e) { return Array.isArray(e) && !Object.isFrozen(e) && Object.defineProperties(e, he), e } function fe(e, t, n) { var r = ce; if (ce = null, e || (e = r), r = this.constructor.ca, e || (e = r ? [r] : []), this.j = r ? 0 : -1, this.m = this.g = null, this.h = e, e = (r = this.h.length) - 1, !r || (null === (r = this.h[e]) || "object" != typeof r || Array.isArray(r) || oe && r instanceof Uint8Array) ? void 0 !== t && -1 < t ? (this.l = Math.max(t, e + 1 - this.j), this.i = null) : this.l = Number.MAX_VALUE : (this.l = e - this.j, this.i = r), n) for (t = 0; t < n.length; t++)(e = n[t]) < this.l ? (e += this.j, (r = this.h[e]) ? de(r) : this.h[e] = pe) : (me(this), (r = this.i[e]) ? de(r) : this.i[e] = pe) } var pe = Object.freeze(de([])); function me(e) { var t = e.l + e.j; e.h[t] || (e.i = e.h[t] = {}) } function ge(e, t, n) { return -1 === t ? null : void 0 !== n && n || t >= e.l ? e.i ? e.i[t] : void 0 : e.h[t + e.j] } function ye(e, t) { var n = void 0 !== n && n, r = ge(e, t, n); return null == r && (r = pe), r === pe && we(e, t, r = de([]), n), r } function be(e) { var t = ye(e, 3); if (e.m || (e.m = {}), !e.m[3]) { for (var n = 0; n < t.length; n++)t[n] = +t[n]; e.m[3] = !0 } return t } function ve(e, t, n) { return null == (e = ge(e, t)) ? n : e } function xe(e, t, n) { return null == (e = null == (e = ge(e, t)) ? e : +e) ? void 0 === n ? 0 : n : e } function we(e, t, n, r) { void 0 !== r && r || t >= e.l ? (me(e), e.i[t] = n) : e.h[t + e.j] = n } function ke(e, t, n) { if (-1 === n) return null; if (e.g || (e.g = {}), !e.g[n]) { var r = ge(e, n, !1); r && (e.g[n] = new t(r)) } return e.g[n] } function Se(e, t) { e.g || (e.g = {}); var n = e.g[1]; if (!n) { var r = ye(e, 1); n = []; for (var i = 0; i < r.length; i++)n[i] = new t(r[i]); e.g[1] = n } return n } function _e(e, t, n) { var r = void 0 !== r && r; e.g || (e.g = {}); var i = n ? Ae(n, !1) : n; e.g[t] = n, we(e, t, i, r) } function Ce(e, t, n, r) { var i = Se(e, n); t = t || new n, e = ye(e, 1), null != r ? (i.splice(r, 0, t), e.splice(r, 0, Ae(t, !1))) : (i.push(t), e.push(Ae(t, !1))) } function Ae(e, t) { if (e.g) for (var n in e.g) { var r = e.g[n]; if (Array.isArray(r)) for (var i = 0; i < r.length; i++)r[i] && Ae(r[i], t); else r && Ae(r, t) } return e.h } function Te(e, t) { if (e = e.o) { re(t, t.g.end()); for (var n = 0; n < e.length; n++)re(t, e[n]) } } function Ee(e, t) { if (4 == t.h) return !1; var n = t.m; return K(t), t.N || (t = L(t.g.h, n, t.g.g), (n = e.o) ? n.push(t) : e.o = [t]), !0 } function Ne(e) { fe.call(this, e, -1, Me) } function Ie(e, t) { for (; X(t);)switch (t.i) { case 8: var n = t.g.i(); we(e, 1, n); break; case 16: we(e, 2, n = t.g.i()); break; case 29: case 26: te(t, e.getPackedDataList()); break; case 32: we(e, 4, n = V(t.g)); break; default: if (!Ee(e, t)) return e }return e } fe.prototype.toJSON = function () { return ue(Ae(this, !1), le, R) }, fe.prototype.toString = function () { return Ae(this, !1).toString() }, p(Ne, fe), Ne.prototype.getRows = function () { return ge(this, 1) }, Ne.prototype.getCols = function () { return ge(this, 2) }, Ne.prototype.getPackedDataList = function () { return be(this) }, Ne.prototype.getLayout = function () { return ve(this, 4, 0) }; var Me = [3]; function Fe(e, t) { var n = void 0; return new (n || (n = Promise))((function (r, i) { function a(e) { try { s(t.next(e)) } catch (e) { i(e) } } function o(e) { try { s(t.throw(e)) } catch (e) { i(e) } } function s(e) { e.done ? r(e.value) : new n((function (t) { t(e.value) })).then(a, o) } s((t = t.apply(e, void 0)).next()) })) } function De(e) { fe.call(this, e) } function $e(e, t) { for (; X(t);)switch (t.i) { case 8: var n = t.g.i(); we(e, 1, n); break; case 21: we(e, 2, n = J(t)); break; case 26: we(e, 3, n = Q(t)); break; case 34: we(e, 4, n = Q(t)); break; default: if (!Ee(e, t)) return e }return e } function Re(e) { fe.call(this, e, -1, Oe) } p(De, fe), p(Re, fe), Re.prototype.addClassification = function (e, t) { return Ce(this, e, De, t), this }; var Oe = [1]; function ze(e) { fe.call(this, e) } function Pe(e, t) { for (; X(t);)switch (t.i) { case 13: var n = J(t); we(e, 1, n); break; case 21: we(e, 2, n = J(t)); break; case 29: we(e, 3, n = J(t)); break; case 37: we(e, 4, n = J(t)); break; case 45: we(e, 5, n = J(t)); break; default: if (!Ee(e, t)) return e }return e } function Be(e) { fe.call(this, e, -1, je) } function Le(e) { e: { var t = new Be; for (e = new Y(e); X(e);)if (10 === e.i) { Ce(t, Z(e, new ze, Pe), ze, void 0) } else if (!Ee(t, e)) break e } return t } p(ze, fe), p(Be, fe); var je = [1]; function Ue(e) { fe.call(this, e) } function We(e) { fe.call(this, e, -1, Ge) } function Ve(e, t) { for (; X(t);)switch (t.i) { case 8: var n = V(t.g); we(e, 1, n); break; case 16: we(e, 2, n = V(t.g)); break; case 29: case 26: te(t, e.getVertexBufferList()); break; case 32: case 34: n = t; var r = e.getIndexBufferList(); 2 == n.h ? ee(n, U.prototype.i, r) : r.push(n.g.i()); break; default: if (!Ee(e, t)) return e }return e } p(Ue, fe), p(We, fe), We.prototype.getVertexType = function () { return ve(this, 1, 0) }, We.prototype.getPrimitiveType = function () { return ve(this, 2, 0) }, We.prototype.getVertexBufferList = function () { return be(this) }, We.prototype.getIndexBufferList = function () { return ye(this, 4) }; var Ge = [3, 4]; function He(e) { fe.call(this, e) } function qe(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function Ye(e) { return Se(e, De).map((function (e) { return { index: ve(e, 1, 0), Y: xe(e, 2), label: null != ge(e, 3) ? ve(e, 3, "") : void 0, displayName: null != ge(e, 4) ? ve(e, 4, "") : void 0 } })) } function Xe(e) { return { x: xe(e, 1), y: xe(e, 2), z: xe(e, 3), visibility: null != ge(e, 4) ? xe(e, 4) : void 0 } } function Ke(e, t) { this.h = e, this.g = t, this.l = 0 } function Ze(e, t, n) { return function (e, t) { var n = e.g; if (void 0 === e.m) { var r = qe(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = qe(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.m = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.j = { I: n.getAttribLocation(r, "aVertex"), H: n.getAttribLocation(r, "aTex"), da: i }, e.s = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.enableVertexAttribArray(e.j.I), n.vertexAttribPointer(e.j.I, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.o = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.o), n.enableVertexAttribArray(e.j.H), n.vertexAttribPointer(e.j.H, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.j, n.useProgram(e.m), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.h.bindTexture2d(t.glName), n.enableVertexAttribArray(r.I), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.vertexAttribPointer(r.I, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.H), n.bindBuffer(n.ARRAY_BUFFER, e.o), n.vertexAttribPointer(r.H, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.I), n.disableVertexAttribArray(r.H), n.bindBuffer(n.ARRAY_BUFFER, null), e.h.bindTexture2d(0) }(e, t), "function" == typeof e.g.canvas.transferToImageBitmap ? Promise.resolve(e.g.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.g.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.g.canvas) : (void 0 === e.i && (e.i = document.createElement("canvas")), new Promise((function (t) { e.i.height = e.g.canvas.height, e.i.width = e.g.canvas.width, e.i.getContext("2d", {}).drawImage(e.g.canvas, 0, 0, e.g.canvas.width, e.g.canvas.height), t(e.i) }))) } function Je(e) { this.g = e } p(He, fe), He.prototype.getMesh = function () { return ke(this, We, 1) }, He.prototype.getPoseTransformMatrix = function () { return ke(this, Ne, 2) }; var Qe = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function et(e, t) { return t + e } function tt(e, t) { window[e] = t } function nt(e) { if (this.g = e, this.listeners = {}, this.j = {}, this.F = {}, this.m = {}, this.s = {}, this.G = this.o = this.R = !0, this.C = Promise.resolve(), this.P = "", this.B = {}, this.locateFile = e && e.locateFile || et, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.S = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.j[n] = "function" == typeof r ? r() : r) } } function rt(e) { return Fe(e, (function e() { var t, n, r, i, a, o, s, l, c, h, d, f = this; return S(e, (function (e) { switch (e.g) { case 1: return t = f, f.R ? (n = function (e, t) { return void 0 === e.g.files ? [] : "function" == typeof e.g.files ? e.g.files(t) : e.g.files }(f, f.j), b(e, function () { return Fe(this, (function e() { return S(e, (function (e) { switch (e.g) { case 1: return e.m = 2, b(e, WebAssembly.instantiate(Qe), 4); case 4: e.g = 3, e.m = 0; break; case 2: return e.m = 0, e.j = null, e.return(!1); case 3: return e.return(!0) } })) })) }(), 2)) : e.return(); case 2: if (r = e.h, "object" == typeof window) return tt("createMediapipeSolutionsWasm", { locateFile: f.locateFile }), tt("createMediapipeSolutionsPackedAssets", { locateFile: f.locateFile }), o = n.filter((function (e) { return void 0 !== e.data })), s = n.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (e) { var n = it(t, e.url); if (void 0 !== e.path) { var r = e.path; n = n.then((function (e) { return t.overrideFile(r, e), Promise.resolve(e) })) } return n }))), c = Promise.all(s.map((function (e) { return void 0 === e.simd || e.simd && r || !e.simd && !r ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(t.locateFile(e.url, t.S)) : Promise.resolve() }))).then((function () { return Fe(t, (function e() { var t, n, r = this; return S(e, (function (e) { if (1 == e.g) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, b(e, t(n), 2); r.h = e.h, e.g = 0 })) })) })), h = Fe(t, (function e() { var t = this; return S(e, (function (e) { return t.g.graph && t.g.graph.url ? e = b(e, it(t, t.g.graph.url), 0) : (e.g = 0, e = void 0), e })) })), b(e, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return i = n.filter((function (e) { return void 0 === e.simd || e.simd && r || !e.simd && !r })).map((function (e) { return t.locateFile(e.url, t.S) })), importScripts.apply(null, u(i)), b(e, createMediapipeSolutionsWasm(Module), 6); case 6: f.h = e.h, f.l = new OffscreenCanvas(1, 1), f.h.canvas = f.l, a = f.h.GL.createContext(f.l, { antialias: !1, alpha: !1, ba: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), f.h.GL.makeContextCurrent(a), e.g = 4; break; case 7: if (f.l = document.createElement("canvas"), !(d = f.l.getContext("webgl2", {})) && !(d = f.l.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), e.return(); f.D = d, f.h.canvas = f.l, f.h.createContext(f.l, !0, !0, {}); case 4: f.i = new f.h.SolutionWasm, f.R = !1, e.g = 0 } })) })) } function it(e, t) { return Fe(e, (function e() { var n, r, i = this; return S(e, (function (e) { return t in i.F ? e.return(i.F[t]) : (n = i.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), i.F[t] = r, e.return(r)) })) })) } function at(e, t, n) { return Fe(e, (function e() { var r, i, a, o, u, l, c, h, d, f, p, m, g, y, v = this; return S(e, (function (e) { switch (e.g) { case 1: if (!n) return e.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (v.G = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { e.g = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, b(e, function (e, t, n) { return Fe(e, (function e() { var r, i = this; return S(e, (function (e) { return "number" == typeof n || n instanceof Uint8Array || n instanceof i.h.Uint8BlobList ? e.return(n) : n instanceof i.h.Texture2dDataOut ? ((r = i.s[t]) || (r = new Ke(i.h, i.D), i.s[t] = r), e.return(Ze(r, n, i.G))) : e.return(void 0) })) })) }(v, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), _ = [], C = 0; C < x.size(); ++C) { var A = x.get(C); e: { var T = new Ue; for (A = new Y(A); X(A);)switch (A.i) { case 13: var E = J(A); we(T, 1, E); break; case 21: we(T, 2, E = J(A)); break; case 29: we(T, 3, E = J(A)); break; case 37: we(T, 4, E = J(A)); break; case 45: we(T, 5, E = J(A)); break; case 48: we(T, 6, E = V(A.g)); break; default: if (!Ee(T, A)) break e } } T = { Z: xe(T, 1), $: xe(T, 2), height: xe(T, 3), width: xe(T, 4), rotation: xe(T, 5, 0), X: ve(T, 6, 0) }, A = Se(Le(w.get(C)), ze).map(Xe); var N = k.get(C); e: for (E = new Re, N = new Y(N); X(N);)if (10 === N.i) E.addClassification(Z(N, new De, $e)); else if (!Ee(E, N)) break e; T = { T, O: A, M: Ye(E) }, _.push(T) } x = _ } else x = []; r[h] = x, e.g = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, e.g = 7; break } if (void 0 === f) { e.g = 3; break } if ("float_list" === d.type) { r[h] = f, e.g = 7; break } if ("proto" === d.type) { r[h] = f, e.g = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = v.s[h]) || (p = new Ke(v.h, v.D), v.s[h] = p), b(e, Ze(p, f, v.G), 13); case 13: m = e.h, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), e.g = 3; break; case 14: g[y] = e.h; case 3: o = c.next(), e.g = 2; break; case 4: return e.return(r) } })) })) } function ot(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.h.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.h.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.C = at(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.C = n) }))) } }), e.i.attachMultiListener(i, a), i.delete() } function st(e) { e = function (e) { e: { var t = new He; for (e = new Y(e); X(e);)switch (e.i) { case 10: var n = Z(e, new We, Ve); _e(t, 1, n); break; case 18: _e(t, 2, n = Z(e, new Ne, Ie)); break; default: if (!Ee(t, e)) break e } } return t }(e); var t = e.getMesh(); if (!t) return e; var n = new Float32Array(t.getVertexBufferList()); t.getVertexBufferList = function () { return n }; var r = new Uint32Array(t.getIndexBufferList()); return t.getIndexBufferList = function () { return r }, e } (e = nt.prototype).close = function () { return this.i && this.i.delete(), Promise.resolve() }, e.reset = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { t.i && (t.i.reset(), t.m = {}, t.s = {}), e.g = 0 })) })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.g.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { K: a.K, L: a.L }, u = o.next()) { var l = u.value; l in this.j && this.j[l] === e[l] || (this.j[l] = e[l], void 0 !== (u = t[l]) && (u.onChange && (a.K = u.onChange, a.L = e[l], r.push(function (e) { return function () { return Fe(n, (function t() { var n = this; return S(t, (function (t) { if (1 == t.g) return b(t, e.K(e.L), 2); !0 === t.h && (n.o = !0), t.g = 0 })) })) } }(a))), u.graphOptionXref && (l = { valueNumber: 1 === u.type ? e[l] : 0, valueBoolean: 0 === u.type && e[l], valueString: 2 === u.type ? e[l] : "" }, u = Object.assign(Object.assign(Object.assign({}, { calculatorName: "", calculatorIndex: 0 }), u.graphOptionXref), l), i.push(u)))) } 0 === r.length && 0 === i.length || (this.o = !0, this.A = (void 0 === this.A ? [] : this.A).concat(i), this.u = (void 0 === this.u ? [] : this.u).concat(r)) } }, e.initialize = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { return 1 == e.g ? b(e, rt(t), 2) : 3 != e.g ? b(e, Fe(t, (function e() { var t, n, r, i, a, o, u, l, c = this; return S(e, (function (e) { if (1 == e.g) return c.g.graph && c.g.graph.url && c.P === c.g.graph.url ? e.return() : (c.o = !0, c.g.graph && c.g.graph.url ? (c.P = c.g.graph.url, b(e, it(c, c.g.graph.url), 3)) : void (e.g = 2)); for (2 != e.g && (t = e.h, c.i.loadGraph(t)), n = s(Object.keys(c.B)), r = n.next(); !r.done; r = n.next())i = r.value, c.i.overrideFile(i, c.B[i]); if (c.B = {}, c.g.listeners) for (a = s(c.g.listeners), o = a.next(); !o.done; o = a.next())u = o.value, ot(c, u); l = c.j, c.j = {}, c.setOptions(l), e.g = 0 })) })), 3) : b(e, function (e) { return Fe(e, (function e() { var t, n, r, i, a, o, u = this; return S(e, (function (e) { switch (e.g) { case 1: if (!u.o) return e.return(); if (!u.u) { e.g = 2; break } t = s(u.u), n = t.next(); case 3: if (n.done) { e.g = 5; break } return b(e, (0, n.value)(), 4); case 4: n = t.next(), e.g = 3; break; case 5: u.u = void 0; case 2: if (u.A) { for (r = new u.h.GraphOptionChangeRequestList, i = s(u.A), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); u.i.changeOptions(r), r.delete(), u.A = void 0 } u.o = !1, e.g = 0 } })) })) }(t), 0) })) })) }, e.overrideFile = function (e, t) { this.i ? this.i.overrideFile(e, t) : this.B[e] = t }, e.clearOverriddenFiles = function () { this.B = {}, this.i && this.i.clearOverriddenFiles() }, e.send = function (e, t) { return Fe(this, (function n() { var r, i, a, o, u, l, c, h, d, f = this; return S(n, (function (n) { switch (n.g) { case 1: return f.g.inputs ? (r = 1e3 * (null == t ? performance.now() : t), b(n, f.C, 2)) : n.return(); case 2: return b(n, f.initialize(), 3); case 3: for (i = new f.h.PacketDataList, a = s(Object.keys(e)), o = a.next(); !o.done; o = a.next())if (u = o.value, l = f.g.inputs[u]) { e: { var p = f, m = e[u]; switch (l.type) { case "video": var g = p.m[l.stream]; if (g || (g = new Ke(p.h, p.D), p.m[l.stream] = g), 0 === (p = g).l && (p.l = p.h.createTexture()), "undefined" != typeof HTMLVideoElement && m instanceof HTMLVideoElement) { var y = m.videoWidth; g = m.videoHeight } else "undefined" != typeof HTMLImageElement && m instanceof HTMLImageElement ? (y = m.naturalWidth, g = m.naturalHeight) : (y = m.width, g = m.height); g = { glName: p.l, width: y, height: g }, (y = p.g).canvas.width = g.width, y.canvas.height = g.height, y.activeTexture(y.TEXTURE0), p.h.bindTexture2d(p.l), y.texImage2D(y.TEXTURE_2D, 0, y.RGBA, y.RGBA, y.UNSIGNED_BYTE, m), p.h.bindTexture2d(0), p = g; break e; case "detections": for ((g = p.m[l.stream]) || (g = new Je(p.h), p.m[l.stream] = g), (p = g).data || (p.data = new p.g.DetectionListData), p.data.reset(m.length), g = 0; g < m.length; ++g) { y = m[g]; var v = p.data, x = v.setBoundingBox, w = g, k = y.T, S = new Ue; we(S, 1, k.Z), we(S, 2, k.$), we(S, 3, k.height), we(S, 4, k.width), we(S, 5, k.rotation), we(S, 6, k.X); var _ = k = new ne; ae(_, 1, ge(S, 1)), ae(_, 2, ge(S, 2)), ae(_, 3, ge(S, 3)), ae(_, 4, ge(S, 4)), ae(_, 5, ge(S, 5)); var C = ge(S, 6); if (null != C && null != C) { q(_.g, 48); var A = _.g, T = C; C = 0 > T; var E = (T = Math.abs(T)) >>> 0; for (T = Math.floor((T - E) / 4294967296), T >>>= 0, C && (T = ~T >>> 0, 4294967295 < (E = 1 + (~E >>> 0)) && (E = 0, 4294967295 < ++T && (T = 0))), C = j = E, E = T; 0 < E || 127 < C;)A.push(127 & C | 128), C = (C >>> 7 | E << 25) >>> 0, E >>>= 7; A.push(C) } if (Te(S, _), k = ie(k), x.call(v, w, k), y.O) for (v = 0; v < y.O.length; ++v)_ = !!(S = y.O[v]).visibility, w = (x = p.data).addNormalizedLandmark, k = g, S = Object.assign(Object.assign({}, S), { visibility: _ ? S.visibility : 0 }), we(_ = new ze, 1, S.x), we(_, 2, S.y), we(_, 3, S.z), S.visibility && we(_, 4, S.visibility), ae(A = S = new ne, 1, ge(_, 1)), ae(A, 2, ge(_, 2)), ae(A, 3, ge(_, 3)), ae(A, 4, ge(_, 4)), ae(A, 5, ge(_, 5)), Te(_, A), S = ie(S), w.call(x, k, S); if (y.M) for (v = 0; v < y.M.length; ++v) { if (w = (x = p.data).addClassification, k = g, S = y.M[v], we(_ = new De, 2, S.Y), S.index && we(_, 1, S.index), S.label && we(_, 3, S.label), S.displayName && we(_, 4, S.displayName), A = S = new ne, null != (E = ge(_, 1)) && null != E) if (q(A.g, 8), C = A.g, 0 <= E) q(C, E); else { for (T = 0; 9 > T; T++)C.push(127 & E | 128), E >>= 7; C.push(1) } ae(A, 2, ge(_, 2)), null != (C = ge(_, 3)) && (C = F(C), q(A.g, 26), q(A.g, C.length), re(A, A.g.end()), re(A, C)), null != (C = ge(_, 4)) && (C = F(C), q(A.g, 34), q(A.g, C.length), re(A, A.g.end()), re(A, C)), Te(_, A), S = ie(S), w.call(x, k, S) } } p = p.data; break e; default: p = {} } } switch (c = p, h = l.stream, l.type) { case "video": i.pushTexture2d(Object.assign(Object.assign({}, c), { stream: h, timestamp: r })); break; case "detections": (d = c).stream = h, d.timestamp = r, i.pushDetectionList(d); break; default: throw Error("Unknown input config type: '" + l.type + "'") } } return f.i.send(i), b(n, f.C, 4); case 4: i.delete(), n.g = 0 } })) })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, A("Solution", nt), A("OptionType", { BOOL: 0, NUMBER: 1, aa: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }); var ut = { files: [{ url: "face_mesh_solution_packed_assets_loader.js" }, { simd: !0, url: "face_mesh_solution_simd_wasm_bin.js" }, { simd: !1, url: "face_mesh_solution_wasm_bin.js" }], graph: { url: "face_mesh.binarypb" }, listeners: [{ wants: ["multi_face_geometry", "image_transformed", "multi_face_landmarks"], outs: { image: "image_transformed", multiFaceGeometry: { type: "proto_list", stream: "multi_face_geometry", transform: function (e) { return e.map(st) } }, multiFaceLandmarks: { type: "proto_list", stream: "multi_face_landmarks", transform: function (e) { return e.map((function (e) { return Se(Le(e), ze).map(Xe) })) } } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document }, enableFaceGeometry: { type: 0, graphOptionXref: { calculatorName: "EnableFaceGeometryConstant", calculatorType: "ConstantSidePacketCalculator", fieldName: "bool_value" } }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, maxNumFaces: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorNumFaces", fieldName: "int_value" } }, refineLandmarks: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorRefineLandmarks", fieldName: "bool_value" } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "facelandmarkfrontgpu__facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "facelandmarkfrontgpu__facelandmarkgpu__ThresholdingCalculator", fieldName: "threshold" } }, cameraNear: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "near" } }, cameraFar: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "far" } }, cameraVerticalFovDegrees: { type: 1, graphOptionXref: { calculatorType: "FaceGeometryEnvGeneratorCalculator", fieldName: "vertical_fov_degrees" } } } }, lt = [[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]], ct = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]], ht = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]], dt = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]], ft = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]], pt = [[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]], mt = [].concat(u(lt), u(ct), u(ht), u(dt), u(ft), u(pt)); function gt(e) { e = e || {}, e = Object.assign(Object.assign({}, ut), e), this.g = new nt(e) } (e = gt.prototype).close = function () { return this.g.close(), Promise.resolve() }, e.onResults = function (e) { this.g.onResults(e) }, e.initialize = function () { return Fe(this, (function e() { var t = this; return S(e, (function (e) { return b(e, t.g.initialize(), 0) })) })) }, e.reset = function () { this.g.reset() }, e.send = function (e) { return Fe(this, (function t() { var n = this; return S(t, (function (t) { return b(t, n.g.send(e), 0) })) })) }, e.setOptions = function (e) { this.g.setOptions(e) }, A("FACE_GEOMETRY", { Layout: { COLUMN_MAJOR: 0, ROW_MAJOR: 1, 0: "COLUMN_MAJOR", 1: "ROW_MAJOR" }, PrimitiveType: { TRIANGLE: 0, 0: "TRIANGLE" }, VertexType: { VERTEX_PT: 0, 0: "VERTEX_PT" }, DEFAULT_CAMERA_PARAMS: { verticalFovDegrees: 63, near: 1, far: 1e4 } }), A("FaceMesh", gt), A("FACEMESH_LIPS", lt), A("FACEMESH_LEFT_EYE", ct), A("FACEMESH_LEFT_EYEBROW", ht), A("FACEMESH_LEFT_IRIS", [[474, 475], [475, 476], [476, 477], [477, 474]]), A("FACEMESH_RIGHT_EYE", dt), A("FACEMESH_RIGHT_EYEBROW", ft), A("FACEMESH_RIGHT_IRIS", [[469, 470], [470, 471], [471, 472], [472, 469]]), A("FACEMESH_FACE_OVAL", pt), A("FACEMESH_CONTOURS", mt), A("FACEMESH_TESSELATION", [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]]), A("matrixDataToMatrix", (function (e) { for (var t = e.getCols(), n = e.getRows(), r = e.getPackedDataList(), i = [], a = 0; a < n; a++)i.push(Array(t)); for (a = 0; a < n; a++)for (var o = 0; o < t; o++) { var s = 1 === e.getLayout() ? a * t + o : o * n + a; i[a][o] = r[s] } return i })), A("VERSION", "0.4.1633559619") }).call(this) }, 8554: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.ya = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.qa; o || (i.J = a.wa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.qa = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.va) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, score: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e) { return e.map((function (e) { return Ke(Jt(e), Yt, 1).map(an) })) } function sn(e, t) { this.i = e, this.h = t, this.m = 0 } function un(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), xa: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function ln(e) { this.h = e } Qt.prototype.l = Ut(en); var cn = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function hn(e, t) { return t + e } function dn(e, t) { window[e] = t } function fn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || hn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function pn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(cn), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return dn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), dn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = mn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, mn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, ua: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function mn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function gn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new sn(e.i, e.K), e.v[t] = r), i.return(un(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { ra: et(A, 1), sa: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: Ke(Jt(w.get(C)), Yt, 1).map(an), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new sn(e.i, e.K), e.v[h] = p), v(b, un(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function yn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = gn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function bn(e) { return void 0 === e && (e = 0), 1 === e ? "hand_landmark_full.tflite" : "hand_landmark_lite.tflite" } function vn(e) { var t = this; e = e || {}, this.h = new fn({ locateFile: e.locateFile, files: function (e) { return [{ url: "hands_solution_packed_assets_loader.js" }, { simd: !1, url: "hands_solution_wasm_bin.js" }, { simd: !0, url: "hands_solution_simd_wasm_bin.js" }, { data: !0, url: bn(e.modelComplexity) }] }, graph: { url: "hands.binarypb" }, inputs: { image: { type: "video", stream: "input_frames_gpu" } }, listeners: [{ wants: ["multi_hand_landmarks", "multi_hand_world_landmarks", "image_transformed", "multi_handedness"], outs: { image: "image_transformed", multiHandLandmarks: { type: "proto_list", stream: "multi_hand_landmarks", transform: on }, multiHandWorldLandmarks: { type: "proto_list", stream: "multi_hand_world_landmarks", transform: on }, multiHandedness: { type: "proto_list", stream: "multi_handedness", transform: function (e) { return e.map((function (e) { return rn(qt(e))[0] })) } } } }], options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, maxNumHands: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculator", fieldName: "int_value" } }, modelComplexity: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelComplexity", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = bn(e), r = "third_party/mediapipe/modules/hand_landmark/" + n, v(a, mn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "handlandmarktrackinggpu__palmdetectiongpu__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "handlandmarktrackinggpu__handlandmarkgpu__ThresholdingCalculator", fieldName: "threshold" } } } }) } (e = fn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, pn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, mn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, yn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new sn(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new ln(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.ra), Ze(S, 2, k.sa), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.score), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", fn), T("OptionType", { BOOL: 0, NUMBER: 1, ta: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = vn.prototype).close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.reset = function () { this.h.reset() }, e.send = function (e) { var t = this; return _((function (n) { return v(n, t.h.send(e), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("Hands", vn), T("HAND_CONNECTIONS", [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [5, 9], [9, 10], [10, 11], [11, 12], [9, 13], [13, 14], [14, 15], [15, 16], [13, 17], [0, 17], [17, 18], [18, 19], [19, 20]]), T("VERSION", "0.4.1675469240") }).call(this) }, 3242: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.za = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ra; o || (i.J = a.xa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.ra = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.wa) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, qa: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e) { return Ke(Jt(e), Yt, 1).map(an) } function sn(e, t) { this.i = e, this.h = t, this.m = 0 } function un(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), ya: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function ln(e) { this.h = e } Qt.prototype.l = Ut(en); var cn = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function hn(e, t) { return t + e } function dn(e, t) { window[e] = t } function fn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || hn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function pn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(cn), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return dn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), dn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = mn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, mn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, va: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function mn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function gn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new sn(e.i, e.K), e.v[t] = r), i.return(un(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { sa: et(A, 1), ta: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: on(w.get(C)), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new sn(e.i, e.K), e.v[h] = p), v(b, un(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function yn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = gn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function bn(e) { switch (void 0 === e && (e = 0), e) { case 1: return "pose_landmark_full.tflite"; case 2: return "pose_landmark_heavy.tflite"; default: return "pose_landmark_lite.tflite" } } function vn(e) { var t = this; e = e || {}, this.h = new fn({ locateFile: e.locateFile, files: function (e) { return [{ url: "pose_solution_packed_assets_loader.js" }, { simd: !1, url: "pose_solution_wasm_bin.js" }, { simd: !0, url: "pose_solution_simd_wasm_bin.js" }, { data: !0, url: bn(e.modelComplexity) }] }, graph: { url: "pose_web.binarypb" }, listeners: [{ wants: ["pose_landmarks", "world_landmarks", "segmentation_mask", "image_transformed"], outs: { image: { type: "texture", stream: "image_transformed" }, poseLandmarks: { type: "proto", stream: "pose_landmarks", transform: on }, poseWorldLandmarks: { type: "proto", stream: "world_landmarks", transform: on }, segmentationMask: { type: "texture", stream: "segmentation_mask" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, modelComplexity: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelComplexity", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = bn(e), r = "third_party/mediapipe/modules/pose_landmark/" + n, v(a, mn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } }, smoothLandmarks: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorSmoothLandmarks", fieldName: "bool_value" } }, enableSegmentation: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorEnableSegmentation", fieldName: "bool_value" } }, smoothSegmentation: { type: 0, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorSmoothSegmentation", fieldName: "bool_value" } }, minDetectionConfidence: { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "poselandmarkgpu__posedetectiongpu__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }, minTrackingConfidence: { type: 1, graphOptionXref: { calculatorType: "ThresholdingCalculator", calculatorName: "poselandmarkgpu__poselandmarkbyroigpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator", fieldName: "threshold" } } } }) } (e = fn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, pn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, mn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, yn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new sn(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new ln(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.sa), Ze(S, 2, k.ta), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.qa), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", fn), T("OptionType", { BOOL: 0, NUMBER: 1, ua: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = vn.prototype).reset = function () { this.h.reset() }, e.close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.send = function (e, t) { var n = this; return _((function (r) { return v(r, n.h.send(e, t), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("Pose", vn), T("POSE_CONNECTIONS", [[0, 1], [1, 2], [2, 3], [3, 7], [0, 4], [4, 5], [5, 6], [6, 8], [9, 10], [11, 12], [11, 13], [13, 15], [15, 17], [15, 19], [15, 21], [17, 19], [12, 14], [14, 16], [16, 18], [16, 20], [16, 22], [18, 20], [11, 23], [12, 24], [23, 24], [23, 25], [24, 26], [25, 27], [26, 28], [27, 29], [28, 30], [29, 31], [30, 32], [27, 31], [28, 32]]), T("POSE_LANDMARKS", { NOSE: 0, LEFT_EYE_INNER: 1, LEFT_EYE: 2, LEFT_EYE_OUTER: 3, RIGHT_EYE_INNER: 4, RIGHT_EYE: 5, RIGHT_EYE_OUTER: 6, LEFT_EAR: 7, RIGHT_EAR: 8, LEFT_RIGHT: 9, RIGHT_LEFT: 10, LEFT_SHOULDER: 11, RIGHT_SHOULDER: 12, LEFT_ELBOW: 13, RIGHT_ELBOW: 14, LEFT_WRIST: 15, RIGHT_WRIST: 16, LEFT_PINKY: 17, RIGHT_PINKY: 18, LEFT_INDEX: 19, RIGHT_INDEX: 20, LEFT_THUMB: 21, RIGHT_THUMB: 22, LEFT_HIP: 23, RIGHT_HIP: 24, LEFT_KNEE: 25, RIGHT_KNEE: 26, LEFT_ANKLE: 27, RIGHT_ANKLE: 28, LEFT_HEEL: 29, RIGHT_HEEL: 30, LEFT_FOOT_INDEX: 31, RIGHT_FOOT_INDEX: 32 }), T("POSE_LANDMARKS_LEFT", { LEFT_EYE_INNER: 1, LEFT_EYE: 2, LEFT_EYE_OUTER: 3, LEFT_EAR: 7, LEFT_RIGHT: 9, LEFT_SHOULDER: 11, LEFT_ELBOW: 13, LEFT_WRIST: 15, LEFT_PINKY: 17, LEFT_INDEX: 19, LEFT_THUMB: 21, LEFT_HIP: 23, LEFT_KNEE: 25, LEFT_ANKLE: 27, LEFT_HEEL: 29, LEFT_FOOT_INDEX: 31 }), T("POSE_LANDMARKS_RIGHT", { RIGHT_EYE_INNER: 4, RIGHT_EYE: 5, RIGHT_EYE_OUTER: 6, RIGHT_EAR: 8, RIGHT_LEFT: 10, RIGHT_SHOULDER: 12, RIGHT_ELBOW: 14, RIGHT_WRIST: 16, RIGHT_PINKY: 18, RIGHT_INDEX: 20, RIGHT_THUMB: 22, RIGHT_HIP: 24, RIGHT_KNEE: 26, RIGHT_ANKLE: 28, RIGHT_HEEL: 30, RIGHT_FOOT_INDEX: 32 }), T("POSE_LANDMARKS_NEUTRAL", { NOSE: 0 }), T("VERSION", "0.5.1675469404") }).call(this) }, 9958: function (e, t, n) { (function () { "use strict"; var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var r = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }; var i = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof n.g && n.g]; for (var t = 0; t < e.length; ++t) { var r = e[t]; if (r && r.Math == Math) return r } throw Error("Cannot find global object") }(this); function a(e, t) { if (t) e: { var n = i; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in n)) break e; n = n[o] } (t = t(a = n[e = e[e.length - 1]])) != a && null != t && r(n, e, { configurable: !0, writable: !0, value: t }) } } function o(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function s(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function u(e) { if (!(e instanceof Array)) { e = s(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } a("Symbol", (function (e) { function t(e, t) { this.h = e, r(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.h }; var n = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(r) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(n + (r || "") + "_" + i++, r) } })), a("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var n = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), a = 0; a < n.length; a++) { var s = i[n[a]]; "function" == typeof s && "function" != typeof s.prototype[e] && r(s.prototype, e, { configurable: !0, writable: !0, value: function () { return o(t(this)) } }) } return e })); var l = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; a("Object.assign", (function (e) { return e || l })); var c, h = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) c = Object.setPrototypeOf; else { var d; e: { var f = {}; try { f.__proto__ = { a: !0 }, d = f.a; break e } catch (e) { } d = !1 } c = d ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var p = c; function m(e, t) { if (e.prototype = h(t.prototype), e.prototype.constructor = e, p) p(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.za = t.prototype } function g() { this.m = !1, this.j = null, this.i = void 0, this.h = 1, this.v = this.s = 0, this.l = null } function y(e) { if (e.m) throw new TypeError("Generator is already running"); e.m = !0 } function b(e, t) { e.l = { ma: t, na: !0 }, e.h = e.s || e.v } function v(e, t, n) { return e.h = n, { value: t } } function x(e) { this.h = new g, this.i = e } function w(e, t, n, r) { try { var i = t.call(e.h.j, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.h.m = !1, i; var a = i.value } catch (t) { return e.h.j = null, b(e.h, t), k(e) } return e.h.j = null, r.call(e.h, a), k(e) } function k(e) { for (; e.h.h;)try { var t = e.i(e.h); if (t) return e.h.m = !1, { value: t.value, done: !1 } } catch (t) { e.h.i = void 0, b(e.h, t) } if (e.h.m = !1, e.h.l) { if (t = e.h.l, e.h.l = null, t.na) throw t.ma; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function S(e) { this.next = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.next, t, e.h.u) : (e.h.u(t), t = k(e)), t }, this.throw = function (t) { return y(e.h), e.h.j ? t = w(e, e.h.j.throw, t, e.h.u) : (b(e.h, t), t = k(e)), t }, this.return = function (t) { return function (e, t) { y(e.h); var n = e.h.j; return n ? w(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.h.return) : (e.h.return(t), k(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function _(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new S(new x(e))) } function C(e) { return e || Array.prototype.fill } g.prototype.u = function (e) { this.i = e }, g.prototype.return = function (e) { this.l = { return: e }, this.h = this.v }, a("Promise", (function (e) { function t(e) { this.i = 0, this.j = void 0, this.h = [], this.u = !1; var t = this.l(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.h = null } function r(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.i = function (e) { if (null == this.h) { this.h = []; var t = this; this.j((function () { t.m() })) } this.h.push(e) }; var a = i.setTimeout; n.prototype.j = function (e) { a(e, 0) }, n.prototype.m = function () { for (; this.h && this.h.length;) { var e = this.h; this.h = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.l(e) } } } this.h = null }, n.prototype.l = function (e) { this.j((function () { throw e })) }, t.prototype.l = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.I), reject: e(this.m) } }, t.prototype.I = function (e) { if (e === this) this.m(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.L(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.F(e) : this.s(e) } }, t.prototype.F = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.m(e) } "function" == typeof t ? this.M(t, e) : this.s(e) }, t.prototype.m = function (e) { this.v(2, e) }, t.prototype.s = function (e) { this.v(1, e) }, t.prototype.v = function (e, t) { if (0 != this.i) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.i); this.i = e, this.j = t, 2 === this.i && this.K(), this.H() }, t.prototype.K = function () { var e = this; a((function () { if (e.D()) { var t = i.console; void 0 !== t && t.error(e.j) } }), 1) }, t.prototype.D = function () { if (this.u) return !1; var e = i.CustomEvent, t = i.Event, n = i.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = i.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.j, n(e)) }, t.prototype.H = function () { if (null != this.h) { for (var e = 0; e < this.h.length; ++e)o.i(this.h[e]); this.h = null } }; var o = new n; return t.prototype.L = function (e) { var t = this.l(); e.T(t.resolve, t.reject) }, t.prototype.M = function (e, t) { var n = this.l(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.T(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.T = function (e, t) { function n() { switch (r.i) { case 1: e(r.j); break; case 2: t(r.j); break; default: throw Error("Unexpected state: " + r.i) } } var r = this; null == this.h ? o.i(n) : this.h.push(n), this.u = !0 }, t.resolve = r, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var i = s(e), a = i.next(); !a.done; a = i.next())r(a.value).T(t, n) })) }, t.all = function (e) { var n = s(e), i = n.next(); return i.done ? r([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, r(i.value).T(a(o.length - 1), t), i = n.next() } while (!i.done) })) }, t })), a("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })), a("Array.prototype.fill", (function (e) { return e || function (e, t, n) { var r = this.length || 0; for (0 > t && (t = Math.max(0, r + t)), (null == n || n > r) && (n = r), 0 > (n = Number(n)) && (n = Math.max(0, r + n)), t = Number(t || 0); t < n; t++)this[t] = e; return this } })), a("Int8Array.prototype.fill", C), a("Uint8Array.prototype.fill", C), a("Uint8ClampedArray.prototype.fill", C), a("Int16Array.prototype.fill", C), a("Uint16Array.prototype.fill", C), a("Int32Array.prototype.fill", C), a("Uint32Array.prototype.fill", C), a("Float32Array.prototype.fill", C), a("Float64Array.prototype.fill", C), a("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), a("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), a("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })); var A = this || self; function T(e, t) { e = e.split("."); var n, r = A; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function E(e) { var t; return (t = A.navigator) && (t = t.userAgent) || (t = ""), -1 != t.indexOf(e) } var N = Array.prototype.map ? function (e, t) { return Array.prototype.map.call(e, t, void 0) } : function (e, t) { for (var n = e.length, r = Array(n), i = "string" == typeof e ? e.split("") : e, a = 0; a < n; a++)a in i && (r[a] = t.call(void 0, i[a], a, e)); return r }, I = {}, M = null; function F(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = M[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } D(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function D() { if (!M) { M = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); I[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === M[a] && (M[a] = i) } } } } var $ = "undefined" != typeof Uint8Array, R = !(E("Trident") || E("MSIE")) && "function" == typeof A.btoa; function O(e) { if (!R) { var t; void 0 === t && (t = 0), D(), t = I[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } for (t = ""; 10240 < e.length;)t += String.fromCharCode.apply(null, e.subarray(0, 10240)), e = e.subarray(10240); return t += String.fromCharCode.apply(null, e), btoa(t) } var z, P = RegExp("[-_.]", "g"); function B(e) { switch (e) { case "-": return "+"; case "_": return "/"; case ".": return "="; default: return "" } } function L(e) { if (!R) return F(e); P.test(e) && (e = e.replace(P, B)), e = atob(e); for (var t = new Uint8Array(e.length), n = 0; n < e.length; n++)t[n] = e.charCodeAt(n); return t } function j() { return z || (z = new Uint8Array(0)) } var U = {}, W = "function" == typeof Uint8Array.prototype.slice, V = 0, G = 0; function H(e) { var t = 0 > e, n = (e = Math.abs(e)) >>> 0; e = Math.floor((e - n) / 4294967296), t && (t = (n = s(X(n, e))).next().value, e = n.next().value, n = t), V = n >>> 0, G = e >>> 0 } var q, Y = "function" == typeof BigInt; function X(e, t) { return t = ~t, e ? e = 1 + ~e : t += 1, [e, t] } function K(e, t) { this.i = e >>> 0, this.h = t >>> 0 } function Z(e) { if (!e) return q || (q = new K(0, 0)); if (!/^-?\d+$/.test(e)) return null; if (16 > e.length) H(Number(e)); else if (Y) e = BigInt(e), V = Number(e & BigInt(4294967295)) >>> 0, G = Number(e >> BigInt(32) & BigInt(4294967295)); else { var t = +("-" === e[0]); G = V = 0; for (var n = e.length, r = t, i = (n - t) % 6 + t; i <= n; r = i, i += 6)r = Number(e.slice(r, i)), G *= 1e6, 4294967296 <= (V = 1e6 * V + r) && (G += V / 4294967296 | 0, V %= 4294967296); t && (e = (t = s(X(V, G))).next().value, t = t.next().value, V = e, G = t) } return new K(V, G) } function J(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function Q() { return Error("Failed to read varint, encoding is invalid.") } function ee(e, t) { return Error("Tried to read past the end of the data " + t + " > " + e) } function te() { throw Error("Invalid UTF8") } function ne(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var re, ie, ae, oe = void 0, se = "undefined" != typeof TextDecoder, ue = "undefined" != typeof TextEncoder; function le(e) { if (e !== U) throw Error("illegal external caller") } function ce(e, t) { if (le(t), this.V = e, null != e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } function he() { return ae || (ae = new ce(null, U)) } function de(e) { le(U); var t = e.V; return null == (t = null == t || $ && null != t && t instanceof Uint8Array ? t : "string" == typeof t ? L(t) : null) ? t : e.V = t } function fe(e, t) { this.i = null, this.m = !1, this.h = this.j = this.l = 0, pe(this, e, t) } function pe(e, t, n) { n = void 0 === n ? {} : n, e.S = void 0 !== n.S && n.S, t && (t = function (e) { if ("string" == typeof e) return { buffer: L(e), C: !1 }; if (Array.isArray(e)) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === Uint8Array) return { buffer: e, C: !1 }; if (e.constructor === ArrayBuffer) return { buffer: new Uint8Array(e), C: !1 }; if (e.constructor === ce) return { buffer: de(e) || j(), C: !0 }; if (e instanceof Uint8Array) return { buffer: new Uint8Array(e.buffer, e.byteOffset, e.byteLength), C: !1 }; throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, a ByteString or an Array of numbers") }(t), e.i = t.buffer, e.m = t.C, e.l = 0, e.j = e.i.length, e.h = e.l) } function me(e, t) { if (e.h = t, t > e.j) throw ee(e.j, t) } function ge(e) { var t = e.i, n = e.h, r = t[n++], i = 127 & r; if (128 & r && (i |= (127 & (r = t[n++])) << 7, 128 & r && (i |= (127 & (r = t[n++])) << 14, 128 & r && (i |= (127 & (r = t[n++])) << 21, 128 & r && (i |= (r = t[n++]) << 28, 128 & r && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++] && 128 & t[n++]))))) throw Q(); return me(e, n), i } function ye(e, t) { if (0 > t) throw Error("Tried to read a negative byte length: " + t); var n = e.h, r = n + t; if (r > e.j) throw ee(t, e.j - n); return e.h = r, n } fe.prototype.reset = function () { this.h = this.l }; var be = []; function ve() { this.h = [] } function xe(e, t, n) { for (; 0 < n || 127 < t;)e.h.push(127 & t | 128), t = (t >>> 7 | n << 25) >>> 0, n >>>= 7; e.h.push(t) } function we(e, t) { for (; 127 < t;)e.h.push(127 & t | 128), t >>>= 7; e.h.push(t) } function ke(e, t) { if (be.length) { var n = be.pop(); pe(n, e, t), e = n } else e = new fe(e, t); this.h = e, this.j = this.h.h, this.i = this.l = -1, this.setOptions(t) } function Se(e) { var t = e.h; if (t.h == t.j) return !1; e.j = e.h.h; var n = ge(e.h) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw J(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.l = t, e.i = n, !0 } function _e(e) { switch (e.i) { case 0: if (0 != e.i) _e(e); else e: { for (var t = (e = e.h).h, n = t + 10, r = e.i; t < n;)if (!(128 & r[t++])) { me(e, t); break e } throw Q() } break; case 1: me(e = e.h, e.h + 8); break; case 2: 2 != e.i ? _e(e) : (t = ge(e.h) >>> 0, me(e = e.h, e.h + t)); break; case 5: me(e = e.h, e.h + 4); break; case 3: for (t = e.l; ;) { if (!Se(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.i) { if (e.l != t) throw Error("Unmatched end-group tag"); break } _e(e) } break; default: throw J(e.i, e.j) } } ve.prototype.length = function () { return this.h.length }, ve.prototype.end = function () { var e = this.h; return this.h = [], e }, ke.prototype.setOptions = function (e) { e = void 0 === e ? {} : e, this.ca = void 0 !== e.ca && e.ca }, ke.prototype.reset = function () { this.h.reset(), this.j = this.h.h, this.i = this.l = -1 }; var Ce = []; function Ae() { this.j = [], this.i = 0, this.h = new ve } function Te(e, t) { 0 !== t.length && (e.j.push(t), e.i += t.length) } var Ee = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol() : void 0; function Ne(e, t) { return Ee ? e[Ee] |= t : void 0 !== e.A ? e.A |= t : (Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }), t) } function Ie(e, t) { Ee ? e[Ee] && (e[Ee] &= ~t) : void 0 !== e.A && (e.A &= ~t) } function Me(e) { var t; return null == (t = Ee ? e[Ee] : e.A) ? 0 : t } function Fe(e, t) { Ee ? e[Ee] = t : void 0 !== e.A ? e.A = t : Object.defineProperties(e, { A: { value: t, configurable: !0, writable: !0, enumerable: !1 } }) } function De(e) { return Ne(e, 1), e } function $e(e, t) { Fe(t, -51 & e) } function Re(e, t) { Fe(t, -41 & e | 18) } var Oe = {}; function ze(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var Pe, Be, Le = []; function je(e) { if (2 & Me(e.o)) throw Error("Cannot mutate an immutable Message") } function Ue(e) { var t = e.length; (t = t ? e[t - 1] : void 0) && ze(t) ? t.g = 1 : (t = {}, e.push((t.g = 1, t))) } function We(e) { var t = e.i + e.G; return e.B || (e.B = e.o[t] = {}) } function Ve(e, t) { return -1 === t ? null : t >= e.i ? e.B ? e.B[t] : void 0 : e.o[t + e.G] } function Ge(e, t, n, r) { je(e), He(e, t, n, r) } function He(e, t, n, r) { e.j && (e.j = void 0), t >= e.i || r ? We(e)[t] = n : (e.o[t + e.G] = n, (e = e.B) && t in e && delete e[t]) } function qe(e, t, n, r) { var i = Ve(e, t); Array.isArray(i) || (i = Pe); var a = Me(i); if (1 & a || De(i), r) 2 & a || Ne(i, 2), 1 & n || Object.freeze(i); else { r = !(2 & n); var o = 2 & a; 1 & n || !o ? r && 16 & a && !o && Ie(i, 16) : He(e, t, i = De(Array.prototype.slice.call(i))) } return i } function Ye(e, t) { var n = Ve(e, t), r = null == n ? n : "number" == typeof n || "NaN" === n || "Infinity" === n || "-Infinity" === n ? Number(n) : void 0; return null != r && r !== n && He(e, t, r), r } function Xe(e, t, n, r, i) { e.h || (e.h = {}); var a = e.h[n], o = qe(e, n, 3, i); if (!a) { var s = o; a = []; var u = !!(16 & Me(e.o)); o = !!(2 & Me(s)); var l = s; !i && o && (s = Array.prototype.slice.call(s)); for (var c = o, h = 0; h < s.length; h++) { var d = s[h], f = t, p = !1; if (p = void 0 !== p && p, void 0 !== (d = Array.isArray(d) ? new f(d) : p ? new f : void 0)) { var m = p = Me(f = d.o); o && (m |= 2), u && (m |= 16), m != p && Fe(f, m), f = m, c = c || !!(2 & f), a.push(d) } } return e.h[n] = a, t = 33 | (u = Me(s)), u != (t = c ? -9 & t : 8 | t) && (c = s, Object.isFrozen(c) && (c = Array.prototype.slice.call(c)), Fe(c, t), s = c), l !== s && He(e, n, s), (i || r && o) && Ne(a, 2), r && Object.freeze(a), a } return i || (i = Object.isFrozen(a), r && !i ? Object.freeze(a) : !r && i && (a = Array.prototype.slice.call(a), e.h[n] = a)), a } function Ke(e, t, n) { var r = !!(2 & Me(e.o)); if (t = Xe(e, t, n, r, r), e = qe(e, n, 3, r), !(r || 8 & Me(e))) { for (r = 0; r < t.length; r++) { if (2 & Me((n = t[r]).o)) { var i = ut(n, !1); i.j = n } else i = n; n !== i && (t[r] = i, e[r] = i.o) } Ne(e, 8) } return t } function Ze(e, t, n) { if (null != n && "number" != typeof n) throw Error("Value of float/double field must be a number|null|undefined, found " + typeof n + ": " + n); Ge(e, t, n) } function Je(e, t, n, r, i) { je(e); var a = Xe(e, n, t, !1, !1); return n = null != r ? r : new n, e = qe(e, t, 2, !1), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.o)) : (a.push(n), e.push(n.o)), n.C() && Ie(e, 8), n } function Qe(e, t) { return null == e ? t : e } function et(e, t, n) { return n = void 0 === n ? 0 : n, Qe(Ye(e, t), n) } function tt(e, t, n, r) { if (null != e) { if (Array.isArray(e)) e = nt(e, t, n, void 0 !== r); else if (ze(e)) { var i, a = {}; for (i in e) a[i] = tt(e[i], t, n, r); e = a } else e = t(e, r); return e } } function nt(e, t, n, r) { var i = Me(e); r = r ? !!(16 & i) : void 0, e = Array.prototype.slice.call(e); for (var a = 0; a < e.length; a++)e[a] = tt(e[a], t, n, r); return n(i, e), e } function rt(e) { return e.ja === Oe ? e.toJSON() : function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e) if (Array.isArray(e)) { if (128 & Me(e)) return Ue(e = Array.prototype.slice.call(e)), e } else { if ($ && null != e && e instanceof Uint8Array) return O(e); if (e instanceof ce) { var t = e.V; return null == t ? "" : "string" == typeof t ? t : e.V = O(t) } } }return e }(e) } function it(e, t) { 128 & e && Ue(t) } function at(e, t, n) { if (n = void 0 === n ? Re : n, null != e) { if ($ && e instanceof Uint8Array) return e.length ? new ce(new Uint8Array(e), U) : he(); if (Array.isArray(e)) { var r = Me(e); return 2 & r ? e : !t || 32 & r || !(16 & r || 0 === r) ? (4 & (t = Me(e = nt(e, at, 4 & r ? Re : n, !0))) && 2 & t && Object.freeze(e), e) : (Fe(e, 2 | r), e) } return e.ja === Oe ? st(e) : e } } function ot(e, t, n, r, i, a, o) { if (e = e.h && e.h[n]) { if (2 & (r = Me(e)) ? r = e : (Re(r, a = N(e, st)), Object.freeze(a), r = a), je(t), o = null == r ? Pe : De([]), null != r) { for (a = !!r.length, e = 0; e < r.length; e++) { var s = r[e]; a = a && !(2 & Me(s.o)), o[e] = s.o } a = 1 | (a ? 8 : 0), ((e = Me(o)) & a) !== a && (Object.isFrozen(o) && (o = Array.prototype.slice.call(o)), Fe(o, e | a)), t.h || (t.h = {}), t.h[n] = r } else t.h && (t.h[n] = void 0); He(t, n, o, i) } else Ge(t, n, at(r, a, o), i) } function st(e) { return 2 & Me(e.o) || Ne((e = ut(e, !0)).o, 2), e } function ut(e, t) { var n = e.o, r = []; Ne(r, 16); var i = e.constructor.h; if (i && r.push(i), i = e.B) { r.length = n.length, r.fill(void 0, r.length, n.length); var a = {}; r[r.length - 1] = a } 128 & Me(n) && Ue(r), t = t || e.C() ? Re : $e, a = e.constructor, Be = r, r = new a(r), Be = void 0, e.R && (r.R = e.R.slice()), a = !!(16 & Me(n)); for (var o = i ? n.length - 1 : n.length, s = 0; s < o; s++)ot(e, r, s - e.G, n[s], !1, a, t); if (i) for (var u in i) ot(e, r, +u, i[u], !0, a, t); return r } function lt(e, t, n) { null == e && (e = Be), Be = void 0; var r, i = this.constructor.i || 0, a = 0 < i, o = this.constructor.h, s = !1; if (null == e) { var u = 48, l = !0; a && (i = 0, u |= 128), Fe(e = o ? [o] : [], u) } else { if (!Array.isArray(e)) throw Error(); if (o && o !== e[0]) throw Error(); var c = u = Ne(e, 0); if ((l = !!(16 & c)) && ((s = !!(32 & c)) || (c |= 32)), a) { if (128 & c) i = 0; else if (0 < e.length) { var h = e[e.length - 1]; if (ze(h) && "g" in h) { i = 0, c |= 128, delete h.g; var d, f = !0; for (d in h) { f = !1; break } f && e.pop() } } } else if (128 & c) throw Error(); u !== c && Fe(e, c) } if (this.G = (o ? 0 : -1) - i, this.h = void 0, this.o = e, i = (o = this.o.length) - 1, o && ze(o = this.o[i]) ? (this.B = o, this.i = i - this.G) : void 0 !== t && -1 < t ? (this.i = Math.max(t, i + 1 - this.G), this.B = void 0) : this.i = Number.MAX_VALUE, !a && this.B && "g" in this.B) throw Error('Unexpected "g" flag in sparse object of message that is not a group type.'); if (n) for (t = l && !s && !0, a = this.i, l = 0; l < n.length; l++)(s = n[l]) < a ? (i = e[s += this.G]) ? ct(i, t) : e[s] = Pe : (r || (r = We(this)), (i = r[s]) ? ct(i, t) : r[s] = Pe) } function ct(e, t) { if (Array.isArray(e)) { var n = Me(e), r = 1; !t || 2 & n || (r |= 16), (n & r) !== r && Fe(e, n | r) } } function ht(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ra; o || (i.J = a.xa || a.oa.W, a.ia ? (i.aa = vt(a.ia), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.aa) } }(i)) : a.ka ? (i.Z = xt(a.da.P, a.ka), o = function (e) { return function (t, n, r) { return e.J(t, n, r, e.Z) } }(i)) : o = i.J, a.ra = o), o(t, e, a.da), i = { J: i.J, aa: i.aa, Z: i.Z } } } !function (e, t) { if (t = t.R) { Te(e, e.h.end()); for (var n = 0; n < t.length; n++)Te(e, de(t[n]) || j()) } }(t, e) } Fe(Le, 23), Pe = Object.freeze(Le), lt.prototype.toJSON = function () { return nt(this.o, rt, it) }, lt.prototype.C = function () { return !!(2 & Me(this.o)) }, lt.prototype.ja = Oe, lt.prototype.toString = function () { return this.o.toString() }; var dt = Symbol(); function ft(e, t, n) { return e[dt] || (e[dt] = function (e, r) { return t(e, r, n) }) } function pt(e) { var t = e[dt]; if (!t) { var n = Ft(e); t = function (e, t) { return Dt(e, t, n) }, e[dt] = t } return t } function mt(e) { var t = function (e) { var t = e.ia; return t ? pt(t) : (t = e.wa) ? ft(e.da.P, t, e.ka) : void 0 }(e), n = e.da, r = e.oa.U; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function gt(e, t) { var n = e[t]; return "function" == typeof n && 0 === n.length && (n = n(), e[t] = n), Array.isArray(n) && (Tt in n || wt in n || 0 < n.length && "function" == typeof n[0]) ? n : void 0 } function yt(e, t, n, r, i, a) { t.P = e[0]; var o = 1; if (e.length > o && "number" != typeof e[o]) { var s = e[o++]; n(t, s) } for (; o < e.length;) { n = e[o++]; for (var u = o + 1; u < e.length && "number" != typeof e[u];)u++; switch (s = e[o++], u -= o) { case 0: r(t, n, s); break; case 1: (u = gt(e, o)) ? (o++, i(t, n, s, u)) : r(t, n, s, e[o++]); break; case 2: i(t, n, s, u = gt(e, u = o++), e[o++]); break; case 3: a(t, n, s, e[o++], e[o++], e[o++]); break; case 4: a(t, n, s, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + u) } } return t } var bt = Symbol(); function vt(e) { var t = e[bt]; if (!t) { var n = At(e); t = function (e, t) { return $t(e, t, n) }, e[bt] = t } return t } function xt(e, t) { var n = e[bt]; return n || (n = function (e, n) { return ht(e, n, t) }, e[bt] = n), n } var wt = Symbol(); function kt(e, t) { e.push(t) } function St(e, t, n) { e.push(t, n.W) } function _t(e, t, n, r) { var i = vt(r), a = At(r).P, o = n.W; e.push(t, (function (e, t, n) { return o(e, t, n, a, i) })) } function Ct(e, t, n, r, i, a) { var o = xt(r, a), s = n.W; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function At(e) { var t = e[wt]; return t || (t = yt(e, e[wt] = [], kt, St, _t, Ct), Tt in e && wt in e && (e.length = 0), t) } var Tt = Symbol(); function Et(e, t) { e[0] = t } function Nt(e, t, n, r) { var i = n.U; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function It(e, t, n, r, i) { var a = n.U, o = pt(r), s = Ft(r).P; e[t] = function (e, t, n) { return a(e, t, n, s, o, i) } } function Mt(e, t, n, r, i, a, o) { var s = n.U, u = ft(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Ft(e) { var t = e[Tt]; return t || (t = yt(e, e[Tt] = {}, Et, Nt, It, Mt), Tt in e && wt in e && (e.length = 0), t) } function Dt(e, t, n) { for (; Se(t) && 4 != t.i;) { var r = t.l, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = mt(a)) } if (!i || !i(t, e, r)) { r = e, a = (i = t).j, _e(i); var o = i; if (!o.ca) { if (i = o.h.h - a, o.h.h = a, o = o.h, 0 == i) i = he(); else { if (a = ye(o, i), o.S && o.m) i = o.i.subarray(a, a + i); else { o = o.i; var s = a; i = s === (i = a + i) ? j() : W ? o.slice(s, i) : new Uint8Array(o.subarray(s, i)) } i = 0 == i.length ? he() : new ce(i, U) } (a = r.R) ? a.push(i) : r.R = [i] } } } return e } function $t(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); ht(e, t, i ? n[0] : void 0) } function Rt(e, t) { return { U: e, W: t } } var Ot = Rt((function (e, t, n) { if (5 !== e.i) return !1; var r = (e = e.h).i, i = e.h, a = r[i], o = r[i + 1], s = r[i + 2]; return r = r[i + 3], me(e, e.h + 4), e = 2 * ((o = (a | o << 8 | s << 16 | r << 24) >>> 0) >> 31) + 1, a = o >>> 23 & 255, o &= 8388607, Ge(t, n, 255 == a ? o ? NaN : 1 / 0 * e : 0 == a ? e * Math.pow(2, -149) * o : e * Math.pow(2, a - 150) * (o + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = Ye(t, n))) { we(e.h, 8 * n + 5), e = e.h; var r = +t; 0 === r ? 0 < 1 / r ? V = G = 0 : (G = 0, V = 2147483648) : isNaN(r) ? (G = 0, V = 2147483647) : 34028234663852886e22 < (r = (n = 0 > r ? -2147483648 : 0) ? -r : r) ? (G = 0, V = (2139095040 | n) >>> 0) : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), G = 0, V = (n | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, G = 0, V = (n | t + 127 << 23 | 8388607 & r) >>> 0), n = V, e.h.push(n >>> 0 & 255), e.h.push(n >>> 8 & 255), e.h.push(n >>> 16 & 255), e.h.push(n >>> 24 & 255) } })), zt = Rt((function (e, t, n) { if (0 !== e.i) return !1; var r = e.h, i = 0, a = e = 0, o = r.i, s = r.h; do { var u = o[s++]; i |= (127 & u) << a, a += 7 } while (32 > a && 128 & u); for (32 < a && (e |= (127 & u) >> 4), a = 3; 32 > a && 128 & u; a += 7)e |= (127 & (u = o[s++])) << a; if (me(r, s), !(128 > u)) throw Q(); return r = i >>> 0, (e = 2147483648 & (u = e >>> 0)) && (u = ~u >>> 0, 0 == (r = 1 + ~r >>> 0) && (u = u + 1 >>> 0)), r = 4294967296 * u + (r >>> 0), Ge(t, n, e ? -r : r), !0 }), (function (e, t, n) { null != (t = Ve(t, n)) && ("string" == typeof t && Z(t), null != t && (we(e.h, 8 * n), "number" == typeof t ? (e = e.h, H(t), xe(e, V, G)) : (n = Z(t), xe(e.h, n.i, n.h)))) })), Pt = Rt((function (e, t, n) { return 0 === e.i && (Ge(t, n, ge(e.h)), !0) }), (function (e, t, n) { if (null != (t = Ve(t, n)) && null != t) if (we(e.h, 8 * n), e = e.h, 0 <= (n = t)) we(e, n); else { for (t = 0; 9 > t; t++)e.h.push(127 & n | 128), n >>= 7; e.h.push(1) } })), Bt = Rt((function (e, t, n) { if (2 !== e.i) return !1; var r = ge(e.h) >>> 0, i = ye(e = e.h, r); if (e = e.i, se) { var a, o = e; (a = re) || (a = re = new TextDecoder("utf-8", { fatal: !0 })), e = i + r, o = 0 === i && e === o.length ? o : o.subarray(i, e); try { var s = a.decode(o) } catch (e) { if (void 0 === oe) { try { a.decode(new Uint8Array([128])) } catch (e) { } try { a.decode(new Uint8Array([97])), oe = !0 } catch (e) { oe = !1 } } throw !oe && (re = void 0), e } } else { r = (s = i) + r, i = []; for (var u, l, c = null; s < r;)128 > (u = e[s++]) ? i.push(u) : 224 > u ? s >= r ? te() : (l = e[s++], 194 > u || 128 != (192 & l) ? (s--, te()) : i.push((31 & u) << 6 | 63 & l)) : 240 > u ? s >= r - 1 ? te() : 128 != (192 & (l = e[s++])) || 224 === u && 160 > l || 237 === u && 160 <= l || 128 != (192 & (o = e[s++])) ? (s--, te()) : i.push((15 & u) << 12 | (63 & l) << 6 | 63 & o) : 244 >= u ? s >= r - 2 ? te() : 128 != (192 & (l = e[s++])) || l - 144 + (u << 28) >> 30 || 128 != (192 & (o = e[s++])) || 128 != (192 & (a = e[s++])) ? (s--, te()) : (u = (7 & u) << 18 | (63 & l) << 12 | (63 & o) << 6 | 63 & a, u -= 65536, i.push(55296 + (u >> 10 & 1023), 56320 + (1023 & u))) : te(), 8192 <= i.length && (c = ne(c, i), i.length = 0); s = ne(c, i) } return Ge(t, n, s), !0 }), (function (e, t, n) { if (null != (t = Ve(t, n))) { var r = !1; if (r = void 0 !== r && r, ue) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (ie || (ie = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = i === a.length ? a : a.subarray(0, i) } we(e.h, 8 * n + 2), we(e.h, t.length), Te(e, e.h.end()), Te(e, t) } })), Lt = Rt((function (e, t, n, r, i) { if (2 !== e.i) return !1; t = Je(t, n, r), n = e.h.j, r = ge(e.h) >>> 0; var a = e.h.h + r, o = a - n; if (0 >= o && (e.h.j = a, i(t, e, void 0, void 0, void 0), o = a - e.h.h), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.h.h = a, e.h.j = n, !0 }), (function (e, t, n, r, i) { if (null != (t = Ke(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; we(a.h, 8 * n + 2); var o = a.h.end(); Te(a, o), o.push(a.i), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.i + o.h.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.i++; a.push(s), o.i++ } })); function jt(e) { return function (t, n) { e: { if (Ce.length) { var r = Ce.pop(); r.setOptions(n), pe(r.h, t, n), t = r } else t = new ke(t, n); try { var i = Ft(e), a = Dt(new i.P, t, i); break e } finally { (i = t.h).i = null, i.m = !1, i.l = 0, i.j = 0, i.h = 0, i.S = !1, t.l = -1, t.i = -1, 100 > Ce.length && Ce.push(t) } a = void 0 } return a } } function Ut(e) { return function () { var t = new Ae; $t(this, t, At(e)), Te(t, t.h.end()); for (var n = new Uint8Array(t.i), r = t.j, i = r.length, a = 0, o = 0; o < i; o++) { var s = r[o]; n.set(s, a), a += s.length } return t.j = [n], n } } function Wt(e) { lt.call(this, e) } m(Wt, lt); var Vt = [Wt, 1, Pt, 2, Ot, 3, Bt, 4, Bt]; function Gt(e) { lt.call(this, e, -1, Ht) } Wt.prototype.l = Ut(Vt), m(Gt, lt), Gt.prototype.addClassification = function (e, t) { return Je(this, 1, Wt, e, t), this }; var Ht = [1], qt = jt([Gt, 1, Lt, Vt]); function Yt(e) { lt.call(this, e) } m(Yt, lt); var Xt = [Yt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot]; function Kt(e) { lt.call(this, e, -1, Zt) } Yt.prototype.l = Ut(Xt), m(Kt, lt); var Zt = [1], Jt = jt([Kt, 1, Lt, Xt]); function Qt(e) { lt.call(this, e) } m(Qt, lt); var en = [Qt, 1, Ot, 2, Ot, 3, Ot, 4, Ot, 5, Ot, 6, zt], tn = jt(en); function nn(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function rn(e) { return Ke(e, Wt, 1).map((function (e) { var t = Ve(e, 1); return { index: null == t ? 0 : t, qa: et(e, 2), label: null != Ve(e, 3) ? Qe(Ve(e, 3), "") : void 0, displayName: null != Ve(e, 4) ? Qe(Ve(e, 4), "") : void 0 } })) } function an(e) { return { x: et(e, 1), y: et(e, 2), z: et(e, 3), visibility: null != Ye(e, 4) ? et(e, 4) : void 0 } } function on(e, t) { this.i = e, this.h = t, this.m = 0 } function sn(e, t, n) { return function (e, t) { var n = e.h; if (void 0 === e.s) { var r = nn(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = nn(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.s = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.l = { O: n.getAttribLocation(r, "aVertex"), N: n.getAttribLocation(r, "aTex"), ya: i }, e.v = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.enableVertexAttribArray(e.l.O), n.vertexAttribPointer(e.l.O, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.l.N), n.vertexAttribPointer(e.l.N, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.l, n.useProgram(e.s), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.i.bindTexture2d(t.glName), n.enableVertexAttribArray(r.O), n.bindBuffer(n.ARRAY_BUFFER, e.v), n.vertexAttribPointer(r.O, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.N, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.O), n.disableVertexAttribArray(r.N), n.bindBuffer(n.ARRAY_BUFFER, null), e.i.bindTexture2d(0) }(e, t), "function" == typeof e.h.canvas.transferToImageBitmap ? Promise.resolve(e.h.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.h.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.h.canvas) : (void 0 === e.j && (e.j = document.createElement("canvas")), new Promise((function (t) { e.j.height = e.h.canvas.height, e.j.width = e.h.canvas.width, e.j.getContext("2d", {}).drawImage(e.h.canvas, 0, 0, e.h.canvas.width, e.h.canvas.height), t(e.j) }))) } function un(e) { this.h = e } Qt.prototype.l = Ut(en); var ln = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function cn(e, t) { return t + e } function hn(e, t) { window[e] = t } function dn(e) { if (this.h = e, this.listeners = {}, this.l = {}, this.L = {}, this.s = {}, this.v = {}, this.M = this.u = this.ga = !0, this.I = Promise.resolve(), this.fa = "", this.D = {}, this.locateFile = e && e.locateFile || cn, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.ha = t, e.options) for (var n = (t = s(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.l[n] = "function" == typeof r ? r() : r) } } function fn(e) { var t, n, r, i, a, o, s, l, c, h, d; return _((function (f) { switch (f.h) { case 1: return e.ga ? (t = void 0 === e.h.files ? [] : "function" == typeof e.h.files ? e.h.files(e.l) : e.h.files, v(f, _((function (e) { switch (e.h) { case 1: return e.s = 2, v(e, WebAssembly.instantiate(ln), 4); case 4: e.h = 3, e.s = 0; break; case 2: return e.s = 0, e.l = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.i, "object" == typeof window) return hn("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), hn("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), s = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = pn(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(s.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.ha)) : Promise.resolve() }))).then((function () { var t, n, r; return _((function (i) { if (1 == i.h) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, v(i, t(n), 2); r.i = i.i, i.h = 0 })) })), h = _((function (t) { return e.h.graph && e.h.graph.url ? t = v(t, pn(e, e.h.graph.url), 0) : (t.h = 0, t = void 0), t })), v(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.ha) })), importScripts.apply(null, u(r)), i = e, v(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.i = f.i, e.m = new OffscreenCanvas(1, 1), e.i.canvas = e.m, a = e.i.GL.createContext(e.m, { antialias: !1, alpha: !1, va: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.i.GL.makeContextCurrent(a), f.h = 4; break; case 7: if (e.m = document.createElement("canvas"), !(d = e.m.getContext("webgl2", {})) && !(d = e.m.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.K = d, e.i.canvas = e.m, e.i.createContext(e.m, !0, !0, {}); case 4: e.j = new e.i.SolutionWasm, e.ga = !1, f.h = 0 } })) } function pn(e, t) { var n, r; return _((function (i) { return t in e.L ? i.return(e.L[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.L[t] = r, i.return(r)) })) } function mn(e, t, n) { var r, i, a, o, u, l, c, h, d, f, p, m, g, y; return _((function (b) { switch (b.h) { case 1: if (!n) return b.return(t); for (r = {}, i = 0, a = s(Object.keys(n)), o = a.next(); !o.done; o = a.next())u = o.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.M = !1), c = s(Object.keys(n)), o = c.next(); case 2: if (o.done) { b.h = 4; break } if (h = o.value, "string" == typeof (d = n[h])) return g = r, y = h, v(b, function (e, t, n) { var r; return _((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.i.Uint8BlobList ? i.return(n) : n instanceof e.i.Texture2dDataOut ? ((r = e.v[t]) || (r = new on(e.i, e.K), e.v[t] = r), i.return(sn(r, n, e.M))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), k = f.getClassificationsList(), S = [], C = 0; C < x.size(); ++C) { var A = tn(x.get(C)), T = void 0; T = void 0 === T ? 0 : T, A = { la: { sa: et(A, 1), ta: et(A, 2), height: et(A, 3), width: et(A, 4), rotation: et(A, 5, 0), pa: Qe(Ve(A, 6), T) }, ea: Ke(Jt(w.get(C)), Yt, 1).map(an), ba: rn(qt(k.get(C))) }, S.push(A) } x = S } else x = []; r[h] = x, b.h = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, b.h = 7; break } if (void 0 === f) { b.h = 3; break } if ("float_list" === d.type) { r[h] = f, b.h = 7; break } if ("proto" === d.type) { r[h] = f, b.h = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.v[h]) || (p = new on(e.i, e.K), e.v[h] = p), v(b, sn(p, f, e.M), 13); case 13: m = b.i, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), b.h = 3; break; case 14: g[y] = b.i; case 3: o = c.next(), b.h = 2; break; case 4: return b.return(r) } })) } function gn(e, t) { for (var n = t.name || "$", r = [].concat(u(t.wants)), i = new e.i.StringList, a = s(t.wants), o = a.next(); !o.done; o = a.next())i.push_back(o.value); a = e.i.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.I = mn(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.I = n) }))) } }), e.j.attachMultiListener(i, a), i.delete() } function yn(e) { return void 0 === e && (e = 0), 1 === e ? "selfie_segmentation_landscape.tflite" : "selfie_segmentation.tflite" } function bn(e) { var t = this; e = e || {}, this.h = new dn({ locateFile: e.locateFile, files: function (e) { return [{ simd: !0, url: "selfie_segmentation_solution_simd_wasm_bin.js" }, { simd: !1, url: "selfie_segmentation_solution_wasm_bin.js" }, { data: !0, url: yn(e.modelSelection) }] }, graph: { url: "selfie_segmentation.binarypb" }, listeners: [{ wants: ["segmentation_mask", "image_transformed"], outs: { image: { type: "texture", stream: "image_transformed" }, segmentationMask: { type: "texture", stream: "segmentation_mask" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, modelSelection: { type: 1, graphOptionXref: { calculatorType: "ConstantSidePacketCalculator", calculatorName: "ConstantSidePacketCalculatorModelSelection", fieldName: "int_value" }, onChange: function (e) { var n, r, i; return _((function (a) { return 1 == a.h ? (n = yn(e), r = "third_party/mediapipe/modules/selfie_segmentation/" + n, v(a, pn(t.h, n), 2)) : (i = a.i, t.h.overrideFile(r, i), a.return(!0)) })) } } } }) } (e = dn.prototype).close = function () { return this.j && this.j.delete(), Promise.resolve() }, e.reset = function () { var e = this; return _((function (t) { e.j && (e.j.reset(), e.s = {}, e.v = {}), t.h = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.h.options) { for (var r = [], i = [], a = {}, o = s(Object.keys(e)), u = o.next(); !u.done; a = { X: a.X, Y: a.Y }, u = o.next())if (!((u = u.value) in this.l) || this.l[u] !== e[u]) { this.l[u] = e[u]; var l = t[u]; void 0 !== l && (l.onChange && (a.X = l.onChange, a.Y = e[u], r.push(function (e) { return function () { return _((function (t) { if (1 == t.h) return v(t, e.X(e.Y), 2); !0 === t.i && (n.u = !0), t.h = 0 })) } }(a))), l.graphOptionXref && (u = Object.assign({}, { calculatorName: "", calculatorIndex: 0 }, l.graphOptionXref, { valueNumber: 1 === l.type ? e[u] : 0, valueBoolean: 0 === l.type && e[u], valueString: 2 === l.type ? e[u] : "" }), i.push(u))) } 0 === r.length && 0 === i.length || (this.u = !0, this.H = (void 0 === this.H ? [] : this.H).concat(i), this.F = (void 0 === this.F ? [] : this.F).concat(r)) } }, e.initialize = function () { var e = this; return _((function (t) { return 1 == t.h ? v(t, fn(e), 2) : 3 != t.h ? v(t, function (e) { var t, n, r, i, a, o, u, l; return _((function (c) { if (1 == c.h) return e.h.graph && e.h.graph.url && e.fa === e.h.graph.url ? c.return() : (e.u = !0, e.h.graph && e.h.graph.url ? (e.fa = e.h.graph.url, v(c, pn(e, e.h.graph.url), 3)) : void (c.h = 2)); for (2 != c.h && (t = c.i, e.j.loadGraph(t)), n = s(Object.keys(e.D)), r = n.next(); !r.done; r = n.next())i = r.value, e.j.overrideFile(i, e.D[i]); if (e.D = {}, e.h.listeners) for (a = s(e.h.listeners), o = a.next(); !o.done; o = a.next())u = o.value, gn(e, u); l = e.l, e.l = {}, e.setOptions(l), c.h = 0 })) }(e), 3) : v(t, function (e) { var t, n, r, i, a, o; return _((function (u) { switch (u.h) { case 1: if (!e.u) return u.return(); if (!e.F) { u.h = 2; break } t = s(e.F), n = t.next(); case 3: if (n.done) { u.h = 5; break } return v(u, (0, n.value)(), 4); case 4: n = t.next(), u.h = 3; break; case 5: e.F = void 0; case 2: if (e.H) { for (r = new e.i.GraphOptionChangeRequestList, i = s(e.H), a = i.next(); !a.done; a = i.next())o = a.value, r.push_back(o); e.j.changeOptions(r), r.delete(), e.H = void 0 } e.u = !1, u.h = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.j ? this.j.overrideFile(e, t) : this.D[e] = t }, e.clearOverriddenFiles = function () { this.D = {}, this.j && this.j.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, o, u, l, c, h, d = this; return _((function (f) { switch (f.h) { case 1: return d.h.inputs ? (n = 1e3 * (null == t ? performance.now() : t), v(f, d.I, 2)) : f.return(); case 2: return v(f, d.initialize(), 3); case 3: for (r = new d.i.PacketDataList, i = s(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (o = a.value, u = d.h.inputs[o]) { e: { var p = e[o]; switch (u.type) { case "video": var m = d.s[u.stream]; if (m || (m = new on(d.i, d.K), d.s[u.stream] = m), 0 === m.m && (m.m = m.i.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, y = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, y = p.naturalHeight) : (g = p.width, y = p.height); y = { glName: m.m, width: g, height: y }, (g = m.h).canvas.width = y.width, g.canvas.height = y.height, g.activeTexture(g.TEXTURE0), m.i.bindTexture2d(m.m), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.i.bindTexture2d(0), m = y; break e; case "detections": for ((m = d.s[u.stream]) || (m = new un(d.i), d.s[u.stream] = m), m.data || (m.data = new m.h.DetectionListData), m.data.reset(p.length), y = 0; y < p.length; ++y) { g = p[y]; var b = m.data, x = b.setBoundingBox, w = y, k = g.la, S = new Qt; if (Ze(S, 1, k.sa), Ze(S, 2, k.ta), Ze(S, 3, k.height), Ze(S, 4, k.width), Ze(S, 5, k.rotation), Ge(S, 6, k.pa), k = S.l(), x.call(b, w, k), g.ea) for (b = 0; b < g.ea.length; ++b) { S = g.ea[b], w = (x = m.data).addNormalizedLandmark, k = y, S = Object.assign({}, S, { visibility: S.visibility ? S.visibility : 0 }); var _ = new Yt; Ze(_, 1, S.x), Ze(_, 2, S.y), Ze(_, 3, S.z), S.visibility && Ze(_, 4, S.visibility), S = _.l(), w.call(x, k, S) } if (g.ba) for (b = 0; b < g.ba.length; ++b)w = (x = m.data).addClassification, k = y, S = g.ba[b], Ze(_ = new Wt, 2, S.qa), S.index && Ge(_, 1, S.index), S.label && Ge(_, 3, S.label), S.displayName && Ge(_, 4, S.displayName), S = _.l(), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign({}, l, { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.j.send(r), v(f, d.I, 4); case 4: r.delete(), f.h = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, T("Solution", dn), T("OptionType", { BOOL: 0, NUMBER: 1, ua: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = bn.prototype).close = function () { return this.h.close(), Promise.resolve() }, e.onResults = function (e) { this.h.onResults(e) }, e.initialize = function () { var e = this; return _((function (t) { return v(t, e.h.initialize(), 0) })) }, e.reset = function () { this.h.reset() }, e.send = function (e) { var t = this; return _((function (n) { return v(n, t.h.send(e), 0) })) }, e.setOptions = function (e) { this.h.setOptions(e) }, T("SelfieSegmentation", bn), T("VERSION", "0.1.1675465747") }).call(this) }, 3185: (e, t) => { "use strict"; /** * @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 * * https://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. * ============================================================================= */ t.c6 = void 0, t.c6 = [[0, 1], [1, 2], [2, 3], [3, 4], [0, 5], [5, 6], [6, 7], [7, 8], [0, 9], [9, 10], [10, 11], [11, 12], [0, 13], [13, 14], [14, 15], [15, 16], [0, 17], [17, 18], [18, 19], [19, 20]] }, 5149: (e, t, n) => { "use strict"; n.d(t, { GJ: () => r, uI: () => i }); class r { constructor(e, t) { this.backend = e, this.dataMover = t, this.data = new WeakMap, this.dataIdsCount = 0 } get(e) { return this.data.has(e) || this.dataMover.moveData(this.backend, e), this.data.get(e) } set(e, t) { this.dataIdsCount++, this.data.set(e, t) } has(e) { return this.data.has(e) } delete(e) { return this.dataIdsCount--, this.data.delete(e) } numDataIds() { return this.dataIdsCount } } class i { refCount(e) { return a("refCount") } incRef(e) { return a("incRef") } timerAvailable() { return !0 } time(e) { return a("time") } read(e) { return a("read") } readSync(e) { return a("readSync") } readToGPU(e, t) { return a("readToGPU") } numDataIds() { return a("numDataIds") } disposeData(e, t) { return a("disposeData") } write(e, t, n) { return a("write") } move(e, t, n, r, i) { return a("move") } createTensorFromGPUData(e, t, n) { return a("createTensorFromGPUData") } memory() { return a("memory") } floatPrecision() { return a("floatPrecision") } epsilon() { return 32 === this.floatPrecision() ? 1e-7 : 1e-4 } dispose() { return a("dispose") } } function a(e) { throw new Error(`'${e}' not yet implemented or not found in the registry. This kernel may not be supported by the tfjs backend you have chosen`) } }, 8360: (e, t, n) => { "use strict"; /** * @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 r(e, t, n) { const r = function (e, t, n) { return function (e, t, n) { let r = 0, i = e.length, a = 0, o = !1; for (; r < i;) { a = r + (i - r >>> 1); const s = n(t, e[a]); s > 0 ? r = a + 1 : (i = a, o = !s) } return o ? r : -r - 1 }(e, t, n || i) }(e, t, n), a = r < 0 ? -(r + 1) : r; e.splice(a, 0, t) } function i(e, t) { return e > t ? 1 : e < t ? -1 : 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 a(e, t, n, r, i) { return u(e, t, n, r, i, 0) } function o(e, t, n, r, i, a) { return u(e, t, n, r, i, 0, !1, a, !0) } function s(e, t, n, r, i, a) { return u(e, t, n, r, i, a, !0) } function u(e, t, n, i, a, o, s = !1, u = !1, d = !1) { const f = []; for (let e = 0; e < t.length; e++)t[e] > a && f.push({ score: t[e], boxIndex: e, suppressBeginIndex: 0 }); f.sort(h); const p = o > 0 ? -.5 / o : 0, m = [], g = []; for (; m.length < n && f.length > 0;) { const t = f.pop(), { score: n, boxIndex: o, suppressBeginIndex: s } = t; if (n < a) break; let u = !1; for (let n = m.length - 1; n >= s; --n) { const r = l(e, o, m[n]); if (r >= i) { u = !0; break } if (t.score = t.score * c(i, p, r), t.score <= a) break } t.suppressBeginIndex = m.length, u || (t.score === n ? (m.push(o), g.push(t.score)) : t.score > a && r(f, t, h)) } const y = m.length, b = n - y; u && b > 0 && (m.push(...new Array(b).fill(0)), g.push(...new Array(b).fill(0))); const v = { selectedIndices: m }; return s && (v.selectedScores = g), d && (v.validOutputs = y), v } function l(e, t, n) { const r = e.subarray(4 * t, 4 * t + 4), i = e.subarray(4 * n, 4 * n + 4), a = Math.min(r[0], r[2]), o = Math.min(r[1], r[3]), s = Math.max(r[0], r[2]), u = Math.max(r[1], r[3]), l = Math.min(i[0], i[2]), c = Math.min(i[1], i[3]), h = Math.max(i[0], i[2]), d = Math.max(i[1], i[3]), f = (s - a) * (u - o), p = (h - l) * (d - c); if (f <= 0 || p <= 0) return 0; const m = Math.max(a, l), g = Math.max(o, c), y = Math.min(s, h), b = Math.min(u, d), v = Math.max(y - m, 0) * Math.max(b - g, 0); return v / (f + p - v) } function c(e, t, n) { const r = Math.exp(t * n * n); return n <= e ? r : 0 } function h(e, t) { return e.score - t.score || e.score === t.score && t.boxIndex - e.boxIndex } n.d(t, { c7: () => a, ZS: () => o, ut: () => s }) }, 4411: (e, t, n) => { "use strict"; n.d(t, { Y: () => i }); var r = n(448); /** * @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 i(e, t) { const n = []; for (let e = 0; e < t.length; e++)t[e] && n.push(e); const i = (0, r.r)(e, "int32"), a = (0, r.r)([n.length, e.length], "int32"); for (let t = 0; t < n.length; t++) { const r = i.indexToLoc(n[t]), o = t * e.length; a.values.set(r, o) } return a.toTensor() } }, 1585: (e, t, n) => { "use strict"; n.d(t, { T2: () => x, Ye: () => v }); var r = n(5149), i = n(6574), a = n(1743), o = n(5441), s = n(7074), u = n(3673), l = n(3879), c = n(5119); /** * @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 h { constructor(e, t) { this.backendTimer = e, this.logger = t, null == t && (this.logger = new f) } profileKernel(e, t, n) { let r; const a = () => { r = n() }; let o; const s = l.now(); if (this.backendTimer.timerAvailable()) o = this.backendTimer.time(a); else { a(); for (const e of r) e.dataSync(); o = Promise.resolve({ kernelMs: l.now() - s }) } if ((0, i._K)().getBool("CHECK_COMPUTATION_FOR_ERRORS")) for (let t = 0; t < r.length; t++) { const n = r[t]; n.data().then((t => { d(t, n.dtype, e) })) } return { kernelName: e, outputs: r, inputs: t, timeMs: o.then((e => e.kernelMs)), extraInfo: o.then((e => null != e.getExtraProfileInfo ? e.getExtraProfileInfo() : "")) } } logKernelProfile(e) { const { kernelName: t, outputs: n, timeMs: r, inputs: i, extraInfo: a } = e; n.forEach((e => { Promise.all([e.data(), r, a]).then((n => { this.logger.logKernelProfile(t, e, n[0], n[1], i, n[2]) })) })) } } function d(e, t, n) { if ("float32" !== t) return !1; for (let t = 0; t < e.length; t++) { const r = e[t]; if (isNaN(r) || !isFinite(r)) return console.warn(`Found ${r} in the result of '${n}'`), !0 } return !1 } class f { logKernelProfile(e, t, n, r, i, a) { const o = "number" == typeof r ? c.av(`${r}ms`, 9) : r.error, s = c.av(e, 25), u = t.rank, l = t.size, h = c.av(t.shape.toString(), 14); let d = ""; for (const e in i) { const n = i[e]; if (null != n) { const r = n.shape || t.shape, i = r.length; d += `${e}: ${i}D ${i > 0 ? r : ""} ` } } console.log(`%c${s}\t%c${o}\t%c${u}D ${h}\t%c${l}\t%c${d}\t%c${a}`, "font-weight:bold", "color:red", "color:blue", "color: orange", "color: green", "color: steelblue") } } var p = n(259), m = n(565); /** * @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 g(e) { return null != e.kernelName } class y { constructor() { this.registeredVariables = {}, this.nextTapeNodeId = 0, this.numBytes = 0, this.numTensors = 0, this.numStringTensors = 0, this.numDataBuffers = 0, this.gradientDepth = 0, this.kernelDepth = 0, this.scopeStack = [], this.numDataMovesStack = [], this.nextScopeId = 0, this.tensorInfo = new WeakMap, this.profiling = !1, this.activeProfile = { newBytes: 0, newTensors: 0, peakBytes: 0, kernels: [], result: null, get kernelNames() { return Array.from(new Set(this.kernels.map((e => e.name)))) } } } dispose() { for (const e in this.registeredVariables) this.registeredVariables[e].dispose() } } class b { constructor(e) { this.ENV = e, this.registry = {}, this.registryFactory = {}, this.pendingBackendInitId = 0, this.state = new y } async ready() { if (null != this.pendingBackendInit) return this.pendingBackendInit.then((() => { })); if (null != this.backendInstance) return; const e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { const n = e[t]; if (await this.initializeBackend(n).success) return void await this.setBackend(n) } throw new Error("Could not initialize any backends, all backend initializations failed.") } get backend() { if (null != this.pendingBackendInit) throw new Error(`Backend '${this.backendName}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); if (null == this.backendInstance) { const { name: e, asyncInit: t } = this.initializeBackendsAndReturnBest(); if (t) throw new Error(`The highest priority backend '${e}' has not yet been initialized. Make sure to await tf.ready() or await tf.setBackend() before calling other methods`); this.setBackend(e) } return this.backendInstance } backendNames() { return Object.keys(this.registryFactory) } findBackend(e) { if (!(e in this.registry)) { if (!(e in this.registryFactory)) return null; { const { asyncInit: t } = this.initializeBackend(e); if (t) return null } } return this.registry[e] } findBackendFactory(e) { return e in this.registryFactory ? this.registryFactory[e].factory : null } registerBackend(e, t, n = 1) { return e in this.registryFactory ? (u.i(`${e} backend was already registered. Reusing existing backend factory.`), !1) : (this.registryFactory[e] = { factory: t, priority: n }, !0) } async setBackend(e) { if (null == this.registryFactory[e]) throw new Error(`Backend name '${e}' not found in registry`); if (this.backendName = e, null == this.registry[e]) { this.backendInstance = null; const { success: t, asyncInit: n } = this.initializeBackend(e); if (!(n ? await t : t)) return !1 } return this.backendInstance = this.registry[e], this.setupRegisteredKernels(), this.profiler = new h(this.backendInstance), !0 } setupRegisteredKernels() { (0, s.Op)(this.backendName).forEach((e => { null != e.setupFunc && e.setupFunc(this.backendInstance) })) } disposeRegisteredKernels(e) { (0, s.Op)(e).forEach((t => { null != t.disposeFunc && t.disposeFunc(this.registry[e]) })) } initializeBackend(e) { const t = this.registryFactory[e]; if (null == t) throw new Error(`Cannot initialize backend ${e}, no registration found.`); try { const n = t.factory(); if (!n || n instanceof r.uI || "function" != typeof n.then) return this.registry[e] = n, { success: !0, asyncInit: !1 }; { const t = ++this.pendingBackendInitId, r = n.then((n => !(t < this.pendingBackendInitId) && (this.registry[e] = n, this.pendingBackendInit = null, !0))).catch((n => (t < this.pendingBackendInitId || (this.pendingBackendInit = null, u.i(`Initialization of backend ${e} failed`), u.i(n.stack || n.message)), !1))); return this.pendingBackendInit = r, { success: r, asyncInit: !0 } } } catch (t) { return u.i(`Initialization of backend ${e} failed`), u.i(t.stack || t.message), { success: !1, asyncInit: !1 } } } removeBackend(e) { if (!(e in this.registryFactory)) throw new Error(`${e} backend not found in registry`); this.backendName === e && null != this.pendingBackendInit && this.pendingBackendInitId++, e in this.registry && (this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]), delete this.registryFactory[e], this.backendName === e && (this.pendingBackendInit = null, this.backendName = null, this.backendInstance = null) } getSortedBackends() { if (0 === Object.keys(this.registryFactory).length) throw new Error("No backend found in registry."); return Object.keys(this.registryFactory).sort(((e, t) => this.registryFactory[t].priority - this.registryFactory[e].priority)) } initializeBackendsAndReturnBest() { const e = this.getSortedBackends(); for (let t = 0; t < e.length; t++) { const n = e[t], { success: r, asyncInit: i } = this.initializeBackend(n); if (i || r) return { name: n, asyncInit: i } } throw new Error("Could not initialize any backends, all backend initializations failed.") } moveData(e, t) { const n = this.state.tensorInfo.get(t), r = n.backend, i = this.readSync(t), a = r.refCount(t); r.disposeData(t, !0), n.backend = e, e.move(t, i, n.shape, n.dtype, a), this.shouldCheckForMemLeaks() && this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1]++ } tidy(e, t) { let n, r = null; if (null == t) { if ("function" != typeof e) throw new Error("Please provide a function to tidy()"); t = e } else { if ("string" != typeof e && !(e instanceof String)) throw new Error("When calling with two arguments, the first argument to tidy() must be a string"); if ("function" != typeof t) throw new Error("When calling with two arguments, the 2nd argument to tidy() must be a function"); r = e } return this.scopedRun((() => this.startScope(r)), (() => this.endScope(n)), (() => (n = t(), n instanceof Promise && console.error("Cannot return a Promise inside of tidy."), n))) } scopedRun(e, t, n) { e(); try { const e = n(); return t(), e } catch (e) { throw t(), e } } nextTensorId() { return b.nextTensorId++ } nextVariableId() { return b.nextVariableId++ } clone(e) { const t = x.runKernel(o.lzr, { x: e }), n = { x: e }; return this.addTapeNode(this.state.activeScope.name, n, [t], (e => ({ x: () => { const t = { x: e }, n = { dtype: "float32" }; return x.runKernel(o.KXH, t, n) } })), [], {}), t } runKernel(e, t, n) { null == this.backendName && this.backend; if (!(null != (0, s._5)(e, this.backendName))) throw new Error(`Kernel '${e}' not registered for backend '${this.backendName}'`); return this.runKernelFunc({ kernelName: e, inputs: t, attrs: n }) } shouldCheckForMemLeaks() { return this.ENV.getBool("IS_TEST") } checkKernelForMemLeak(e, t, n) { const r = this.backend.numDataIds(); let i = 0; n.forEach((e => { i += "complex64" === e.dtype ? 3 : 1 })); const a = this.state.numDataMovesStack[this.state.numDataMovesStack.length - 1], o = r - t - i - a; if (o > 0) throw new Error(`Backend '${this.backendName}' has an internal memory leak (${o} data ids) after running '${e}'`) } runKernelFunc(e) { let t, n = []; const r = this.isTapeOn(), i = this.state.numBytes, a = this.state.numTensors; let o, u; this.shouldCheckForMemLeaks() && this.state.numDataMovesStack.push(0), null == this.backendName && this.backend; const l = g(e) ? e.kernelName : null != this.state.activeScope ? this.state.activeScope.name : ""; if (g(e)) { const { kernelName: t, inputs: i, attrs: a } = e; null == this.backendName && this.backend; const l = (0, s._5)(t, this.backendName); c.vA(null != l, (() => `Cannot find registered kernel '${t}' for backend '${this.backendName}'`)), o = () => { const e = this.backend.numDataIds(); u = l.kernelFunc({ inputs: i, attrs: a, backend: this.backend }); const o = Array.isArray(u) ? u : [u]; this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(t, e, o); const s = o.map((e => null != e.rank ? e : this.makeTensorFromTensorInfo(e))); if (r) { const e = this.getTensorsForGradient(t, i, s); n = this.saveTensorsForBackwardMode(e) } return s } } else { const { forwardFunc: t } = e, i = e => { r && (n = e.map((e => this.keep(this.clone(e))))) }; o = () => { const e = this.backend.numDataIds(); u = this.tidy((() => t(this.backend, i))); const n = Array.isArray(u) ? u : [u]; return this.shouldCheckForMemLeaks() && this.checkKernelForMemLeak(l, e, n), n } } const { inputs: h, attrs: d } = e, f = g(e) ? null : e.backwardsFunc; let p; return this.scopedRun((() => this.state.kernelDepth++), (() => this.state.kernelDepth--), (() => { this.ENV.getBool("DEBUG") || this.state.profiling ? (p = this.profiler.profileKernel(l, h, (() => o())), this.ENV.getBool("DEBUG") && this.profiler.logKernelProfile(p), t = p.outputs) : t = o() })), r && this.addTapeNode(l, h, t, f, n, d), this.state.profiling && this.state.activeProfile.kernels.push({ name: l, bytesAdded: this.state.numBytes - i, totalBytesSnapshot: this.state.numBytes, tensorsAdded: this.state.numTensors - a, totalTensorsSnapshot: this.state.numTensors, inputShapes: Object.keys(h).map((e => null != h[e] ? h[e].shape : null)), outputShapes: t.map((e => e.shape)), kernelTimeMs: p.timeMs, extraInfo: p.extraInfo }), Array.isArray(u) ? t : t[0] } saveTensorsForBackwardMode(e) { const t = e.map((e => this.keep(this.clone(e)))); return t } getTensorsForGradient(e, t, n) { const r = (0, s.vQ)(e); if (null != r) { const e = r.inputsToSave || [], i = r.outputsToSave || []; let a; r.saveAllInputs ? (c.vA(Array.isArray(t), (() => "saveAllInputs is true, expected inputs to be an array.")), a = Object.keys(t).map((e => t[e]))) : a = e.map((e => t[e])); const o = n.filter(((e, t) => i[t])); return a.concat(o) } return [] } makeTensor(e, t, n, r) { if (null == e) throw new Error("Values passed to engine.makeTensor() are null"); n = n || "float32", r = r || this.backend; let i = e; "string" === n && c.Kg(e[0]) && (i = e.map((e => l.encodeString(e)))); const a = r.write(i, t, n), o = new p.qY(t, n, a, this.nextTensorId()); if (this.trackTensor(o, r), "string" === n) { const e = this.state.tensorInfo.get(a), t = (0, c.SL)(i); this.state.numBytes += t - e.bytes, e.bytes = t } return o } makeTensorFromDataId(e, t, n, r) { const i = { dataId: e, shape: t, dtype: n = n || "float32" }; return this.makeTensorFromTensorInfo(i, r) } makeTensorFromTensorInfo(e, t) { const { dataId: n, shape: r, dtype: i } = e, a = new p.qY(r, i, n, this.nextTensorId()); return this.trackTensor(a, t), a } makeVariable(e, t = !0, n, r) { n = n || this.nextVariableId().toString(), null != r && r !== e.dtype && (e = e.cast(r)); const i = new p.rT(e, t, n, this.nextTensorId()); if (null != this.state.registeredVariables[i.name]) throw new Error(`Variable with name ${i.name} was already registered`); return this.state.registeredVariables[i.name] = i, this.incRef(i, this.backend), i } trackTensor(e, t) { this.state.numTensors++, "string" === e.dtype && this.state.numStringTensors++; let n = 0; "complex64" !== e.dtype && "string" !== e.dtype && (n = e.size * c.jv(e.dtype)), this.state.numBytes += n, this.state.tensorInfo.has(e.dataId) || (this.state.numDataBuffers++, this.state.tensorInfo.set(e.dataId, { backend: t || this.backend, dtype: e.dtype, shape: e.shape, bytes: n })), e instanceof p.rT || this.track(e) } incRef(e, t) { this.trackTensor(e, t), this.backend.incRef(e.dataId) } removeDataId(e, t) { this.state.tensorInfo.has(e) && this.state.tensorInfo.get(e).backend === t && (this.state.tensorInfo.delete(e), this.state.numDataBuffers--) } disposeTensor(e) { if (!this.state.tensorInfo.has(e.dataId)) return; const t = this.state.tensorInfo.get(e.dataId); if (this.state.numTensors--, "string" === e.dtype && (this.state.numStringTensors--, this.state.numBytes -= t.bytes), "complex64" !== e.dtype && "string" !== e.dtype) { const t = e.size * c.jv(e.dtype); this.state.numBytes -= t } t.backend.disposeData(e.dataId) && this.removeDataId(e.dataId, t.backend) } disposeVariables() { for (const e in this.state.registeredVariables) { const t = this.state.registeredVariables[e]; this.disposeVariable(t) } } disposeVariable(e) { this.disposeTensor(e), null != this.state.registeredVariables[e.name] && delete this.state.registeredVariables[e.name] } memory() { const e = this.backend.memory(); return e.numTensors = this.state.numTensors, e.numDataBuffers = this.state.numDataBuffers, e.numBytes = this.state.numBytes, this.state.numStringTensors > 0 && (e.unreliable = !0, null == e.reasons && (e.reasons = []), e.reasons.push("Memory usage by string tensors is approximate (2 bytes per character)")), e } async profile(e) { this.state.profiling = !0; const t = this.state.numBytes, n = this.state.numTensors; this.state.activeProfile.kernels = [], this.state.activeProfile.result = await e(), this.state.profiling = !1, this.state.activeProfile.peakBytes = Math.max(...this.state.activeProfile.kernels.map((e => e.totalBytesSnapshot))), this.state.activeProfile.newBytes = this.state.numBytes - t, this.state.activeProfile.newTensors = this.state.numTensors - n; for (const e of this.state.activeProfile.kernels) e.kernelTimeMs = await e.kernelTimeMs, e.extraInfo = await e.extraInfo; return this.state.activeProfile } isTapeOn() { return this.state.gradientDepth > 0 && 0 === this.state.kernelDepth } addTapeNode(e, t, n, r, i, a) { const o = { id: this.state.nextTapeNodeId++, kernelName: e, inputs: t, outputs: n, saved: i }, u = (0, s.vQ)(e); null != u && (r = u.gradFunc), null != r && (o.gradient = e => (e = e.map(((e, t) => { if (null == e) { const e = n[t], r = c.Ty(e.size, e.dtype); return this.makeTensor(r, e.shape, e.dtype) } return e })), r(e.length > 1 ? e : e[0], i, a))), this.state.activeTape.push(o) } keep(e) { return e.kept = !0, e } startTape() { 0 === this.state.gradientDepth && (this.state.activeTape = []), this.state.gradientDepth++ } endTape() { this.state.gradientDepth-- } startScope(e) { const t = { track: [], name: "unnamed scope", id: this.state.nextScopeId++ }; e && (t.name = e), this.state.scopeStack.push(t), this.state.activeScope = t } endScope(e) { const t = (0, m.getTensorsInContainer)(e), n = new Set(t.map((e => e.id))); for (let e = 0; e < this.state.activeScope.track.length; e++) { const t = this.state.activeScope.track[e]; t.kept || n.has(t.id) || t.dispose() } const r = this.state.scopeStack.pop(); this.state.activeScope = 0 === this.state.scopeStack.length ? null : this.state.scopeStack[this.state.scopeStack.length - 1], t.forEach((e => { e.kept || e.scopeId !== r.id || this.track(e) })) } gradients(e, t, n, r = !1) { if (c.vA(t.length > 0, (() => "gradients() received an empty list of xs.")), null != n && "float32" !== n.dtype) throw new Error(`dy must have 'float32' dtype, but has '${n.dtype}'`); const i = this.scopedRun((() => this.startTape()), (() => this.endTape()), (() => this.tidy("forward", e))); c.vA(i instanceof p.qY, (() => "The result y returned by f() must be a tensor.")); const a = /** * @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. * ============================================================================= */ function (e, t, n) { const r = {}, i = {}; for (let e = 0; e < t.length; e++)r[t[e].id] = !0; for (let n = 0; n < e.length; n++) { const a = e[n], o = a.inputs; for (const e in o) { const n = o[e]; let s = !1; for (let e = 0; e < t.length; e++)if (r[n.id]) { a.outputs.forEach((e => r[e.id] = !0)), s = !0, i[a.id] = !0; break } if (s) break } } const a = {}; a[n.id] = !0; const o = {}; for (let t = e.length - 1; t >= 0; t--) { const n = e[t], r = n.inputs; for (let e = 0; e < n.outputs.length; e++)if (a[n.outputs[e].id]) { for (const e in r) a[r[e].id] = !0, o[n.id] = !0; break } } const s = []; for (let t = 0; t < e.length; t++) { const n = e[t]; if (i[n.id] && o[n.id]) { const e = {}; for (const t in n.inputs) { const i = n.inputs[t]; r[i.id] && (e[t] = i) } const t = Object.assign({}, n); t.inputs = e, t.outputs = n.outputs, s.push(t) } } return s }(this.state.activeTape, t, i); if (!r && 0 === a.length && t.length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y."); return this.tidy("backward", (() => { const e = {}; e[i.id] = null == n ? function (e) { const t = (0, c.FZ)((0, c.Ze)(e), "float32"); return x.makeTensor(t, e, "float32") }(i.shape) : n, function (e, t, n, r) { for (let i = t.length - 1; i >= 0; i--) { const a = t[i], o = []; if (a.outputs.forEach((t => { const n = e[t.id]; null != n ? o.push(n) : o.push(null) })), null == a.gradient) throw new Error(`Cannot compute gradient: gradient function not found for ${a.kernelName}.`); const s = a.gradient(o); for (const t in a.inputs) { if (!(t in s)) throw new Error(`Cannot backprop through input ${t}. Available gradients found: ${Object.keys(s)}.`); const i = n((() => s[t]())); if ("float32" !== i.dtype) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input ${t} must have 'float32' dtype, but has '${i.dtype}'`); const o = a.inputs[t]; if (!c.r1(i.shape, o.shape)) throw new Error(`Error in gradient for op ${a.kernelName}. The gradient of input '${t}' has shape '${i.shape}', which does not match the shape of the input '${o.shape}'`); if (null == e[o.id]) e[o.id] = i; else { const t = e[o.id]; e[o.id] = r(t, i), t.dispose() } } } }(e, a, (e => this.tidy(e)), w); const r = t.map((t => e[t.id])); return 0 === this.state.gradientDepth && (this.state.activeTape.forEach((e => { for (const t of e.saved) t.dispose() })), this.state.activeTape = null), { value: i, grads: r } })) } customGrad(e) { return c.vA(c.Tn(e), (() => "The f passed in customGrad(f) must be a function.")), (...t) => { let n; c.vA(t.every((e => e instanceof p.qY)), (() => "The args passed in customGrad(f)(x1, x2,...) must all be tensors")); const r = {}; t.forEach(((e, t) => { r[t] = e })); return this.runKernelFunc({ forwardFunc: (r, i) => (n = e(...t, i), c.vA(n.value instanceof p.qY, (() => "The function f passed in customGrad(f) must return an object where `obj.value` is a tensor")), c.vA(c.Tn(n.gradFunc), (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function.")), n.value), backwardsFunc: (e, r) => { const i = n.gradFunc(e, r), a = Array.isArray(i) ? i : [i]; c.vA(a.length === t.length, (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns the same number of tensors as inputs passed to f(...).")), c.vA(a.every((e => e instanceof p.qY)), (() => "The function f passed in customGrad(f) must return an object where `obj.gradFunc` is a function that returns a list of only tensors.")); const o = {}; return a.forEach(((e, t) => { o[t] = () => e })), o }, inputs: r }) } } readSync(e) { return this.state.tensorInfo.get(e).backend.readSync(e) } read(e) { return this.state.tensorInfo.get(e).backend.read(e) } readToGPU(e, t) { return this.state.tensorInfo.get(e).backend.readToGPU(e, t) } async time(e) { const t = (0, l.now)(), n = await this.backend.time(e); return n.wallMs = (0, l.now)() - t, n } track(e) { return null != this.state.activeScope && (e.scopeId = this.state.activeScope.id, this.state.activeScope.track.push(e)), e } get registeredVariables() { return this.state.registeredVariables } reset() { this.pendingBackendInitId++, this.state.dispose(), this.ENV.reset(), this.state = new y; for (const e in this.registry) this.disposeRegisteredKernels(e), this.registry[e].dispose(), delete this.registry[e]; this.backendName = null, this.backendInstance = null, this.pendingBackendInit = null } } function v() { const e = (0, a.L)(); if (null == e._tfengine) { const t = new i.OH(e); e._tfengine = new b(t) } return (0, i.tj)(e._tfengine.ENV), (0, p.qP)((() => e._tfengine)), e._tfengine } b.nextTensorId = 0, b.nextVariableId = 0; const x = v(); function w(e, t) { const n = { a: e, b: t }; return x.runKernel(o.OMN, n) } }, 6574: (e, t, n) => { "use strict"; n.d(t, { Km: () => u, OH: () => a, _K: () => s, tj: () => l }); var r = n(5119); /** * @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 i = "tfjsflags"; class a { constructor(e) { this.global = e, this.flags = {}, this.flagRegistry = {}, this.urlFlags = {}, this.getQueryParams = o, this.populateURLFlags() } setPlatform(e, t) { null != this.platform && (s().getBool("IS_TEST") || s().getBool("PROD") || console.warn(`Platform ${this.platformName} has already been set. Overwriting the platform with ${e}.`)), this.platformName = e, this.platform = t } registerFlag(e, t, n) { if (this.flagRegistry[e] = { evaluationFn: t, setHook: n }, null != this.urlFlags[e]) { const t = this.urlFlags[e]; s().getBool("IS_TEST") || s().getBool("PROD") || console.warn(`Setting feature override from URL ${e}: ${t}.`), this.set(e, t) } } async getAsync(e) { return e in this.flags || (this.flags[e] = await this.evaluateFlag(e)), this.flags[e] } get(e) { if (e in this.flags) return this.flags[e]; const t = this.evaluateFlag(e); if ((0, r.yL)(t)) throw new Error(`Flag ${e} cannot be synchronously evaluated. Please use getAsync() instead.`); return this.flags[e] = t, this.flags[e] } getNumber(e) { return this.get(e) } getBool(e) { return this.get(e) } getString(e) { return this.get(e) } getFlags() { return this.flags } get features() { return this.flags } set(e, t) { if (null == this.flagRegistry[e]) throw new Error(`Cannot set flag ${e} as it has not been registered.`); this.flags[e] = t, null != this.flagRegistry[e].setHook && this.flagRegistry[e].setHook(t) } evaluateFlag(e) { if (null == this.flagRegistry[e]) throw new Error(`Cannot evaluate flag '${e}': no evaluation function found.`); return this.flagRegistry[e].evaluationFn() } setFlags(e) { this.flags = Object.assign({}, e) } reset() { this.flags = {}, this.urlFlags = {}, this.populateURLFlags() } populateURLFlags() { if (void 0 === this.global || void 0 === this.global.location || void 0 === this.global.location.search) return; const e = this.getQueryParams(this.global.location.search); if (i in e) { e[i].split(",").forEach((e => { const [t, n] = e.split(":"); this.urlFlags[t] = function (e, t) { const n = t.toLowerCase(); return "true" === n || "false" === n ? "true" === n : "" + +n === n ? +n : t }(0, n) })) } } } function o(e) { const t = {}; return e.replace(/[?&]([^=?&]+)(?:=([^&]*))?/g, ((e, ...n) => (function (e, t, n) { e[decodeURIComponent(t)] = decodeURIComponent(n || "") }(t, n[0], n[1]), n.join("=")))), t } function s() { return u } let u = null; function l(e) { u = e } }, 1743: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */ let r; function i() { if (null == r) { let e; if ("undefined" != typeof window) e = window; else if (void 0 !== n.g) e = n.g; else if ("undefined" != typeof process) e = process; else { if ("undefined" == typeof self) throw new Error("Could not find a global object"); e = self } r = e } return r } function a(e, t) { const n = function () { const e = i(); return null == e._tfGlobals && (e._tfGlobals = new Map), e._tfGlobals }(); if (n.has(e)) return n.get(e); { const r = t(); return n.set(e, r), n.get(e) } } n.d(t, { L: () => i, m: () => a }) }, 5287: (e, t, n) => { "use strict"; n.d(t, { AS: () => g, DZ: () => m, Gc: () => x, Hi: () => d, Hs: () => A, IS: () => l, ME: () => p, Ok: () => T, Sm: () => s, W4: () => _, aC: () => y, fL: () => c, gJ: () => C, gY: () => u, go: () => S, jh: () => v, jz: () => w, kB: () => b, m1: () => f, rE: () => k, rm: () => h }); var r = n(1585), i = n(6574), a = n(259), o = n(565); /** * @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 s() { (0, i._K)().set("PROD", !0) } function u() { (0, i._K)().set("DEBUG", !0) } function l() { (0, i._K)().set("DEPRECATION_WARNINGS_ENABLED", !1), console.warn("TensorFlow.js deprecation warnings have been disabled.") } function c(e) { (0, i._K)().getBool("DEPRECATION_WARNINGS_ENABLED") && console.warn(e + " You can disable deprecation warnings with tf.disableDeprecationWarnings().") } function h() { r.T2.disposeVariables() } function d() { return r.T2 } function f() { return r.T2.memory() } function p(e) { return r.T2.profile(e) } function m(e, t) { return r.T2.tidy(e, t) } function g(e) { (0, o.getTensorsInContainer)(e).forEach((e => e.dispose())) } function y(e) { return r.T2.keep(e) } function b(e) { return r.T2.time(e) } function v(e) { return r.T2.setBackend(e) } function x() { return r.T2.ready() } function w() { return r.T2.backendName } function k(e) { r.T2.removeBackend(e) } function S(e) { return r.T2.findBackend(e) } function _(e) { return r.T2.findBackendFactory(e) } function C(e, t, n = 1) { return r.T2.registerBackend(e, t, n) } function A() { return r.T2.backend } function T(e, t) { (0, i._K)().setPlatform(e, t) } (0, a.B4)(c) }, 1830: (e, t, n) => { "use strict"; n.d(t, { Dv: () => s, _X: () => d, jY: () => l, mu: () => c, ok: () => u, y7: () => h }); var r = n(1585), i = n(259), a = n(8189), o = n(5119); /** * @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 s(e) { return o.vA(o.Tn(e), (() => "The f passed in grad(f) must be a function")), (t, n) => { const i = (0, a.YT)(t, "x", "tf.grad", "string_or_numeric"), s = null != n ? (0, a.YT)(n, "dy", "tf.grad") : null; return r.T2.tidy((() => { const { value: t, grads: n } = r.T2.gradients((() => e(i)), [i], s); return null != s && o.O3(t.shape, s.shape, "The shape of dy passed in grad(f)(x, dy) must match the shape returned by f(x)"), f(n), n[0] })) } } function u(e) { return o.vA(o.Tn(e), (() => "The f passed in grads(f) must be a function")), (t, n) => { o.vA(Array.isArray(t), (() => "The args passed in grads(f)(args) must be an array of `Tensor`s or `TensorLike`s")); const i = (0, a.j1)(t, "args", "tf.grads", "string_or_numeric"), s = null != n ? (0, a.YT)(n, "dy", "tf.grads") : null; return r.T2.tidy((() => { const { value: t, grads: n } = r.T2.gradients((() => e(...i)), i, s); return null != s && o.O3(t.shape, s.shape, "The shape of dy passed in grads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), f(n), n })) } } function l(e) { return o.vA(o.Tn(e), (() => "The f passed in valueAndGrad(f) must be a function")), (t, n) => { o.vA(t instanceof i.qY, (() => "The x passed in valueAndGrad(f)(x) must be a tensor")), o.vA(null == n || n instanceof i.qY, (() => "The dy passed in valueAndGrad(f)(x, dy) must be a tensor")); const { grads: a, value: s } = r.T2.gradients((() => e(t)), [t], n); return f(a), { grad: a[0], value: s } } } function c(e) { return o.vA(o.Tn(e), (() => "The f passed in valueAndGrads(f) must be a function")), (t, n) => { o.vA(Array.isArray(t) && t.every((e => e instanceof i.qY)), (() => "The args passed in valueAndGrads(f)(args) must be array of tensors")), o.vA(null == n || n instanceof i.qY, (() => "The dy passed in valueAndGrads(f)(args, dy) must be a tensor")); const a = r.T2.gradients((() => e(...t)), t, n); return null != n && o.O3(a.value.shape, n.shape, "The shape of dy passed in valueAndGrads(f)([x1,...], dy) must match the shape returned by f([x1,...])"), f(a.grads), a } } function h(e, t) { o.vA(o.Tn(e), (() => "The f passed in variableGrads(f) must be a function")), o.vA(null == t || Array.isArray(t) && t.every((e => e instanceof i.rT)), (() => "The varList passed in variableGrads(f, varList) must be an array of variables")); const n = null != t; if (!n) { t = []; for (const e in r.T2.registeredVariables) t.push(r.T2.registeredVariables[e]) } const a = n ? t.filter((e => !e.trainable)) : null, s = t.length; t = t.filter((e => e.trainable)), o.vA(t.length > 0, (() => `variableGrads() expects at least one of the input variables to be trainable, but none of the ${s} variables is trainable.`)); const { value: u, grads: l } = r.T2.gradients(e, t, null, !0); o.vA(l.some((e => null != e)), (() => "Cannot find a connection between any variable and the result of the loss function y=f(x). Please make sure the operations that use variables are inside the function f passed to minimize().")), o.vA(0 === u.rank, (() => `The f passed in variableGrads(f) must return a scalar, but it returned a rank-${u.rank} tensor`)); const c = {}; return t.forEach(((e, t) => { null != l[t] && (c[e.name] = l[t]) })), null != a && a.forEach((e => c[e.name] = null)), { value: u, grads: c } } function d(e) { return r.T2.customGrad(e) } function f(e) { if (e.filter((e => null == e)).length > 0) throw new Error("Cannot compute gradient of y=f(x) with respect to x. Make sure that\n the f you passed encloses all operations that lead from x to y.") } }, 5838: (e, t, n) => { "use strict"; n.r(t), n.d(t, { Abs: () => yt.ljI, Acos: () => yt.Vvy, Acosh: () => yt.PH8, AdadeltaOptimizer: () => Ie, AdagradOptimizer: () => Fe, AdamOptimizer: () => Re, AdamaxOptimizer: () => Pe, Add: () => yt.OMN, AddN: () => yt.EkD, All: () => yt.u8Z, Any: () => yt.FSt, ArgMax: () => yt.Jp_, ArgMin: () => yt.p_m, Asin: () => yt.QKF, Asinh: () => yt.epO, Atan: () => yt.TyE, Atan2: () => yt.lxb, Atanh: () => yt.zP9, AvgPool: () => yt.ho8, AvgPool3D: () => yt.cS, AvgPool3DGrad: () => yt.wwC, AvgPoolGrad: () => yt.VCH, BatchMatMul: () => yt.jAQ, BatchToSpaceND: () => yt.Ik2, Bincount: () => yt.N4F, BitwiseAnd: () => yt.HNs, BroadcastArgs: () => yt.vj7, BroadcastTo: () => yt.LB5, Cast: () => yt.KXH, Ceil: () => yt.QDP, ClipByValue: () => yt.vaV, Complex: () => yt.pr3, ComplexAbs: () => yt.$zE, Concat: () => yt.$dB, Conv2D: () => yt.p2J, Conv2DBackpropFilter: () => yt.rFm, Conv2DBackpropInput: () => yt.jfg, Conv3D: () => yt.A1h, Conv3DBackpropFilterV2: () => yt.iGz, Conv3DBackpropInputV2: () => yt.gC7, Cos: () => yt.Mn0, Cosh: () => yt.MnK, CropAndResize: () => yt.MRQ, Cumprod: () => yt.jj_, Cumsum: () => yt.nY8, DataStorage: () => fr.GJ, DenseBincount: () => yt.wNW, DepthToSpace: () => yt.TMz, DepthwiseConv2dNative: () => yt.tGH, DepthwiseConv2dNativeBackpropFilter: () => yt.X$8, DepthwiseConv2dNativeBackpropInput: () => yt.nVu, Diag: () => yt.ORI, Dilation2D: () => yt.jxD, Dilation2DBackpropFilter: () => yt.pk0, Dilation2DBackpropInput: () => yt.bP9, Draw: () => yt.XmO, ENV: () => b.Km, Einsum: () => yt.Qgm, Elu: () => yt.Pah, EluGrad: () => yt.rsH, Environment: () => b.OH, Equal: () => yt.BRl, Erf: () => yt._s9, Exp: () => yt.ox3, ExpandDims: () => yt.ybN, Expm1: () => yt.ybj, FFT: () => yt.rGP, Fill: () => yt.SQl, FlipLeftRight: () => yt.BxF, Floor: () => yt.ZgB, FloorDiv: () => yt.ElG, FromPixels: () => yt.awo, FusedBatchNorm: () => yt.i5R, FusedConv2D: () => yt.aAr, FusedDepthwiseConv2D: () => yt.T7M, GatherNd: () => yt.O4G, GatherV2: () => yt.mxL, Greater: () => yt.XhZ, GreaterEqual: () => yt.lLS, IFFT: () => yt.OAQ, Identity: () => yt.lzr, Imag: () => yt.dv8, IsFinite: () => yt.gIW, IsInf: () => yt.E3$, IsNan: () => yt.iPs, KernelBackend: () => fr.uI, LRN: () => yt.jM4, LRNGrad: () => yt.ToN, LeakyRelu: () => yt.X0$, Less: () => yt.mIA, LessEqual: () => yt.CwD, LinSpace: () => yt.mnI, Log: () => yt.tG8, Log1p: () => yt.Cg$, LogSoftmax: () => yt.zfU, LogicalAnd: () => yt.RUm, LogicalNot: () => yt.nZd, LogicalOr: () => yt.LXA, LogicalXor: () => yt.RW8, LowerBound: () => yt.yPW, MatrixBandPart: () => yt.WRv, Max: () => yt.VAI, MaxPool: () => yt.t3d, MaxPool3D: () => yt.ySp, MaxPool3DGrad: () => yt.cHb, MaxPoolGrad: () => yt.RXX, MaxPoolWithArgmax: () => yt.TL8, Maximum: () => yt.LDN, Mean: () => yt.g5A, Min: () => yt.lNG, Minimum: () => yt.LG0, MirrorPad: () => yt.x7F, Mod: () => yt.BLA, MomentumOptimizer: () => Le, Multinomial: () => yt.WT3, Multiply: () => yt.xu7, Neg: () => yt.l0G, NonMaxSuppressionV3: () => yt.SDM, NonMaxSuppressionV4: () => yt.Zl4, NonMaxSuppressionV5: () => yt.e0f, NotEqual: () => yt.ylV, OP_SCOPE_SUFFIX: () => Zt.BTT, OneHot: () => yt.urI, OnesLike: () => yt.LWX, Optimizer: () => Ne, OptimizerConstructors: () => Xt, Pack: () => yt.mM$, PadV2: () => yt.ODT, Pool: () => yt.bCz, Pow: () => yt.pyJ, Prelu: () => yt.Ncv, Prod: () => yt.kdj, RMSPropOptimizer: () => je, RaggedGather: () => yt.oJ2, RaggedRange: () => yt.CQC, RaggedTensorToTensor: () => yt.mH5, Range: () => yt.Q6t, Rank: () => Kt.rg, Real: () => yt.LRy, RealDiv: () => yt.sDr, Reciprocal: () => yt.huO, Reduction: () => Jt.i, Relu: () => yt.fUj, Relu6: () => yt.P_L, Reshape: () => yt.R23, ResizeBilinear: () => yt.hgw, ResizeBilinearGrad: () => yt.FCQ, ResizeNearestNeighbor: () => yt.jOE, ResizeNearestNeighborGrad: () => yt.XQy, Reverse: () => yt.D7i, RotateWithOffset: () => yt.BK4, Round: () => yt.hVg, Rsqrt: () => yt.TOR, SGDOptimizer: () => Be, ScatterNd: () => yt.pJc, SearchSorted: () => yt.uWl, Select: () => yt.l6P, Selu: () => yt.u$b, Sigmoid: () => yt.vI1, Sign: () => yt.YVe, Sin: () => yt.hql, Sinh: () => yt.J3C, Slice: () => yt.JiE, Softmax: () => yt.rFG, Softplus: () => yt.Fin, SpaceToBatchND: () => yt.A8B, SparseFillEmptyRows: () => yt.C8s, SparseReshape: () => yt.BoJ, SparseSegmentMean: () => yt.L6G, SparseSegmentSum: () => yt.DvZ, SparseToDense: () => yt.jgd, SplitV: () => yt.Blb, Sqrt: () => yt.dFH, Square: () => yt.M6A, SquaredDifference: () => yt.Ddj, StaticRegexReplace: () => yt.GZp, Step: () => yt.pnw, StridedSlice: () => yt.UcO, StringNGrams: () => yt.YAb, StringSplit: () => yt.iW0, StringToHashBucketFast: () => yt.$jE, Sub: () => yt.PbM, Sum: () => yt.WuN, Tan: () => yt.oFs, Tanh: () => yt.iuW, Tensor: () => de.qY, TensorBuffer: () => de.yl, TensorScatterUpdate: () => yt.X4r, Tile: () => yt.FAs, TopK: () => yt.TBb, Transform: () => yt.dLy, Transpose: () => yt.wx0, Unique: () => yt.EwU, Unpack: () => yt.dXR, UnsortedSegmentSum: () => yt.pPe, UpperBound: () => yt.RMm, Variable: () => de.rT, ZerosLike: () => yt.xJ3, _FusedMatMul: () => yt.Dr, abs: () => Zt.tnl, acos: () => Zt.HQu, acosh: () => Zt.FqL, add: () => Zt.WQq, addN: () => Zt.QiD, all: () => Zt.Q7R, any: () => Zt.bzn, argMax: () => Zt.FLi, argMin: () => Zt.XRg, asin: () => Zt.qRo, asinh: () => Zt.yHs, atan: () => Zt.rYl, atan2: () => Zt.FPz, atanh: () => Zt.rfv, avgPool: () => Zt.$jT, avgPool3d: () => Zt.sub, backend: () => pe.Hs, backend_util: () => h, basicLSTMCell: () => Zt.lZX, batchNorm: () => Zt.$v7, batchNorm2d: () => Zt.BFc, batchNorm3d: () => Zt.kSi, batchNorm4d: () => Zt.T5N, batchToSpaceND: () => Zt.GTe, bincount: () => Zt.HbZ, bitwiseAnd: () => Zt.vjT, booleanMaskAsync: () => Zt.ftb, broadcastArgs: () => Zt.ROE, broadcastTo: () => Zt.hOW, broadcast_util: () => gt, browser: () => s, buffer: () => Zt.ra8, cast: () => Zt.wgE, ceil: () => Zt.mkO, clipByValue: () => Zt.zQh, clone: () => Zt.o8B, complex: () => Zt.faB, concat: () => Zt.xWs, concat1d: () => Zt.I1m, concat2d: () => Zt.RPU, concat3d: () => Zt.O5O, concat4d: () => Zt.P1l, conv1d: () => Zt.kA9, conv2d: () => Zt.Xtf, conv2dTranspose: () => Zt.wX9, conv3d: () => Zt.IPL, conv3dTranspose: () => Zt.jIJ, copyRegisteredKernels: () => bt.Cf, cos: () => Zt.gnS, cosh: () => Zt.yIG, cosineWindow: () => Zt._jP, cumprod: () => Zt.Lp0, cumsum: () => Zt.rCv, customGrad: () => we._X, denseBincount: () => Zt.aOp, deprecationWarn: () => pe.fL, depthToSpace: () => Zt.Rj8, depthwiseConv2d: () => Zt.Gl3, device_util: () => r, diag: () => Zt.smy, dilation2d: () => Zt.X7t, disableDeprecationWarnings: () => pe.IS, dispose: () => pe.AS, disposeVariables: () => pe.rm, div: () => Zt.y4m, divNoNan: () => Zt.ek5, dot: () => Zt.Omf, dropout: () => Zt.EZY, einsum: () => Zt._3C, elu: () => Zt.Pqc, enableDebugMode: () => pe.gY, enableProdMode: () => pe.Sm, enclosingPowerOfTwo: () => Zt.FJY, engine: () => pe.Hi, ensureShape: () => Zt.QP2, env: () => b._K, equal: () => Zt.LCg, erf: () => Zt.Y12, euclideanNorm: () => Zt.p4S, exp: () => Zt.oNF, expandDims: () => Zt.UG6, expm1: () => Zt.IYd, eye: () => Zt.y5U, fft: () => Zt.hVP, fill: () => Zt.GSj, findBackend: () => pe.go, findBackendFactory: () => pe.W4, floor: () => Zt.RIf, floorDiv: () => Zt.wh_, fused: () => Zt.cZk, gather: () => Zt.kgh, gatherND: () => Zt.SY9, gather_util: () => u, getBackend: () => pe.jz, getGradient: () => bt.vQ, getKernel: () => bt._5, getKernelsForBackend: () => bt.Op, grad: () => we.Dv, grads: () => we.ok, greater: () => Zt.rhj, greaterEqual: () => Zt.DQN, ifft: () => Zt.KGM, imag: () => Zt.ngS, image: () => Zt.Slp, inTopKAsync: () => Zt.U4u, io: () => a, irfft: () => Zt.ggX, isFinite: () => Zt.MIs, isInf: () => Zt.EN4, isNaN: () => Zt.yrW, keep: () => pe.aC, kernel_impls: () => d, leakyRelu: () => Zt.H8d, less: () => Zt.M7h, lessEqual: () => Zt.InN, linalg: () => Zt.mPL, linspace: () => Zt.mT8, localResponseNormalization: () => Zt.Kgs, log: () => Zt.Rm2, log1p: () => Zt.Kko, logSigmoid: () => Zt.nqI, logSoftmax: () => Zt.HPB, logSumExp: () => Zt.VZ, logicalAnd: () => Zt.n76, logicalNot: () => Zt.NSZ, logicalOr: () => Zt.ztW, logicalXor: () => Zt.rxB, losses: () => Zt.YYh, lowerBound: () => Zt.yzS, matMul: () => Zt.NoW, math: () => o, max: () => Zt.T9B, maxPool: () => Zt.jgi, maxPool3d: () => Zt.NYV, maxPoolWithArgmax: () => Zt.RO, maximum: () => Zt.PhQ, mean: () => Zt.i2o, memory: () => pe.m1, meshgrid: () => Zt.OYQ, min: () => Zt.jkA, minimum: () => Zt.BpO, mirrorPad: () => Zt.FFZ, mod: () => Zt.ziu, moments: () => Zt.Clk, movingAverage: () => Zt.CRk, mul: () => Zt.lKK, multiRNNCell: () => Zt.YDF, multinomial: () => Zt.OjQ, neg: () => Zt.HZy, nextFrame: () => tn, norm: () => Zt.xbf, notEqual: () => Zt.Ec, oneHot: () => Zt.Mw0, ones: () => Zt.SaS, onesLike: () => Zt.P61, op: () => Zt.op, outerProduct: () => Zt.X4o, pad: () => Zt.eVF, pad1d: () => Zt.BZs, pad2d: () => Zt.grY, pad3d: () => Zt.XHu, pad4d: () => Zt.WLX, pool: () => Zt.dzn, pow: () => Zt.n7C, prelu: () => Zt.NsG, print: () => Zt.yyV, prod: () => Zt._eU, profile: () => pe.ME, raggedGather: () => Zt.whe, raggedRange: () => Zt.iyU, raggedTensorToTensor: () => Zt.Q0_, rand: () => Zt._9M, randomGamma: () => Zt.pR9, randomNormal: () => Zt.FE$, randomStandardNormal: () => Zt.m0H, randomUniform: () => Zt.YeY, randomUniformInt: () => Zt.HYA, range: () => Zt.y17, ready: () => pe.Gc, real: () => Zt.xav, reciprocal: () => Zt.VOZ, registerBackend: () => pe.gJ, registerGradient: () => bt.kr, registerKernel: () => bt.tA, relu: () => Zt.VVh, relu6: () => Zt.j__, removeBackend: () => pe.rE, reshape: () => Zt.tQQ, reverse: () => Zt.BEg, reverse1d: () => Zt.QD2, reverse2d: () => Zt.LMr, reverse3d: () => Zt.I2l, reverse4d: () => Zt.JYU, rfft: () => Zt.z8$, round: () => Zt.LIG, rsqrt: () => Zt.Z$r, scalar: () => Zt.d_2, scatterND: () => Zt.NFr, scatter_util: () => It, searchSorted: () => Zt.sZg, selu: () => Zt.WfX, separableConv2d: () => Zt.wdz, serialization: () => i, setBackend: () => pe.jh, setPlatform: () => pe.Ok, setdiff1dAsync: () => Zt.F12, sigmoid: () => Zt.ry7, sign: () => Zt._SZ, signal: () => Zt.vPA, sin: () => Zt.F8e, sinh: () => Zt.L0l, slice: () => Zt.dik, slice1d: () => Zt.Q$M, slice2d: () => Zt.zAd, slice3d: () => Zt.wck, slice4d: () => Zt.R0O, slice_util: () => Mt, softmax: () => Zt.Vs9, softplus: () => Zt.lw0, spaceToBatchND: () => Zt.eDJ, sparse: () => Zt.lMo, sparseToDense: () => Zt.Zhr, spectral: () => Zt.lOn, split: () => Zt.lDo, sqrt: () => Zt.RZD, square: () => Zt.EwI, squaredDifference: () => Zt.Pbu, squeeze: () => Zt.r2V, stack: () => Zt.t$z, step: () => Zt.PMw, stridedSlice: () => Zt.Ym9, string: () => Zt.YjP, sub: () => Zt.jbE, sum: () => Zt.czq, sumOutType: () => Kt.ch, tan: () => Zt.Mlm, tanh: () => Zt.ymU, tensor: () => Zt.OEK, tensor1d: () => Zt.tGX, tensor2d: () => Zt.KtR, tensor3d: () => Zt.$_$, tensor4d: () => Zt.g9W, tensor5d: () => Zt.Lpo, tensor6d: () => Zt.yxw, tensorScatterUpdate: () => Zt.NNh, tensor_util: () => Ft, test_util: () => l, tidy: () => pe.DZ, tile: () => Zt.Vsq, time: () => pe.kB, topk: () => Zt.rfw, train: () => Qt, transpose: () => Zt.mgz, truncatedNormal: () => Zt.efE, unique: () => Zt.AmM, unregisterGradient: () => bt.rY, unregisterKernel: () => bt.iP, unsortedSegmentSum: () => Zt.zAU, unstack: () => Zt.K$i, upcastType: () => Kt.Tu, upperBound: () => Zt.rni, util: () => Dt, valueAndGrad: () => we.jY, valueAndGrads: () => we.mu, variable: () => Zt.bvq, variableGrads: () => we.y7, version_core: () => Yt, where: () => Zt._M9, whereAsync: () => Zt.YJN, zeros: () => Zt.Ul9, zerosLike: () => Zt.POl }); var r = {}; n.r(r), n.d(r, { isBrowser: () => y, isMobile: () => g, mockIsMobile: () => m }); var i = {}; n.r(i), n.d(i, { Serializable: () => Ce, SerializationMap: () => Ae, getRegisteredName: () => Ee, registerClass: () => Te }); var a = {}; n.r(a), n.d(a, { CompositeArrayBuffer: () => A.D, browserFiles: () => He, browserHTTPRequest: () => nt, concatenateArrayBuffers: () => x.AQ, copyModel: () => te, decodeWeights: () => x.CY, decodeWeightsStream: () => x.s5, encodeWeights: () => x.aG, fromMemory: () => ot, fromMemorySync: () => st, getLoadHandlers: () => C, getModelArtifactsForJSON: () => x.Ej, getModelArtifactsForJSONSync: () => x.Rl, getModelArtifactsInfoForJSON: () => x.oR, getSaveHandlers: () => _, getWeightSpecs: () => x.Xf, http: () => tt, isHTTPScheme: () => Qe, listModels: () => Q, loadWeights: () => Ke, moveModel: () => ne, registerLoadRouter: () => S, registerSaveRouter: () => k, removeModel: () => ee, weightsLoaderFactory: () => Ze, withSaveHandler: () => ut, withSaveHandlerSync: () => lt }); var o = {}; n.r(o), n.d(o, { confusionMatrix: () => mt }); var s = {}; n.r(s), n.d(s, { draw: () => Tt, fromPixels: () => Et, fromPixelsAsync: () => _t, toPixels: () => At }); var u = {}; n.r(u), n.d(u, { prepareAndValidate: () => Nt }); var l = {}; n.r(l), n.d(l, { TEST_EPSILON_FLOAT16: () => Rt, createVideoElement: () => Ht, encodeStrings: () => Gt, expectArrayBuffersEqual: () => Vt, expectArraysClose: () => Ot, expectArraysEqual: () => Lt, expectNumbersClose: () => jt, expectPromiseToFail: () => Bt, expectValuesInRange: () => Wt, play: () => qt, testEpsilon: () => zt }); var c = {}; n.r(c), n.d(c, { collectGatherOpShapeInfo: () => ur, computeOutShape: () => sr, segOpComputeOptimalWindowSize: () => or }); var h = {}; n.r(h), n.d(h, { ERF_A1: () => Sn, ERF_A2: () => _n, ERF_A3: () => Cn, ERF_A4: () => An, ERF_A5: () => Tn, ERF_P: () => kn, PARALLELIZE_THRESHOLD: () => fn, RowPartitionType: () => on, SELU_SCALE: () => wn.X, SELU_SCALEALPHA: () => wn.j, applyActivation: () => un.f2, assertAndGetBroadcastShape: () => gt.assertAndGetBroadcastShape, assertAxesAreInnerMostDims: () => nn.WC, assertParamsConsistent: () => rn, assignToTypedArray: () => $n, axesAreInnerMostDims: () => nn.WH, calculateShapes: () => It.calculateShapes, checkEinsumDimSizes: () => Wn, checkPadOnDimRoundingMode: () => sn.s_, combineLocations: () => nn.aF, combineRaggedTensorToTensorShapes: () => ln, complexWithEvenIndex: () => Mn, complexWithOddIndex: () => Fn, computeConv2DInfo: () => sn.uf, computeConv3DInfo: () => sn.p$, computeDefaultPad: () => sn.G8, computeDilation2DInfo: () => sn.YQ, computeOptimalWindowSize: () => pn, computeOutAndReduceShapes: () => nn.lb, computeOutShape: () => an, computePool2DInfo: () => sn.E6, computePool3DInfo: () => sn.l5, convertConv2DDataFormat: () => sn.$Q, decodeEinsumEquation: () => jn, eitherStridesOrDilationsAreOne: () => sn.G0, expandShapeToKeepDim: () => nn.SM, exponent: () => On, exponents: () => Rn, fromStringArrayToUint8: () => cr, fromUint8ToStringArray: () => lr, getAxesPermutation: () => nn.Em, getBroadcastDims: () => gt.getBroadcastDims, getComplexWithIndex: () => Dn, getEinsumComputePath: () => Vn, getEinsumPermutation: () => Un, getFusedBiasGradient: () => un.Do, getFusedDyActivation: () => un.XB, getImageCenter: () => mn, getInnerMostAxes: () => nn.fK, getPermuted: () => yn, getRaggedRank: () => hn, getReductionAxes: () => gt.getReductionAxes, getReshaped: () => gn, getReshapedPermuted: () => bn, getRowPartitionTypesHelper: () => cn, getSliceBeginCoords: () => vn, getSliceSize: () => xn, getSparseFillEmptyRowsIndicesDenseShapeMismatch: () => Yn, getSparseFillEmptyRowsNegativeIndexErrorMessage: () => Xn, getSparseFillEmptyRowsOutOfRangeIndexErrorMessage: () => Kn, getSparseReshapeEmptyTensorZeroOutputDimErrorMessage: () => Qn, getSparseReshapeInputOutputMismatchErrorMessage: () => tr, getSparseReshapeInputOutputMultipleErrorMessage: () => er, getSparseReshapeMultipleNegativeOneOutputDimErrorMessage: () => Zn, getSparseReshapeNegativeOutputDimErrorMessage: () => Jn, getSparseSegmentReductionIndicesOutOfRangeErrorMessage: () => ar, getSparseSegmentReductionNegativeSegmentIdsErrorMessage: () => nr, getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage: () => rr, getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage: () => ir, getUndoAxesPermutation: () => nn.gx, isIdentityPermutation: () => Gn, log: () => En.R, mergeRealAndImagArrays: () => Nn, prepareAndValidate: () => Nt, prepareSplitSize: () => qn, segment_util: () => c, shouldFuse: () => un.zE, slice_util: () => Mt, splitRealAndImagArrays: () => In, stridesOrDilationsArePositive: () => sn.qk, tupleValuesAreOne: () => sn.Dh, upcastType: () => Kt.Tu, validateDefaultValueShape: () => dn, validateInput: () => It.validateInput, validateUpdateShape: () => It.validateUpdateShape, warn: () => En.i }); var d = {}; n.r(d), n.d(d, { nonMaxSuppressionV3Impl: () => hr.c7, nonMaxSuppressionV4Impl: () => hr.ZS, nonMaxSuppressionV5Impl: () => hr.ut, whereImpl: () => dr.Y }); var f = n(1585); let p; function m(e) { p = e } function g(e) { if (void 0 !== p) return p; if (e || "undefined" != typeof navigator && null != navigator) { if (e || (e = navigator), "ReactNative" === e.product) return !0; const t = e.userAgent || e.vendor || ("undefined" != typeof window ? window.opera : ""); if (!t) { const t = e; return t.userAgentData && t.userAgentData.mobile } return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(t) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(t.substr(0, 4)) } return !1 } function y() { return "undefined" != typeof window && null != window.document || "undefined" != typeof WorkerGlobalScope } var b = n(6574); /** * @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 v = (0, b._K)(); v.registerFlag("DEBUG", (() => !1), (e => { e && console.warn("Debugging mode is ON. The output of every math call will be downloaded to CPU and checked for NaNs. This significantly impacts performance.") })), v.registerFlag("IS_BROWSER", (() => y())), v.registerFlag("IS_NODE", (() => "undefined" != typeof process && void 0 !== process.versions && void 0 !== process.versions.node)), v.registerFlag("IS_CHROME", (() => "undefined" != typeof navigator && null != navigator && null != navigator.userAgent && /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor))), v.registerFlag("IS_SAFARI", (() => "undefined" != typeof navigator && null != navigator && null != navigator.userAgent && /Safari/.test(navigator.userAgent) && /Apple/.test(navigator.vendor))), v.registerFlag("PROD", (() => !1)), v.registerFlag("TENSORLIKE_CHECK_SHAPE_CONSISTENCY", (() => v.getBool("DEBUG"))), v.registerFlag("DEPRECATION_WARNINGS_ENABLED", (() => !0)), v.registerFlag("IS_TEST", (() => !1)), v.registerFlag("CHECK_COMPUTATION_FOR_ERRORS", (() => v.getBool("DEBUG"))), v.registerFlag("WRAP_TO_IMAGEBITMAP", (() => !1)), v.registerFlag("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU", (() => !1)), v.registerFlag("USE_SETTIMEOUTCUSTOM", (() => !1)); var x = n(7084); /** * @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 w { constructor() { this.saveRouters = [], this.loadRouters = [] } static getInstance() { return null == w.instance && (w.instance = new w), w.instance } static registerSaveRouter(e) { w.getInstance().saveRouters.push(e) } static registerLoadRouter(e) { w.getInstance().loadRouters.push(e) } static getSaveHandlers(e) { return w.getHandlers(e, "save") } static getLoadHandlers(e, t) { return w.getHandlers(e, "load", t) } static getHandlers(e, t, n) { const r = []; return ("load" === t ? w.getInstance().loadRouters : w.getInstance().saveRouters).forEach((t => { const i = t(e, n); null !== i && r.push(i) })), r } } const k = e => w.registerSaveRouter(e), S = e => w.registerLoadRouter(e), _ = e => w.getSaveHandlers(e), C = (e, t) => w.getLoadHandlers(e, t); var A = n(6734); /** * @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 T = "tensorflowjs", E = "models_store", N = "model_info_store"; function I() { if (!(0, b._K)().getBool("IS_BROWSER")) throw new Error("Failed to obtain IndexedDB factory because the current environmentis not a web browser."); const e = "undefined" == typeof window ? self : window, t = e.indexedDB || e.mozIndexedDB || e.webkitIndexedDB || e.msIndexedDB || e.shimIndexedDB; if (null == t) throw new Error("The current browser does not appear to support IndexedDB."); return t } function M(e) { const t = e.result; t.createObjectStore(E, { keyPath: "modelPath" }), t.createObjectStore(N, { keyPath: "modelPath" }) } class F { constructor(e) { if (this.indexedDB = I(), null == e || !e) throw new Error("For IndexedDB, modelPath must not be null, undefined or empty."); this.modelPath = e } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); return this.databaseAction(this.modelPath, e) } async load() { return this.databaseAction(this.modelPath) } databaseAction(e, t) { return new Promise(((e, n) => { const r = this.indexedDB.open(T, 1); r.onupgradeneeded = () => M(r), r.onsuccess = () => { const i = r.result; if (null == t) { const t = i.transaction(E, "readonly"), r = t.objectStore(E).get(this.modelPath); r.onsuccess = () => { if (null == r.result) return i.close(), n(new Error(`Cannot find model with path '${this.modelPath}' in IndexedDB.`)); e(r.result.modelArtifacts) }, r.onerror = e => (i.close(), n(r.error)), t.oncomplete = () => i.close() } else { t.weightData = A.D.join(t.weightData); const r = (0, x.oR)(t), a = i.transaction(N, "readwrite"); let o, s, u = a.objectStore(N); try { o = u.put({ modelPath: this.modelPath, modelArtifactsInfo: r }) } catch (e) { return n(e) } o.onsuccess = () => { s = i.transaction(E, "readwrite"); const o = s.objectStore(E); let l; try { l = o.put({ modelPath: this.modelPath, modelArtifacts: t, modelArtifactsInfo: r }) } catch (e) { return n(e) } l.onsuccess = () => e({ modelArtifactsInfo: r }), l.onerror = e => { u = a.objectStore(N); const t = u.delete(this.modelPath); t.onsuccess = () => (i.close(), n(l.error)), t.onerror = e => (i.close(), n(l.error)) } }, o.onerror = e => (i.close(), n(o.error)), a.oncomplete = () => { null == s ? i.close() : s.oncomplete = () => i.close() } } }, r.onerror = e => n(r.error) })) } } F.URL_SCHEME = "indexeddb://"; const D = e => { return (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(F.URL_SCHEME) ? (t = e.slice(F.URL_SCHEME.length), new F(t)) : null; var t }; w.registerSaveRouter(D), w.registerLoadRouter(D); class $ { constructor() { this.indexedDB = I() } async listModels() { return new Promise(((e, t) => { const n = this.indexedDB.open(T, 1); n.onupgradeneeded = () => M(n), n.onsuccess = () => { const r = n.result, i = r.transaction(N, "readonly"), a = i.objectStore(N).getAll(); a.onsuccess = () => { const t = {}; for (const e of a.result) t[e.modelPath] = e.modelArtifactsInfo; e(t) }, a.onerror = e => (r.close(), t(a.error)), i.oncomplete = () => r.close() }, n.onerror = e => t(n.error) })) } async removeModel(e) { var t; return e = (t = e).startsWith(F.URL_SCHEME) ? t.slice(F.URL_SCHEME.length) : t, new Promise(((t, n) => { const r = this.indexedDB.open(T, 1); r.onupgradeneeded = () => M(r), r.onsuccess = () => { const i = r.result, a = i.transaction(N, "readwrite"), o = a.objectStore(N), s = o.get(e); let u; s.onsuccess = () => { if (null == s.result) return i.close(), n(new Error(`Cannot find model with path '${e}' in IndexedDB.`)); { const r = o.delete(e), a = () => { u = i.transaction(E, "readwrite"); const r = u.objectStore(E).delete(e); r.onsuccess = () => t(s.result.modelArtifactsInfo), r.onerror = e => n(s.error) }; r.onsuccess = a, r.onerror = e => (a(), i.close(), n(s.error)) } }, s.onerror = e => (i.close(), n(s.error)), a.oncomplete = () => { null == u ? i.close() : u.oncomplete = () => i.close() } }, r.onerror = e => n(r.error) })) } } var R = n(5119); /** * @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 O = "/", z = "tensorflowjs_models", P = "info", B = "model_topology", L = "weight_specs", j = "weight_data", U = "model_metadata"; function W(e) { return { info: [z, e, P].join(O), topology: [z, e, B].join(O), weightSpecs: [z, e, L].join(O), weightData: [z, e, j].join(O), modelMetadata: [z, e, U].join(O) } } function V(e) { for (const t of Object.values(e)) window.localStorage.removeItem(t) } function G(e) { const t = e.split(O); if (t.length < 3) throw new Error(`Invalid key format: ${e}`); return t.slice(1, t.length - 1).join(O) } class H { constructor(e) { if (!(0, b._K)().getBool("IS_BROWSER") || "undefined" == typeof window || void 0 === window.localStorage) throw new Error("The current environment does not support local storage."); if (this.LS = window.localStorage, null == e || !e) throw new Error("For local storage, modelPath must not be null, undefined or empty."); this.modelPath = e, this.keys = W(this.modelPath) } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserLocalStorage.save() does not support saving model topology in binary formats yet."); { const t = JSON.stringify(e.modelTopology), n = JSON.stringify(e.weightSpecs), r = (0, x.oR)(e), i = A.D.join(e.weightData); try { this.LS.setItem(this.keys.info, JSON.stringify(r)), this.LS.setItem(this.keys.topology, t), this.LS.setItem(this.keys.weightSpecs, n), this.LS.setItem(this.keys.weightData, (0, x.l3)(i)); const a = { format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, signature: null != e.signature ? e.signature : void 0, userDefinedMetadata: null != e.userDefinedMetadata ? e.userDefinedMetadata : void 0, modelInitializer: null != e.modelInitializer ? e.modelInitializer : void 0, initializerSignature: null != e.initializerSignature ? e.initializerSignature : void 0, trainingConfig: null != e.trainingConfig ? e.trainingConfig : void 0 }; return this.LS.setItem(this.keys.modelMetadata, JSON.stringify(a)), { modelArtifactsInfo: r } } catch (e) { throw V(this.keys), new Error(`Failed to save model '${this.modelPath}' to local storage: size quota being exceeded is a possible cause of this failure: modelTopologyBytes=${r.modelTopologyBytes}, weightSpecsBytes=${r.weightSpecsBytes}, weightDataBytes=${r.weightDataBytes}.`) } } } async load() { const e = JSON.parse(this.LS.getItem(this.keys.info)); if (null == e) throw new Error(`In local storage, there is no model with name '${this.modelPath}'`); if ("JSON" !== e.modelTopologyType) throw new Error("BrowserLocalStorage does not support loading non-JSON model topology yet."); const t = {}, n = JSON.parse(this.LS.getItem(this.keys.topology)); if (null == n) throw new Error(`In local storage, the topology of model '${this.modelPath}' is missing.`); t.modelTopology = n; const r = JSON.parse(this.LS.getItem(this.keys.weightSpecs)); if (null == r) throw new Error(`In local storage, the weight specs of model '${this.modelPath}' are missing.`); t.weightSpecs = r; const i = this.LS.getItem(this.keys.modelMetadata); if (null != i) { const e = JSON.parse(i); t.format = e.format, t.generatedBy = e.generatedBy, t.convertedBy = e.convertedBy, null != e.signature && (t.signature = e.signature), null != e.userDefinedMetadata && (t.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (t.modelInitializer = e.modelInitializer), null != e.initializerSignature && (t.initializerSignature = e.initializerSignature), null != e.trainingConfig && (t.trainingConfig = e.trainingConfig) } const a = this.LS.getItem(this.keys.weightData); if (null == a) throw new Error(`In local storage, the binary weight values of model '${this.modelPath}' are missing.`); return t.weightData = (0, x.jf)(a), t } } H.URL_SCHEME = "localstorage://"; const q = e => { return (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(H.URL_SCHEME) ? (t = e.slice(H.URL_SCHEME.length), new H(t)) : null; var t }; w.registerSaveRouter(q), w.registerLoadRouter(q); class Y { constructor() { (0, R.vA)((0, b._K)().getBool("IS_BROWSER"), (() => "Current environment is not a web browser")), (0, R.vA)("undefined" == typeof window || void 0 !== window.localStorage, (() => "Current browser does not appear to support localStorage")), this.LS = window.localStorage } async listModels() { const e = {}, t = z + O, n = O + P; for (let r = 0; r < this.LS.length; ++r) { const i = this.LS.key(r); if (i.startsWith(t) && i.endsWith(n)) { e[G(i)] = JSON.parse(this.LS.getItem(i)) } } return e } async removeModel(e) { var t; const n = W(e = (t = e).startsWith(H.URL_SCHEME) ? t.slice(H.URL_SCHEME.length) : t); if (null == this.LS.getItem(n.info)) throw new Error(`Cannot find model at path '${e}'`); const r = JSON.parse(this.LS.getItem(n.info)); return V(n), r } } /** * @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 X = "://"; class K { constructor() { this.managers = {} } static getInstance() { return null == K.instance && (K.instance = new K), K.instance } static registerManager(e, t) { (0, R.vA)(null != e, (() => "scheme must not be undefined or null.")), e.endsWith(X) && (e = e.slice(0, e.indexOf(X))), (0, R.vA)(e.length > 0, (() => "scheme must not be an empty string.")); const n = K.getInstance(); (0, R.vA)(null == n.managers[e], (() => `A model store manager is already registered for scheme '${e}'.`)), n.managers[e] = t } static getManager(e) { const t = K.getInstance().managers[e]; if (null == t) throw new Error(`Cannot find model manager for scheme '${e}'`); return t } static getSchemes() { return Object.keys(K.getInstance().managers) } } function Z(e) { if (-1 === e.indexOf(X)) throw new Error(`The url string provided does not contain a scheme. Supported schemes are: ${K.getSchemes().join(",")}`); return { scheme: e.split(X)[0], path: e.split(X)[1] } } async function J(e, t, n = !1) { (0, R.vA)(e !== t, (() => `Old path and new path are the same: '${e}'`)); const r = w.getLoadHandlers(e); (0, R.vA)(r.length > 0, (() => `Copying failed because no load handler is found for source URL ${e}.`)), (0, R.vA)(r.length < 2, (() => `Copying failed because more than one (${r.length}) load handlers for source URL ${e}.`)); const i = r[0], a = w.getSaveHandlers(t); (0, R.vA)(a.length > 0, (() => `Copying failed because no save handler is found for destination URL ${t}.`)), (0, R.vA)(a.length < 2, (() => `Copying failed because more than one (${r.length}) save handlers for destination URL ${t}.`)); const o = a[0], s = Z(e).scheme, u = Z(e).path, l = s === Z(e).scheme, c = await i.load(); n && l && await K.getManager(s).removeModel(u); const h = await o.save(c); return n && !l && await K.getManager(s).removeModel(u), h.modelArtifactsInfo } async function Q() { const e = K.getSchemes(), t = {}; for (const n of e) { const e = await K.getManager(n).listModels(); for (const r in e) { t[n + X + r] = e[r] } } return t } async function ee(e) { const t = Z(e); return K.getManager(t.scheme).removeModel(t.path) } async function te(e, t) { return J(e, t, !1) } async function ne(e, t) { return J(e, t, !0) } var re = n(6448); /** * @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. * ============================================================================= */ class ie { constructor() { this.messageName = "setTimeoutCustom", this.functionRefs = [], this.handledMessageCount = 0, this.hasEventListener = !1 } fetch(e, t) { return fetch(e, t) } now() { return performance.now() } encode(e, t) { if ("utf-8" !== t && "utf8" !== t) throw new Error(`Browser's encoder only supports utf-8, but got ${t}`); return null == this.textEncoder && (this.textEncoder = new TextEncoder), this.textEncoder.encode(e) } decode(e, t) { return new TextDecoder(t).decode(e) } setTimeoutCustom(e, t) { "undefined" != typeof window && (0, b._K)().getBool("USE_SETTIMEOUTCUSTOM") ? (this.functionRefs.push(e), setTimeout((() => { window.postMessage({ name: this.messageName, index: this.functionRefs.length - 1 }, "*") }), t), this.hasEventListener || (this.hasEventListener = !0, window.addEventListener("message", (e => { if (e.source === window && e.data.name === this.messageName) { e.stopPropagation(); (0, this.functionRefs[e.data.index])(), this.handledMessageCount++, this.handledMessageCount === this.functionRefs.length && (this.functionRefs = [], this.handledMessageCount = 0) } }), !0))) : setTimeout(e, t) } isTypedArray(e) { return (0, re.Y)(e) } } if ((0, b._K)().get("IS_BROWSER")) { (0, b._K)().setPlatform("browser", new ie); try { K.registerManager(H.URL_SCHEME, new Y) } catch (e) { } try { K.registerManager(F.URL_SCHEME, new $) } catch (e) { } } /** * @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 ae = () => n(5817); let oe; class se { constructor() { this.util = n(8590), this.textEncoder = new this.util.TextEncoder } fetch(e, t) { return null != (0, b._K)().global.fetch ? (0, b._K)().global.fetch(e, t) : (null == oe && (oe = ae()), oe(e, t)) } now() { const e = process.hrtime(); return 1e3 * e[0] + e[1] / 1e6 } encode(e, t) { if ("utf-8" !== t && "utf8" !== t) throw new Error(`Node built-in encoder only supports utf-8, but got ${t}`); return this.textEncoder.encode(e) } decode(e, t) { return 0 === e.length ? "" : new this.util.TextDecoder(t).decode(e) } isTypedArray(e) { return this.util.types.isFloat32Array(e) || this.util.types.isInt32Array(e) || this.util.types.isUint8Array(e) || this.util.types.isUint8ClampedArray(e) } } (0, b._K)().get("IS_NODE") && !(0, b._K)().get("IS_BROWSER") && (0, b._K)().setPlatform("node", new se); var ue = n(448), le = n(9809), ce = n(125), he = n(5295), de = n(259); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, f.Ye)(); const fe = { buffer: ue.r, cast: le.w, clone: ce.o, print: he.y }; (0, de.Q5)(fe); var pe = n(5287), me = n(7523), ge = n(9359), ye = n(9258), be = n(9348), ve = n(5793), xe = n(5537), we = n(1830), ke = n(5702); /** * @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 Se = new Map, _e = new Map; class Ce { getClassName() { return this.constructor.className } static fromConfig(e, t) { return new e(t) } } class Ae { constructor() { this.classNameMap = {} } static getMap() { return null == Ae.instance && (Ae.instance = new Ae), Ae.instance } static register(e) { Ae.getMap().classNameMap[e.className] = [e, e.fromConfig] } } function Te(e, t, n) { (0, R.vA)(null != e.className, (() => "Class being registered does not have the static className property defined.")), (0, R.vA)("string" == typeof e.className, (() => "className is required to be a string, but got type " + typeof e.className)), (0, R.vA)(e.className.length > 0, (() => "Class being registered has an empty-string as its className, which is disallowed.")), void 0 === t && (t = "Custom"), void 0 === n && (n = e.className); const r = t + ">" + n; return Ae.register(e), Se.set(r, e), _e.set(e, r), e } function Ee(e) { return _e.has(e) ? _e.get(e) : e.className } /** * @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 Ne extends Ce { minimize(e, t = !1, n) { const { value: r, grads: i } = this.computeGradients(e, n); if (null != n) { const e = n.map((e => ({ name: e.name, tensor: i[e.name] }))); this.applyGradients(e) } else this.applyGradients(i); return (0, pe.AS)(i), t ? r : (r.dispose(), null) } get iterations() { return null == this.iterations_ && (this.iterations_ = 0), this.iterations_ } incrementIterations() { this.iterations_ = this.iterations + 1 } computeGradients(e, t) { return (0, we.y7)(e, t) } dispose() { null != this.iterations_ && (0, pe.AS)(this.iterations_) } async saveIterations() { return null == this.iterations_ && (this.iterations_ = 0), { name: "iter", tensor: (0, ke.d)(this.iterations_, "int32") } } async getWeights() { throw new Error("getWeights() is not implemented for this optimizer yet.") } async setWeights(e) { throw new Error(`setWeights() is not implemented for this optimizer class ${this.getClassName()}`) } async extractIterations(e) { return this.iterations_ = (await e[0].tensor.data())[0], e.slice(1) } } Object.defineProperty(Ne, Symbol.hasInstance, { value: e => null != e.minimize && null != e.computeGradients && null != e.applyGradients }); /** * @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 Ie extends Ne { static get className() { return "Adadelta" } constructor(e, t, n = null) { super(), this.learningRate = e, this.rho = t, this.epsilon = n, this.accumulatedGrads = [], this.accumulatedUpdates = [], null == n && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t], i = !1; null == this.accumulatedGrads[n] && (this.accumulatedGrads[n] = { originalName: `${t}/accum_grad`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedUpdates[n] && (this.accumulatedUpdates[n] = { originalName: `${t}/accum_var`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }); const a = Array.isArray(e) ? e[n].tensor : e[t]; if (null == a) return; const o = this.accumulatedGrads[n].variable, s = this.accumulatedUpdates[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(o, this.rho), (0, ye.l)((0, ve.E)(a), 1 - this.rho)), t = (0, ye.l)((0, ge.y)((0, be.R)((0, me.W)(s, this.epsilon)), (0, be.R)((0, me.W)(o, this.epsilon))), a), n = (0, me.W)((0, ye.l)(s, this.rho), (0, ye.l)((0, ve.E)(t), 1 - this.rho)); o.assign(e), s.assign(n); const i = (0, me.W)((0, ye.l)(t, -this.learningRate), r); r.assign(i) })) })), this.incrementIterations() } dispose() { null != this.accumulatedUpdates && ((0, pe.AS)(this.accumulatedGrads.map((e => e.variable))), (0, pe.AS)(this.accumulatedUpdates.map((e => e.variable)))) } async getWeights() { const e = [...this.accumulatedGrads, ...this.accumulatedUpdates]; return [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { const t = (e = await this.extractIterations(e)).length / 2, n = !1; this.accumulatedGrads = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedUpdates = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))) } getConfig() { return { learningRate: this.learningRate, rho: this.rho, epsilon: this.epsilon } } static fromConfig(e, t) { return new e(t.learningRate, t.rho, t.epsilon) } } var Me = n(6111); /** * @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 Fe extends Ne { static get className() { return "Adagrad" } constructor(e, t = .1) { super(), this.learningRate = e, this.initialAccumulatorValue = t, this.accumulatedGrads = [] } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t]; if (null == this.accumulatedGrads[n]) { const e = !1; this.accumulatedGrads[n] = { originalName: `${t}/accumulator`, variable: (0, pe.DZ)((() => (0, Me.G)(r.shape, this.initialAccumulatorValue).variable(e))) } } const i = Array.isArray(e) ? e[n].tensor : e[t]; if (null == i) return; const a = this.accumulatedGrads[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)(a, (0, ve.E)(i)); a.assign(e); const t = (0, me.W)((0, ye.l)((0, ge.y)(i, (0, be.R)((0, me.W)(e, f.T2.backend.epsilon()))), -this.learningRate), r); r.assign(t) })) })), this.incrementIterations() } dispose() { null != this.accumulatedGrads && (0, pe.AS)(this.accumulatedGrads.map((e => e.variable))) } async getWeights() { return [await this.saveIterations()].concat(this.accumulatedGrads.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); this.accumulatedGrads = e.map((e => ({ originalName: e.name, variable: e.tensor.variable(false) }))) } getConfig() { return { learningRate: this.learningRate, initialAccumulatorValue: this.initialAccumulatorValue } } static fromConfig(e, t) { return new e(t.learningRate, t.initialAccumulatorValue) } } var De = n(8990), $e = n(7126); /** * @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 Re extends Ne { static get className() { return "Adam" } constructor(e, t, n, r = null) { super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = r, this.accumulatedFirstMoment = [], this.accumulatedSecondMoment = [], (0, pe.DZ)((() => { this.accBeta1 = (0, ke.d)(t).variable(), this.accBeta2 = (0, ke.d)(n).variable() })), null == r && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { const t = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); (0, pe.DZ)((() => { const n = (0, $e.j)(1, this.accBeta1), r = (0, $e.j)(1, this.accBeta2); t.forEach(((t, i) => { const a = f.T2.registeredVariables[t], o = !1; null == this.accumulatedFirstMoment[i] && (this.accumulatedFirstMoment[i] = { originalName: `${t}/m`, variable: (0, pe.DZ)((() => (0, xe.P)(a).variable(o))) }), null == this.accumulatedSecondMoment[i] && (this.accumulatedSecondMoment[i] = { originalName: `${t}/v`, variable: (0, pe.DZ)((() => (0, xe.P)(a).variable(o))) }); const s = Array.isArray(e) ? e[i].tensor : e[t]; if (null == s) return; const u = this.accumulatedFirstMoment[i].variable, l = this.accumulatedSecondMoment[i].variable, c = (0, me.W)((0, ye.l)(u, this.beta1), (0, ye.l)(s, 1 - this.beta1)), h = (0, me.W)((0, ye.l)(l, this.beta2), (0, ye.l)((0, ve.E)(s), 1 - this.beta2)), d = (0, ge.y)(c, n), p = (0, ge.y)(h, r); u.assign(c), l.assign(h); const m = (0, me.W)((0, ye.l)((0, ge.y)(d, (0, me.W)((0, be.R)(p), this.epsilon)), -this.learningRate), a); a.assign(m) })), this.accBeta1.assign((0, ye.l)(this.accBeta1, this.beta1)), this.accBeta2.assign((0, ye.l)(this.accBeta2, this.beta2)) })), this.incrementIterations() } dispose() { this.accBeta1.dispose(), this.accBeta2.dispose(), null != this.accumulatedFirstMoment && (0, pe.AS)(this.accumulatedFirstMoment.map((e => e.variable))), null != this.accumulatedSecondMoment && (0, pe.AS)(this.accumulatedSecondMoment.map((e => e.variable))) } async getWeights() { const e = [...this.accumulatedFirstMoment, ...this.accumulatedSecondMoment]; return [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e), (0, pe.DZ)((() => { this.accBeta1.assign((0, De.n)(this.beta1, this.iterations_ + 1)), this.accBeta2.assign((0, De.n)(this.beta2, this.iterations_ + 1)) })); const t = e.length / 2, n = !1; this.accumulatedFirstMoment = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedSecondMoment = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))) } getConfig() { return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon } } static fromConfig(e, t) { return new e(t.learningRate, t.beta1, t.beta2, t.epsilon) } } var Oe = n(4888), ze = n(178); /** * @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 Pe extends Ne { static get className() { return "Adamax" } constructor(e, t, n, r = null, i = 0) { super(), this.learningRate = e, this.beta1 = t, this.beta2 = n, this.epsilon = r, this.decay = i, this.accumulatedFirstMoment = [], this.accumulatedWeightedInfNorm = [], (0, pe.DZ)((() => { this.iteration = (0, ke.d)(0).variable(), this.accBeta1 = (0, ke.d)(t).variable() })), null == r && (this.epsilon = f.T2.backend.epsilon()) } applyGradients(e) { const t = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); (0, pe.DZ)((() => { const n = (0, $e.j)(1, this.accBeta1), r = (0, ge.y)(-this.learningRate, (0, me.W)((0, ye.l)(this.iteration, this.decay), 1)); t.forEach(((t, i) => { const a = f.T2.registeredVariables[t], o = !1; null == this.accumulatedFirstMoment[i] && (this.accumulatedFirstMoment[i] = { originalName: `${t}/m`, variable: (0, xe.P)(a).variable(o) }), null == this.accumulatedWeightedInfNorm[i] && (this.accumulatedWeightedInfNorm[i] = { originalName: `${t}/v`, variable: (0, xe.P)(a).variable(o) }); const s = Array.isArray(e) ? e[i].tensor : e[t]; if (null == s) return; const u = this.accumulatedFirstMoment[i].variable, l = this.accumulatedWeightedInfNorm[i].variable, c = (0, me.W)((0, ye.l)(u, this.beta1), (0, ye.l)(s, 1 - this.beta1)), h = (0, ye.l)(l, this.beta2), d = (0, Oe.t)(s), p = (0, ze.P)(h, d); u.assign(c), l.assign(p); const m = (0, me.W)((0, ye.l)((0, ge.y)(r, n), (0, ge.y)(c, (0, me.W)(p, this.epsilon))), a); a.assign(m) })), this.iteration.assign((0, me.W)(this.iteration, 1)), this.accBeta1.assign((0, ye.l)(this.accBeta1, this.beta1)) })), this.incrementIterations() } dispose() { this.accBeta1.dispose(), this.iteration.dispose(), null != this.accumulatedFirstMoment && (0, pe.AS)(this.accumulatedFirstMoment.map((e => e.variable))), null != this.accumulatedWeightedInfNorm && (0, pe.AS)(this.accumulatedWeightedInfNorm.map((e => e.variable))) } async getWeights() { throw new Error("getWeights() is not implemented for Adamax yet.") } async setWeights(e) { throw new Error("setWeights() is not implemented for Adamax yet.") } getConfig() { return { learningRate: this.learningRate, beta1: this.beta1, beta2: this.beta2, epsilon: this.epsilon, decay: this.decay } } static fromConfig(e, t) { return new e(t.learningRate, t.beta1, t.beta2, t.epsilon, t.decay) } } /** * @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 Be extends Ne { static get className() { return "SGD" } constructor(e) { super(), this.learningRate = e, this.setLearningRate(e) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = Array.isArray(e) ? e[n].tensor : e[t]; if (null == r) return; const i = f.T2.registeredVariables[t]; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(this.c, r), i); i.assign(e) })) })), this.incrementIterations() } setLearningRate(e) { this.learningRate = e, null != this.c && this.c.dispose(), this.c = (0, pe.aC)((0, ke.d)(-e)) } dispose() { this.c.dispose() } async getWeights() { return [await this.saveIterations()] } async setWeights(e) { if (0 !== (e = await this.extractIterations(e)).length) throw new Error("SGD optimizer does not have settable weights.") } getConfig() { return { learningRate: this.learningRate } } static fromConfig(e, t) { return new e(t.learningRate) } } /** * @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 Le extends Be { static get className() { return "Momentum" } constructor(e, t, n = !1) { super(e), this.learningRate = e, this.momentum = t, this.useNesterov = n, this.accumulations = [], this.m = (0, ke.d)(this.momentum) } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t]; if (null == this.accumulations[n]) { const e = !1; this.accumulations[n] = { originalName: `${t}/momentum`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(e))) } } const i = this.accumulations[n].variable, a = Array.isArray(e) ? e[n].tensor : e[t]; null != a && (0, pe.DZ)((() => { let e; const t = (0, me.W)((0, ye.l)(this.m, i), a); e = this.useNesterov ? (0, me.W)((0, ye.l)(this.c, (0, me.W)(a, (0, ye.l)(t, this.m))), r) : (0, me.W)((0, ye.l)(this.c, t), r), i.assign(t), r.assign(e) })) })), this.incrementIterations() } dispose() { this.m.dispose(), null != this.accumulations && (0, pe.AS)(this.accumulations.map((e => e.variable))) } setMomentum(e) { this.momentum = e } async getWeights() { return [await this.saveIterations()].concat(this.accumulations.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); this.accumulations = e.map((e => ({ originalName: e.name, variable: e.tensor.variable(false) }))) } getConfig() { return { learningRate: this.learningRate, momentum: this.momentum, useNesterov: this.useNesterov } } static fromConfig(e, t) { return new e(t.learningRate, t.momentum, t.useNesterov) } } /** * @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 je extends Ne { static get className() { return "RMSProp" } constructor(e, t = .9, n = 0, r = null, i = !1) { if (super(), this.learningRate = e, this.decay = t, this.momentum = n, this.epsilon = r, this.accumulatedMeanSquares = [], this.accumulatedMoments = [], this.accumulatedMeanGrads = [], this.centered = i, null == r && (this.epsilon = f.T2.backend.epsilon()), null == e) throw new Error("learningRate for RMSPropOptimizer must be defined.") } applyGradients(e) { (Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e)).forEach(((t, n) => { const r = f.T2.registeredVariables[t], i = !1; null == this.accumulatedMeanSquares[n] && (this.accumulatedMeanSquares[n] = { originalName: `${t}/rms`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedMoments[n] && (this.accumulatedMoments[n] = { originalName: `${t}/momentum`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }), null == this.accumulatedMeanGrads[n] && this.centered && (this.accumulatedMeanGrads[n] = { originalName: `${t}/mg`, variable: (0, pe.DZ)((() => (0, xe.P)(r).variable(i))) }); const a = Array.isArray(e) ? e[n].tensor : e[t]; if (null == a) return; const o = this.accumulatedMeanSquares[n].variable, s = this.accumulatedMoments[n].variable; (0, pe.DZ)((() => { const e = (0, me.W)((0, ye.l)(o, this.decay), (0, ye.l)((0, ve.E)(a), 1 - this.decay)); if (this.centered) { const t = this.accumulatedMeanGrads[n].variable, i = (0, me.W)((0, ye.l)(t, this.decay), (0, ye.l)(a, 1 - this.decay)), u = (0, ge.y)((0, ye.l)(a, this.learningRate), (0, be.R)((0, $e.j)(e, (0, me.W)((0, ve.E)(i), this.epsilon)))), l = (0, me.W)((0, ye.l)(s, this.momentum), u); o.assign(e), t.assign(i), s.assign(l); const c = (0, $e.j)(r, l); r.assign(c) } else { const e = (0, me.W)((0, ye.l)(o, this.decay), (0, ye.l)((0, ve.E)(a), 1 - this.decay)), t = (0, me.W)((0, ye.l)(s, this.momentum), (0, ge.y)((0, ye.l)(a, this.learningRate), (0, be.R)((0, me.W)(e, this.epsilon)))); o.assign(e), s.assign(t); const n = (0, $e.j)(r, t); r.assign(n) } })) })), this.incrementIterations() } dispose() { null != this.accumulatedMeanSquares && (0, pe.AS)(this.accumulatedMeanSquares.map((e => e.variable))), null != this.accumulatedMeanGrads && this.centered && (0, pe.AS)(this.accumulatedMeanGrads.map((e => e.variable))), null != this.accumulatedMoments && (0, pe.AS)(this.accumulatedMoments.map((e => e.variable))) } async getWeights() { const e = [...this.accumulatedMeanSquares, ...this.accumulatedMoments]; return this.centered && e.push(...this.accumulatedMeanGrads), [await this.saveIterations()].concat(e.map((e => ({ name: e.originalName, tensor: e.variable })))) } async setWeights(e) { e = await this.extractIterations(e); const t = this.centered ? e.length / 3 : e.length / 2, n = !1; this.accumulatedMeanSquares = e.slice(0, t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.accumulatedMoments = e.slice(t, 2 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) }))), this.centered && (this.accumulatedMeanGrads = e.slice(2 * t, 3 * t).map((e => ({ originalName: e.name, variable: e.tensor.variable(n) })))) } getConfig() { return { learningRate: this.learningRate, decay: this.decay, momentum: this.momentum, epsilon: this.epsilon, centered: this.centered } } static fromConfig(e, t) { return new e(t.learningRate, t.decay, t.momentum, t.epsilon, t.centered) } } /** * @license * Copyright 2022 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 Ue = [Ie, Fe, Re, Pe, Le, je, Be]; function We(e) { return new Promise((e => setTimeout(e))).then(e) } class Ve { constructor(e) { if (!(0, b._K)().getBool("IS_BROWSER")) throw new Error("browserDownloads() cannot proceed because the current environment is not a browser."); e.startsWith(Ve.URL_SCHEME) && (e = e.slice(Ve.URL_SCHEME.length)), null != e && 0 !== e.length || (e = "model"), this.modelJsonFileName = e + ".json", this.weightDataFileName = e + ".weights.bin" } async save(e) { if ("undefined" == typeof document) throw new Error("Browser downloads are not supported in this environment since `document` is not present"); const t = A.D.join(e.weightData), n = window.URL.createObjectURL(new Blob([t], { 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 t = [{ paths: ["./" + this.weightDataFileName], weights: e.weightSpecs }], r = (0, x.zV)(e, t), i = window.URL.createObjectURL(new Blob([JSON.stringify(r)], { type: "application/json" })), a = null == this.modelJsonAnchor ? document.createElement("a") : this.modelJsonAnchor; if (a.download = this.modelJsonFileName, a.href = i, await We((() => a.dispatchEvent(new MouseEvent("click")))), null != e.weightData) { const e = null == this.weightDataAnchor ? document.createElement("a") : this.weightDataAnchor; e.download = this.weightDataFileName, e.href = n, await We((() => e.dispatchEvent(new MouseEvent("click")))) } return { modelArtifactsInfo: (0, x.oR)(e) } } } } Ve.URL_SCHEME = "downloads://"; class Ge { constructor(e) { if (null == e || 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 n = new FileReader; n.onload = n => { const r = JSON.parse(n.target.result), i = r.modelTopology; if (null == i) return void t(new Error(`modelTopology field is missing from file ${this.jsonFile.name}`)); if (null == r.weightsManifest) return void t(new Error(`weightManifest field is missing from file ${this.jsonFile.name}`)); if (0 === this.weightsFiles.length) return void e({ modelTopology: i }); const a = (0, x.Ej)(r, (e => this.loadWeights(e))); e(a) }, n.onerror = e => t(`Failed to read model topology and weights manifest JSON from file '${this.jsonFile.name}'. BrowserFiles supports loading Keras-style tf.Model artifacts only.`), n.readAsText(this.jsonFile) })) } loadWeights(e) { const t = [], n = []; for (const r of e) t.push(...r.weights), n.push(...r.paths); const r = this.checkManifestAndWeightFiles(e), i = n.map((e => this.loadWeightsFile(e, r[e]))); return Promise.all(i).then((e => [t, e])) } loadWeightsFile(e, t) { return new Promise(((n, r) => { const i = new FileReader; i.onload = e => { const t = e.target.result; n(t) }, i.onerror = t => r(`Failed to weights data from file of path '${e}'.`), i.readAsArrayBuffer(t) })) } checkManifestAndWeightFiles(e) { const t = [], n = this.weightsFiles.map((e => (0, x.P8)(e.name))), r = {}; for (const i of e) i.paths.forEach((e => { const i = (0, x.P8)(e); if (-1 !== t.indexOf(i)) throw new Error(`Duplicate file basename found in weights manifest: '${i}'`); if (t.push(i), -1 === n.indexOf(i)) throw new Error(`Weight file with basename '${i}' is not provided.`); r[e] = this.weightsFiles[n.indexOf(i)] })); 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 } } function He(e) { return new Ge(e) } /** * @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 qe(e, t, n, r) { !function (e) { (0, R.vA)(null != e && Array.isArray(e) && e.length > 0, (() => "promises must be a none empty array")) }(e), function (e, t) { (0, R.vA)(e >= 0 && e <= 1, (() => `Progress fraction must be in range [0, 1], but got startFraction ${e}`)), (0, R.vA)(t >= 0 && t <= 1, (() => `Progress fraction must be in range [0, 1], but got endFraction ${t}`)), (0, R.vA)(t >= e, (() => `startFraction must be no more than endFraction, but got startFraction ${e} and endFraction ${t}`)) }(n = null == n ? 0 : n, r = null == r ? 1 : r); let i = 0; return Promise.all(e.map((a => (a.then((a => { const o = n + ++i / e.length * (r - n); return t(o), a })), a)))) } w.registerSaveRouter((e => (0, b._K)().getBool("IS_BROWSER") && !Array.isArray(e) && e.startsWith(Ve.URL_SCHEME) ? function (e = "model") { return new Ve(e) }(e.slice(Ve.URL_SCHEME.length)) : null)); var Ye = n(5685); /** * @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. * ============================================================================= */ async function Xe(e, t) { null == t && (t = {}); const n = null == t.fetchFunc ? (0, b._K)().platform.fetch : t.fetchFunc, r = e.map((e => n(e, t.requestInit, { isBinary: !0 }))), i = (null == t.onProgress ? await Promise.all(r) : await qe(r, t.onProgress, 0, .5)).map((e => e.arrayBuffer())); return null == t.onProgress ? await Promise.all(i) : await qe(i, t.onProgress, .5, 1) } async function Ke(e, t = "", n, r) { return Ze((e => Xe(e, { requestInit: r })))(e, t, n) } function Ze(e) { return async (t, n = "", r) => { const i = t.map((() => !1)), a = {}, o = null != r ? r.map((() => !1)) : [], s = []; if (t.forEach(((e, t) => { let n = 0; e.weights.forEach((e => { const u = "quantization" in e ? e.quantization.dtype : e.dtype, l = Ye.i[u] * R.Ze(e.shape), c = () => { i[t] = !0, null == a[t] && (a[t] = []), a[t].push({ manifestEntry: e, groupOffset: n, sizeBytes: l }) }; null != r ? r.forEach(((t, n) => { t === e.name && (c(), o[n] = !0) })) : c(), s.push(e.name), n += l })) })), !o.every((e => e))) { const e = r.filter(((e, t) => !o[t])); throw new Error(`Could not find weights in manifest with names: ${e.join(", ")}. \nManifest JSON has weights with names: ${s.join(", ")}.`) } const u = i.reduce(((e, t, n) => (t && e.push(n), e)), []), l = []; u.forEach((e => { t[e].paths.forEach((e => { const t = n + (n.endsWith("/") ? "" : "/") + e; l.push(t) })) })); const c = await e(l), h = {}; let d = 0; return u.forEach((e => { const n = t[e].paths.length, r = new A.D(c.slice(d, d + n)); a[e].forEach((e => { const t = r.slice(e.groupOffset, e.groupOffset + e.sizeBytes), n = (0, x.CY)(t, [e.manifestEntry]); for (const e in n) h[e] = n[e] })), d += n })), h } } class Je { constructor(e, t) { if (this.DEFAULT_METHOD = "POST", null == t && (t = {}), this.weightPathPrefix = t.weightPathPrefix, this.weightUrlConverter = t.weightUrlConverter, null != t.fetchFunc ? ((0, R.vA)("function" == typeof t.fetchFunc, (() => "Must pass a function that matches the signature of `fetch` (see https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)")), this.fetch = t.fetchFunc) : this.fetch = (0, b._K)().platform.fetch, (0, R.vA)(null != e && e.length > 0, (() => "URL path for http must not be null, undefined or empty.")), Array.isArray(e) && (0, R.vA)(2 === e.length, (() => `URL paths for http must have a length of 2, (actual length is ${e.length}).`)), this.path = e, null != t.requestInit && null != t.requestInit.body) throw new Error("requestInit is expected to have no pre-existing body, but has one."); this.requestInit = t.requestInit || {}, this.loadOptions = t } async save(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("BrowserHTTPRequest.save() does not support saving model topology in binary formats yet."); const t = Object.assign({ method: this.DEFAULT_METHOD }, this.requestInit); t.body = new FormData; const n = [{ paths: ["./model.weights.bin"], weights: e.weightSpecs }], r = (0, x.zV)(e, n); if (t.body.append("model.json", new Blob([JSON.stringify(r)], { type: "application/json" }), "model.json"), null != e.weightData) { const n = A.D.join(e.weightData); t.body.append("model.weights.bin", new Blob([n], { type: "application/octet-stream" }), "model.weights.bin") } const i = await this.fetch(this.path, t); if (i.ok) return { modelArtifactsInfo: (0, x.oR)(e), responses: [i] }; throw new Error(`BrowserHTTPRequest.save() failed due to HTTP response status ${i.status}.`) } async loadModelJSON() { const e = await this.fetch(this.path, this.requestInit); if (!e.ok) throw new Error(`Request to ${this.path} failed with status code ${e.status}. Please verify this URL points to the model JSON of the model to load.`); let t; try { t = await e.json() } catch (e) { let t = `Failed to parse model JSON of response from ${this.path}.`; throw this.path.endsWith(".pb") ? t += " Your path contains a .pb file extension. Support for .pb models have been removed in TensorFlow.js 1.0 in favor of .json models. You can re-convert your Python TensorFlow model using the TensorFlow.js 1.0 conversion scripts or you can convert your.pb models with the 'pb2json'NPM script in the tensorflow/tfjs-converter repository." : t += " Please make sure the server is serving valid JSON for this request.", new Error(t) } const n = t.modelTopology, r = t.weightsManifest; if (null == n && null == r) throw new Error(`The JSON from HTTP path ${this.path} contains neither model topology or manifest for weights.`); return t } async load() { if (this.loadOptions.streamWeights) return this.loadStream(); const e = await this.loadModelJSON(); return (0, x.Ej)(e, (e => this.loadWeights(e))) } async loadStream() { const e = await this.loadModelJSON(), t = await this.getWeightUrls(e.weightsManifest), n = (0, x.Xf)(e.weightsManifest); return Object.assign(Object.assign({}, e), { weightSpecs: n, getWeightStream: () => function (e, t) { var n; const r = null == t.fetchFunc ? (0, b._K)().platform.fetch : t.fetchFunc; let i, a = 0; return null === (n = t.onProgress) || void 0 === n || n.call(t, 0), new ReadableStream({ pull: async n => { for (var o; a < e.length;) { if (!i) { const n = (await r(e[a], t.requestInit, { isBinary: !0 })).body; i = n.getReader() } const { done: s, value: u } = await i.read(); if (!s) return void n.enqueue(u); a++, i = void 0, null === (o = t.onProgress) || void 0 === o || o.call(t, a / e.length) } n.close() } }) }(t, this.loadOptions) }) } async getWeightUrls(e) { const t = Array.isArray(this.path) ? this.path[1] : this.path, [n, r] = function (e) { const t = e.lastIndexOf("/"), n = e.lastIndexOf("?"), r = e.substring(0, t), i = n > t ? e.substring(n) : ""; return [r + "/", i] }(t), i = this.weightPathPrefix || n, a = [], o = []; for (const t of e) for (const e of t.paths) null != this.weightUrlConverter ? o.push(this.weightUrlConverter(e)) : a.push(i + e + r); return this.weightUrlConverter && a.push(...await Promise.all(o)), a } async loadWeights(e) { const t = await this.getWeightUrls(e); return [(0, x.Xf)(e), await Xe(t, this.loadOptions)] } } function Qe(e) { return null != e.match(Je.URL_SCHEME_REGEX) } Je.URL_SCHEME_REGEX = /^https?:\/\//; const et = (e, t) => { if ("undefined" == typeof fetch && (null == t || null == t.fetchFunc)) return null; { let n = !0; if (n = Array.isArray(e) ? e.every((e => Qe(e))) : Qe(e), n) return tt(e, t) } return null }; function tt(e, t) { return new Je(e, t) } function nt(e, t) { return tt(e, t) } w.registerSaveRouter(et), w.registerLoadRouter(et); /** * @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 rt { constructor(e) { this.modelArtifacts = e } load() { return this.modelArtifacts } } class it { constructor(e) { this.saveHandler = e } save(e) { return this.saveHandler(e) } } class at { constructor(e) { e.load && (this.load = () => Promise.resolve(e.load())), e.save && (this.save = t => Promise.resolve(e.save(t))) } } function ot(e, t, n, r) { return new at(st(...arguments)) } function st(e, t, n, r) { if (1 === arguments.length) { return null != e.modelTopology || null != e.weightSpecs ? new rt(e) : (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 rt({ modelTopology: e })) } return 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 rt({ modelTopology: e, weightSpecs: t, weightData: n, trainingConfig: r }) } function ut(e) { return new it(e) } function lt(e) { return new it(e) } /** * @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. * ============================================================================= */ var ct = n(8189), ht = n(5703), dt = n(1760), ft = n(929), pt = n(7703); const mt = (0, ft.op)({ confusionMatrix_: /** * @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 (e, t, n) { const r = (0, ct.YT)(e, "labels", "confusionMatrix"), i = (0, ct.YT)(t, "predictions", "confusionMatrix"); R.vA(null == n || n > 0 && Number.isInteger(n), (() => `If provided, numClasses must be a positive integer, but got ${n}`)), R.vA(1 === r.rank, (() => `Expected the rank of labels to be 1, but got ${r.rank}`)), R.vA(1 === i.rank, (() => `Expected the rank of predictions to be 1, but got ${i.rank}`)), R.vA(r.shape[0] === i.shape[0], (() => `Mismatch in the number of examples: ${r.shape[0]} vs. ${i.shape[0]}. Labels and predictions should have the same number of elements.`)), R.vA(n > 0 && Number.isInteger(n), (() => `numClasses is required to be a positive integer, but got ${n}`)); const a = (0, dt.M)((0, le.w)(r, "int32"), n), o = (0, dt.M)((0, le.w)(i, "int32"), n), s = (0, pt.m)(a), u = (0, ht.N)(s, o); return (0, le.w)(u, "int32") } }); /** * @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. * ============================================================================= */ var gt = n(2198), yt = n(5441), bt = n(7074), vt = n(2768); /** * @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 xt, wt = !1; function kt(e, t = 3) { if (t > 4) throw new Error("Cannot construct Tensor with more than 4 channels from pixels."); if (null == e) throw new Error("pixels passed to tf.browser.fromPixels() can not be null"); let n = !1, r = !1, i = !1, a = !1, o = !1, s = !1; if (e.data instanceof Uint8Array) n = !0; else if ("undefined" != typeof ImageData && e instanceof ImageData) r = !0; else if ("undefined" != typeof HTMLVideoElement && e instanceof HTMLVideoElement) i = !0; else if ("undefined" != typeof HTMLImageElement && e instanceof HTMLImageElement) a = !0; else if (null != e.getContext) o = !0; else { if (!("undefined" != typeof ImageBitmap && e instanceof ImageBitmap)) throw new Error(`pixels passed to tf.browser.fromPixels() must be either an HTMLVideoElement, HTMLImageElement, HTMLCanvasElement, ImageData in browser, or OffscreenCanvas, ImageData in webworker or {data: Uint32Array, width: number, height: number}, but was ${e.constructor.name}`); s = !0 } if (null != (0, bt._5)(yt.awo, f.T2.backendName)) { const n = { pixels: e }, r = { numChannels: t }; return f.T2.runKernel(yt.awo, n, r) } const [u, l] = i ? [e.videoWidth, e.videoHeight] : [e.width, e.height]; let c, h; if (o) c = e.getContext("2d").getImageData(0, 0, u, l).data; else if (r || n) c = e.data; else if (a || i || s) { if (null == xt) if ("undefined" == typeof document) { if ("undefined" == typeof OffscreenCanvas || "undefined" == typeof OffscreenCanvasRenderingContext2D) throw new Error("Cannot parse input in current context. Reason: OffscreenCanvas Context2D rendering is not supported."); xt = new OffscreenCanvas(1, 1).getContext("2d") } else xt = document.createElement("canvas").getContext("2d", { willReadFrequently: !0 }); xt.canvas.width = u, xt.canvas.height = l, xt.drawImage(e, 0, 0, u, l), c = xt.getImageData(0, 0, u, l).data } if (4 === t) h = new Int32Array(c); else { const e = u * l; h = new Int32Array(e * t); for (let n = 0; n < e; n++)for (let e = 0; e < t; ++e)h[n * t + e] = c[4 * n + e] } const d = [l, u, t]; return (0, vt.$)(h, d, "int32") } function St(e) { return "undefined" != typeof window && "undefined" != typeof ImageBitmap && window.hasOwnProperty("createImageBitmap") && !(e instanceof ImageBitmap) && function (e) { return null != e && 0 !== e.width && 0 !== e.height }(e) && !function (e) { return null != e && e.data instanceof Uint8Array }(e) } async function _t(e, t = 3) { let n = null; if ((0, b._K)().getBool("WRAP_TO_IMAGEBITMAP") && St(e)) { let t; try { t = await createImageBitmap(e, { premultiplyAlpha: "none" }) } catch (e) { t = null } n = null != t && t.width === e.width && t.height === e.height ? t : e } else n = e; return kt(n, t) } function Ct(e) { if (2 !== e.rank && 3 !== e.rank) throw new Error(`toPixels only supports rank 2 or 3 tensors, got rank ${e.rank}.`); const t = 2 === e.rank ? 1 : e.shape[2]; if (t > 4 || 2 === t) throw new Error(`toPixels only supports depth of size 1, 3 or 4 but got ${t}`); if ("float32" !== e.dtype && "int32" !== e.dtype) throw new Error(`Unsupported type for toPixels: ${e.dtype}. Please use float32 or int32 tensors.`) } async function At(e, t) { let n = (0, ct.YT)(e, "img", "toPixels"); if (!(e instanceof de.qY)) { const e = n; n = (0, le.w)(e, "int32"), e.dispose() } Ct(n); const [r, i] = n.shape.slice(0, 2), a = 2 === n.rank ? 1 : n.shape[2], o = await n.data(), s = "float32" === n.dtype ? 255 : 1, u = new Uint8ClampedArray(i * r * 4); for (let e = 0; e < r * i; ++e) { const t = [0, 0, 0, 255]; for (let r = 0; r < a; r++) { const i = o[e * a + r]; if ("float32" === n.dtype) { if (i < 0 || i > 1) throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${i}.`) } else if ("int32" === n.dtype && (i < 0 || i > 255)) throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${i}.`); 1 === a ? (t[0] = i * s, t[1] = i * s, t[2] = i * s) : t[r] = i * s } const r = 4 * e; u[r + 0] = Math.round(t[0]), u[r + 1] = Math.round(t[1]), u[r + 2] = Math.round(t[2]), u[r + 3] = Math.round(t[3]) } if (null != t) { if (!wt) { null != (0, bt._5)(yt.XmO, f.T2.backendName) && (console.warn("tf.browser.toPixels is not efficient to draw tensor on canvas. Please try tf.browser.draw instead."), wt = !0) } t.width = i, t.height = r; const e = t.getContext("2d"), n = new ImageData(u, i, r); e.putImageData(n, 0, 0) } return n !== e && n.dispose(), u } function Tt(e, t, n) { let r = (0, ct.YT)(e, "img", "draw"); if (!(e instanceof de.qY)) { const e = r; r = (0, le.w)(e, "int32"), e.dispose() } Ct(r), function (e) { const t = (null == e ? void 0 : e.alpha) || 1; if (t > 1 || t < 0) throw new Error(`Alpha value ${t} is suppoed to be in range [0 - 1].`) }(null == n ? void 0 : n.imageOptions); const i = { image: r }, a = { canvas: t, options: n }; f.T2.runKernel(yt.XmO, i, a) } const Et = (0, ft.op)({ fromPixels_: kt }); function Nt(e, t) { const n = e.shape.length, r = t.shape.length; if (n < 1) throw new Error(`tf.gatherND() expects the input to be rank 1 or higher, but the rank was ${n}.`); if (r < 1) throw new Error(`tf.gatherND() expects the indices to be rank 1 or higher, but the rank was ${r}.`); if ("int32" !== t.dtype) throw new Error(`tf.gatherND() expects the indices to be int32 type, but the dtype was ${t.dtype}.`); if (t.shape[r - 1] > n) throw new Error(`index innermost dimension length must be <= tensor rank; saw: ${t.shape[r - 1]} vs. ${n}`); if (0 === (0, R.Ze)(e.shape)) throw new Error(`Requested more than 0 entries, but input is empty. Input shape: ${e.shape}.`); const i = t.shape, a = i[i.length - 1]; let o = 1; for (let e = 0; e < i.length - 1; ++e)o *= i[e]; const s = e.shape, u = i.slice(); u.pop(); let l = 1; for (let e = a; e < n; ++e)l *= s[e], u.push(s[e]); const c = [...(0, R.Ur)(e.shape).map((e => e / l)), 1].slice(0, a); return [u, o, l, c] } var It = n(6170), Mt = n(4969), Ft = n(565), Dt = n(3879); /** * @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 $t = .001, Rt = .1; function Ot(e, t, n) { return null == n && (n = zt()), Pt(e, t, ((e, t) => Ut(e, t, n))) } function zt() { return 32 === f.T2.backend.floatPrecision() ? $t : Rt } function Pt(e, t, n) { let r = !0; if (((0, Dt.isTypedArray)(e) || (0, Dt.isTypedArray)(t)) && (r = !1), (0, Dt.isTypedArray)(e) && (0, Dt.isTypedArray)(t) && (r = !0), r) { const n = e.constructor.name, r = t.constructor.name; if (n !== r) throw new Error(`Arrays are of different type. Actual: ${n}. Expected: ${r}`) } if (Array.isArray(e) && Array.isArray(t)) { const n = (0, ct.MZ)(e), r = (0, ct.MZ)(t); if (!(0, R.r1)(n, r)) throw new Error(`Arrays have different shapes. Actual: [${n}]. Expected: [${r}]`) } const i = (0, Dt.isTypedArray)(e) ? e : (0, Dt.flatten)(e), a = (0, Dt.isTypedArray)(t) ? t : (0, Dt.flatten)(t); if (i.length !== a.length) throw new Error(`Arrays have different lengths actual: ${i.length} vs expected: ${a.length}.\nActual: ${i}.\nExpected: ${a}.`); for (let e = 0; e < a.length; ++e) { const t = i[e], r = a[e]; if (!n(t, r)) throw new Error(`Arrays differ: actual[${e}] = ${t}, expected[${e}] = ${r}.\nActual: ${i}.\nExpected: ${a}.`) } "undefined" != typeof expect && expect().nothing() } function Bt(e, t) { e().then((() => t.fail()), (() => t())), "undefined" != typeof expect && expect().nothing() } function Lt(e, t) { const n = "string" == typeof t || "number" == typeof t || "boolean" == typeof t ? [t] : t; return (0, R.Kg)(e) || (0, R.Kg)(e[0]) || (0, R.Kg)(t) || (0, R.Kg)(t[0]) ? Pt(e, n, ((e, t) => e == t)) : Pt(e, t, ((e, t) => Ut(e, t, 0))) } function jt(e, t, n) { if (null == n && (n = zt()), !Ut(e, t, n)) throw new Error(`Numbers differ: actual === ${e}, expected === ${t}`); "undefined" != typeof expect && expect().nothing() } function Ut(e, t, n) { return !isFinite(e) && !isFinite(t) || !(isNaN(e) || isNaN(t) || Math.abs(e - t) > n) } function Wt(e, t, n) { for (let r = 0; r < e.length; r++)if (e[r] < t || e[r] > n) throw new Error(`Value out of range:${e[r]} low: ${t}, high: ${n}`) } function Vt(e, t) { const n = new Float32Array(e), r = new Float32Array(t); if (n.length !== r.length) throw new Error(`Expected ArrayBuffer to be of length ${r.length}, but it was ${n.length}`); for (let e = 0; e < r.length; e++)if (n[e] !== r[e]) throw new Error(`Expected ArrayBuffer value at ${e} to be ${r[e]} but got ${n[e]} instead`) } function Gt(e) { for (let t = 0; t < e.length; t++) { const n = e[t]; Array.isArray(n) ? Gt(n) : e[t] = (0, Dt.encodeString)(n) } return e } function Ht(e) { const t = document.createElement("video"); return "playsInline" in t && (t.playsInline = !0), t.muted = !0, t.loop = !0, t.style.position = "fixed", t.style.left = "0px", t.style.top = "0px", t.preload = "auto", t.appendChild(e), new Promise((e => { t.addEventListener("loadeddata", (n => e(t))), t.load() })) } async function qt(e) { await e.play(), "requestVideoFrameCallback" in e && await new Promise((t => { e.requestVideoFrameCallback(t) })) } /** @license See the LICENSE file. */ const Yt = "4.22.0"; /** * @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 Xt { static sgd(e) { return new Be(e) } static momentum(e, t, n = !1) { return new Le(e, t, n) } static rmsprop(e, t = .9, n = 0, r = null, i = !1) { return new je(e, t, n, r, i) } static adam(e = .001, t = .9, n = .999, r = null) { return new Re(e, t, n, r) } static adadelta(e = .001, t = .95, n = null) { return new Ie(e, t, n) } static adamax(e = .002, t = .9, n = .999, r = null, i = 0) { return new Pe(e, t, n, r, i) } static adagrad(e, t = .1) { return new Fe(e, t) } } var Kt = n(2046), Zt = n(7270), Jt = n(4703); /** * @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 Qt = Xt, en = "undefined" != typeof requestAnimationFrame ? requestAnimationFrame : "undefined" != typeof setImmediate ? setImmediate : e => e(); function tn() { return new Promise((e => en((() => e())))) } var nn = n(1078); /** * @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. * ============================================================================= */ function rn(e, t) { const n = e[0].length; e.forEach(((e, t) => { R.vA(e.length === n, (() => `Error in concat${n}D: rank of tensors[${t}] must be the same as the rank of the rest (${n})`)) })), R.vA(t >= 0 && t < n, (() => `Error in concat${n}D: axis must be between 0 and ${n - 1}.`)); const r = e[0]; e.forEach(((e, i) => { for (let a = 0; a < n; a++)R.vA(a === t || e[a] === r[a], (() => `Error in concat${n}D: Shape of tensors[${i}] (${e}) does not match the shape of the rest (${r}) along the non-concatenated axis ${i}.`)) })) } function an(e, t) { const n = e[0].slice(); for (let r = 1; r < e.length; r++)n[t] += e[r][t]; return n } var on, sn = n(7195), un = n(8646); function ln(e, t, n) { let r = new Array; if (null == n && null == t) return r; if (null == t) for (; r.length < e + n.length;)r.push(-1); else r = t.slice(); if (null == n) return r; if (e + n.length !== r.length) throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.rank = ${e + n.length}, but shape.rank = ${r.length}`); for (let i = 1; i < n.length; ++i) { const a = n[i], o = r[r.length - n.length + i], s = r[o]; if (a >= 0) if (s >= 0) { if (s !== a) throw new Error(`rt input.shape and shape=${t} are incompatible: rt input.shape[${i + e}] = ${a} but shape[${i + e}] = ${s}`) } else r[o] = a } return r } function cn(e) { const t = { FIRST_DIM_SIZE: on.FIRST_DIM_SIZE, VALUE_ROWIDS: on.VALUE_ROWIDS, ROW_LENGTHS: on.ROW_LENGTHS, ROW_SPLITS: on.ROW_SPLITS, ROW_LIMITS: on.ROW_LIMITS, ROW_STARTS: on.ROW_STARTS }, n = []; for (const r of e) { if (!(r in t)) break; n.push(t[r]) } return n } function hn(e) { return 0 === e.length ? 0 : e[0] === on.FIRST_DIM_SIZE ? e.length - 1 : e.length } function dn(e, t) { if (null == e || null == t) return; const n = e.length, r = t.length; if (n >= r) throw new Error(`defaultValue.shape=${e} and ragged tensor flatValues.shape=${t}, are incompatible: defaultValue.rank = ${n} must be less than ragged tensor input flatValues.rank = ${r})`); for (let i = 0; i < Math.min(n, r - 1); ++i) { const n = e[i], r = t[i + 1]; if (n >= 0 && r >= 0 && 1 !== n && n !== r) throw new Error(`defaultValue.shape=${e}, and ragged tensor input flatValues.shape=${t} are incompatible: defaultValue.shape[${i - e.length}] = ${n} but ragged tensor input.flatValues.shape[${i - e.length}] = ${r}`) } } !function (e) { e[e.FIRST_DIM_SIZE = 0] = "FIRST_DIM_SIZE", e[e.VALUE_ROWIDS = 1] = "VALUE_ROWIDS", e[e.ROW_LENGTHS = 2] = "ROW_LENGTHS", e[e.ROW_SPLITS = 3] = "ROW_SPLITS", e[e.ROW_LIMITS = 4] = "ROW_LIMITS", e[e.ROW_STARTS = 5] = "ROW_STARTS" }(on || (on = {})); /** * @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 fn = 30; function pn(e) { return e <= fn ? e : (0, R.lK)(e, Math.floor(Math.sqrt(e))) } /** * @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 mn(e, t, n) { return [n * ("number" == typeof e ? e : e[0]), t * ("number" == typeof e ? e : e[1])] } /** * @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 gn(e, t, n, r = !0) { let i = []; if (r) i = i.concat(t.slice(0)), i.push(e[0] / n), i = i.concat(e.slice(1)); else { i = i.concat(e[0]); const n = t.length; for (let r = 0; r < n; ++r)i = i.concat([e[r + 1] / t[r], t[r]]); i = i.concat(e.slice(n + 1)) } return i } function yn(e, t, n = !0) { const r = []; if (n) { r.push(t); for (let n = t + 1; n < e; ++n)n <= 2 * t ? (r.push(n), r.push(n - (t + 1))) : r.push(n) } else { const n = [], i = []; for (let r = 1; r < e; ++r)r >= 2 * t + 1 || r % 2 == 1 ? i.push(r) : n.push(r); r.push(...n), r.push(0), r.push(...i) } return r } function bn(e, t, n, r = !0) { const i = []; r ? i.push(e[0] / n) : i.push(e[0] * n); for (let n = 1; n < e.length; ++n)n <= t.length ? r ? i.push(t[n - 1] * e[n]) : i.push(e[n] / t[n - 1]) : i.push(e[n]); return i } function vn(e, t) { const n = [0]; for (let r = 0; r < t; ++r)n.push(e[r][0]); return n } function xn(e, t, n) { const r = e.slice(0, 1); for (let i = 0; i < n; ++i)r.push(e[i + 1] - t[i][0] - t[i][1]); return r } var wn = n(8576); /** * @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 kn = .3275911, Sn = .254829592, _n = -.284496736, Cn = 1.421413741, An = -1.453152027, Tn = 1.061405429; var En = n(3673); /** * @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(e, t) { if (e.length !== t.length) throw new Error(`Cannot merge real and imag arrays of different lengths. real:${e.length}, imag: ${t.length}.`); const n = new Float32Array(2 * e.length); for (let r = 0; r < n.length; r += 2)n[r] = e[r / 2], n[r + 1] = t[r / 2]; return n } function In(e) { const t = new Float32Array(e.length / 2), n = new Float32Array(e.length / 2); for (let r = 0; r < e.length; r += 2)t[r / 2] = e[r], n[r / 2] = e[r + 1]; return { real: t, imag: n } } function Mn(e) { const t = Math.ceil(e.length / 4), n = new Float32Array(t), r = new Float32Array(t); for (let t = 0; t < e.length; t += 4)n[Math.floor(t / 4)] = e[t], r[Math.floor(t / 4)] = e[t + 1]; return { real: n, imag: r } } function Fn(e) { const t = Math.floor(e.length / 4), n = new Float32Array(t), r = new Float32Array(t); for (let t = 2; t < e.length; t += 4)n[Math.floor(t / 4)] = e[t], r[Math.floor(t / 4)] = e[t + 1]; return { real: n, imag: r } } function Dn(e, t) { return { real: e[2 * t], imag: e[2 * t + 1] } } function $n(e, t, n, r) { e[2 * r] = t, e[2 * r + 1] = n } function Rn(e, t) { const n = new Float32Array(e / 2), r = new Float32Array(e / 2); for (let i = 0; i < Math.ceil(e / 2); i++) { const a = (t ? 2 : -2) * Math.PI * (i / e); n[i] = Math.cos(a), r[i] = Math.sin(a) } return { real: n, imag: r } } function On(e, t, n) { const r = (n ? 2 : -2) * Math.PI * (e / t); return { real: Math.cos(r), imag: Math.sin(r) } } /** * @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 zn = "->", Pn = /->/g, Bn = ",", Ln = "..."; function jn(e, t) { const n = ((e = e.replace(/\s/g, "")).length - e.replace(Pn, "").length) / zn.length; if (n < 1) throw new Error("Equations without an arrow are not supported."); if (n > 1) throw new Error(`Equation must contain exactly one arrow ("${zn}").`); const [r, i] = e.split(zn); (0, R.vA)(-1 === r.indexOf(Ln), (() => `The ellipsis notation ("${Ln}") is not supported yet.`)); const a = r.split(Bn), o = a.length; if (t !== o) throw new Error(`Expected ${o} input tensors, received ${t}`); if (o > 2) throw new Error("Support for more than 2 input tensors is not implemented yet."); const s = []; for (let e = 0; e < i.length; ++e) { const t = i[e]; if (!a.some((e => -1 !== e.indexOf(t)))) throw new Error(`Output subscripts contain the label ${t} not present in the input subscripts.`); -1 === s.indexOf(t) && s.push(t) } for (let e = 0; e < r.length; ++e) { const t = r[e]; -1 === s.indexOf(t) && t !== Bn && s.push(t) } const u = new Array(a.length); for (let e = 0; e < o; ++e) { if (new Set(a[e].split("")).size !== a[e].length) throw new Error(`Found duplicate axes in input component ${a[e]}. Support for duplicate axes in input is not implemented yet.`); u[e] = []; for (let t = 0; t < a[e].length; ++t)u[e].push(s.indexOf(a[e][t])) } const l = s.length, c = []; for (let e = i.length; e < l; ++e)c.push(e); return { allDims: s, summedDims: c, idDims: u } } function Un(e, t) { let n = new Array(e); n.fill(-1); for (let e = 0; e < t.length; ++e)n[t[e]] = e; const r = []; for (let t = 0; t < e; ++t)-1 === n[t] && r.push(t); return n = n.filter((e => -1 !== e)), { permutationIndices: n, expandDims: r } } function Wn(e, t, n) { const r = new Array(e); for (let e = 0; e < n.length; ++e) { const i = n[e].shape; for (let n = 0; n < t[e].length; ++n)void 0 === r[t[e][n]] ? r[t[e][n]] = i[n] : (0, R.vA)(r[t[e][n]] === i[n], (() => `Expected dimension ${r[t[e][n]]} at axis ${n} of input shaped ${JSON.stringify(i)}, but got dimension ${i[n]}`)) } } function Vn(e, t) { const n = e, r = []; let i = 0; 0 === e.length && n.push(-1), i = e.length + 1; for (let e = 0; e < i; ++e)r.push([]); const a = []; for (let e = 0; e < n.length; ++e) { const i = Hn(t, n[e]); for (const t of i) -1 === a.indexOf(t) && (r[e].push(t), a.push(t)) } return { path: n, steps: r } } function Gn(e) { return e.every(((e, t) => e === t)) } function Hn(e, t) { const n = []; for (let r = 0; r < e.length; ++r)0 !== e[r].length && -1 === e[r].indexOf(t) && -1 !== t || n.push(r); return n } function qn(e, t, n = 0) { let r = []; if ("number" == typeof t) (0, R.vA)(e.shape[n] % t == 0, (() => "Number of splits must evenly divide the axis.")), r = new Array(t).fill(e.shape[n] / t); else { const i = t.reduce(((e, t) => (-1 === t && (e += 1), e)), 0); (0, R.vA)(i <= 1, (() => "There should be only one negative value in split array.")); const a = t.indexOf(-1); if (-1 !== a) { const r = t.reduce(((e, t) => t > 0 ? e + t : e)); t[a] = e.shape[n] - r } (0, R.vA)(e.shape[n] === t.reduce(((e, t) => e + t)), (() => "The sum of sizes must match the size of the axis dimension.")), r = t } return r } /** * @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 Yn(e) { return `Received SparseTensor with denseShape[0] = 0 but\n indices.shape[0] = ${e}` } function Xn(e, t) { return `indices(${e}, 0) is invalid: ${t} < 0` } function Kn(e, t, n) { return `indices(${e}, 0) is invalid: ${t} >= ${n}` } /** * @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 Zn(e, t) { return `only one output dimension may be -1, not both ${e} and ${t}` } function Jn(e, t) { return `size ${e} must be non-negative, not ${t}` } function Qn() { return "reshape cannot infer the missing input size for an empty tensor unless all specified input sizes are non-zero" } function er(e, t) { return `Input to reshape is a SparseTensor with ${(0, R.Ze)(e)}\n dense values, but the requested shape requires a multiple of ${(0, R.Ze)(t)}. inputShape=${e} outputShape= ${t}` } function tr(e, t) { return `Input to reshape is a tensor with ${(0, R.Ze)(e)} dense values, but the requested shape has ${(0, R.Ze)(t)}. inputShape=${e} outputShape=${t}` } /** * @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 nr() { return "segment ids must be >= 0" } function rr() { return "segment ids are not increasing" } function ir(e, t) { return `Segment id ${e} out of range [0, ${t}), possibly because segmentIds input is not sorted.` } function ar(e, t, n) { return `Bad: indices[${e}] == ${t} out of range [0, ${n})` } /** * @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 or(e, t) { let n, r = !1; for (e <= fn ? (n = e, r = !0) : n = (0, R.lK)(e, Math.floor(Math.sqrt(e))); !r;)n > t || n === e ? r = !0 : n = (0, R.lK)(e, n + 1); return n } function sr(e, t, n) { const r = [], i = e.length; for (let a = 0; a < i; a++)a !== t ? r.push(e[a]) : r.push(n); return r } function ur(e, t, n, r) { const i = t.shape.length, a = e.shape.length; if (0 !== r && (r < -i || r > i)) throw new Error(`Expect batchDims in the range of [-${i}, ${i}], but got ${r}`); if (r < 0 && (r += i), r > a) throw new Error(`batchDims (${r}) must be less than rank(x) (\n ${a}).`); if (n < r) throw new Error(`batchDims (${r}) must be less than or equal to axis (${n}).`); for (let n = 0; n < r; ++n)if (e.shape[n] !== t.shape[n]) throw new Error(`x.shape[${n}]: ${e.shape[n]} should be equal to indices.shape[${n}]: ${t.shape[n]}.`); const o = e.shape[n], s = []; let u = 1, l = 1, c = 1; for (let t = 0; t < r; ++t)s.push(e.shape[t]), u *= e.shape[t]; for (let t = r; t < n; t++)s.push(e.shape[t]), l *= e.shape[t]; for (let e = r; e < i; e++)s.push(t.shape[e]); for (let t = n + 1; t < a; t++)s.push(e.shape[t]), c *= e.shape[t]; return { batchSize: u, sliceSize: c, outerSize: l, dimSize: o, outputShape: 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. * ============================================================================= */ function lr(e) { try { return e.map((e => (0, Dt.decodeString)(e))) } catch (e) { throw new Error(`Failed to decode encoded string bytes into utf-8, error: ${e}`) } } function cr(e) { return e.map((e => (0, Dt.encodeString)(e))) } var hr = n(8360), dr = n(4411), fr = n(5149); /** * @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. * ============================================================================= */ !function () { for (const e of Ue) Te(e) }() }, 6734: (e, t, n) => { "use strict"; n.d(t, { D: () => i }); var r = n(3879); class i { static join(e) { return new i(e).slice() } constructor(e) { if (this.shards = [], this.previousShardIndex = 0, null == e) return; if (e instanceof Array || (e = [e]), 0 === (e = e.map((e => r.isTypedArray(e) ? e.buffer : e))).length) return; this.bufferUniformSize = e[0].byteLength; let t = 0; for (let n = 0; n < e.length; n++) { const r = e[n]; n !== e.length - 1 && r.byteLength !== this.bufferUniformSize && (this.bufferUniformSize = void 0); const i = t + r.byteLength; this.shards.push({ buffer: r, start: t, end: i }), t = i } 0 === this.shards.length && (this.byteLength = 0), this.byteLength = this.shards[this.shards.length - 1].end } slice(e = 0, t = this.byteLength) { if (0 === this.shards.length) return new ArrayBuffer(0); if (e = isNaN(Number(e)) ? 0 : e, t = isNaN(Number(t)) ? 0 : t, e = Math.max(0, e), (t = Math.min(this.byteLength, t)) <= e) return new ArrayBuffer(0); const n = this.findShardForByte(e); if (-1 === n) throw new Error(`Could not find start shard for byte ${e}`); const r = new ArrayBuffer(t - e), i = new Uint8Array(r); let a = 0; for (let r = n; r < this.shards.length; r++) { const n = this.shards[r], o = e + a - n.start, s = a, u = Math.min(t, n.end) - n.start, l = new Uint8Array(n.buffer, o, u - o); if (i.set(l, s), a += l.length, t < n.end) break } return r } findShardForByte(e) { if (0 === this.shards.length || e < 0 || e >= this.byteLength) return -1; if (null != this.bufferUniformSize) return this.previousShardIndex = Math.floor(e / this.bufferUniformSize), this.previousShardIndex; function t(t) { return e < t.start ? -1 : e >= t.end ? 1 : 0 } if (0 === t(this.shards[this.previousShardIndex])) return this.previousShardIndex; const n = function (e, t) { let n = 0, r = e.length; for (; n <= r;) { const i = Math.floor((r - n) / 2) + n, a = t(e[i]); if (0 === a) return i; a < 0 ? r = i : n = i + 1 } return -1 }(this.shards, t); return -1 === n ? -1 : (this.previousShardIndex = n, this.previousShardIndex) } } }, 7084: (e, t, n) => { "use strict"; n.d(t, { AQ: () => S, CY: () => d, Ej: () => T, P8: () => _, Rl: () => A, Xf: () => N, aG: () => h, jf: () => k, l3: () => w, oR: () => E, s5: () => y, zV: () => C }); var r = n(7148), i = n(4027), a = n(5119), o = n(5685), s = n(6734), u = n(5287), l = n(6574); /** * @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 c = 4; async function h(e, t) { const n = [], r = [], i = Array.isArray(e) ? e.map((e => e.name)) : Object.keys(e); for (let a = 0; a < i.length; ++a) { const o = i[a], s = Array.isArray(e) ? e[a].tensor : e[o]; if ("float32" !== s.dtype && "int32" !== s.dtype && "bool" !== s.dtype && "string" !== s.dtype && "complex64" !== s.dtype) throw new Error(`Unsupported dtype in weight '${o}': ${s.dtype}`); const u = { name: o, shape: s.shape, dtype: s.dtype }; if ("string" === s.dtype) { const e = new Promise((async e => { const t = await s.bytes(), n = t.reduce(((e, t) => e + t.length), 0) + c * t.length, r = new Uint8Array(n); let i = 0; for (let e = 0; e < t.length; e++) { const n = t[e], a = new Uint8Array(new Uint32Array([n.length]).buffer); r.set(a, i), i += c, r.set(n, i), i += n.length } e(r) })); r.push(e) } else r.push(s.data()); null != t && (u.group = t), n.push(u) } return { data: b(await Promise.all(r)), specs: n } } function d(e, t) { const n = new s.D(e), r = {}; let i = 0; for (const e of t) { const t = f(e, ((e, t) => n.slice(i + e, i + t))); r[e.name] = m(e, n.slice(i, i + t)), i += t } return r } function f(e, t) { const n = (0, a.Ze)(e.shape); let r; if ("quantization" in e) { const t = e.quantization; r = o.i[t.dtype] } else { if ("string" === e.dtype) { let e = 0; for (let r = 0; r < n; r++)e += c + new Uint32Array(t(e, e + c))[0]; return e } r = o.i[e.dtype] } return n * r } async function p(e, t) { const n = (0, a.Ze)(e.shape); let r; if ("quantization" in e) { const t = e.quantization; r = o.i[t.dtype] } else { if ("string" === e.dtype) { let e = 0; for (let r = 0; r < n; r++)e += c + new Uint32Array(await t(e, e + c))[0]; return e } r = o.i[e.dtype] } return n * r } function m(e, t) { const n = e.name, s = e.dtype, u = e.shape, l = (0, a.Ze)(u); let h, d = 0; if ("quantization" in e) { const r = e.quantization; if ("uint8" === r.dtype || "uint16" === r.dtype) { if (!("min" in r) || !("scale" in r)) throw new Error(`Weight ${e.name} with quantization ${r.dtype} doesn't have corresponding metadata min and scale.`) } else { if ("float16" !== r.dtype) throw new Error(`Weight ${e.name} has unknown quantization dtype ${r.dtype}. Supported quantization dtypes are: 'uint8', 'uint16', and 'float16'.`); if ("float32" !== s) throw new Error(`Weight ${e.name} is quantized with ${r.dtype} which only supports weights of type float32 not ${s}.`) } const i = o.i[r.dtype], a = "uint8" === r.dtype ? new Uint8Array(t) : new Uint16Array(t); if ("float32" === s) if ("uint8" === r.dtype || "uint16" === r.dtype) { h = new Float32Array(a.length); for (let e = 0; e < a.length; e++) { const t = a[e]; h[e] = t * r.scale + r.min } } else { if ("float16" !== r.dtype) throw new Error(`Unsupported quantization type ${r.dtype} for weight type float32.`); { const e = function () { const e = function () { const e = e => { let t = e << 13, n = 0; for (; !(8388608 & t);)n -= 8388608, t <<= 1; return t &= -8388609, n += 947912704, t | n }, t = new Uint32Array(2048); t[0] = 0; for (let n = 1; n < 1024; n++)t[n] = e(n); for (let e = 1024; e < 2048; e++)t[e] = 939524096 + (e - 1024 << 13); return t }(), t = function () { const e = new Uint32Array(64); e[0] = 0, e[31] = 1199570944, e[32] = 2147483648, e[63] = 3347054592; for (let t = 1; t < 31; t++)e[t] = t << 23; for (let t = 33; t < 63; t++)e[t] = 2147483648 + (t - 32 << 23); return e }(), n = function () { const e = new Uint32Array(64); for (let t = 0; t < 64; t++)e[t] = 1024; return e[0] = e[32] = 0, e }(); return r => { const i = new ArrayBuffer(4 * r.length), a = new Uint32Array(i); for (let i = 0; i < r.length; i++) { const o = r[i], s = e[n[o >> 10] + (1023 & o)] + t[o >> 10]; a[i] = s } return new Float32Array(i) } }(); h = e(a) } } else { if ("int32" !== s) throw new Error(`Unsupported dtype in weight '${n}': ${s}`); if ("uint8" !== r.dtype && "uint16" !== r.dtype) throw new Error(`Unsupported quantization type ${r.dtype} for weight type int32.`); h = new Int32Array(a.length); for (let e = 0; e < a.length; e++) { const t = a[e]; h[e] = Math.round(t * r.scale + r.min) } } d += l * i } else if ("string" === s) { const n = (0, a.Ze)(e.shape); h = []; for (let e = 0; e < n; e++) { const e = new Uint32Array(t.slice(d, d + c))[0]; d += c; const n = new Uint8Array(t.slice(d, d + e)); h.push(n), d += e } } else { const e = o.i[s]; if ("float32" === s) h = new Float32Array(t); else if ("int32" === s) h = new Int32Array(t); else { if ("bool" !== s) { if ("complex64" === s) { h = new Float32Array(t); const e = new Float32Array(h.length / 2), n = new Float32Array(h.length / 2); for (let t = 0; t < e.length; t++)e[t] = h[2 * t], n[t] = h[2 * t + 1]; const a = (0, i.O)(e, u, "float32"), o = (0, i.O)(n, u, "float32"), s = (0, r.f)(a, o); return a.dispose(), o.dispose(), s } throw new Error(`Unsupported dtype in weight '${n}': ${s}`) } h = new Uint8Array(t) } d += l * e } return (0, i.O)(h, u, s) } async function g(e, t, n) { let r = new Uint8Array(t); for (; r.byteLength < n;) { const { done: t, value: i } = await e.read(); if (t && null == i) { const e = n - r.byteLength; throw new Error(`Reader is done but ${e} bytes are still expected`) } const a = new Uint8Array(r.length + i.byteLength); a.set(r, 0), a.set(new Uint8Array(i), r.length), r = a } return r.buffer } async function y(e, t) { const n = {}, r = e.getReader(); let i = new ArrayBuffer(0); for (const e of t) { const t = await p(e, (async (e, t) => (i = await g(r, i, t), i.slice(e, t)))); i = await g(r, i, t); const o = i.slice(0, t); i = i.slice(t); const s = m(e, o); if (n[e.name] = s, "webgpu" === (0, u.jz)()) { const e = (0, u.Hs)(); "uploadToGPU" in e && (0, a.Ze)(s.shape) >= (0, l._K)().get("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD") && e.uploadToGPU(s.dataId) } } return n } function b(e) { if (null === e) throw new Error(`Invalid input value: ${JSON.stringify(e)}`); let t = 0; const n = []; e.forEach((e => { if (t += e.byteLength, n.push(e.byteLength === e.buffer.byteLength ? e : new e.constructor(e)), !(e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array)) throw new Error(`Unsupported TypedArray subtype: ${e.constructor.name}`) })); const r = new Uint8Array(t); let i = 0; return n.forEach((e => { r.set(new Uint8Array(e.buffer), i), i += e.byteLength })), r.buffer } const v = "undefined" != typeof Buffer && ("undefined" == typeof Blob || "undefined" == typeof atob || "undefined" == typeof btoa); function x(e) { return v ? Buffer.byteLength(e, "utf8") : new Blob([e]).size } function w(e) { if (v) return Buffer.from(e).toString("base64"); const t = new Uint8Array(e); let n = ""; for (let e = 0, r = t.length; e < r; e++)n += String.fromCharCode(t[e]); return btoa(n) } function k(e) { if (v) { const t = Buffer.from(e, "base64"); return t.buffer.slice(t.byteOffset, t.byteOffset + t.byteLength) } const t = atob(e), n = new Uint8Array(t.length); for (let e = 0; e < t.length; ++e)n.set([t.charCodeAt(e)], e); return n.buffer } function S(e) { return s.D.join(e) } function _(e) { for (e = e.trim(); e.endsWith("/");)e = e.slice(0, e.length - 1); const t = e.split("/"); return t[t.length - 1] } function C(e, t) { const n = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy, weightsManifest: t }; return null != e.signature && (n.signature = e.signature), null != e.userDefinedMetadata && (n.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (n.modelInitializer = e.modelInitializer), null != e.initializerSignature && (n.initializerSignature = e.initializerSignature), null != e.trainingConfig && (n.trainingConfig = e.trainingConfig), n } function A(e, t, n) { const r = { modelTopology: e.modelTopology, format: e.format, generatedBy: e.generatedBy, convertedBy: e.convertedBy }; if (null != e.trainingConfig && (r.trainingConfig = e.trainingConfig), null != e.weightsManifest) { if (!t) throw new Error("modelJSON has weightsManifest but weightSpecs is null"); if (!n) throw new Error("modelJSON has weightsManifest but weightData is null"); r.weightSpecs = t, r.weightData = n } return null != e.signature && (r.signature = e.signature), null != e.userDefinedMetadata && (r.userDefinedMetadata = e.userDefinedMetadata), null != e.modelInitializer && (r.modelInitializer = e.modelInitializer), null != e.initializerSignature && (r.initializerSignature = e.initializerSignature), r } async function T(e, t) { let n, r; return null != e.weightsManifest && ([n, r] = await t(e.weightsManifest)), A(e, n, r) } function E(e) { if (e.modelTopology instanceof ArrayBuffer) throw new Error("Expected JSON model topology, received ArrayBuffer."); return { dateSaved: new Date, modelTopologyType: "JSON", modelTopologyBytes: null == e.modelTopology ? 0 : x(JSON.stringify(e.modelTopology)), weightSpecsBytes: null == e.weightSpecs ? 0 : x(JSON.stringify(e.weightSpecs)), weightDataBytes: null == e.weightData ? 0 : new s.D(e.weightData).byteLength } } function N(e) { const t = []; for (const n of e) t.push(...n.weights); return t } }, 5685: (e, t, n) => { "use strict"; n.d(t, { i: () => r }); /** * @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 r = { float32: 4, float16: 2, int32: 4, uint16: 2, uint8: 1, bool: 1, complex64: 8 } }, 5441: (e, t, n) => { "use strict"; n.d(t, { $dB: () => F, $jE: () => nn, $zE: () => M, A1h: () => O, A8B: () => Ut, BK4: () => bn, BLA: () => Ze, BRl: () => ae, Blb: () => Wt, BoJ: () => Ht, BxF: () => he, C8s: () => Gt, CQC: () => pt, Cg$: () => Ie, CwD: () => Te, D7i: () => At, Ddj: () => Kt, Dr: () => vn, DvZ: () => Yt, E3$: () => Se, EkD: () => s, ElG: () => fe, EwU: () => hn, FAs: () => sn, FCQ: () => _t, FSt: () => l, Fin: () => Bt, GZp: () => Jt, HNs: () => _, Ik2: () => k, J3C: () => Ot, JiE: () => $t, Jp_: () => c, KXH: () => T, L6G: () => qt, LB5: () => C, LDN: () => je, LG0: () => Xe, LRy: () => yt, LWX: () => at, LXA: () => De, M6A: () => Zt, MRQ: () => W, Mn0: () => B, MnK: () => L, N4F: () => S, Ncv: () => ht, O4G: () => ge, OAQ: () => xe, ODT: () => ut, OMN: () => o, ORI: () => X, PH8: () => a, P_L: () => Ct, Pah: () => ne, PbM: () => rn, Q6t: () => gt, QDP: () => E, QKF: () => d, Qgm: () => te, R23: () => xt, RMm: () => pn, RUm: () => Me, RW8: () => $e, RXX: () => We, SDM: () => nt, SQl: () => ce, T7M: () => wn, TBb: () => un, TL8: () => He, TMz: () => G, TOR: () => Et, ToN: () => Pe, TyE: () => p, UcO: () => Qt, VAI: () => Le, VCH: () => b, Vvy: () => i, WRv: () => Be, WT3: () => Je, WuN: () => jt, X$8: () => q, X0$: () => Ce, X4r: () => It, XQy: () => kt, XhZ: () => ye, XmO: () => Q, YAb: () => en, YVe: () => zt, ZgB: () => de, Zl4: () => rt, _s9: () => ie, aAr: () => xn, awo: () => yn, bCz: () => lt, bP9: () => Z, cHb: () => Ge, cS: () => v, dFH: () => Lt, dLy: () => ln, dXR: () => dn, dv8: () => we, e0f: () => it, epO: () => f, fUj: () => vt, g5A: () => qe, gC7: () => P, gIW: () => ke, hVg: () => Tt, hgw: () => St, ho8: () => y, hql: () => Rt, huO: () => bt, i5R: () => pe, iGz: () => z, iPs: () => _e, iW0: () => tn, iuW: () => on, jAQ: () => w, jM4: () => ze, jOE: () => wt, jfg: () => R, jgd: () => Xt, jj_: () => j, jxD: () => K, kdj: () => dt, l0G: () => et, l6P: () => Ft, lLS: () => be, lNG: () => Ye, ljI: () => r, lxb: () => g, lzr: () => ve, mH5: () => mt, mIA: () => Ae, mM$: () => st, mnI: () => Ee, mxL: () => me, nVu: () => Y, nY8: () => U, nZd: () => Fe, oFs: () => an, oJ2: () => ft, ox3: () => oe, p2J: () => D, pJc: () => Nt, pPe: () => fn, p_m: () => h, pk0: () => J, pnw: () => gn, pr3: () => I, pyJ: () => ct, rFG: () => Vt, rFm: () => $, rGP: () => le, rsH: () => re, sDr: () => ee, t3d: () => Ue, tG8: () => Ne, tGH: () => H, u$b: () => Dt, u8Z: () => u, uWl: () => Mt, urI: () => ot, vI1: () => Pt, vaV: () => N, vj7: () => A, wNW: () => V, wwC: () => x, wx0: () => cn, x7F: () => Ke, xJ3: () => mn, xu7: () => Qe, yPW: () => Oe, ySp: () => Ve, ybN: () => se, ybj: () => ue, ylV: () => tt, zP9: () => m, zfU: () => Re }); const r = "Abs", i = "Acos", a = "Acosh", o = "Add", s = "AddN", u = "All", l = "Any", c = "ArgMax", h = "ArgMin", d = "Asin", f = "Asinh", p = "Atan", m = "Atanh", g = "Atan2", y = "AvgPool", b = "AvgPoolGrad", v = "AvgPool3D", x = "AvgPool3DGrad", w = "BatchMatMul", k = "BatchToSpaceND", S = "Bincount", _ = "BitwiseAnd", C = "BroadcastTo", A = "BroadcastArgs", T = "Cast", E = "Ceil", N = "ClipByValue", I = "Complex", M = "ComplexAbs", F = "Concat", D = "Conv2D", $ = "Conv2DBackpropFilter", R = "Conv2DBackpropInput", O = "Conv3D", z = "Conv3DBackpropFilterV2", P = "Conv3DBackpropInputV2", B = "Cos", L = "Cosh", j = "Cumprod", U = "Cumsum", W = "CropAndResize", V = "DenseBincount", G = "DepthToSpace", H = "DepthwiseConv2dNative", q = "DepthwiseConv2dNativeBackpropFilter", Y = "DepthwiseConv2dNativeBackpropInput", X = "Diag", K = "Dilation2D", Z = "Dilation2DBackpropInput", J = "Dilation2DBackpropFilter", Q = "Draw", ee = "RealDiv", te = "Einsum", ne = "Elu", re = "EluGrad", ie = "Erf", ae = "Equal", oe = "Exp", se = "ExpandDims", ue = "Expm1", le = "FFT", ce = "Fill", he = "FlipLeftRight", de = "Floor", fe = "FloorDiv", pe = "FusedBatchNorm", me = "GatherV2", ge = "GatherNd", ye = "Greater", be = "GreaterEqual", ve = "Identity", xe = "IFFT", we = "Imag", ke = "IsFinite", Se = "IsInf", _e = "IsNan", Ce = "LeakyRelu", Ae = "Less", Te = "LessEqual", Ee = "LinSpace", Ne = "Log", Ie = "Log1p", Me = "LogicalAnd", Fe = "LogicalNot", De = "LogicalOr", $e = "LogicalXor", Re = "LogSoftmax", Oe = "LowerBound", ze = "LRN", Pe = "LRNGrad", Be = "MatrixBandPart", Le = "Max", je = "Maximum", Ue = "MaxPool", We = "MaxPoolGrad", Ve = "MaxPool3D", Ge = "MaxPool3DGrad", He = "MaxPoolWithArgmax", qe = "Mean", Ye = "Min", Xe = "Minimum", Ke = "MirrorPad", Ze = "Mod", Je = "Multinomial", Qe = "Multiply", et = "Neg", tt = "NotEqual", nt = "NonMaxSuppressionV3", rt = "NonMaxSuppressionV4", it = "NonMaxSuppressionV5", at = "OnesLike", ot = "OneHot", st = "Pack", ut = "PadV2", lt = "Pool", ct = "Pow", ht = "Prelu", dt = "Prod", ft = "RaggedGather", pt = "RaggedRange", mt = "RaggedTensorToTensor", gt = "Range", yt = "Real", bt = "Reciprocal", vt = "Relu", xt = "Reshape", wt = "ResizeNearestNeighbor", kt = "ResizeNearestNeighborGrad", St = "ResizeBilinear", _t = "ResizeBilinearGrad", Ct = "Relu6", At = "Reverse", Tt = "Round", Et = "Rsqrt", Nt = "ScatterNd", It = "TensorScatterUpdate", Mt = "SearchSorted", Ft = "Select", Dt = "Selu", $t = "Slice", Rt = "Sin", Ot = "Sinh", zt = "Sign", Pt = "Sigmoid", Bt = "Softplus", Lt = "Sqrt", jt = "Sum", Ut = "SpaceToBatchND", Wt = "SplitV", Vt = "Softmax", Gt = "SparseFillEmptyRows", Ht = "SparseReshape", qt = "SparseSegmentMean", Yt = "SparseSegmentSum", Xt = "SparseToDense", Kt = "SquaredDifference", Zt = "Square", Jt = "StaticRegexReplace", Qt = "StridedSlice", en = "StringNGrams", tn = "StringSplit", nn = "StringToHashBucketFast", rn = "Sub", an = "Tan", on = "Tanh", sn = "Tile", un = "TopK", ln = "Transform", cn = "Transpose", hn = "Unique", dn = "Unpack", fn = "UnsortedSegmentSum", pn = "UpperBound", mn = "ZerosLike", gn = "Step", yn = "FromPixels", bn = "RotateWithOffset", vn = "_FusedMatMul", xn = "FusedConv2D", wn = "FusedDepthwiseConv2D" }, 7074: (e, t, n) => { "use strict"; n.d(t, { Cf: () => m, Op: () => c, _5: () => u, iP: () => f, kr: () => d, rY: () => p, tA: () => h, vQ: () => l }); var r = n(6574), i = n(1743), a = n(3673); /** * @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 o = (0, i.m)("kernelRegistry", (() => new Map)), s = (0, i.m)("gradRegistry", (() => new Map)); function u(e, t) { const n = g(e, t); return o.get(n) } function l(e) { return s.get(e) } function c(e) { const t = o.entries(), n = []; for (; ;) { const { done: r, value: i } = t.next(); if (r) break; const [a, o] = i, [s] = a.split("_"); s === e && n.push(o) } return n } function h(e) { const { kernelName: t, backendName: n } = e, r = g(t, n); o.has(r) && a.i(`The kernel '${t}' for backend '${n}' is already registered`), o.set(r, e) } function d(e) { const { kernelName: t } = e; s.has(t) && (0, r._K)().getBool("DEBUG") && a.i(`Overriding the gradient for '${t}'`), s.set(t, e) } function f(e, t) { const n = g(e, t); if (!o.has(n)) throw new Error(`The kernel '${e}' for backend '${t}' is not registered`); o.delete(n) } function p(e) { if (!s.has(e)) throw new Error(`The gradient '${e}' for backend is not registered`); s.delete(e) } function m(e, t) { c(e).forEach((e => { h(Object.assign({}, e, { backendName: t })) })) } function g(e, t) { return `${t}_${e}` } }, 3673: (e, t, n) => { "use strict"; n.d(t, { R: () => a, i: () => i }); var r = n(6574); /** * @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 i(...e) { (0, r._K)().getBool("IS_TEST") || (0, r._K)().getBool("PROD") || console.warn(...e) } function a(...e) { (0, r._K)().getBool("IS_TEST") || (0, r._K)().getBool("PROD") || console.log(...e) } }, 4888: (e, t, n) => { "use strict"; n.d(t, { t: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ abs_: /** * @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 (e) { const t = (0, a.YT)(e, "x", "abs"); if ("complex64" === t.dtype) { const e = { x: t }; return r.T2.runKernel(i.$zE, e) } { const e = { x: t }; return r.T2.runKernel(i.ljI, e) } } }) }, 2804: (e, t, n) => { "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ acos_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "acos") }; return r.T2.runKernel(i.Vvy, t) } }) }, 7558: (e, t, n) => { "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ acosh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "acosh") }; return r.T2.runKernel(i.PH8, t) } }) }, 7523: (e, t, n) => { "use strict"; n.d(t, { W: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ add_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "add"), s = (0, o.YT)(t, "b", "add");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.OMN, u) } }) }, 2307: (e, t, n) => { "use strict"; n.d(t, { Q: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ all_: /** * @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 (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "all", "bool") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.u8Z, o, s) } }) }, 9326: (e, t, n) => { "use strict"; n.d(t, { b: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ any_: /** * @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 (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "any", "bool") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.FSt, o, s) } }) }, 897: (e, t, n) => { "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ argMax_: /** * @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 (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "argMax") }, o = { axis: t }; return r.T2.runKernel(i.Jp_, n, o) } }) }, 4339: (e, t, n) => { "use strict"; n.d(t, { X: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ argMin_: /** * @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 (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "argMin") }, o = { axis: t }; return r.T2.runKernel(i.p_m, n, o) } }) }, 6841: (e, t, n) => { "use strict"; n.d(t, { q: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ asin_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "asin") }; return r.T2.runKernel(i.QKF, t) } }) }, 269: (e, t, n) => { "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ asinh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "asinh") }; return r.T2.runKernel(i.epO, t) } }) }, 9580: (e, t, n) => { "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ atan_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "atan") }; return r.T2.runKernel(i.TyE, t) } }) }, 1404: (e, t, n) => { "use strict"; n.d(t, { F: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ atan2_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "atan2"), s = (0, o.YT)(t, "b", "atan2");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.lxb, u) } }) }, 3774: (e, t, n) => { "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ atanh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "atanh") }; return r.T2.runKernel(i.zP9, t) } }) }, 3909: (e, t, n) => { "use strict"; n.d(t, { $: () => h }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(9809), u = n(7195), l = n(929), c = n(2302); const h = (0, l.op)({ avgPool_: /** * @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 (e, t, n, l, h) { const d = (0, a.YT)(e, "x", "avgPool", "float32"); o.vA(u.G0(n, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)); let f = d, p = !1; 3 === d.rank && (p = !0, f = (0, c.t)(d, [1, d.shape[0], d.shape[1], d.shape[2]])), o.vA(4 === f.rank, (() => `Error in avgPool: x must be rank 4 but got rank ${f.rank}.`)), u.s_("avgPool", l, h); const m = { x: f }, g = { filterSize: t, strides: n, pad: l, dimRoundingMode: h }; let y = r.T2.runKernel(i.ho8, m, g); return y = (0, s.w)(y, d.dtype), p ? (0, c.t)(y, [y.shape[1], y.shape[2], y.shape[3]]) : y } }) }, 1078: (e, t, n) => { "use strict"; n.d(t, { Em: () => l, SM: () => s, WC: () => u, WH: () => i, aF: () => a, fK: () => h, gx: () => c, lb: () => o }); var r = n(5119); /** * @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. * ============================================================================= */function i(e, t) { for (let n = 0; n < e.length; ++n)if (e[e.length - n - 1] !== t - 1 - n) return !1; return !0 } function a(e, t, n) { const r = e.length + t.length, i = []; let a = 0, o = 0; for (let s = 0; s < r; s++)-1 === n.indexOf(s) ? i.push(e[a++]) : i.push(t[o++]); return i } function o(e, t) { const n = [], r = e.length; for (let i = 0; i < r; i++)-1 === t.indexOf(i) && n.push(e[i]); return [n, t.map((t => e[t]))] } function s(e, t) { return a(e, t.map((e => 1)), t) } function u(e, t, n) { r.vA(i(t, n), (() => `${e} supports only inner-most axes for now. Got axes ${t} and rank-${n} input.`)) } function l(e, t) { if (i(e, t)) return null; const n = []; for (let r = 0; r < t; ++r)-1 === e.indexOf(r) && n.push(r); return e.forEach((e => n.push(e))), n } function c(e) { return e.map(((e, t) => [t, e])).sort(((e, t) => e[1] - t[1])).map((e => e[0])) } function h(e, t) { const n = []; for (let r = t - e; r < t; ++r)n.push(r); return n } }, 9772: (e, t, n) => { "use strict"; n.d(t, { G: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ batchToSpaceND_: /** * @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 (e, t, n) { const s = (0, a.YT)(e, "x", "batchToSpaceND"), u = t.reduce(((e, t) => e * t)); o.vA(s.rank >= 1 + t.length, (() => `input rank is ${s.rank} but should be > than blockShape.length ${t.length}`)), o.vA(n.length === t.length, (() => `crops.length is ${n.length} but should be equal to blockShape.length ${t.length}`)), o.vA(s.shape[0] % u == 0, (() => `input tensor batch is ${s.shape[0]} but is not divisible by the product of the elements of blockShape ${t.join(" * ")} === ${u}`)); const l = { x: s }, c = { blockShape: t, crops: n }; return r.T2.runKernel(i.Ik2, l, c) } }) }, 9160: (e, t, n) => { "use strict"; n.d(t, { $: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(2302); const u = (0, n(929).op)({ batchNorm_: /** * @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 (e, t, n, u, l, c) { null == c && (c = .001); const h = (0, a.YT)(e, "x", "batchNorm"), d = (0, a.YT)(t, "mean", "batchNorm"), f = (0, a.YT)(n, "variance", "batchNorm"); let p, m; null != l && (p = (0, a.YT)(l, "scale", "batchNorm")), null != u && (m = (0, a.YT)(u, "offset", "batchNorm")), o.vA(d.rank === f.rank, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), o.vA(null == m || d.rank === m.rank, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), o.vA(null == p || d.rank === p.rank, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")); const g = { x: function (e) { let t; return t = 0 === e.rank || 1 === e.rank ? (0, s.t)(e, [1, 1, 1, e.size]) : 2 === e.rank ? (0, s.t)(e, [1, 1, e.shape[0], e.shape[1]]) : 3 === e.rank ? (0, s.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]]) : e, t }(h), scale: p, offset: m, mean: d, variance: f }, y = { varianceEpsilon: c }, b = r.T2.runKernel(i.i5R, g, y); return (0, s.t)(b, h.shape) } }) }, 3567: (e, t, n) => { "use strict"; n.d(t, { h: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(125), u = n(929), l = n(2302); const c = (0, u.op)({ broadcastTo_: /** * @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 (e, t) { let n = (0, a.YT)(e, "broadcastTo", "x"); const u = n.shape; if ((0, o.SA)(t), t.length < n.rank) throw new Error(`broadcastTo(): shape.length=${t.length} < input.rank=${n.rank}.`); if (t.length > n.rank) { const e = n.shape.slice(); for (; e.length < t.length;)e.unshift(1); n = (0, l.t)(n, e) } const c = n.shape, h = Array.from(t); for (let e = t.length - 1; e >= 0; e--)if (c[e] === t[e]) h[e] = 1; else if (1 !== n.shape[e]) throw new Error(`broadcastTo(): [${u}] cannot be broadcast to [${t}].`); if (0 === h.map(((e, t) => e > 1 ? t : -1)).filter((e => e >= 0)).length) return (0, s.o)(n); const d = { x: n }, f = { reps: h }; return r.T2.runKernel(i.FAs, d, f) } }) }, 2198: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */ function r(e, t) { const n = e.length, r = []; for (let i = 0; i < n; i++) { const a = n - 1 - i, o = e[a] || 1; (t[t.length - 1 - i] || 1) > 1 && 1 === o && r.unshift(a) } return r } function i(e, t) { const n = []; for (let r = 0; r < t.length; r++) { const i = e[e.length - r - 1], a = t.length - r - 1, o = t[a]; (null == i || 1 === i && o > 1) && n.unshift(a) } return n } function a(e, t) { const n = Math.max(e.length, t.length), r = new Array(n); for (let i = 0; i < n; i++) { let a = e[e.length - i - 1]; null == a && (a = 1); let o = t[t.length - i - 1]; if (null == o && (o = 1), 1 === a) r[n - i - 1] = o; else if (1 === o) r[n - i - 1] = a; else { if (a !== o) { throw Error(`Operands could not be broadcast together with shapes ${e} and ${t}.`) } r[n - i - 1] = a } } return r } n.r(t), n.d(t, { assertAndGetBroadcastShape: () => a, getBroadcastDims: () => r, getReductionAxes: () => i }) }, 448: (e, t, n) => { "use strict"; n.d(t, { r: () => a }); var r = n(259), i = n(5119); /** * @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 a(e, t = "float32", n) { return t = t || "float32", i.SA(e), new r.yl(e, t, n) } }, 9809: (e, t, n) => { "use strict"; n.d(t, { w: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ cast_: /** * @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 (e, t) { const n = (0, a.YT)(e, "x", "cast"); if (!o.xn(t)) throw new Error(`Failed to cast to unknown dtype ${t}`); if ("string" === t && "string" !== n.dtype || "string" !== t && "string" === n.dtype) throw new Error("Only strings can be casted to strings"); const s = { x: n }, u = { dtype: t }; return r.T2.runKernel(i.KXH, s, u) } }) }, 855: (e, t, n) => { "use strict"; n.d(t, { m: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ ceil_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "ceil", "float32") }; return r.T2.runKernel(i.QDP, t) } }) }, 6928: (e, t, n) => { "use strict"; n.d(t, { z: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(6111); const u = (0, n(929).op)({ clipByValue_: /** * @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 (e, t, n) { const u = (0, a.YT)(e, "x", "clipByValue"); if (o.vA(t <= n, (() => `Error in clip: min (${t}) must be less than or equal to max (${n}).`)), t === n) return (0, s.G)(u.shape, t, u.dtype); const l = { x: u }, c = { clipValueMin: t, clipValueMax: n }; return r.T2.runKernel(i.vaV, l, c) } }) }, 125: (e, t, n) => { "use strict"; n.d(t, { o: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ clone_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "clone", "string_or_numeric") }; return r.T2.runKernel(i.lzr, t) } }) }, 7148: (e, t, n) => { "use strict"; n.d(t, { f: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ complex_: /** * @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 (e, t) { const n = (0, a.YT)(e, "real", "complex"), s = (0, a.YT)(t, "imag", "complex"); o.O3(n.shape, s.shape, `real and imag shapes, ${n.shape} and ${s.shape}, must match in call to tf.complex().`); const u = { real: n, imag: s }; return r.T2.runKernel(i.pr3, u) } }) }, 5030: (e, t, n) => { "use strict"; n.d(t, { x: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(125); const u = (0, n(929).op)({ concat_: /** * @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 (e, t = 0) { (0, o.vA)(e.length >= 1, (() => "Pass at least one tensor to concat")); const n = (0, a.j1)(e, "tensors", "concat", "string_or_numeric"); if ("complex64" === n[0].dtype && n.forEach((e => { if ("complex64" !== e.dtype) throw new Error(`Cannot concatenate complex64 tensors with a tensor\n with dtype ${e.dtype}. `) })), 1 === n.length) return (0, s.o)(n[0]); const u = n, l = { axis: t }; return r.T2.runKernel(i.$dB, u, l) } }) }, 3701: (e, t, n) => { "use strict"; n.d(t, { k: () => l }); var r = n(8189), i = n(5119), a = n(8794), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ conv1d_: function (e, t, n, s, l = "NWC", c = 1, h) { const d = (0, r.YT)(e, "x", "conv1d"), f = (0, r.YT)(t, "filter", "conv1d"); let p = d, m = !1; 2 === d.rank && (m = !0, p = (0, u.t)(d, [1, d.shape[0], d.shape[1]])), i.vA(3 === p.rank, (() => `Error in conv1d: input must be rank 3, but got rank ${p.rank}.`)), i.vA(3 === f.rank, (() => `Error in conv1d: filter must be rank 3, but got rank ${f.rank}.`)), o.s_("conv1d", s, h), i.vA(p.shape[2] === f.shape[1], (() => `Error in conv1d: depth of input (${p.shape[2]}) must match input depth for filter ${f.shape[1]}.`)), i.vA(o.G0(n, c), (() => `Error in conv1D: Either stride or dilation must be 1. Got stride ${n} and dilation '${c}'`)), i.vA(o.qk(c), (() => "Error in conv1D: Dilated rates should be larger than 0.")), i.vA(o.qk(n), (() => "Error in conv1D: Stride should be larger than 0.")), i.vA("NWC" === l, (() => `Error in conv1d: got dataFormat of ${l} but only NWC is currently supported.`)); const g = (0, u.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]]), y = (0, u.t)(p, [p.shape[0], 1, p.shape[1], p.shape[2]]), b = [1, n], v = [1, c], x = (0, a.X)(y, g, b, s, "NHWC", v, h); return m ? (0, u.t)(x, [x.shape[2], x.shape[3]]) : (0, u.t)(x, [x.shape[0], x.shape[2], x.shape[3]]) } }) }, 8794: (e, t, n) => { "use strict"; n.d(t, { X: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ conv2d_: /** * @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 (e, t, n, u, c = "NHWC", h = [1, 1], d) { const f = (0, a.YT)(e, "x", "conv2d", "float32"), p = (0, a.YT)(t, "filter", "conv2d", "float32"); let m = f, g = !1; 3 === f.rank && (g = !0, m = (0, l.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]])), o.vA(4 === m.rank, (() => `Error in conv2d: input must be rank 4, but got rank ${m.rank}.`)), o.vA(4 === p.rank, (() => `Error in conv2d: filter must be rank 4, but got rank ${p.rank}.`)), s.s_("conv2d", u, d); const y = "NHWC" === c ? m.shape[3] : m.shape[1]; o.vA(y === p.shape[2], (() => `Error in conv2d: depth of input (${y}) must match input depth for filter ${p.shape[2]}.`)), o.vA(s.G0(n, h), (() => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${h}'`)), o.vA(s.qk(h), (() => "Error in conv2D: Dilated rates should be larger than 0.")), o.vA(s.qk(n), (() => "Error in conv2D: Strides should be larger than 0.")); const b = { x: m, filter: p }, v = { strides: n, pad: u, dataFormat: c, dilations: h, dimRoundingMode: d }, x = r.T2.runKernel(i.p2J, b, v); return g ? (0, l.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } }) }, 5248: (e, t, n) => { "use strict"; n.d(t, { H: () => l }); var r = n(1585), i = n(5441), a = n(5119), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ conv2DBackpropFilter_: /** * @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 (e, t, n, s, l, c = "NHWC", h) { let d = e; 3 === e.rank && (d = (0, u.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]])); let f = t; 3 === f.rank && (f = (0, u.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])), a.vA(4 === d.rank, (() => `Error in conv2dDerFilter: input must be rank 4, but got shape ${d.shape}.`)), a.vA(4 === f.rank, (() => `Error in conv2dDerFilter: dy must be rank 4, but got shape ${f.shape}.`)), a.vA(4 === n.length, (() => `Error in conv2dDerFilter: filterShape must be length 4, but got ${n}.`)); const p = "NHWC" === c ? d.shape[3] : d.shape[1], m = "NHWC" === c ? f.shape[3] : f.shape[1]; a.vA(p === n[2], (() => `Error in conv2dDerFilter: depth of input ${p}) must match input depth in filter (${n[2]}.`)), a.vA(m === n[3], (() => `Error in conv2dDerFilter: depth of dy (${m}) must match output depth for filter (${n[3]}).`)), o.s_("conv2dDerFilter", l, h); const g = { x: d, dy: f }, y = { strides: s, pad: l, dataFormat: c, dimRoundingMode: h, filterShape: n }; return r.T2.runKernel(i.rFm, g, y) } }) }, 252: (e, t, n) => { "use strict"; n.d(t, { v: () => l }); var r = n(1585), i = n(5441), a = n(5119), o = n(7195), s = n(929), u = n(2302); const l = (0, s.op)({ conv2DBackpropInput_: /** * @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 (e, t, n, s, l, c = "NHWC", h) { a.vA(e.length === t.rank, (() => `Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`)); let d = e, f = t, p = !1; 3 === t.rank && (p = !0, f = (0, u.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]]), d = [1, e[0], e[1], e[2]]), a.vA(4 === d.length, (() => `Error in conv2dDerInput: inShape must be length 4, but got length ${d.length}.`)), a.vA(4 === f.rank, (() => `Error in conv2dDerInput: dy must be rank 4, but got rank ${f.rank}`)), a.vA(4 === n.rank, (() => `Error in conv2dDerInput: filter must be rank 4, but got rank ${n.rank}`)); const m = "NHWC" === c ? d[3] : d[1], g = "NHWC" === c ? f.shape[3] : f.shape[1]; a.vA(m === n.shape[2], (() => `Error in conv2dDerInput: depth of input (${m}) must match input depth for filter ${n.shape[2]}.`)), a.vA(g === n.shape[3], (() => `Error in conv2dDerInput: depth of output (${g}) must match output depth for filter ${n.shape[3]}.`)), o.s_("conv2dDerInput", l, h); const y = { dy: f, filter: n }, b = { strides: s, pad: l, dataFormat: c, dimRoundingMode: h, inputShape: d }, v = r.T2.runKernel(i.jfg, y, b); return p ? (0, u.t)(v, [v.shape[1], v.shape[2], v.shape[3]]) : v } }) }, 1106: (e, t, n) => { "use strict"; n.d(t, { w: () => a }); var r = n(8189), i = n(252); const a = (0, n(929).op)({ conv2dTranspose_: function (e, t, n, a, o, s) { const u = (0, r.YT)(e, "x", "conv2dTranspose"), l = (0, r.YT)(t, "filter", "conv2dTranspose"); return (0, i.v)(n, u, l, a, o, "NHWC", s) } }) }, 1895: (e, t, n) => { "use strict"; n.d(t, { c: () => u }); var r = n(1585), i = n(5441), a = n(5119), o = n(929), s = n(2302); const u = (0, o.op)({ conv3DBackpropInput_: /** * @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 (e, t, n, o, u) { a.vA(e.length === t.rank, (() => `Length of inShape (${e.length}) and rank of dy (${t.rank}) must match`)); let l = e, c = t, h = !1; 4 === t.rank && (h = !0, c = (0, s.t)(t, [1, t.shape[0], t.shape[1], t.shape[2], t.shape[3]]), l = [1, e[0], e[1], e[2], e[3]]); const d = l[4], f = c.shape[4]; a.vA(5 === l.length, (() => `Error in conv3dDerInput: inShape must be length 5, but got length ${l.length}.`)), a.vA(5 === c.rank, (() => `Error in conv3dDerInput: dy must be rank 5, but got rank ${c.rank}`)), a.vA(5 === n.rank, (() => `Error in conv3dDerInput: filter must be rank 5, but got rank ${n.rank}`)), a.vA(d === n.shape[3], (() => `Error in conv3dDerInput: depth of input (${d}) must match input depth for filter ${n.shape[3]}.`)), a.vA(f === n.shape[4], (() => `Error in conv3dDerInput: depth of output (${f}) must match output depth for filter ${n.shape[4]}.`)); const p = { dy: c, filter: n }, m = { pad: u, strides: o, inputShape: l }, g = r.T2.runKernel(i.gC7, p, m); return h ? (0, s.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g } }) }, 7195: (e, t, n) => { "use strict"; n.d(t, { $Q: () => y, Dh: () => p, E6: () => a, G0: () => m, G8: () => l, YQ: () => i, l5: () => o, p$: () => u, qk: () => g, s_: () => b, uf: () => s }); var r = n(5119); /** * @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 i(e, t, n, r, i = "NHWC", a) { return s(e, [...t, e[3]], n, a, r, null, null, y(i)) } function a(e, t, n, r, i, a, o = "channelsLast") { const [u, l] = c(t); let h; if ("channelsLast" === o) h = [u, l, e[3], e[3]]; else { if ("channelsFirst" !== o) throw new Error(`Unknown dataFormat ${o}`); h = [u, l, e[1], e[1]] } return s(e, h, n, r, i, a, !1, o) } function o(e, t, n, r, i, a, o = "NDHWC") { const [s, l, c] = h(t); let d, f; if ("NDHWC" === o) f = "channelsLast", d = [s, l, c, e[4], e[4]]; else { if ("NCDHW" !== o) throw new Error(`Unknown dataFormat ${o}`); f = "channelsFirst", d = [s, l, c, e[1], e[1]] } return u(e, d, n, r, i, !1, f, a) } function s(e, t, n, r, i, a, o = !1, s = "channelsLast") { let [u, h, p, m] = [-1, -1, -1, -1]; if ("channelsLast" === s) [u, h, p, m] = e; else { if ("channelsFirst" !== s) throw new Error(`Unknown dataFormat ${s}`);[u, m, h, p] = e } const [g, y, , b] = t, [v, x] = c(n), [w, k] = c(r), S = d(g, w), _ = d(y, k), { padInfo: C, outHeight: A, outWidth: T } = function (e, t, n, r, i, a, o, s, u) { let c, h, d; if ("number" == typeof e) { c = { top: e, bottom: e, left: e, right: e, type: 0 === e ? "VALID" : "NUMBER" }; const i = function (e, t, n, r, i) { null == r && (r = l(e, t, n)); const a = e[0], o = e[1], s = f((a - t + 2 * r) / n + 1, i), u = f((o - t + 2 * r) / n + 1, i); return [s, u] }([t, n], a, r, e, s); h = i[0], d = i[1] } else if ("same" === e) { h = Math.ceil(t / r), d = Math.ceil(n / i); const e = Math.max(0, (h - 1) * r + a - t), s = Math.max(0, (d - 1) * i + o - n), u = Math.floor(e / 2), l = e - u, f = Math.floor(s / 2); c = { top: u, bottom: l, left: f, right: s - f, type: "SAME" } } else if ("valid" === e) c = { top: 0, bottom: 0, left: 0, right: 0, type: "VALID" }, h = Math.ceil((t - a + 1) / r), d = Math.ceil((n - o + 1) / i); else { if ("object" != typeof e) throw Error(`Unknown padding parameter: ${e}`); { const l = "channelsLast" === u ? e[1][0] : e[2][0], p = "channelsLast" === u ? e[1][1] : e[2][1], m = "channelsLast" === u ? e[2][0] : e[3][0], g = "channelsLast" === u ? e[2][1] : e[3][1]; c = { top: l, bottom: p, left: m, right: g, type: 0 === l && 0 === p && 0 === m && 0 === g ? "VALID" : "EXPLICIT" }, h = f((t - a + l + p) / r + 1, s), d = f((n - o + m + g) / i + 1, s) } } return { padInfo: c, outHeight: h, outWidth: d } }(i, h, p, v, x, S, _, a, s), E = o ? b * m : b; let N; return "channelsFirst" === s ? N = [u, E, A, T] : "channelsLast" === s && (N = [u, A, T, E]), { batchSize: u, dataFormat: s, inHeight: h, inWidth: p, inChannels: m, outHeight: A, outWidth: T, outChannels: E, padInfo: C, strideHeight: v, strideWidth: x, filterHeight: g, filterWidth: y, effectiveFilterHeight: S, effectiveFilterWidth: _, dilationHeight: w, dilationWidth: k, inShape: e, outShape: N, filterShape: t } } function u(e, t, n, r, i, a = !1, o = "channelsLast", s) { let [u, c, p, m, g] = [-1, -1, -1, -1, -1]; if ("channelsLast" === o) [u, c, p, m, g] = e; else { if ("channelsFirst" !== o) throw new Error(`Unknown dataFormat ${o}`);[u, g, c, p, m] = e } const [y, b, v, , x] = t, [w, k, S] = h(n), [_, C, A] = h(r), T = d(y, _), E = d(b, C), N = d(v, A), { padInfo: I, outDepth: M, outHeight: F, outWidth: D } = function (e, t, n, r, i, a, o, s, u, c, h) { let d, p, m, g; "valid" === e && (e = 0); if ("number" == typeof e) { d = { top: e, bottom: e, left: e, right: e, front: e, back: e, type: 0 === e ? "VALID" : "NUMBER" }; const y = function (e, t, n, r, i, a) { null == i && (i = l(e, t[0], r[0])); const o = [0, 0, 0, n]; for (let n = 0; n < 3; n++)e[n] + 2 * i >= t[n] && (o[n] = f((e[n] - t[n] + 2 * i) / r[n] + 1, a)); return o }([t, n, r, 1], [s, u, c], 1, [i, a, o], e, h); p = y[0], m = y[1], g = y[2] } else { if ("same" !== e) throw Error(`Unknown padding parameter: ${e}`); { p = Math.ceil(t / i), m = Math.ceil(n / a), g = Math.ceil(r / o); const e = (p - 1) * i + s - t, l = (m - 1) * a + u - n, h = (g - 1) * o + c - r, f = Math.floor(e / 2), y = e - f, b = Math.floor(l / 2), v = l - b, x = Math.floor(h / 2); d = { top: b, bottom: v, left: x, right: h - x, front: f, back: y, type: "SAME" } } } return { padInfo: d, outDepth: p, outHeight: m, outWidth: g } }(i, c, p, m, w, k, S, T, E, N, s), $ = a ? x * g : x; let R; return "channelsFirst" === o ? R = [u, $, M, F, D] : "channelsLast" === o && (R = [u, M, F, D, $]), { batchSize: u, dataFormat: o, inDepth: c, inHeight: p, inWidth: m, inChannels: g, outDepth: M, outHeight: F, outWidth: D, outChannels: $, padInfo: I, strideDepth: w, strideHeight: k, strideWidth: S, filterDepth: y, filterHeight: b, filterWidth: v, effectiveFilterDepth: T, effectiveFilterHeight: E, effectiveFilterWidth: N, dilationDepth: _, dilationHeight: C, dilationWidth: A, inShape: e, outShape: R, filterShape: t } } function l(e, t, n, r = 1) { const i = d(t, r); return Math.floor((e[0] * (n - 1) - n + i) / 2) } function c(e) { return "number" == typeof e ? [e, e, e] : 2 === e.length ? [e[0], e[1], 1] : e } function h(e) { return "number" == typeof e ? [e, e, e] : e } function d(e, t) { return t <= 1 ? e : e + (e - 1) * (t - 1) } function f(e, t) { if (!t) return Math.trunc(e); switch (t) { case "round": return Math.round(e); case "ceil": return Math.ceil(e); case "floor": return Math.floor(e); default: throw new Error(`Unknown roundingMode ${t}`) } } function p(e) { const [t, n, r] = c(e); return 1 === t && 1 === n && 1 === r } function m(e, t) { return p(e) || p(t) } function g(e) { return c(e).every((e => e > 0)) } function y(e) { if ("NHWC" === e) return "channelsLast"; if ("NCHW" === e) return "channelsFirst"; throw new Error(`Unknown dataFormat ${e}`) } function b(e, t, n) { if (null != n) { if ("string" == typeof t) throw Error(`Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`); if ("number" == typeof t) r.vA(r.E6(t), (() => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`)); else { if ("object" != typeof t) throw Error(`Error in ${e}: Unknown padding parameter: ${t}`); t.forEach((t => { t.forEach((t => { r.vA(r.E6(t), (() => `Error in ${e}: pad must be an integer when using dimRoundingMode ${n} but got pad ${t}.`)) })) })) } } } }, 9907: (e, t, n) => { "use strict"; n.d(t, { g: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ cos_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "cos", "float32") }; return r.T2.runKernel(i.Mn0, t) } }) }, 7451: (e, t, n) => { "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ cosh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "cosh", "float32") }; return r.T2.runKernel(i.MnK, t) } }) }, 302: (e, t, n) => { "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ cumprod_: /** * @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 (e, t = 0, n = !1, o = !1) { const s = { x: (0, a.YT)(e, "x", "cumprod") }, u = { axis: t, exclusive: n, reverse: o }; return r.T2.runKernel(i.jj_, s, u) } }) }, 6808: (e, t, n) => { "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ cumsum_: /** * @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 (e, t = 0, n = !1, o = !1) { const s = { x: (0, a.YT)(e, "x", "cumsum") }, u = { axis: t, exclusive: n, reverse: o }; return r.T2.runKernel(i.nY8, s, u) } }) }, 1216: (e, t, n) => { "use strict"; n.d(t, { R: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ depthToSpace_: /** * @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 (e, t, n = "NHWC") { const s = (0, a.YT)(e, "x", "depthToSpace", "float32"), u = "NHWC" === n ? s.shape[1] : s.shape[2], l = "NHWC" === n ? s.shape[2] : s.shape[3], c = "NHWC" === n ? s.shape[3] : s.shape[1]; o.vA(t > 1, (() => `blockSize should be > 1 for depthToSpace, but was: ${t}`)), o.vA(u * t >= 0, (() => `Negative dimension size caused by overflow when multiplying\n ${u} and ${t} for depthToSpace with input shape\n ${s.shape}`)), o.vA(l * t >= 0, (() => `Negative dimension size caused by overflow when multiplying\n ${l} and ${t} for depthToSpace with input shape\n ${s.shape}`)), o.vA(c % (t * t) == 0, (() => `Dimension size must be evenly divisible by ${t * t} but is ${c} for depthToSpace with input shape ${s.shape}`)); const h = { x: s }, d = { blockSize: t, dataFormat: n }; return r.T2.runKernel(i.TMz, h, d) } }) }, 676: (e, t, n) => { "use strict"; n.d(t, { G: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ depthwiseConv2d_: /** * @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 (e, t, n, u, c = "NHWC", h = [1, 1], d) { const f = (0, a.YT)(e, "x", "depthwiseConv2d", "float32"), p = (0, a.YT)(t, "filter", "depthwiseConv2d", "float32"); let m = f, g = !1; 3 === f.rank && (g = !0, m = (0, l.t)(f, [1, f.shape[0], f.shape[1], f.shape[2]])), o.vA(4 === m.rank, (() => `Error in depthwiseConv2d: input must be rank 4, but got rank ${m.rank}.`)), o.vA(4 === p.rank, (() => `Error in depthwiseConv2d: filter must be rank 4, but got rank ${p.rank}.`)); const y = "NHWC" === c ? m.shape[3] : m.shape[1]; o.vA(y === p.shape[2], (() => `Error in depthwiseConv2d: number of input channels (${y}) must match the inChannels dimension in filter ${p.shape[2]}.`)), s.s_("depthwiseConv2d", u, d); const b = { x: m, filter: p }, v = { strides: n, pad: u, dataFormat: c, dilations: h, dimRoundingMode: d }, x = r.T2.runKernel(i.tGH, b, v); return g ? (0, l.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } }) }, 1890: (e, t, n) => { "use strict"; n.d(t, { x: () => s }); var r = n(1585), i = n(5441), a = n(929), o = n(2302); const s = (0, a.op)({ depthwiseConv2dNativeBackpropFilter_: /** * @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 (e, t, n, a, s, u = [1, 1], l) { let c = e; 3 === e.rank && (c = (0, o.t)(e, [1, e.shape[0], e.shape[1], e.shape[2]])); let h = t; 3 === h.rank && (h = (0, o.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])); const d = { x: c, dy: h }, f = { strides: a, pad: s, dimRoundingMode: l, dilations: u, filterShape: n }; return r.T2.runKernel(i.X$8, d, f) } }) }, 3134: (e, t, n) => { "use strict"; n.d(t, { l: () => s }); var r = n(1585), i = n(5441), a = n(929), o = n(2302); const s = (0, a.op)({ depthwiseConv2dNativeBackpropInput_: /** * @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 (e, t, n, a, s, u = [1, 1], l) { let c = t, h = !1; 3 === t.rank && (h = !0, c = (0, o.t)(t, [1, t.shape[0], t.shape[1], t.shape[2]])); const d = { dy: c, filter: n }, f = { strides: a, pad: s, dimRoundingMode: l, dilations: u, inputShape: e }, p = r.T2.runKernel(i.nVu, d, f); return h ? (0, o.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } }) }, 3002: (e, t, n) => { "use strict"; n.d(t, { X: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ dilation2d_: /** * @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 (e, t, n, s, l = [1, 1], c = "NHWC") { const h = (0, a.YT)(e, "x", "dilation2d"), d = (0, a.YT)(t, "filter", "dilation2d"); o.vA(3 === h.rank || 4 === h.rank, (() => `Error in dilation2d: input must be rank 3 or 4, but got rank ${h.rank}.`)), o.vA(3 === d.rank, (() => `Error in dilation2d: filter must be rank 3, but got rank ${d.rank}.`)), o.vA("NHWC" === c, (() => `Error in dilation2d: Only NHWC is currently supported, but got dataFormat of ${c}`)); let f = h, p = !1; 3 === h.rank && (f = (0, u.t)(h, [1, h.shape[0], h.shape[1], h.shape[2]]), p = !0), o.vA(f.shape[3] === d.shape[2], (() => `Error in dilation2d: input and filter must have the same depth: ${f.shape[3]} vs ${d.shape[2]}`)); const m = { x: f, filter: d }, g = { strides: n, pad: s, dilations: l }, y = r.T2.runKernel(i.jxD, m, g); return p ? (0, u.t)(y, [y.shape[1], y.shape[2], y.shape[3]]) : y } }) }, 9359: (e, t, n) => { "use strict"; n.d(t, { y: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(8991); const u = (0, n(929).op)({ div_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "div"), u = (0, o.YT)(t, "b", "div"); if ([n, u] = (0, a.makeTypesMatch)(n, u), "int32" === n.dtype && "int32" === u.dtype) return (0, s.w)(n, u); const l = { a: n, b: u }; return r.T2.runKernel(i.sDr, l, {}) } }) }, 919: (e, t, n) => { "use strict"; n.d(t, { e: () => c }); var r = n(565), i = n(8189), a = n(9359), o = n(3020), s = n(929), u = n(2151), l = n(5537); const c = (0, s.op)({ divNoNan_: /** * @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 (e, t) { let n = (0, i.YT)(e, "a", "div"), s = (0, i.YT)(t, "b", "div");[n, s] = (0, r.makeTypesMatch)(n, s); const c = (0, a.y)(n, s), h = (0, l.P)(c), d = (0, o.L)(s, h); return (0, u._)(d, h, c) } }) }, 9759: (e, t, n) => { "use strict"; n.d(t, { O: () => u }); var r = n(8189), i = n(5119), a = n(5703), o = n(929), s = n(2302); const u = (0, o.op)({ dot_: /** * @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 (e, t) { const n = (0, r.YT)(e, "t1", "dot"), o = (0, r.YT)(t, "t2", "dot"); i.vA(!(1 !== n.rank && 2 !== n.rank || 1 !== o.rank && 2 !== o.rank), (() => `Error in dot: inputs must all be rank 1 or 2, but got ranks ${n.rank} and ${o.rank}.`)); const u = 1 === n.rank ? n.size : n.shape[1], l = 1 === o.rank ? o.size : o.shape[0]; if (i.vA(u === l, (() => `Error in dot: inner dimensions of inputs must match, but got ${u} and ${l}.`)), 1 === n.rank && 1 === o.rank) { const e = (0, s.t)(n, [1, -1]), t = (0, s.t)(o, [-1, 1]), r = (0, a.N)(e, t); return (0, s.t)(r, []) } if (1 === n.rank && 2 === o.rank) { const e = (0, s.t)(n, [1, -1]), t = (0, s.t)(o, [o.shape[0], o.shape[1]]), r = (0, a.N)(e, t); return (0, s.t)(r, [r.size]) } if (2 === n.rank && 1 === o.rank) { const e = (0, s.t)(o, [-1, 1]), t = (0, a.N)(n, e); return (0, s.t)(t, [t.size]) } { const e = (0, s.t)(o, [o.shape[0], o.shape[1]]); return (0, a.N)(n, e) } } }) }, 3416: (e, t, n) => { "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ elu_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "elu", "float32") }; return r.T2.runKernel(i.Pah, t) } }) }, 3020: (e, t, n) => { "use strict"; n.d(t, { L: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ equal_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "equal", "string_or_numeric"), u = (0, o.YT)(t, "b", "equal", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.BRl, l) } }) }, 5207: (e, t, n) => { "use strict"; n.d(t, { Y: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(9809); const u = (0, n(929).op)({ erf_: /** * @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 (e) { let t = (0, a.YT)(e, "x", "erf"); o.vA("int32" === t.dtype || "float32" === t.dtype, (() => "Input dtype must be `int32` or `float32`.")), "int32" === t.dtype && (t = (0, s.w)(t, "float32")); const n = { x: t }; return r.T2.runKernel(i._s9, n) } }) }, 4881: (e, t, n) => { "use strict"; n.d(t, { p: () => i }); var r = n(2596); const i = (0, n(929).op)({ euclideanNorm_: /** * @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 (e, t = null, n = !1) { return (0, r.x)(e, "euclidean", t, n) } }) }, 8631: (e, t, n) => { "use strict"; n.d(t, { o: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ exp_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "exp") }; return r.T2.runKernel(i.ox3, t) } }) }, 8710: (e, t, n) => { "use strict"; n.d(t, { U: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ expandDims_: /** * @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 (e, t = 0) { const n = (0, a.YT)(e, "x", "expandDims", "string_or_numeric"); o.vA(t <= n.rank, (() => "Axis must be <= rank of the tensor")); const s = { input: n }, u = { dim: t }; return r.T2.runKernel(i.ybN, s, u) } }) }, 517: (e, t, n) => { "use strict"; n.d(t, { I: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ expm1_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "expm1") }; return r.T2.runKernel(i.ybj, t) } }) }, 6111: (e, t, n) => { "use strict"; n.d(t, { G: () => o }); var r = n(1585), i = n(5441), a = n(5119); /** * @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 o(e, t, n) { (0, a.SA)(e); const o = { shape: e, value: t, dtype: n = n || (0, a.X$)(t) }; return r.T2.runKernel(i.SQl, {}, o) } }, 5606: (e, t, n) => { "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ floor_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "floor", "float32") }; return r.T2.runKernel(i.ZgB, t) } }) }, 8991: (e, t, n) => { "use strict"; n.d(t, { w: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ floorDiv_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "floorDiv"), s = (0, o.YT)(t, "b", "floorDiv");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.ElG, u) } }) }, 8646: (e, t, n) => { "use strict"; n.d(t, { Do: () => m, XB: () => p, f2: () => g, zE: () => y }); var r = n(2198), i = n(3416), a = n(6919), o = n(9258), s = n(4394), u = n(112), l = n(3732), c = n(2302), h = n(8968), d = n(700), f = n(3791); /** * @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 p(e, t, n) { if (null == n || "linear" === n) return e; if ("relu" === n) return (0, o.l)(e, (0, d.P)(t)); throw new Error(`Cannot compute gradient for fused activation ${n}.`) } function m(e, t) { let n = t; const i = r.getReductionAxes(e.shape, t.shape); return i.length > 0 && (n = (0, f.c)(n, i)), (0, c.t)(n, e.shape) } function g(e, t, n, r) { if ("linear" === t) return e; if ("relu" === t) return (0, u.V)(e); if ("elu" === t) return (0, i.P)(e); if ("relu6" === t) return (0, l.j)(e); if ("prelu" === t) return (0, s.N)(e, n); if ("leakyrelu" === t) return (0, a.H)(e, r); if ("sigmoid" === t) return (0, h.r)(e); throw new Error(`Unknown fused activation ${t}.`) } const y = (e, t) => !(e > 0) || "linear" === t }, 8229: (e, t, n) => { "use strict"; n.d(t, { k: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ gather_: /** * @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 (e, t, n = 0, o = 0) { const s = { x: (0, a.YT)(e, "x", "gather"), indices: (0, a.YT)(t, "indices", "gather", "int32") }, u = { axis: n, batchDims: o }; return r.T2.runKernel(i.mxL, s, u) } }) }, 2058: (e, t, n) => { "use strict"; n.d(t, { r: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ greater_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "greater", "string_or_numeric"), u = (0, o.YT)(t, "b", "greater", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.XhZ, l) } }) }, 3337: (e, t, n) => { "use strict"; n.d(t, { D: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ greaterEqual_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "greaterEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "greaterEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.lLS, l) } }) }, 5040: (e, t, n) => { "use strict"; n.d(t, { n: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ imag_: /** * @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 (e) { const t = { input: (0, a.YT)(e, "input", "imag") }; return r.T2.runKernel(i.dv8, t) } }) }, 4711: (e, t, n) => { "use strict"; n.d(t, { v: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ resizeBilinear_: /** * @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 (e, t, n = !1, s = !1) { const l = (0, a.YT)(e, "images", "resizeBilinear"); o.vA(3 === l.rank || 4 === l.rank, (() => `Error in resizeBilinear: x must be rank 3 or 4, but got rank ${l.rank}.`)), o.vA(2 === t.length, (() => `Error in resizeBilinear: new shape must 2D, but got shape ${t}.`)), o.vA(!1 === s || !1 === n, (() => "Error in resizeBilinear: If halfPixelCenters is true, alignCorners must be false.")); let c = l, h = !1; 3 === l.rank && (h = !0, c = (0, u.t)(l, [1, l.shape[0], l.shape[1], l.shape[2]])); const [] = t, d = { images: c }, f = { alignCorners: n, halfPixelCenters: s, size: t }, p = r.T2.runKernel(i.hgw, d, f); return h ? (0, u.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } }) }, 2954: (e, t, n) => { "use strict"; n.d(t, { b: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ resizeNearestNeighbor_: /** * @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 (e, t, n = !1, s = !1) { const l = (0, a.YT)(e, "images", "resizeNearestNeighbor"); o.vA(3 === l.rank || 4 === l.rank, (() => `Error in resizeNearestNeighbor: x must be rank 3 or 4, but got rank ${l.rank}.`)), o.vA(2 === t.length, (() => `Error in resizeNearestNeighbor: new shape must 2D, but got shape ${t}.`)), o.vA("float32" === l.dtype || "int32" === l.dtype, (() => "`images` must have `int32` or `float32` as dtype")), o.vA(!1 === s || !1 === n, (() => "Error in resizeNearestNeighbor: If halfPixelCenters is true, alignCorners must be false.")); let c = l, h = !1; 3 === l.rank && (h = !0, c = (0, u.t)(l, [1, l.shape[0], l.shape[1], l.shape[2]])); const [] = t, d = { images: c }, f = { alignCorners: n, halfPixelCenters: s, size: t }, p = r.T2.runKernel(i.jOE, d, f); return h ? (0, u.t)(p, [p.shape[1], p.shape[2], p.shape[3]]) : p } }) }, 8318: (e, t, n) => { "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ isFinite_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "isFinite") }; return r.T2.runKernel(i.gIW, t) } }) }, 3454: (e, t, n) => { "use strict"; n.d(t, { E: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ isInf_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "isInf") }; return r.T2.runKernel(i.E3$, t) } }) }, 6300: (e, t, n) => { "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ isNaN_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "isNaN") }; return r.T2.runKernel(i.iPs, t) } }) }, 6919: (e, t, n) => { "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ leakyRelu_: /** * @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 (e, t = .2) { const n = { x: (0, a.YT)(e, "x", "leakyRelu") }, o = { alpha: t }; return r.T2.runKernel(i.X0$, n, o) } }) }, 1303: (e, t, n) => { "use strict"; n.d(t, { M: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ less_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "less", "string_or_numeric"), u = (0, o.YT)(t, "b", "less", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.mIA, l) } }) }, 6508: (e, t, n) => { "use strict"; n.d(t, { I: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ lessEqual_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "lessEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "lessEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.CwD, l) } }) }, 3531: (e, t, n) => { "use strict"; n.d(t, { K: () => l }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(929), u = n(2302); const l = (0, s.op)({ localResponseNormalization_: /** * @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 (e, t = 5, n = 1, s = 1, l = .5) { const c = (0, a.YT)(e, "x", "localResponseNormalization"); o.vA(4 === c.rank || 3 === c.rank, (() => `Error in localResponseNormalization: x must be rank 3 or 4 but got\n rank ${c.rank}.`)), o.vA(o.E6(t), (() => `Error in localResponseNormalization: depthRadius must be an integer but got depthRadius ${t}.`)); let h = c, d = !1; 3 === c.rank && (d = !0, h = (0, u.t)(c, [1, c.shape[0], c.shape[1], c.shape[2]])); const f = { x: h }, p = { depthRadius: t, bias: n, alpha: s, beta: l }, m = r.T2.runKernel(i.jM4, f, p); return d ? (0, u.t)(m, [m.shape[1], m.shape[2], m.shape[3]]) : m } }) }, 4010: (e, t, n) => { "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ log_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "log", "float32") }; return r.T2.runKernel(i.tG8, t) } }) }, 2015: (e, t, n) => { "use strict"; n.d(t, { K: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ log1p_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "log1p") }; return r.T2.runKernel(i.Cg$, t) } }) }, 5645: (e, t, n) => { "use strict"; n.d(t, { n: () => c }); var r = n(1830), i = n(8189), a = n(9258), o = n(6522), s = n(929), u = n(8968), l = n(6030); const c = (0, s.op)({ logSigmoid_: /** * @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 (e) { const t = (0, i.YT)(e, "x", "logSigmoid"); return (0, r._X)((e => ({ value: (0, o.H)((0, l.l)((0, o.H)(e))), gradFunc: t => (0, a.l)(t, (0, u.r)((0, o.H)(e))) })))(t) } }) }, 7991: (e, t, n) => { "use strict"; n.d(t, { H: () => f }); var r = n(1830), i = n(8189), a = n(9809), o = n(8631), s = n(4010), u = n(1938), l = n(9258), c = n(929), h = n(7126), d = n(3791); const f = (0, c.op)({ logSoftmax_: /** * @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 (e, t = -1) { const n = (0, i.YT)(e, "logits", "logSoftmax"); if (-1 === t && (t = n.rank - 1), t !== n.rank - 1) throw Error(`Log Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and axis was ${t}`); return (0, r._X)(((e, n) => { const r = (0, u.T)(e, t, !0), i = (0, h.j)(e, r), c = (0, h.j)((0, a.w)(i, "float32"), (0, s.R)((0, d.c)((0, o.o)(i), t, !0))); n([c]); return { value: c, gradFunc: (e, n) => { const [r] = n, i = (0, o.o)(r); return (0, h.j)(e, (0, l.l)((0, d.c)(e, t, !0), i)) } } }))(n) } }) }, 3330: (e, t, n) => { "use strict"; n.d(t, { V: () => p }); var r = n(8189), i = n(5119), a = n(7523), o = n(1078), s = n(8631), u = n(4010), l = n(1938), c = n(929), h = n(2302), d = n(7126), f = n(3791); const p = (0, c.op)({ logSumExp_: /** * @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 (e, t = null, n = !1) { const c = (0, r.YT)(e, "x", "logSumExp"), p = (0, i.Y6)(t, c.shape), m = (0, l.T)(c, p, !0), g = (0, d.j)(c, m), y = (0, s.o)(g), b = (0, f.c)(y, p), v = (0, u.R)(b), x = (0, a.W)((0, h.t)(m, v.shape), v); if (n) { const e = (0, o.SM)(x.shape, p); return (0, h.t)(x, e) } return x } }) }, 3789: (e, t, n) => { "use strict"; n.d(t, { n: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(2198); const s = (0, n(929).op)({ logicalAnd_: /** * @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 (e, t) { const n = (0, a.YT)(e, "a", "logicalAnd", "bool"), s = (0, a.YT)(t, "b", "logicalAnd", "bool"); (0, o.assertAndGetBroadcastShape)(n.shape, s.shape); const u = { a: n, b: s }; return r.T2.runKernel(i.RUm, u) } }) }, 9881: (e, t, n) => { "use strict"; n.d(t, { N: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ logicalNot_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "logicalNot", "bool") }; return r.T2.runKernel(i.nZd, t) } }) }, 9879: (e, t, n) => { "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(2198); const s = (0, n(929).op)({ logicalOr_: /** * @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 (e, t) { const n = (0, a.YT)(e, "a", "logicalOr", "bool"), s = (0, a.YT)(t, "b", "logicalOr", "bool"); (0, o.assertAndGetBroadcastShape)(n.shape, s.shape); const u = { a: n, b: s }; return r.T2.runKernel(i.LXA, u) } }) }, 9925: (e, t, n) => { "use strict"; n.d(t, { r: () => u }); var r = n(8189), i = n(2198), a = n(3789), o = n(9881), s = n(9879); const u = (0, n(929).op)({ logicalXor_: /** * @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 (e, t) { const n = (0, r.YT)(e, "a", "logicalXor", "bool"), u = (0, r.YT)(t, "b", "logicalXor", "bool"); return (0, i.assertAndGetBroadcastShape)(n.shape, u.shape), (0, a.n)((0, s.z)(e, t), (0, o.N)((0, a.n)(e, t))) } }) }, 4703: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */ var r; n.d(t, { i: () => r }), function (e) { e[e.NONE = 0] = "NONE", e[e.MEAN = 1] = "MEAN", e[e.SUM = 2] = "SUM", e[e.SUM_BY_NONZERO_WEIGHTS = 3] = "SUM_BY_NONZERO_WEIGHTS" }(r || (r = {})) }, 5703: (e, t, n) => { "use strict"; n.d(t, { N: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ matMul_: /** * @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 (e, t, n = !1, s = !1) { let u = (0, o.YT)(e, "a", "matMul"), l = (0, o.YT)(t, "b", "matMul");[u, l] = (0, a.makeTypesMatch)(u, l); const c = { a: u, b: l }, h = { transposeA: n, transposeB: s }; return r.T2.runKernel(i.jAQ, c, h) } }) }, 1938: (e, t, n) => { "use strict"; n.d(t, { T: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ max_: /** * @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 (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "max") }, s = { reductionIndices: t, keepDims: n }; return r.T2.runKernel(i.VAI, o, s) } }) }, 6999: (e, t, n) => { "use strict"; n.d(t, { j: () => c }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119), s = n(7195), u = n(929), l = n(2302); const c = (0, u.op)({ maxPool_: /** * @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 (e, t, n, u, c) { const h = (0, a.YT)(e, "x", "maxPool"); let d = h, f = !1; 3 === h.rank && (f = !0, d = (0, l.t)(h, [1, h.shape[0], h.shape[1], h.shape[2]])), o.vA(4 === d.rank, (() => `Error in maxPool: input must be rank 4 but got rank ${d.rank}.`)), o.vA(s.G0(n, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${n} and dilations '1'`)), s.s_("maxPool", u, c); const p = { x: d }, m = { filterSize: t, strides: n, pad: u, dimRoundingMode: c }, g = r.T2.runKernel(i.t3d, p, m); return f ? (0, l.t)(g, [g.shape[1], g.shape[2], g.shape[3]]) : g } }) }, 178: (e, t, n) => { "use strict"; n.d(t, { P: () => l }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198), u = n(9809); const l = (0, n(929).op)({ maximum_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "maximum"), l = (0, o.YT)(t, "b", "maximum");[n, l] = (0, a.makeTypesMatch)(n, l), "bool" === n.dtype && (n = (0, u.w)(n, "int32"), l = (0, u.w)(l, "int32")), (0, s.assertAndGetBroadcastShape)(n.shape, l.shape); const c = { a: n, b: l }; return r.T2.runKernel(i.LDN, c) } }) }, 2611: (e, t, n) => { "use strict"; n.d(t, { i: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ mean_: /** * @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 (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "mean") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.g5A, o, s) } }) }, 7436: (e, t, n) => { "use strict"; n.d(t, { j: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ min_: /** * @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 (e, t = null, n = !1) { const o = { x: (0, a.YT)(e, "x", "min") }, s = { axis: t, keepDims: n }; return r.T2.runKernel(i.lNG, o, s) } }) }, 2644: (e, t, n) => { "use strict"; n.d(t, { B: () => l }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198), u = n(9809); const l = (0, n(929).op)({ minimum_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "minimum"), l = (0, o.YT)(t, "b", "minimum");[n, l] = (0, a.makeTypesMatch)(n, l), "bool" === n.dtype && (n = (0, u.w)(n, "int32"), l = (0, u.w)(l, "int32")), (0, s.assertAndGetBroadcastShape)(n.shape, l.shape); const c = { a: n, b: l }; return r.T2.runKernel(i.LG0, c) } }) }, 6567: (e, t, n) => { "use strict"; n.d(t, { F: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ mirrorPad_: /** * @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 (e, t, n) { o.vA("reflect" === n || "symmetric" === n, (() => `Invalid mode. Mode must be either reflect or symmetric. Got ${n}.`)); const s = (0, a.YT)(e, "x", "mirrorPad"); if (0 === s.rank) throw new Error("mirrorPad(scalar) is not defined. Pass non-scalar to mirrorPad"); o.vA(t.length === s.rank, (() => `Padding doesn't match input. Must be ${s.rank}. Got ${t.length}.`)); const u = "reflect" === n ? 1 : 0; for (let e = 0; e < s.rank; e++)o.vA(2 === t[e].length, (() => "Invalid number of paddings. Must be length of 2 each.")), o.vA(t[e][0] >= 0 && t[e][0] <= s.shape[e] - u && t[e][1] >= 0 && t[e][1] <= s.shape[e] - u, (() => `Padding in dimension ${e} cannot be greater than or equal to ${s.shape[e] - u} or less than 0 for input of shape ${s.shape}`)); const l = { paddings: t, mode: n }, c = { x: s }; return r.T2.runKernel(i.x7F, c, l) } }) }, 152: (e, t, n) => { "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ mod_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "mod"), s = (0, o.YT)(t, "b", "mod");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.BLA, u) } }) }, 9258: (e, t, n) => { "use strict"; n.d(t, { l: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ mul_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "mul"), s = (0, o.YT)(t, "b", "mul");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.xu7, u) } }) }, 6522: (e, t, n) => { "use strict"; n.d(t, { H: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ neg_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "neg") }; return r.T2.runKernel(i.l0G, t) } }) }, 2596: (e, t, n) => { "use strict"; n.d(t, { x: () => y }); var r = n(8189), i = n(5119), a = n(4888), o = n(1078), s = n(1938), u = n(7436), l = n(929), c = n(8990), h = n(2302), d = n(5702), f = n(9348), p = n(5793), m = n(3791); function g(e, t, n = null) { if (0 === e.rank) return (0, a.t)(e); if (1 !== e.rank && null === n) return g((0, h.t)(e, [-1]), t, n); if (1 === e.rank || "number" == typeof n || Array.isArray(n) && 1 === n.length) { if (1 === t) return (0, m.c)((0, a.t)(e), n); if (t === 1 / 0) return (0, s.T)((0, a.t)(e), n); if (t === -1 / 0) return (0, u.j)((0, a.t)(e), n); if ("euclidean" === t || 2 === t) return (0, f.R)((0, m.c)((0, c.n)((0, a.t)(e), (0, d.d)(2, "int32")), n)); throw new Error(`Error in norm: invalid ord value: ${t}`) } if (Array.isArray(n) && 2 === n.length) { if (1 === t) return (0, s.T)((0, m.c)((0, a.t)(e), n[0]), n[1] - 1); if (t === 1 / 0) return (0, s.T)((0, m.c)((0, a.t)(e), n[1]), n[0]); if (t === -1 / 0) return (0, u.j)((0, m.c)((0, a.t)(e), n[1]), n[0]); if ("fro" === t || "euclidean" === t) return (0, f.R)((0, m.c)((0, p.E)(e), n)); throw new Error(`Error in norm: invalid ord value: ${t}`) } throw new Error(`Error in norm: invalid axis: ${n}`) } const y = (0, l.op)({ norm_: /** * @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 (e, t = "euclidean", n = null, a = !1) { const s = g(e = (0, r.YT)(e, "x", "norm"), t, n); let u = s.shape; if (a) { const t = (0, i.Y6)(n, e.shape); u = o.SM(s.shape, t) } return (0, h.t)(s, u) } }) }, 2118: (e, t, n) => { "use strict"; n.d(t, { E: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ notEqual_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "notEqual", "string_or_numeric"), u = (0, o.YT)(t, "b", "notEqual", "string_or_numeric");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.ylV, l) } }) }, 1760: (e, t, n) => { "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ oneHot_: /** * @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 (e, t, n = 1, o = 0, s = "int32") { if (t < 2) throw new Error(`Error in oneHot: depth must be >=2, but it is ${t}`); const u = { indices: (0, a.YT)(e, "indices", "oneHot", "int32") }, l = { dtype: s, depth: t, onValue: n, offValue: o }; return r.T2.runKernel(i.urI, u, l) } }) }, 1411: (e, t, n) => { "use strict"; n.d(t, { S: () => s }); var r = n(1585), i = n(5119), a = n(7148), o = n(2855); /** * @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 s(e, t = "float32") { if ((0, i.SA)(e), "complex64" === t) { const t = s(e, "float32"), n = (0, o.U)(e, "float32"); return (0, a.f)(t, n) } const n = (0, i.FZ)((0, i.Ze)(e), t); return r.T2.makeTensor(n, e, t) } }, 9885: (e, t, n) => { "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ onesLike_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "onesLike") }; return r.T2.runKernel(i.LWX, t) } }) }, 929: (e, t, n) => { "use strict"; n.d(t, { B: () => a, op: () => o }); var r = n(1585), i = n(5119); /** * @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 a = "__op"; function o(e) { const t = Object.keys(e); if (1 !== t.length) throw new Error(`Please provide an object with a single key (operation name) mapping to a function. Got an object with ${t.length} keys.`); let n = t[0]; const o = e[n]; n.endsWith("_") && (n = n.substring(0, n.length - 1)), n += a; const s = (...e) => { r.T2.startScope(n); try { const t = o(...e); return (0, i.yL)(t) && console.error("Cannot return a Promise inside of tidy."), r.T2.endScope(t), t } catch (e) { throw r.T2.endScope(null), e } }; return Object.defineProperty(s, "name", { value: n, configurable: !0 }), s } }, 7270: (e, t, n) => { "use strict"; n.d(t, { BTT: () => d.B, tnl: () => i.t, HQu: () => a.H, FqL: () => o.F, WQq: () => s.W, QiD: () => f, Q7R: () => p.Q, bzn: () => m.b, FLi: () => g.F, XRg: () => y.X, qRo: () => b.q, yHs: () => v.y, rYl: () => x.r, FPz: () => w.F, rfv: () => k.r, $jT: () => S.$, sub: () => T, lZX: () => $, $v7: () => O.$, BFc: () => z, kSi: () => P, T5N: () => B, GTe: () => R.G, HbZ: () => L, vjT: () => j, ftb: () => nr, ROE: () => U, hOW: () => W.h, ra8: () => V.r, wgE: () => _.w, mkO: () => G.m, zQh: () => H.z, o8B: () => q.o, faB: () => Y.f, xWs: () => E.x, I1m: () => X, RPU: () => K, O5O: () => Z, P1l: () => J, kA9: () => Q.k, Xtf: () => ee.X, wX9: () => te.w, IPL: () => ne, jIJ: () => ie, gnS: () => ae.g, yIG: () => oe.y, _jP: () => dr, Lp0: () => se.L, rCv: () => ue.r, aOp: () => le, Rj8: () => ce.R, Gl3: () => he.G, smy: () => de, X7t: () => fe.X, y4m: () => pe.y, ek5: () => me.e, Omf: () => ge.O, EZY: () => cr, _3C: () => ye, Pqc: () => be.P, FJY: () => hr, QP2: () => ve, LCg: () => xe.L, Y12: () => we.Y, p4S: () => ke.p, oNF: () => Se.o, UG6: () => _e.U, IYd: () => Ce.I, y5U: () => Te, hVP: () => wn.h, GSj: () => Ee.G, RIf: () => Ne.R, wh_: () => Ie.w, cZk: () => r, kgh: () => Me.k, SY9: () => lr, rhj: () => Fe.r, DQN: () => De.D, KGM: () => kn.K, ngS: () => $e.n, Slp: () => gi, U4u: () => fr, ggX: () => Sn.g, MIs: () => Re.M, EN4: () => Oe.E, yrW: () => ze.y, H8d: () => Pe.H, M7h: () => Be.M, InN: () => Le.I, mPL: () => yi, mT8: () => je, Kgs: () => Ue.K, Rm2: () => We.R, Kko: () => Ve.K, nqI: () => Ge.n, HPB: () => He.H, VZ: () => qe.V, n76: () => Ye.n, NSZ: () => Xe.N, ztW: () => Ke.z, rxB: () => Ze.r, YYh: () => bi, yzS: () => et, NoW: () => N.N, T9B: () => tt.T, jgi: () => nt.j, NYV: () => rt, RO: () => it, PhQ: () => at.P, i2o: () => ot.i, OYQ: () => lt, jkA: () => ct.j, BpO: () => ht.B, FFZ: () => dt.F, ziu: () => ft.z, Clk: () => yt, CRk: () => or, lKK: () => I.l, YDF: () => bt, OjQ: () => vt, HZy: () => xt.H, xbf: () => ir.x, Ec: () => wt.E, Mw0: () => kt.M, SaS: () => st.S, P61: () => St.P, op: () => d.op, X4o: () => _t, eVF: () => Ct.e, BZs: () => At, grY: () => Tt, XHu: () => Et, WLX: () => Nt, dzn: () => It.d, n7C: () => Mt.n, NsG: () => Ft.N, yyV: () => Dt.y, _eU: () => $t._, whe: () => Rt, iyU: () => Ot, Q0_: () => zt, _9M: () => Pt, pR9: () => Wt, FE$: () => Vt, m0H: () => Gt, YeY: () => Ht, HYA: () => qt, y17: () => Yt, xav: () => Xt.x, VOZ: () => Kt.V, VVh: () => Zt.V, j__: () => Jt.j, tQQ: () => A.t, BEg: () => Qt.B, QD2: () => en, LMr: () => tn, I2l: () => nn, JYU: () => rn, z8$: () => _n.z, LIG: () => an.L, Z$r: () => on.Z, d_2: () => sn.d, NFr: () => sr, sZg: () => Qe, WfX: () => un.W, wdz: () => ln.w, F12: () => cn, ry7: () => M.r, _SZ: () => hn._, vPA: () => mi, F8e: () => dn.F, L0l: () => fn.L, dik: () => F.d, Q$M: () => pn, zAd: () => mn, wck: () => gn, R0O: () => yn, Vs9: () => bn.V, lw0: () => vn.l, eDJ: () => xn.e, lMo: () => vi, Zhr: () => ur, lOn: () => pi, lDo: () => Cn.l, RZD: () => An.R, EwI: () => mt.E, Pbu: () => Tn.P, r2V: () => En.r, t$z: () => Nn.t, PMw: () => In.P, Ym9: () => Mn.Y, YjP: () => xi, jbE: () => gt.j, czq: () => Fn.c, Mlm: () => Dn.M, ymU: () => D.y, OEK: () => $n.O, tGX: () => On, KtR: () => zn, $_$: () => Pn.$, g9W: () => Bn, Lpo: () => Ln, yxw: () => jn, NNh: () => Wn, Vsq: () => Ae.V, rfw: () => Vn.r, mgz: () => rr.m, efE: () => Gn, AmM: () => Hn.A, zAU: () => qn.z, K$i: () => Yn.K, rni: () => Xn, bvq: () => Kn, _M9: () => Zn._, YJN: () => Qn, Ul9: () => er.U, POl: () => tr.P }); var r = {}; n.r(r), n.d(r, { conv2d: () => vr, depthwiseConv2d: () => kr, matMul: () => Sr }); var i = n(4888), a = n(2804), o = n(7558), s = n(7523), u = n(1585), l = n(5441), c = n(8189), h = n(5119), d = n(929); const f = (0, d.op)({ addN_: /** * @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 (e) { h.vA(Array.isArray(e), (() => "The argument passed to tf.addN() must be a list of tensors")), h.vA(e.length >= 1, (() => `Must pass at least one tensor to tf.addN(), but got ${e.length}`)); const t = e.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "addN"))), n = t[0]; t.forEach((e => { if (e.dtype !== n.dtype) throw new Error("All tensors passed to tf.addN() must have the same dtype") })), t.forEach((e => { if (!h.r1(e.shape, n.shape)) throw new Error("All tensors passed to tf.addN() must have the same shape") })); const r = t; return u.T2.runKernel(l.EkD, r) } }); var p = n(2307), m = n(9326), g = n(897), y = n(4339), b = n(6841), v = n(269), x = n(9580), w = n(1404), k = n(3774), S = n(3909), _ = n(9809), C = n(7195), A = n(2302); const T = (0, d.op)({ avgPool3d_: /** * @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 (e, t, n, r, i, a = "NDHWC") { const o = (0, c.YT)(e, "x", "avgPool3d", "float32"); let s = o, d = !1; 4 === o.rank && (d = !0, s = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === s.rank, (() => `Error in avgPool3d: x must be rank 5 but got rank ${s.rank}.`)), h.vA("NDHWC" === a, (() => `Error in avgPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`)), h.vA("number" == typeof n && n > 0 || Array.isArray(n) && n[0] > 0 && n[1] > 0 && n[2] > 0, (() => `Error in avgPool3d: Stride must be > 0, but got '${n}'`)), (0, C.s_)("avgPool3d", r, i); const f = { x: s }, p = { filterSize: t, strides: n, pad: r, dimRoundingMode: i, dataFormat: a }; let m = u.T2.runKernel(l.cS, f, p); return m = (0, _.w)(m, s.dtype), d ? (0, A.t)(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m } }); var E = n(5030), N = n(5703), I = n(9258), M = n(8968), F = n(7986), D = n(7311); const $ = (0, d.op)({ basicLSTMCell_: /** * @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 (e, t, n, r, i, a) { const o = (0, c.YT)(e, "forgetBias", "basicLSTMCell"), u = (0, c.YT)(t, "lstmKernel", "basicLSTMCell"), l = (0, c.YT)(n, "lstmBias", "basicLSTMCell"), h = (0, c.YT)(r, "data", "basicLSTMCell"), d = (0, c.YT)(i, "c", "basicLSTMCell"), f = (0, c.YT)(a, "h", "basicLSTMCell"), p = (0, E.x)([h, f], 1), m = (0, N.N)(p, u), g = (0, s.W)(m, l), y = g.shape[0], b = g.shape[1] / 4, v = [y, b], x = (0, F.d)(g, [0, 0], v), w = (0, F.d)(g, [0, b], v), k = (0, F.d)(g, [0, 2 * b], v), S = (0, F.d)(g, [0, 3 * b], v), _ = (0, s.W)((0, I.l)((0, M.r)(x), (0, D.y)(w)), (0, I.l)(d, (0, M.r)((0, s.W)(o, k)))); return [_, (0, I.l)((0, D.y)(_), (0, M.r)(S))] } }); var R = n(9772), O = n(9160); const z = (0, d.op)({ batchNorm2d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(2 === o.rank, (() => `Error in batchNorm2D: x must be rank 2 but got rank ${o.rank}.`)), h.vA(2 === s.rank || 1 === s.rank, (() => `Error in batchNorm2D: mean must be rank 2 or rank 1 but got rank ${s.rank}.`)), h.vA(2 === u.rank || 1 === u.rank, (() => `Error in batchNorm2D: variance must be rank 2 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(2 === l.rank || 1 === l.rank, (() => `Error in batchNorm2D: scale must be rank 2 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(2 === d.rank || 1 === d.rank, (() => `Error in batchNorm2D: offset must be rank 2 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const P = (0, d.op)({ batchNorm3d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(3 === o.rank, (() => `Error in batchNorm3D: x must be rank 3 but got rank ${o.rank}.`)), h.vA(3 === s.rank || 1 === s.rank, (() => `Error in batchNorm3D: mean must be rank 3 or rank 1 but got rank ${s.rank}.`)), h.vA(3 === u.rank || 1 === u.rank, (() => `Error in batchNorm3D: variance must be rank 3 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(3 === l.rank || 1 === l.rank, (() => `Error in batchNorm3D: scale must be rank 3 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(3 === d.rank || 1 === d.rank, (() => `Error in batchNorm3D: offset must be rank 3 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const B = (0, d.op)({ batchNorm4d_: function (e, t, n, r, i, a) { const o = (0, c.YT)(e, "x", "batchNorm"), s = (0, c.YT)(t, "mean", "batchNorm"), u = (0, c.YT)(n, "variance", "batchNorm"); let l, d; return null != i && (l = (0, c.YT)(i, "scale", "batchNorm")), null != r && (d = (0, c.YT)(r, "offset", "batchNorm")), h.vA(4 === o.rank, (() => `Error in batchNorm4D: x must be rank 4 but got rank ${o.rank}.`)), h.vA(4 === s.rank || 1 === s.rank, (() => `Error in batchNorm4D: mean must be rank 4 or rank 1 but got rank ${s.rank}.`)), h.vA(4 === u.rank || 1 === u.rank, (() => `Error in batchNorm4D: variance must be rank 4 or rank 1 but got rank ${u.rank}.`)), null != l && h.vA(4 === l.rank || 1 === l.rank, (() => `Error in batchNorm4D: scale must be rank 4 or rank 1 but got rank ${l.rank}.`)), null != d && h.vA(4 === d.rank || 1 === d.rank, (() => `Error in batchNorm4D: offset must be rank 4 or rank 1 but got rank ${d.rank}.`)), (0, O.$)(o, s, u, d, l, a) } }); const L = (0, d.op)({ bincount_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "x", "bincount"), i = (0, c.YT)(t, "weights", "bincount"); h.vA("int32" === r.dtype, (() => `Error in bincount: input dtype must be int32, but got ${r.dtype}`)), h.vA(n >= 0, (() => `size must be non-negative, but got ${n}.`)), h.vA(i.size === r.size || 0 === i.size, (() => `Error in bincount: weights must have the same size as input or0-length, but got input shape: ${r.shape}, weights shape: ${i.shape}.`)); const a = { x: r, weights: i }, o = { size: n }; return u.T2.runKernel(l.N4F, a, o) } }); const j = (0, d.op)({ bitwiseAnd_: /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "bitwiseAnd"), r = (0, c.YT)(t, "y", "bitwiseAnd"); if (!(0, h.r1)(n.shape, r.shape)) throw new Error(`BitwiseAnd: Tensors must have the same shape. x: ${n.shape}, y: ${r.shape}`); if ("int32" !== n.dtype || "int32" !== r.dtype) throw new Error(`BitwiseAnd: Only supports 'int32' values in tensor, found type of x: ${n.dtype} and type of y: ${r.dtype}`); const i = { a: n, b: r }; return u.T2.runKernel(l.HNs, i) } }); const U = (0, d.op)({ broadcastArgs_: /** * @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 (e, t) { const n = (0, c.YT)(e, "s0", "broadcastArgs", "int32"), r = (0, c.YT)(t, "s1", "broadcastArgs", "int32"); if (1 !== n.rank) throw new Error(`broadcastArgs(): first input must be a vector (rank=1). Has rank ${n.rank}`); if (1 !== r.rank) throw new Error(`broadcastArgs(): second input must be a vector (rank=1). Has rank ${r.rank}`); const i = { s0: n, s1: r }; return u.T2.runKernel(l.vj7, i) } }); var W = n(3567), V = n(448), G = n(855), H = n(6928), q = n(125), Y = n(7148); const X = (0, d.op)({ concat1d_: function (e) { return (0, E.x)(e, 0) } }); const K = (0, d.op)({ concat2d_: function (e, t) { return (0, E.x)(e, t) } }); const Z = (0, d.op)({ concat3d_: function (e, t) { return (0, E.x)(e, t) } }); const J = (0, d.op)({ concat4d_: function (e, t) { return (0, E.x)(e, t) } }); var Q = n(3701), ee = n(8794), te = n(1106); const ne = (0, d.op)({ conv3d_: /** * @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 (e, t, n, r, i = "NDHWC", a = [1, 1, 1]) { const o = (0, c.YT)(e, "x", "conv3d"), s = (0, c.YT)(t, "filter", "conv3d"); let d = o, f = !1; 4 === o.rank && (f = !0, d = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === d.rank, (() => `Error in conv3d: input must be rank 5, but got rank ${d.rank}.`)), h.vA(5 === s.rank, (() => `Error in conv3d: filter must be rank 5, but got rank ${s.rank}.`)), h.vA(d.shape[4] === s.shape[3], (() => `Error in conv3d: depth of input (${d.shape[4]}) must match input depth for filter ${s.shape[3]}.`)), h.vA((0, C.G0)(n, a), (() => `Error in conv3D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)), h.vA("NDHWC" === i, (() => `Error in conv3d: got dataFormat of ${i} but only NDHWC is currently supported.`)), h.vA((0, C.qk)(a), (() => "Error in conv3D: Dilated rates should be larger than 0.")), h.vA((0, C.qk)(n), (() => "Error in conv3D: Strides should be larger than 0.")); const p = { x: d, filter: s }, m = { strides: n, pad: r, dataFormat: i, dilations: a }, g = u.T2.runKernel(l.A1h, p, m); return f ? (0, A.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g } }); var re = n(1895); const ie = (0, d.op)({ conv3dTranspose_: function (e, t, n, r, i) { const a = (0, c.YT)(e, "x", "conv3dTranspose"), o = (0, c.YT)(t, "filter", "conv3dTranspose"); return (0, re.c)(n, a, o, r, i) } }); var ae = n(9907), oe = n(7451), se = n(302), ue = n(6808); const le = (0, d.op)({ denseBincount_: /** * @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 (e, t, n, r = !1) { const i = (0, c.YT)(e, "x", "denseBincount"), a = (0, c.YT)(t, "weights", "denseBincount"); h.vA("int32" === i.dtype, (() => `Error in denseBincount: input dtype must be int32, but got ${i.dtype}`)), h.vA(i.rank <= 2, (() => `Error in denseBincount: input must be at most rank 2, but got rank ${i.rank}.`)), h.vA(n >= 0, (() => `size must be non-negative, but got ${n}.`)), h.vA(a.size === i.size || 0 === a.size, (() => `Error in denseBincount: weights must have the same shape as x or 0-length, but got x shape: ${i.shape}, weights shape: ${a.shape}.`)); const o = { x: i, weights: a }, s = { size: n, binaryOutput: r }; return u.T2.runKernel(l.wNW, o, s) } }); var ce = n(1216), he = n(676); const de = (0, d.op)({ diag_: /** * @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 (e) { const t = { x: (0, c.YT)(e, "x", "diag") }; return u.T2.runKernel(l.ORI, t) } }); var fe = n(3002), pe = n(9359), me = n(919), ge = n(9759); const ye = (0, d.op)({ einsum_: /** * @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 (e, ...t) { const n = t.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "einsum"))), r = { equation: e }; return u.T2.runKernel(l.Qgm, n, r) } }); var be = n(3416); const ve = (0, d.op)({ ensureShape_: /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "ensureShape", "string_or_numeric"); if (!(0, h.e_)(n.shape, t)) throw new Error(`EnsureShape: Shape of tensor ${n.shape} is not compatible with expected shape ${t}`); return e } }); var xe = n(3020), we = n(5207), ke = n(4881), Se = n(8631), _e = n(8710), Ce = n(517), Ae = n(4826); const Te = (0, d.op)({ eye_: /** * @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 (e, t, n, r = "float32") { null == t && (t = e); const i = (0, V.r)([e, t], r), a = e <= t ? e : t; for (let e = 0; e < a; ++e)i.set(1, e, e); const o = (0, A.t)(i.toTensor(), [e, t]); if (null == n) return o; if (1 === n.length) return (0, Ae.V)((0, _e.U)(o, 0), [n[0], 1, 1]); if (2 === n.length) return (0, Ae.V)((0, _e.U)((0, _e.U)(o, 0), 0), [n[0], n[1], 1, 1]); if (3 === n.length) return (0, Ae.V)((0, _e.U)((0, _e.U)((0, _e.U)(o, 0), 0), 0), [n[0], n[1], n[2], 1, 1]); throw new Error(`eye() currently supports only 1D and 2D batchShapes, but received ${n.length}D.`) } }); var Ee = n(6111), Ne = n(5606), Ie = n(8991), Me = n(8229), Fe = n(2058), De = n(3337), $e = n(5040), Re = n(8318), Oe = n(3454), ze = n(6300), Pe = n(6919), Be = n(1303), Le = n(6508); /** * @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 je(e, t, n) { if (n <= 0) throw new Error("The number of values should be positive."); const r = { start: e, stop: t, num: n }; return u.T2.runKernel(l.mnI, {}, r) } var Ue = n(3531), We = n(4010), Ve = n(2015), Ge = n(5645), He = n(7991), qe = n(3330), Ye = n(3789), Xe = n(9881), Ke = n(9879), Ze = n(9925); /** * @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 Je = 2147483648; const Qe = (0, d.op)({ searchSorted_: function (e, t, n = "left") { const r = (0, c.YT)(e, "sortedSequence", "searchSorted"), i = (0, c.YT)(t, "values", "searchSorted"), a = r.shape[r.shape.length - 1], o = i.shape[i.shape.length - 1], s = (0, A.t)(r, [-1, a]), d = (0, A.t)(i, [-1, o]); if (s.rank < 2) throw new Error("Sorted input argument must be at least 2-dimensional"); if (s.shape[0] !== d.shape[0]) throw new Error("Leading dimension of 'sortedSequence' and 'values' must match."); if ((0, h.Ze)(d.shape) >= Je) throw new Error("values tensor size must less than 2147483648"); if (s.shape[1] >= Je) throw new Error(`trailing dim_size must less than 2147483648 for int32 output type, was ${s.shape[1]}`); const f = { sortedSequence: s, values: d }, p = { side: n }; return u.T2.runKernel(l.uWl, f, p) } }); /** * @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 et(e, t) { return Qe(e, t, "left") } var tt = n(1938), nt = n(6999); const rt = (0, d.op)({ maxPool3d_: /** * @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 (e, t = [1, 1, 1], n, r, i, a = "NDHWC") { const o = (0, c.YT)(e, "x", "maxPool3d"); let s = o, d = !1; 4 === o.rank && (d = !0, s = (0, A.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]])), h.vA(5 === s.rank, (() => `Error in maxPool3d: x must be rank 5 but got rank ${s.rank}.`)), h.vA("NDHWC" === a, (() => `Error in maxPool3d: Only NDHWC is currently supported, but got dataFormat of ${a}`)), (0, C.s_)("maxPool3d", r, i); const f = { x: s }, p = { filterSize: t, strides: n, pad: r, dimRoundingMode: i, dataFormat: a }, m = u.T2.runKernel(l.ySp, f, p); return d ? (0, A.t)(m, [m.shape[1], m.shape[2], m.shape[3], m.shape[4]]) : m } }); const it = (0, d.op)({ maxPoolWithArgmax_: /** * @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 (e, t, n, r, i = !1) { const a = { x: (0, c.YT)(e, "x", "maxPoolWithArgmax") }, o = { filterSize: t, strides: n, pad: r, includeBatchInIndex: i }, s = u.T2.runKernel(l.TL8, a, o); return { result: s[0], indexes: s[1] } } }); var at = n(178), ot = n(2611), st = n(1411), ut = n(259); /** * @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 lt(e, t, { indexing: n = "xy" } = {}) { if ("xy" !== n && "ij" !== n) throw new TypeError(`${n} is not a valid third argument to meshgrid`); if (void 0 === e) return []; let r = (0, c.YT)(e, "x", "meshgrid", e instanceof ut.qY ? e.dtype : "float32"); if (void 0 === t) return [r]; let i = (0, c.YT)(t, "y", "meshgrid", t instanceof ut.qY ? t.dtype : "float32"); const a = (0, h.Ze)(r.shape), o = (0, h.Ze)(i.shape); return "xy" === n ? (r = (0, A.t)(r, [1, -1]), i = (0, A.t)(i, [-1, 1]), [(0, N.N)((0, st.S)([o, 1], r.dtype), r), (0, N.N)(i, (0, st.S)([1, a], i.dtype))]) : (r = (0, A.t)(r, [-1, 1]), i = (0, A.t)(i, [1, -1]), [(0, N.N)(r, (0, st.S)([1, o], r.dtype)), (0, N.N)((0, st.S)([a, 1], i.dtype), i)]) } var ct = n(7436), ht = n(2644), dt = n(6567), ft = n(152), pt = n(1078), mt = n(5793), gt = n(7126); const yt = (0, d.op)({ moments_: /** * @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 (e, t = null, n = !1) { e = (0, c.YT)(e, "x", "moments"); const r = (0, h.Y6)(t, e.shape), i = (0, ot.i)(e, r, n); let a = i.shape; n || (a = (0, pt.SM)(i.shape, r)); const o = (0, mt.E)((0, gt.j)((0, _.w)(e, "float32"), (0, A.t)(i, a))); return { mean: i, variance: (0, ot.i)(o, r, n) } } }); const bt = (0, d.op)({ multiRNNCell_: function (e, t, n, r) { const i = (0, c.YT)(t, "data", "multiRNNCell"), a = (0, c.j1)(n, "c", "multiRNNCell"), o = (0, c.j1)(r, "h", "multiRNNCell"); let s = i; const u = []; for (let t = 0; t < e.length; t++) { const n = e[t](s, a[t], o[t]); u.push(n[0]), u.push(n[1]), s = n[1] } const l = [], h = []; for (let e = 0; e < u.length; e += 2)l.push(u[e]), h.push(u[e + 1]); return [l, h] } }); const vt = (0, d.op)({ multinomial_: /** * @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 (e, t, n, r = !1) { const i = (0, c.YT)(e, "logits", "multinomial"), a = i.size, o = i.rank; if (a < 2) throw new Error(`Error in multinomial: you need at least 2 outcomes, but got ${a}.`); if (o > 2) throw new Error(`Rank of probabilities must be 1 or 2, but is ${o}`); n = n || Math.random(); const s = { logits: 1 === o ? (0, A.t)(i, [1, -1]) : i }, h = { numSamples: t, seed: n, normalized: r }, d = u.T2.runKernel(l.WT3, s, h); return 1 === o ? (0, A.t)(d, [d.size]) : d } }); var xt = n(6522), wt = n(2118), kt = n(1760), St = n(9885); const _t = (0, d.op)({ outerProduct_: function (e, t) { const n = (0, c.YT)(e, "v1", "outerProduct"), r = (0, c.YT)(t, "v2", "outerProduct"); h.vA(1 === n.rank && 1 === r.rank, (() => `Error in outerProduct: inputs must be rank 1, but got ranks ${n.rank} and ${r.rank}.`)); const i = (0, A.t)(n, [-1, 1]), a = (0, A.t)(r, [1, -1]); return (0, N.N)(i, a) } }); var Ct = n(5661); const At = (0, d.op)({ pad1d_: function (e, t, n = 0) { return (0, h.vA)(2 === t.length, (() => "Invalid number of paddings. Must be length of 2.")), (0, Ct.e)(e, [t], n) } }); const Tt = (0, d.op)({ pad2d_: function (e, t, n = 0) { return (0, h.vA)(2 === t.length && 2 === t[0].length && 2 === t[1].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); const Et = (0, d.op)({ pad3d_: function (e, t, n = 0) { return (0, h.vA)(3 === t.length && 2 === t[0].length && 2 === t[1].length && 2 === t[2].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); const Nt = (0, d.op)({ pad4d_: function (e, t, n = 0) { return (0, h.vA)(4 === t.length && 2 === t[0].length && 2 === t[1].length && 2 === t[2].length && 2 === t[3].length, (() => "Invalid number of paddings. Must be length of 2 each.")), (0, Ct.e)(e, t, n) } }); var It = n(7872), Mt = n(8990), Ft = n(4394), Dt = n(5295), $t = n(7771); const Rt = (0, d.op)({ raggedGather_: /** * @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 (e, t, n, r) { const i = { paramsNestedSplits: e.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "raggedGather", "int32"))), paramsDenseValues: (0, c.YT)(t, "paramsDenseValues", "raggedGather"), indices: (0, c.YT)(n, "indices", "raggedGather", "int32") }, a = { outputRaggedRank: r }, o = u.T2.runKernel(l.oJ2, i, a); return { outputNestedSplits: o.slice(0, o.length - 1), outputDenseValues: o[o.length - 1] } } }); const Ot = (0, d.op)({ raggedRange_: /** * @license * Copyright 2022 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 (e, t, n) { const r = (0, c.YT)(e, "starts", "raggedRange"), i = { starts: r, limits: (0, c.YT)(t, "limits", "raggedRange", r.dtype), deltas: (0, c.YT)(n, "deltas", "raggedRange", r.dtype) }, a = u.T2.runKernel(l.CQC, i); return { rtNestedSplits: a[0], rtDenseValues: a[1] } } }); const zt = (0, d.op)({ raggedTensorToTensor_: /** * @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 (e, t, n, r, i) { const a = (0, c.YT)(e, "shape", "raggedTensorToTensor", "int32"), o = (0, c.YT)(t, "values", "raggedTensorToTensor"), s = { shape: a, values: o, defaultValue: (0, c.YT)(n, "defaultValue", "raggedTensorToTensor", o.dtype), rowPartitionTensors: r.map(((e, t) => (0, c.YT)(e, `tensors${t}`, "raggedTensorToTensor", "int32"))) }, h = { rowPartitionTypes: i }; return u.T2.runKernel(l.mH5, s, h) } }); const Pt = (0, d.op)({ rand_: /** * @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 (e, t, n) { (0, h.SA)(e); const r = (0, h.Ze)(e); let i = null; if (null == n || "float32" === n) i = new Float32Array(r); else if ("int32" === n) i = new Int32Array(r); else { if ("bool" !== n) throw new Error(`Unknown data type ${n}`); i = new Uint8Array(r) } for (let e = 0; e < r; e++)i[e] = t(); return u.T2.makeTensor(i, e, n) } }); var Bt = n(7391); /** * @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 Lt { constructor(e, t, n, r, i) { this.mean = e, this.stdDev = t, this.dtype = n, this.nextVal = NaN, this.truncated = r, this.truncated && (this.upper = this.mean + 2 * this.stdDev, this.lower = this.mean - 2 * this.stdDev); const a = i || Math.random(); this.random = Bt.alea(a.toString()) } nextValue() { if (!isNaN(this.nextVal)) { const e = this.nextVal; return this.nextVal = NaN, e } let e, t, n = !1; for (; !n;) { let r, i, a; do { r = 2 * this.random() - 1, i = 2 * this.random() - 1, a = r * r + i * i } while (a >= 1 || 0 === a); const o = Math.sqrt(-2 * Math.log(a) / a); e = this.mean + this.stdDev * r * o, t = this.mean + this.stdDev * i * o, this.truncated && !this.isValidTruncated(e) || (n = !0) } return this.truncated && !this.isValidTruncated(t) || (this.nextVal = this.convertValue(t)), this.convertValue(e) } convertValue(e) { return null == this.dtype || "float32" === this.dtype ? e : Math.round(e) } isValidTruncated(e) { return e <= this.upper && e >= this.lower } } class jt { constructor(e, t, n, r) { this.alpha = e, this.beta = 1 / t, this.dtype = n; const i = r || Math.random(); this.randu = Bt.alea(i.toString()), this.randn = new Lt(0, 1, n, !1, this.randu()), this.d = e < 1 ? e + 2 / 3 : e - 1 / 3, this.c = 1 / Math.sqrt(9 * this.d) } nextValue() { let e, t, n, r, i, a; for (; ;) { do { r = this.randn.nextValue(), a = 1 + this.c * r } while (a <= 0); if (a *= a * a, e = r * r, t = 1 - .331 * e * e, n = .5 * e + this.d * (1 - a + Math.log(a)), i = this.randu(), i < t || Math.log(i) < n) break } return a = 1 / this.beta * this.d * a, this.alpha < 1 && (a *= Math.pow(this.randu(), 1 / this.alpha)), this.convertValue(a) } convertValue(e) { return "float32" === this.dtype ? e : Math.round(e) } } class Ut { constructor(e = 0, t = 1, n, r) { if (this.canReturnFloat = () => null == this.dtype || "float32" === this.dtype, this.min = e, this.range = t - e, this.dtype = n, null == r && (r = Math.random()), "number" == typeof r && (r = r.toString()), !this.canReturnFloat() && this.range <= 1) throw new Error(`The difference between ${e} - ${t} <= 1 and dtype is not float`); this.random = Bt.alea(r) } convertValue(e) { return this.canReturnFloat() ? e : Math.round(e) } nextValue() { return this.convertValue(this.min + this.range * this.random()) } } const Wt = (0, d.op)({ randomGamma_: /** * @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 (e, t, n = 1, r = "float32", i) { if ((0, h.SA)(e), null == n && (n = 1), null == r && (r = "float32"), "float32" !== r && "int32" !== r) throw new Error(`Unsupported data type ${r}`); const a = new jt(t, n, r, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } }); const Vt = (0, d.op)({ randomNormal_: /** * @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 (e, t = 0, n = 1, r, i) { if ((0, h.SA)(e), null != r && "bool" === r) throw new Error(`Unsupported data type ${r}`); const a = new Lt(t, n, r, !1, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } }); const Gt = (0, d.op)({ randomStandardNormal_: /** * @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 (e, t, n) { if (null != t && "bool" === t) throw new Error(`Unsupported data type ${t}`); return Vt(e, 0, 1, t, n) } }); const Ht = (0, d.op)({ randomUniform_: /** * @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 (e, t = 0, n = 1, r = "float32", i) { (0, h.SA)(e); const a = (0, V.r)(e, r), o = new Ut(t, n, null, i); for (let e = 0; e < a.values.length; e++)a.values[e] = o.nextValue(); return a.toTensor() } }); const qt = (0, d.op)({ randomUniformInt_: /** * @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 (e, t, n, r) { return Ht(e, t, n, "int32", r) } }); /** * @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 Yt(e, t, n = 1, r = "float32") { if (0 === n) throw new Error("Cannot have a step of zero"); const i = { start: e, stop: t, step: n, dtype: r }; return u.T2.runKernel(l.Q6t, {}, i) } var Xt = n(1902), Kt = n(9870), Zt = n(112), Jt = n(3732), Qt = n(3262); const en = (0, d.op)({ reverse1d_: /** * @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 (e) { const t = (0, c.YT)(e, "x", "reverse"); return h.vA(1 === t.rank, (() => `Error in reverse1D: x must be rank 1 but got rank ${t.rank}.`)), (0, Qt.B)(t, 0) } }); const tn = (0, d.op)({ reverse2d_: /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(2 === n.rank, (() => `Error in reverse2D: x must be rank 2 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } }); const nn = (0, d.op)({ reverse3d_: /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(3 === n.rank, (() => `Error in reverse3D: x must be rank 3 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } }); const rn = (0, d.op)({ reverse4d_: /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "reverse"); return h.vA(4 === n.rank, (() => `Error in reverse4D: x must be rank 4 but got rank ${n.rank}.`)), (0, Qt.B)(n, t) } }); var an = n(5912), on = n(7820), sn = n(5702), un = n(6325), ln = n(9986); const cn = /** * @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 (e, t) { const n = (0, c.YT)(e, "x", "setdiff1d"), r = (0, c.YT)(t, "y", "setdiff1d"); h.vA(n.dtype === r.dtype, (() => `x and y should have the same dtype, but got x (${n.dtype}) and y (${r.dtype}).`)), h.vA(1 === n.rank, (() => `x should be 1D tensor, but got x (${n.shape}).`)), h.vA(1 === r.rank, (() => `y should be 1D tensor, but got y (${r.shape}).`)); const i = await n.data(), a = await r.data(), o = new Set(a); let s = 0; for (let e = 0; e < i.length; e++)o.has(i[e]) || s++; const u = new ut.yl([s], n.dtype), l = new ut.yl([s], "int32"); for (let e = 0, t = 0; e < i.length; e++)o.has(i[e]) || (u.values[t] = i[e], l.values[t] = e, t++); return [u.toTensor(), l.toTensor()] }; var hn = n(1115), dn = n(3726), fn = n(8276); const pn = (0, d.op)({ slice1d_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "x", "slice1d"); return h.vA(1 === r.rank, (() => `slice1d expects a rank-1 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, [t], [n]) } }); const mn = (0, d.op)({ slice2d_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "x", "slice2d"); return h.vA(2 === r.rank, (() => `slice2d expects a rank-2 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } }); const gn = (0, d.op)({ slice3d_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "x", "slice3d"); return h.vA(3 === r.rank, (() => `slice3d expects a rank-3 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } }); const yn = (0, d.op)({ slice4d_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "x", "slice4d"); return h.vA(4 === r.rank, (() => `slice4d expects a rank-4 tensor, but got a rank-${r.rank} tensor`)), (0, F.d)(r, t, n) } }); var bn = n(6346), vn = n(6030), xn = n(776), wn = n(1361), kn = n(3108), Sn = n(2292), _n = n(8775), Cn = n(6512), An = n(9348), Tn = n(3427), En = n(5932), Nn = n(4268), In = n(700), Mn = n(5894), Fn = n(3791), Dn = n(7823), $n = n(4027), Rn = n(9171); /** * @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 On(e, t) { (0, h.HO)(e); const n = (0, c.MZ)(e, t); if (1 !== n.length) throw new Error("tensor1d() requires values to be a flat/TypedArray"); return (0, Rn.Q)(e, null, n, 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 zn(e, t, n) { if ((0, h.HO)(e), null != t && 2 !== t.length) throw new Error("tensor2d() requires shape to have two numbers"); const r = (0, c.MZ)(e, n); if (2 !== r.length && 1 !== r.length) throw new Error("tensor2d() requires values to be number[][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor2d() requires shape to be provided when `values` are a flat/TypedArray"); return (0, Rn.Q)(e, t, r, n) } var Pn = n(2768); /** * @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 Bn(e, t, n) { if ((0, h.HO)(e), null != t && 4 !== t.length) throw new Error("tensor4d() requires shape to have four numbers"); const r = (0, c.MZ)(e, n); if (4 !== r.length && 1 !== r.length) throw new Error("tensor4d() requires values to be number[][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor4d() requires shape to be provided when `values` are a flat array"); return (0, Rn.Q)(e, t, r, n) } /** * @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 Ln(e, t, n) { if ((0, h.HO)(e), null != t && 5 !== t.length) throw new Error("tensor5d() requires shape to have five numbers"); const r = (0, c.MZ)(e, n); if (5 !== r.length && 1 !== r.length) throw new Error("tensor5d() requires values to be number[][][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor5d() requires shape to be provided when `values` are a flat array"); return (0, Rn.Q)(e, t, r, n) } /** * @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 jn(e, t, n) { if ((0, h.HO)(e), null != t && 6 !== t.length) throw new Error("tensor6d() requires shape to have six numbers"); const r = (0, c.MZ)(e, n); if (6 !== r.length && 1 !== r.length) throw new Error("tensor6d() requires values to be number[][][][][][] or flat/TypedArray"); if (1 === r.length && null == t) throw new Error("tensor6d() requires shape to be provided when `values` are a flat array"); return t = t || r, (0, Rn.Q)(e, t, r, n) } var Un = n(6170); const Wn = (0, d.op)({ tensorScatterUpdate_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "tensor", "tensorScatterupdate"), i = (0, c.YT)(t, "indices", "tensorScatterupdate", "int32"), a = (0, c.YT)(n, "updates", "tensorScatterupdate"); if (Un.validateInput(a, i, r.shape), r.dtype !== a.dtype) throw new Error(`tensor and updates must have the same dtype, instead they are ${r.dtype} and ${a.dtype}.`); const o = { tensor: r, indices: i, updates: a }; return u.T2.runKernel(l.X4r, o, {}) } }); var Vn = n(1190); const Gn = (0, d.op)({ truncatedNormal_: /** * @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 (e, t = 0, n = 1, r, i) { if ((0, h.SA)(e), null != r && "bool" === r) throw new Error("Unsupported data type $ { dtype }"); const a = new Lt(t, n, r, !0, i), o = (0, V.r)(e, r); for (let e = 0; e < o.values.length; e++)o.values[e] = a.nextValue(); return o.toTensor() } }); var Hn = n(3937), qn = n(7706), Yn = n(7261); /** * @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 Xn(e, t) { return Qe(e, t, "right") } /** * @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(e, t = !0, n, r) { return u.T2.makeVariable(e, t, n, r) } var Zn = n(2151), Jn = n(4411); const Qn = /** * @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. * ============================================================================= */ async function (e) { const t = (0, c.YT)(e, "condition", "whereAsync", "bool"), n = await t.data(), r = (0, Jn.Y)(t.shape, n); return e !== t && t.dispose(), r }; var er = n(2855), tr = n(5537); const nr = /** * @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. * ============================================================================= */ async function (e, t, n) { const r = (0, c.YT)(e, "tensor", "boolMask"), i = (0, c.YT)(t, "mask", "boolMask", "bool"), a = null == n ? 0 : n, o = i.rank, s = r.shape; h.vA(o > 0, (() => "mask cannot be scalar")), h.O3(s.slice(a, a + o), i.shape, "mask's shape must match the first K dimensions of tensor's shape,"); let u = 1; for (let e = a; e < a + o; e++)u *= s[e]; const l = s.slice(0, a).concat([u], s.slice(a + o)), d = (0, A.t)(r, l), f = (0, A.t)(i, [-1]), p = await Qn(f), m = (0, En.r)(p, [1]), g = (0, Me.k)(d, m, a); return e !== r && r.dispose(), t !== i && i.dispose(), m.dispose(), d.dispose(), f.dispose(), p.dispose(), g }; var rr = n(7703), ir = n(2596), ar = n(565); const or = (0, d.op)({ movingAverage_: /** * @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 (e, t, n, r, i = !0) { const a = (0, c.YT)(e, "v", "movingAverage"), o = (0, c.YT)(t, "x", "movingAverage"), u = (0, c.YT)(n, "decay", "movingAverage"); (0, ar.assertTypesMatch)(a, o), h.vA(h.r1(a.shape, o.shape), (() => "Shape mismatch in v and x")); const l = (0, sn.d)(1), d = (0, gt.j)(l, u); let f = (0, I.l)((0, gt.j)(o, a), d); if (i) { h.vA(null != r, (() => "When using zeroDebias: true, step is required.")); const e = (0, c.YT)(r, "step", "movingAverage"); f = (0, pe.y)(f, (0, gt.j)(l, (0, Mt.n)(u, e))) } return (0, s.W)(a, f) } }); const sr = (0, d.op)({ scatterND_: /** * @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 (e, t, n) { (0, h.SA)(n); const r = (0, c.YT)(e, "indices", "scatterND", "int32"), i = (0, c.YT)(t, "updates", "scatterND"); Un.validateInput(i, r, n); const a = { indices: r, updates: i }, o = { shape: n }; return u.T2.runKernel(l.pJc, a, o) } }); const ur = (0, d.op)({ sparseToDense_: /** * @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 (e, t, n, r = 0) { (0, h.SA)(n); const i = (0, c.YT)(e, "sparseIndices", "sparseToDense", "int32"), a = (0, c.YT)(t, "sparseValues", "sparseToDense", "string_or_numeric"), o = (0, c.YT)(r, "defaultValue", "sparseToDense", a.dtype); !function (e, t, n, r) { if ("int32" !== e.dtype) throw new Error(`tf.sparseToDense() expects the indices to be int32 type, but the dtype was ${e.dtype}.`); if (e.rank > 2) throw new Error(`sparseIndices should be a scalar, vector, or matrix, but got shape ${e.shape}.`); const i = e.rank > 0 ? e.shape[0] : 1, a = e.rank > 1 ? e.shape[1] : 1; if (n.length !== a) throw new Error(`outputShape has incorrect number of elements:, ${n.length}, should be: ${a}.`); const o = t.size; if (0 !== t.rank && (1 !== t.rank || o !== i)) throw new Error(`sparseValues has incorrect shape ${t.shape}, should be [] or [${i}]`); if (t.dtype !== r.dtype) throw new Error("sparseValues.dtype must match defaultValues.dtype") }(i, a, n, o); const s = { sparseIndices: i, sparseValues: a, defaultValue: o }, d = { outputShape: n }; return u.T2.runKernel(l.jgd, s, d) } }); const lr = (0, d.op)({ gatherND_: /** * @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 (e, t) { const n = (0, c.YT)(t, "indices", "gatherND", "int32"), r = { params: (0, c.YT)(e, "x", "gatherND", "string_or_numeric"), indices: n }; return u.T2.runKernel(l.O4G, r) } }); const cr = (0, d.op)({ dropout_: /** * @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 (e, t, n, r) { const i = (0, c.YT)(e, "x", "dropout"); if (h.vA("float32" === i.dtype, (() => `x has to be a floating point tensor since it's going to be scaled, but got a ${i.dtype} tensor instead.`)), h.vA(t >= 0 && t < 1, (() => `rate must be a float in the range [0, 1), but got ${t}.`)), 0 === t) return e instanceof ut.qY ? i.clone() : i; const a = /** * @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 (e, t) { if (null == t) return e.shape.slice(); if (h.r1(e.shape, t)) return t; if (e.shape.length === t.length) { const n = []; for (let r = 0; r < e.shape.length; r++)null == t[r] && null != e.shape[r] ? n.push(e.shape[r]) : n.push(t[r]); return n } return t }(i, n), o = 1 - t, u = (0, pe.y)((0, Ne.R)((0, s.W)(Ht(a, 0, 1, "float32", r), o)), o); return (0, I.l)(i, 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. * ============================================================================= */ function hr(e) { return Math.floor(Math.pow(2, Math.ceil(Math.log(e) / Math.log(2)))) } function dr(e, t, n) { const r = 1 - e % 2, i = new Float32Array(e); for (let a = 0; a < e; ++a) { const o = 2 * Math.PI * a / (e + r - 1); i[a] = t - n * Math.cos(o) } return On(i, "float32") } const fr = /** * @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. * ============================================================================= */ async function (e, t, n = 1) { const r = (0, c.YT)(e, "predictions", "inTopK"), i = (0, c.YT)(t, "targets", "inTopK"); (0, h.vA)(r.rank > 1, (() => `inTopK() expects the predictions to be of rank 2 or higher, but got ${r.rank}`)), (0, h.vA)(r.rank - 1 === i.rank, (() => `predictions rank should be 1 larger than targets rank, but got predictions rank ${r.rank} and targets rank ${i.rank}`)), (0, h.O3)(r.shape.slice(0, r.shape.length - 1), i.shape, "predictions's shape should be align with the targets' shape, except the last dimension."); const a = r.shape[r.shape.length - 1]; (0, h.vA)(n > 0 && n <= a, (() => `'k' passed to inTopK() must be > 0 && <= the predictions last dimension (${a}), but got ${n}`)); const o = await r.data(), s = await i.data(), [u, l] = [o.length / a, a], d = (0, h.ce)("bool", u); for (let e = 0; e < u; e++) { const t = e * l, r = o.subarray(t, t + l), i = []; for (let e = 0; e < r.length; e++)i.push({ value: r[e], index: e }); i.sort(((e, t) => t.value - e.value)), d[e] = 0; for (let t = 0; t < n; t++)if (i[t].index === s[e]) { d[e] = 1; break } } return e !== r && r.dispose(), t !== i && i.dispose(), (0, $n.O)(d, i.shape, "bool") }; var pr = n(1830), mr = n(2198), gr = n(5248), yr = n(252), br = n(8646); const vr = (0, d.op)({ fusedConv2d_: /** * @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 ({ x: e, filter: t, strides: n, pad: r, dataFormat: i = "NHWC", dilations: a = [1, 1], dimRoundingMode: o, bias: d, activation: f = "linear", preluActivationWeights: p, leakyreluAlpha: m }) { if (f = f || "linear", !1 === (0, br.zE)(u.T2.state.gradientDepth, f)) { h.vA("NHWC" === i, (() => `Error in fused conv2d: got dataFormat of ${i} but only NHWC is currently supported for the case of gradient depth is 0 and the activation is not linear.`)); let u = (0, ee.X)(e, t, n, r, i, a, o); return null != d && (u = (0, s.W)(u, d)), (0, br.f2)(u, f, p, m) } const g = (0, c.YT)(e, "x", "conv2d", "float32"), y = (0, c.YT)(t, "filter", "conv2d", "float32"); let b = g, v = !1; 3 === g.rank && (v = !0, b = (0, A.t)(g, [1, g.shape[0], g.shape[1], g.shape[2]])), h.vA(4 === b.rank, (() => `Error in fused conv2d: input must be rank 4, but got rank ${b.rank}.`)), h.vA(4 === y.rank, (() => `Error in fused conv2d: filter must be rank 4, but got rank ${y.rank}.`)), C.s_("fused conv2d", r, o); const x = "NHWC" === i ? b.shape[3] : b.shape[1]; h.vA(y.shape[2] === x, (() => `Error in conv2d: depth of input (${x}) must match input depth for filter ${y.shape[2]}.`)), h.vA(C.G0(n, a), (() => `Error in conv2D: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)); const w = C.uf(b.shape, y.shape, n, a, r, o); let k, S; if (null != d && (k = (0, c.YT)(d, "bias", "fused conv2d"), [k] = (0, ar.makeTypesMatch)(k, g), "NHWC" === i ? mr.assertAndGetBroadcastShape(w.outShape, k.shape) : (h.vA(k.shape.length <= 1, (() => `Error in fused conv2d: only supports scalar or 1-D Tensor bias for NCHW format but got the bias of rank-${k.shape.length}.`)), h.vA(0 === k.shape.length || k.shape[0] === w.outChannels || 1 === k.shape[0], (() => `Error in fused conv2d: bias shape (${k.shape}) is not compatible with the number of output channels (${w.outChannels})`)))), null != p) { const e = p.shape; if (h.vA(e.length <= 1 || 3 === e.length, (() => `Error in fused conv2d: only supports scalar, 1-D Tensor or 3-D Tensor PReLU activation weights but got a tensor of rank-${e.length}.`)), 1 === e.length) h.vA(1 === e[0] || e[0] === w.outChannels, (() => `Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the number of output channels (${w.outChannels}).`)); else if (3 === e.length) try { mr.assertAndGetBroadcastShape(e, w.outShape) } catch (t) { const n = `Error in fused conv2d: PReLU activation weights (${e}) is not compatible with the output shape of the conv2d (${w.outShape}).`; throw Error(n) } S = (0, c.YT)(p, "prelu weights", "fused conv2d") } const _ = (e, t) => { h.vA("NHWC" === i, (() => `Error in gradient of fused conv2D: got dataFormat of ${i} but only NHWC is currently supported.`)); const [o, s, u, l] = t, c = (0, br.XB)(e, u, f); h.vA(C.Dh(a), (() => `Error in gradient of fused conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`)); const d = [(0, yr.v)(s.shape, c, o, n, r), (0, gr.H)(s, c, o.shape, n, r)]; if (null != l) { const e = (0, br.Do)(l, c); d.push(e) } return d }, T = { x: b, filter: y, bias: k, preluActivationWeights: S }, E = { strides: n, pad: r, dataFormat: i, dilations: a, dimRoundingMode: o, activation: f, leakyreluAlpha: m }; if (null == d) { const e = (0, pr._X)(((e, t, n) => { let r = u.T2.runKernel(l.aAr, T, E); return n([t, e, r]), v && (r = (0, A.t)(r, [r.shape[1], r.shape[2], r.shape[3]])), { value: r, gradFunc: _ } })); return e(b, y) } { const e = (0, pr._X)(((e, t, n, r) => { let i = u.T2.runKernel(l.aAr, T, E); return r([t, e, i, n]), v && (i = (0, A.t)(i, [i.shape[1], i.shape[2], i.shape[3]])), { value: i, gradFunc: _ } })); return e(b, y, k) } } }); var xr = n(1890), wr = n(3134); const kr = (0, d.op)({ fusedDepthwiseConv2d_: /** * @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 ({ x: e, filter: t, strides: n, pad: r, dataFormat: i = "NHWC", dilations: a = [1, 1], dimRoundingMode: o, bias: d, activation: f = "linear", preluActivationWeights: p, leakyreluAlpha: m }) { if (!1 === (0, br.zE)(u.T2.state.gradientDepth, f)) { let u = (0, he.G)(e, t, n, r, i, a, o); return null != d && (u = (0, s.W)(u, d)), (0, br.f2)(u, f, p, m) } const g = (0, c.YT)(e, "x", "depthwiseConv2d", "float32"), y = (0, c.YT)(t, "filter", "depthwiseConv2d", "float32"); let b = g, v = !1; 3 === g.rank && (v = !0, b = (0, A.t)(g, [1, g.shape[0], g.shape[1], g.shape[2]])), h.vA(4 === b.rank, (() => `Error in fused depthwiseConv2d: input must be rank 4, but got rank ${b.rank}.`)), h.vA(4 === y.rank, (() => `Error in fused depthwiseConv2d: filter must be rank 4, but got rank ${y.rank}.`)), h.vA(b.shape[3] === y.shape[2], (() => `Error in fused depthwiseConv2d: number of input channels (${b.shape[3]}) must match the inChannels dimension in filter ${y.shape[2]}.`)), null == a && (a = [1, 1]), h.vA(C.G0(n, a), (() => `Error in fused depthwiseConv2d: Either strides or dilations must be 1. Got strides ${n} and dilations '${a}'`)), C.s_("fused depthwiseConv2d", r, o); const x = C.uf(b.shape, y.shape, n, a, r, o, !0); let w, k; null != d && (w = (0, c.YT)(d, "bias", "fused conv2d"), [w] = (0, ar.makeTypesMatch)(w, g), mr.assertAndGetBroadcastShape(x.outShape, w.shape)), null != p && (k = (0, c.YT)(p, "prelu weights", "fused depthwiseConv2d")); const S = (e, t) => { h.vA(C.Dh(a), (() => `Error in gradient of fused depthwiseConv2d: dilation rates greater than 1 are not yet supported. Got dilations '${a}'`)); const [i, s, u, l] = t, c = (0, br.XB)(e, u, f), d = (0, wr.l)(s.shape, c, i, n, r, a, o), p = (0, xr.x)(s, c, i.shape, n, r, a, o); if (null != l) { return [d, p, (0, br.Do)(w, c)] } return [d, p] }, _ = { x: b, filter: y, bias: w, preluActivationWeights: k }, T = { strides: n, pad: r, dataFormat: i, dilations: a, dimRoundingMode: o, activation: f, leakyreluAlpha: m }; if (null == d) { const e = (0, pr._X)(((e, t, n) => { let r = u.T2.runKernel(l.T7M, _, T); return n([t, e, r]), v && (r = (0, A.t)(r, [r.shape[1], r.shape[2], r.shape[3]])), { value: r, gradFunc: S } })); return e(b, y) } { const e = (0, pr._X)(((e, t, n, r) => { let i = u.T2.runKernel(l.T7M, _, T); return r([t, e, i, n]), v && (i = (0, A.t)(i, [i.shape[1], i.shape[2], i.shape[3]])), { value: i, gradFunc: S } })); return e(b, y, w) } } }); const Sr = (0, d.op)({ fusedMatMul_: /** * @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 ({ a: e, b: t, transposeA: n = !1, transposeB: r = !1, bias: i, activation: a = "linear", preluActivationWeights: o, leakyreluAlpha: d = .2 }) { if (!1 === (0, br.zE)(u.T2.state.gradientDepth, a)) { let u = (0, N.N)(e, t, n, r); return null != i && (u = (0, s.W)(u, i)), (0, br.f2)(u, a, o, d) } let f = (0, c.YT)(e, "a", "fused matMul"), p = (0, c.YT)(t, "b", "fused matMul");[f, p] = (0, ar.makeTypesMatch)(f, p); const m = n ? f.shape[f.rank - 2] : f.shape[f.rank - 1], g = r ? p.shape[p.rank - 1] : p.shape[p.rank - 2], y = n ? f.shape[f.rank - 1] : f.shape[f.rank - 2], b = r ? p.shape[p.rank - 2] : p.shape[p.rank - 1], v = f.shape.slice(0, -2), x = p.shape.slice(0, -2), w = h.Ze(v), k = h.Ze(x); h.vA(m === g, (() => `Error in fused matMul: inner shapes (${m}) and (${g}) of Tensors with shapes ${f.shape} and ${p.shape} and transposeA=${n} and transposeB=${r} must match.`)); const S = mr.assertAndGetBroadcastShape(f.shape.slice(0, -2), p.shape.slice(0, -2)).concat([y, b]), _ = n ? (0, A.t)(f, [w, m, y]) : (0, A.t)(f, [w, y, m]), C = r ? (0, A.t)(p, [k, b, g]) : (0, A.t)(p, [k, g, b]); let T, E; null != i && (T = (0, c.YT)(i, "bias", "fused matMul"), [T] = (0, ar.makeTypesMatch)(T, f), mr.assertAndGetBroadcastShape(S, T.shape)), null != o && (E = (0, c.YT)(o, "prelu weights", "fused matMul")); const I = (e, t) => { const [o, s, u, l] = t, c = (0, br.XB)((0, A.t)(e, u.shape), u, a); let h, d; if (n || r ? !n && r ? (h = (0, N.N)(c, s, !1, !1), d = (0, N.N)(c, o, !0, !1)) : n && !r ? (h = (0, N.N)(s, c, !1, !0), d = (0, N.N)(o, c, !1, !1)) : (h = (0, N.N)(s, c, !0, !0), d = (0, N.N)(c, o, !0, !0)) : (h = (0, N.N)(c, s, !1, !0), d = (0, N.N)(o, c, !0, !1)), null != i) { return [h, d, (0, br.Do)(l, c)] } return [h, d] }, M = { a: _, b: C, bias: T, preluActivationWeights: E }, F = { transposeA: n, transposeB: r, activation: a, leakyreluAlpha: d }; if (null == i) { const e = (0, pr._X)(((e, t, n) => { const r = u.T2.runKernel(l.Dr, M, F); return n([e, t, r]), { value: (0, A.t)(r, S), gradFunc: I } })); return e(_, C) } { const e = (0, pr._X)(((e, t, n, r) => { const i = u.T2.runKernel(l.Dr, M, F); return r([e, t, i, n]), { value: (0, A.t)(i, S), gradFunc: I } })); return e(_, C, T) } } }); const _r = (0, d.op)({ hammingWindow_: /** * @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 (e) { return dr(e, .54, .46) } }); const Cr = (0, d.op)({ hannWindow_: /** * @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 (e) { return dr(e, .5, .5) } }); const Ar = (0, d.op)({ frame_: /** * @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 (e, t, n, r = !1, i = 0) { let a = 0; const o = []; for (; a + t <= e.size;)o.push((0, F.d)(e, a, t)), a += n; if (r) for (; a < e.size;) { const r = a + t - e.size, s = (0, E.x)([(0, F.d)(e, a, t - r), (0, Ee.G)([r], i)]); o.push(s), a += n } return 0 === o.length ? zn([], [0, t]) : (0, A.t)((0, E.x)(o), [o.length, t]) } }); const Tr = (0, d.op)({ stft_: /** * @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 (e, t, n, r, i = Cr) { null == r && (r = hr(t)); const a = Ar(e, t, n), o = (0, I.l)(a, i(t)); return (0, _n.z)(o, r) } }); const Er = (0, d.op)({ cropAndResize_: /** * @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 (e, t, n, r, i = "bilinear", a = 0) { const o = (0, c.YT)(e, "image", "cropAndResize"), s = (0, c.YT)(t, "boxes", "cropAndResize", "float32"), d = (0, c.YT)(n, "boxInd", "cropAndResize", "int32"), f = s.shape[0]; h.vA(4 === o.rank, (() => `Error in cropAndResize: image must be rank 4,but got rank ${o.rank}.`)), h.vA(2 === s.rank && 4 === s.shape[1], (() => `Error in cropAndResize: boxes must be have size [${f},4] but had shape ${s.shape}.`)), h.vA(1 === d.rank && d.shape[0] === f, (() => `Error in cropAndResize: boxInd must be have size [${f}] but had shape ${s.shape}.`)), h.vA(2 === r.length, (() => `Error in cropAndResize: cropSize must be of length 2, but got length ${r.length}.`)), h.vA(r[0] >= 1 && r[1] >= 1, (() => `cropSize must be atleast [1,1], but was ${r}`)), h.vA("bilinear" === i || "nearest" === i, (() => `method must be bilinear or nearest, but was ${i}`)); const p = { image: o, boxes: s, boxInd: d }, m = { method: i, extrapolationValue: a, cropSize: r }; return u.T2.runKernel(l.MRQ, p, m) } }); const Nr = (0, d.op)({ flipLeftRight_: /** * @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 (e) { const t = (0, c.YT)(e, "image", "flipLeftRight", "float32"); h.vA(4 === t.rank, (() => `Error in flipLeftRight: image must be rank 4,but got rank ${t.rank}.`)); const n = { image: t }; return u.T2.runKernel(l.BxF, n, {}) } }); const Ir = (0, d.op)({ grayscaleToRGB_: /** * @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 (e) { const t = (0, c.YT)(e, "image", "grayscaleToRGB"), n = t.rank - 1, r = t.shape[n]; h.vA(t.rank >= 2, (() => `Error in grayscaleToRGB: images must be at least rank 2, but got rank ${t.rank}.`)), h.vA(1 === r, (() => `Error in grayscaleToRGB: last dimension of a grayscale image should be size 1, but got size ${r}.`)); const i = new Array(t.rank); return i.fill(1, 0, n), i[n] = 3, (0, Ae.V)(t, i) } }); const Mr = (0, d.op)({ rgbToGrayscale_: /** * @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 (e) { const t = (0, c.YT)(e, "image", "RGBToGrayscale"), n = t.rank - 1, r = t.shape[n]; h.vA(t.rank >= 2, (() => `Error in RGBToGrayscale: images must be at least rank 2, but got rank ${t.rank}.`)), h.vA(3 === r, (() => `Error in RGBToGrayscale: last dimension of an RGB image should be size 3, but got size ${r}.`)); const i = t.dtype, a = (0, _.w)(t, "float32"), o = On([.2989, .587, .114]); let s; switch (t.rank) { case 2: s = ye("ij,j->i", a, o); break; case 3: s = ye("ijk,k->ij", a, o); break; case 4: s = ye("ijkl,l->ijk", a, o); break; case 5: s = ye("ijklm,m->ijkl", a, o); break; case 6: s = ye("ijklmn,n->ijklm", a, o); break; default: throw new Error("Not a valid tensor rank.") }return s = (0, _e.U)(s, -1), (0, _.w)(s, i) } }); const Fr = (0, d.op)({ rotateWithOffset_: /** * @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 (e, t, n = 0, r = .5) { const i = (0, c.YT)(e, "image", "rotateWithOffset", "float32"); h.vA(4 === i.rank, (() => `Error in rotateWithOffset: image must be rank 4,but got rank ${i.rank}.`)); const a = { image: i }, o = { radians: t, fillValue: n, center: r }; return u.T2.runKernel(l.BK4, a, o) } }); /** * @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 Dr(e, t, n, r, i, a) { null == r && (r = .5), null == i && (i = Number.NEGATIVE_INFINITY), null == a && (a = 0); const o = e.shape[0]; return n = Math.min(n, o), h.vA(0 <= r && r <= 1, (() => `iouThreshold must be in [0, 1], but was '${r}'`)), h.vA(2 === e.rank, (() => `boxes must be a 2D tensor, but was of rank '${e.rank}'`)), h.vA(4 === e.shape[1], (() => `boxes must have 4 columns, but 2nd dimension was ${e.shape[1]}`)), h.vA(1 === t.rank, (() => "scores must be a 1D tensor")), h.vA(t.shape[0] === o, (() => `scores has incompatible shape with boxes. Expected ${o}, but was ${t.shape[0]}`)), h.vA(0 <= a && a <= 1, (() => `softNmsSigma must be in [0, 1], but was '${a}'`)), { maxOutputSize: n, iouThreshold: r, scoreThreshold: i, softNmsSigma: a } } const $r = (0, d.op)({ nonMaxSuppression_: /** * @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 (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY) { const a = (0, c.YT)(e, "boxes", "nonMaxSuppression", "float32"), o = (0, c.YT)(t, "scores", "nonMaxSuppression", "float32"), s = Dr(a, o, n, r, i), h = { maxOutputSize: n = s.maxOutputSize, iouThreshold: r = s.iouThreshold, scoreThreshold: i = s.scoreThreshold }; return u.T2.runKernel(l.SDM, { boxes: a, scores: o }, h) } }); var Rr = n(8360); const Or = /** * @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. * ============================================================================= */ async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY) { const a = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), o = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), s = Dr(a, o, n, r, i); n = s.maxOutputSize, r = s.iouThreshold, i = s.scoreThreshold; const u = await Promise.all([a.data(), o.data()]), l = u[0], h = u[1], { selectedIndices: d } = (0, Rr.c7)(l, h, n, r, i); return a !== e && a.dispose(), o !== t && o.dispose(), On(d, "int32") }; const zr = (0, d.op)({ nonMaxSuppressionWithScore_: /** * @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 (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = 0) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppression"), s = (0, c.YT)(t, "scores", "nonMaxSuppression"), h = Dr(o, s, n, r, i, a), d = { boxes: o, scores: s }, f = { maxOutputSize: n = h.maxOutputSize, iouThreshold: r = h.iouThreshold, scoreThreshold: i = h.scoreThreshold, softNmsSigma: a = h.softNmsSigma }, p = u.T2.runKernel(l.e0f, d, f); return { selectedIndices: p[0], selectedScores: p[1] } } }); const Pr = /** * @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. * ============================================================================= */ async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = 0) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), s = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), u = Dr(o, s, n, r, i, a); n = u.maxOutputSize, r = u.iouThreshold, i = u.scoreThreshold, a = u.softNmsSigma; const l = await Promise.all([o.data(), s.data()]), h = l[0], d = l[1], { selectedIndices: f, selectedScores: p } = (0, Rr.ut)(h, d, n, r, i, a); return o !== e && o.dispose(), s !== t && s.dispose(), { selectedIndices: On(f, "int32"), selectedScores: On(p) } }; const Br = (0, d.op)({ nonMaxSuppressionPadded_: /** * @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 (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = !1) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppression"), s = (0, c.YT)(t, "scores", "nonMaxSuppression"), h = Dr(o, s, n, r, i, null), d = { boxes: o, scores: s }, f = { maxOutputSize: h.maxOutputSize, iouThreshold: h.iouThreshold, scoreThreshold: h.scoreThreshold, padToMaxOutputSize: a }, p = u.T2.runKernel(l.Zl4, d, f); return { selectedIndices: p[0], validOutputs: p[1] } } }); const Lr = /** * @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. * ============================================================================= */ async function (e, t, n, r = .5, i = Number.NEGATIVE_INFINITY, a = !1) { const o = (0, c.YT)(e, "boxes", "nonMaxSuppressionAsync"), s = (0, c.YT)(t, "scores", "nonMaxSuppressionAsync"), u = Dr(o, s, n, r, i, null), l = u.maxOutputSize, h = u.iouThreshold, d = u.scoreThreshold, [f, p] = await Promise.all([o.data(), s.data()]), { selectedIndices: m, validOutputs: g } = (0, Rr.ZS)(f, p, l, h, d, a); return o !== e && o.dispose(), s !== t && s.dispose(), { selectedIndices: On(m, "int32"), validOutputs: (0, sn.d)(g, "int32") } }; var jr = n(4711), Ur = n(2954); const Wr = (0, d.op)({ threshold_: /** * @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 * * https://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 (e, t = "binary", n = !1, r = .5) { const i = (0, c.YT)(e, "image", "threshold"), a = i.shape[0] * i.shape[1]; let o, u, l, d, f = (0, I.l)(On([r]), 255); if (h.vA(3 === i.rank, (() => `Error in threshold: image must be rank 3,but got rank ${i.rank}.`)), h.vA(3 === i.shape[2] || 1 === i.shape[2], (() => `Error in threshold: image color channel must be equal to 3 or 1but got ${i.shape[2]}.`)), h.vA("int32" === i.dtype || "float32" === i.dtype, (() => `Error in dtype: image dtype must be int32 or float32,but got dtype ${i.dtype}.`)), h.vA("otsu" === t || "binary" === t, (() => `Method must be binary or otsu, but was ${t}`)), 3 === i.shape[2]) { [o, u, l] = (0, Cn.l)(i, [1, 1, 1], -1); const e = (0, I.l)(o, .2989), t = (0, I.l)(u, .587), n = (0, I.l)(l, .114); d = (0, s.W)((0, s.W)(e, t), n) } else d = e; if ("otsu" === t) { f = function (e, t) { let n, r, i, a, o, u, l = On([-1]), c = On([0]), h = On([0]); for (let d = 0; d < e.size - 1; d++) { n = (0, F.d)(e, 0, d + 1), r = (0, F.d)(e, d + 1), o = (0, pe.y)((0, Fn.c)(n), t), u = (0, pe.y)((0, Fn.c)(r), t); const f = (0, Fn.c)((0, I.l)(n, Yt(0, n.size))); i = (0, pe.y)(f, (0, Fn.c)(n)); const p = (0, Ee.G)(r.shape, n.size), m = (0, s.W)(Yt(0, r.size), p), g = (0, I.l)(r, m); a = (0, pe.y)((0, Fn.c)(g), (0, Fn.c)(r)); const y = (0, gt.j)(i, a), b = (0, gt.j)(i, a), v = (0, I.l)(o, u); h = (0, I.l)((0, I.l)(v, y), b); const x = (0, Fe.r)(h, c); c = (0, Zn._)(x, h, c), l = (0, Zn._)(x, On([d]), l) } return l }(L((0, _.w)((0, an.L)(d), "int32"), (0, $n.O)([]), 256), a) } const p = n ? (0, Le.I)(d, f) : (0, Fe.r)(d, f); return (0, _.w)((0, I.l)(p, 255), "int32") } }); const Vr = (0, d.op)({ transform_: /** * @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 (e, t, n = "nearest", r = "constant", i = 0, a) { const o = (0, c.YT)(e, "image", "transform", "float32"), s = (0, c.YT)(t, "transforms", "transform", "float32"); h.vA(4 === o.rank, (() => `Error in transform: image must be rank 4,but got rank ${o.rank}.`)), h.vA(2 === s.rank && (s.shape[0] === o.shape[0] || 1 === s.shape[0]) && 8 === s.shape[1], (() => "Error in transform: Input transform should be batch x 8 or 1 x 8")), h.vA(null == a || 2 === a.length, (() => `Error in transform: outputShape must be [height, width] or null, but got ${a}.`)); const d = { image: o, transforms: s }, f = { interpolation: n, fillMode: r, fillValue: i, outputShape: a }; return u.T2.runKernel(l.dLy, d, f) } }); const Gr = (0, d.op)({ bandPart_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "a", "bandPart"); (0, h.vA)(r.rank >= 2, (() => `bandPart(): Rank must be at least 2, got ${r.rank}.`)); const i = r.shape, [a, o] = r.shape.slice(-2); let s, u; "number" == typeof t ? ((0, h.vA)(t % 1 == 0, (() => `bandPart(): numLower must be an integer, got ${t}.`)), (0, h.vA)(t <= a, (() => `bandPart(): numLower (${t}) must not be greater than the number of rows (${a}).`)), s = (0, c.YT)(t < 0 ? a : t, "numLower", "bandPart")) : ((0, h.vA)("int32" === t.dtype, (() => "bandPart(): numLower's dtype must be an int32.")), s = (0, Zn._)((0, Be.M)(t, 0), a, (0, ht.B)(t, a))), "number" == typeof n ? ((0, h.vA)(n % 1 == 0, (() => `bandPart(): numUpper must be an integer, got ${n}.`)), (0, h.vA)(n <= o, (() => `bandPart(): numUpper (${n}) must not be greater than the number of columns (${o}).`)), u = (0, c.YT)(n < 0 ? o : n, "numUpper", "bandPart")) : ((0, h.vA)("int32" === n.dtype, (() => "bandPart(): numUpper's dtype must be an int32.")), u = (0, Zn._)((0, Be.M)(n, 0), o, (0, ht.B)(n, o))); const l = (0, A.t)(Yt(0, a, 1, "int32"), [-1, 1]), d = Yt(0, o, 1, "int32"), f = (0, gt.j)(l, d), p = (0, Ye.n)((0, Le.I)(f, s), (0, De.D)(f, (0, xt.H)(u))), m = (0, er.U)([a, o], r.dtype); return (0, A.t)((0, Nn.t)((0, Yn.K)((0, A.t)(r, [-1, a, o])).map((e => (0, Zn._)(p, e, m)))), i) } }); const Hr = (0, d.op)({ gramSchmidt_: /** * @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 (e) { let t; if (Array.isArray(e)) { t = !1, (0, h.vA)(null != e && e.length > 0, (() => "Gram-Schmidt process: input must not be null, undefined, or empty")); const n = e[0].shape[0]; for (let t = 1; t < e.length; ++t)(0, h.vA)(e[t].shape[0] === n, (() => `Gram-Schmidt: Non-unique lengths found in the input vectors: (${e[t].shape[0]} vs. ${n})`)) } else t = !0, e = (0, Cn.l)(e, e.shape[0], 0).map((e => (0, En.r)(e, [0]))); (0, h.vA)(e.length <= e[0].shape[0], (() => `Gram-Schmidt: Number of vectors (${e.length}) exceeds number of dimensions (${e[0].shape[0]}).`)); const n = [], r = e; for (let t = 0; t < e.length; ++t)n.push(u.T2.tidy((() => { let e = r[t]; if (t > 0) for (let r = 0; r < t; ++r) { const t = (0, I.l)((0, Fn.c)((0, I.l)(n[r], e)), n[r]); e = (0, gt.j)(e, t) } return (0, pe.y)(e, (0, ir.x)(e, "euclidean")) }))); return t ? (0, Nn.t)(n, 0) : n } }); var qr = n(5287); function Yr(e, t = !1) { return u.T2.tidy((() => { (0, h.vA)(2 === e.shape.length, (() => `qr2d() requires a 2D Tensor, but got a ${e.shape.length}D Tensor.`)); const n = e.shape[0], r = e.shape[1]; let i = Te(n), a = (0, q.o)(e); const o = zn([[1]], [1, 1]); let s = (0, q.o)(o); const l = n >= r ? r : n; for (let e = 0; e < l; ++e) { const t = a, l = s, c = i;[s, a, i] = u.T2.tidy((() => { const t = (0, F.d)(a, [e, e], [n - e, 1]), u = (0, ir.x)(t), l = (0, F.d)(a, [e, e], [1, 1]), c = (0, Zn._)((0, Fe.r)(l, 0), zn([[-1]]), zn([[1]])), h = (0, gt.j)(l, (0, I.l)(c, u)), d = (0, pe.y)(t, h); s = 1 === d.shape[0] ? (0, q.o)(o) : (0, E.x)([o, (0, F.d)(d, [1, 0], [d.shape[0] - 1, d.shape[1]])], 0); const f = (0, xt.H)((0, pe.y)((0, N.N)(c, h), u)), p = (0, F.d)(a, [e, 0], [n - e, r]), m = (0, I.l)(f, s), g = (0, rr.m)(s); if (0 === e) a = (0, gt.j)(p, (0, N.N)(m, (0, N.N)(g, p))); else { const t = (0, gt.j)(p, (0, N.N)(m, (0, N.N)(g, p))); a = (0, E.x)([(0, F.d)(a, [0, 0], [e, r]), t], 0) } const y = (0, rr.m)(m), b = (0, F.d)(i, [0, e], [n, i.shape[1] - e]); if (0 === e) i = (0, gt.j)(b, (0, N.N)((0, N.N)(b, s), y)); else { const t = (0, gt.j)(b, (0, N.N)((0, N.N)(b, s), y)); i = (0, E.x)([(0, F.d)(i, [0, 0], [n, e]), t], 1) } return [s, a, i] })), (0, qr.AS)([t, l, c]) } return !t && n > r && (i = (0, F.d)(i, [0, 0], [n, r]), a = (0, F.d)(a, [0, 0], [r, r])), [i, a] })) } const Xr = (0, d.op)({ qr_: /** * @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 (e, t = !1) { if ((0, h.vA)(e.rank >= 2, (() => `qr() requires input tensor to have a rank >= 2, but got rank ${e.rank}`)), 2 === e.rank) return Yr(e, t); { const n = e.shape.slice(0, e.shape.length - 2).reduce(((e, t) => e * t)), r = (0, Yn.K)((0, A.t)(e, [n, e.shape[e.shape.length - 2], e.shape[e.shape.length - 1]]), 0), i = [], a = []; r.forEach((e => { const [n, r] = Yr(e, t); i.push(n), a.push(r) })); return [(0, A.t)((0, Nn.t)(i, 0), e.shape), (0, A.t)((0, Nn.t)(a, 0), e.shape)] } } }); var Kr = n(4703); const Zr = (0, d.op)({ computeWeightedLoss_: function (e, t, n = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const r = (0, c.YT)(e, "losses", "computeWeightedLoss"); let i = null; null != t && (i = (0, c.YT)(t, "weights", "computeWeightedLoss")); const a = null == i ? r : (0, I.l)(r, i); if (n === Kr.i.NONE) return a; if (n === Kr.i.SUM) return (0, Fn.c)(a); if (n === Kr.i.MEAN) { if (null == i) return (0, ot.i)(a); { const e = r.size / i.size, t = (0, pe.y)((0, Fn.c)(a), (0, Fn.c)(i)); return e > 1 ? (0, pe.y)(t, (0, sn.d)(e)) : t } } if (n === Kr.i.SUM_BY_NONZERO_WEIGHTS) { if (null == i) return (0, pe.y)((0, Fn.c)(a), (0, sn.d)(r.size)); { const e = (0, I.l)(i, (0, st.S)(r.shape)), t = (0, _.w)((0, Fn.c)((0, wt.E)(e, (0, sn.d)(0))), "float32"); return (0, pe.y)((0, Fn.c)(a), t) } } throw Error(`Unknown reduction: ${n}`) } }); const Jr = (0, d.op)({ absoluteDifference_: /** * @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 (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "absoluteDifference"), o = (0, c.YT)(t, "predictions", "absoluteDifference"); let s = null; null != n && (s = (0, c.YT)(n, "weights", "absoluteDifference")), (0, h.O3)(a.shape, o.shape, "Error in absoluteDifference: "); const u = (0, i.t)((0, gt.j)(a, o)); return Zr(u, s, r) } }); const Qr = (0, d.op)({ cosineDistance_: function (e, t, n, r, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "cosineDistance"), o = (0, c.YT)(t, "predictions", "cosineDistance"); let s = null; null != r && (s = (0, c.YT)(r, "weights", "cosineDistance")), (0, h.O3)(a.shape, o.shape, "Error in cosineDistance: "); const u = (0, sn.d)(1), l = (0, gt.j)(u, (0, Fn.c)((0, I.l)(a, o), n, !0)); return Zr(l, s, i) } }); const ei = (0, d.op)({ hingeLoss_: function (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { let i = (0, c.YT)(e, "labels", "hingeLoss"); const a = (0, c.YT)(t, "predictions", "hingeLoss"); let o = null; null != n && (o = (0, c.YT)(n, "weights", "hingeLoss")), (0, h.O3)(i.shape, a.shape, "Error in hingeLoss: "); const s = (0, sn.d)(1); i = (0, gt.j)((0, I.l)((0, sn.d)(2), i), s); const u = (0, Zt.V)((0, gt.j)(s, (0, I.l)(i, a))); return Zr(u, o, r) } }); const ti = (0, d.op)({ huberLoss_: /** * @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 (e, t, n, r = 1, a = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const o = (0, c.YT)(e, "labels", "huberLoss"), u = (0, c.YT)(t, "predictions", "huberLoss"); let l = null; null != n && (l = (0, c.YT)(n, "weights", "huberLoss")), (0, h.O3)(o.shape, u.shape, "Error in huberLoss: "); const d = (0, sn.d)(r), f = (0, i.t)((0, gt.j)(u, o)), p = (0, ht.B)(f, d), m = (0, gt.j)(f, p), g = (0, s.W)((0, I.l)((0, sn.d)(.5), (0, mt.E)(p)), (0, I.l)(d, m)); return Zr(g, l, a) } }); const ni = (0, d.op)({ logLoss_: /** * @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 (e, t, n, r = 1e-7, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const a = (0, c.YT)(e, "labels", "logLoss"), o = (0, c.YT)(t, "predictions", "logLoss"); let u = null; null != n && (u = (0, c.YT)(n, "weights", "logLoss")), (0, h.O3)(a.shape, o.shape, "Error in logLoss: "); const l = (0, sn.d)(1), d = (0, sn.d)(r), f = (0, xt.H)((0, I.l)(a, (0, We.R)((0, s.W)(o, d)))), p = (0, I.l)((0, gt.j)(l, a), (0, We.R)((0, s.W)((0, gt.j)(l, o), d))), m = (0, gt.j)(f, p); return Zr(m, u, i) } }); const ri = (0, d.op)({ meanSquaredError_: /** * @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 (e, t, n, r = Kr.i.SUM_BY_NONZERO_WEIGHTS) { const i = (0, c.YT)(e, "labels", "meanSquaredError"), a = (0, c.YT)(t, "predictions", "meanSquaredError"); let o = null; null != n && (o = (0, c.YT)(n, "weights", "meanSquaredError")), (0, h.O3)(i.shape, a.shape, "Error in meanSquaredError: "); const s = (0, Tn.P)(i, a); return Zr(s, o, r) } }); const ii = (0, d.op)({ sigmoidCrossEntropy_: function (e, t, n, r = 0, a = Kr.i.SUM_BY_NONZERO_WEIGHTS) { let o = (0, c.YT)(e, "multiClassLabels", "sigmoidCrossEntropy"); const u = (0, c.YT)(t, "logits", "sigmoidCrossEntropy"); let l = null; if (null != n && (l = (0, c.YT)(n, "weights", "sigmoidCrossEntropy")), (0, h.O3)(o.shape, u.shape, "Error in sigmoidCrossEntropy: "), r > 0) { const e = (0, sn.d)(r), t = (0, sn.d)(1), n = (0, sn.d)(.5); o = (0, s.W)((0, I.l)(o, (0, gt.j)(t, e)), (0, I.l)(n, e)) } const d = /** * @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 (e, t) { const n = (0, c.YT)(e, "labels", "sigmoidCrossEntropyWithLogits"), r = (0, c.YT)(t, "logits", "sigmoidCrossEntropyWithLogits"); (0, h.O3)(n.shape, r.shape, "Error in sigmoidCrossEntropyWithLogits: "); const a = (0, Zt.V)(r), o = (0, I.l)(r, n), u = (0, Ve.K)((0, Se.o)((0, xt.H)((0, i.t)(r)))); return (0, s.W)((0, gt.j)(a, o), u) }(o, u); return Zr(d, l, a) } }); const ai = (0, d.op)({ softmaxCrossEntropy_: function (e, t, n, r = 0, i = Kr.i.SUM_BY_NONZERO_WEIGHTS) { let a = (0, c.YT)(e, "onehotLabels", "softmaxCrossEntropy"); const o = (0, c.YT)(t, "logits", "softmaxCrossEntropy"); let u = null; if (null != n && (u = (0, c.YT)(n, "weights", "softmaxCrossEntropy")), (0, h.O3)(a.shape, o.shape, "Error in softmaxCrossEntropy: "), r > 0) { const e = (0, sn.d)(r), t = (0, sn.d)(1), n = (0, sn.d)(a.shape[1]); a = (0, s.W)((0, I.l)(a, (0, gt.j)(t, e)), (0, pe.y)(e, n)) } const l = /** * @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 (e, t, n = -1) { if (-1 === n && (n = t.rank - 1), n !== t.rank - 1) throw Error(`Softmax cross entropy along a non-last dimension is not yet supported. Labels / logits was rank ${t.rank} and dim was ${n}`); const r = (0, pr._X)(((e, t, r) => { const i = (0, qe.V)(t, [n], !0), a = (0, gt.j)((0, _.w)(t, "float32"), i); r([e, a]); const o = (0, xt.H)((0, I.l)(a, e)); return { value: (0, Fn.c)(o, [n]), gradFunc: (e, t) => { const [r, i] = t, a = (0, pt.SM)(e.shape, [n]); return [(0, I.l)((0, A.t)(e, a), (0, gt.j)((0, _.w)(r, "float32"), (0, Se.o)(i))), (0, I.l)((0, A.t)(e, a), (0, gt.j)((0, Se.o)(i), (0, _.w)(r, "float32")))] } } })); return r(e, t) }(a, o); return Zr(l, u, i) } }); const oi = (0, d.op)({ sparseFillEmptyRows_: /** * @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 (e, t, n, r) { const i = (0, c.YT)(e, "indices", "sparseFillEmptyRows", "int32"), a = (0, c.YT)(t, "values", "sparseFillEmptyRows"), o = (0, c.YT)(n, "denseShape", "sparseFillEmptyRows", "int32"), s = (0, c.YT)(r, "defaultValue", "sparseFillEmptyRows", a.dtype); if (2 !== i.rank) throw new Error(`Indices should be Tensor2D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Values should be Tensor1D but received shape ${a.shape}`); if (1 !== o.rank) throw new Error(`Dense shape should be Tensor1D but received shape ${o.shape}`); if (0 !== s.rank) throw new Error(`Default value should be a scalar but received shape ${s.shape}`); const h = { indices: i, values: a, denseShape: o, defaultValue: s }, d = u.T2.runKernel(l.C8s, h); return { outputIndices: d[0], outputValues: d[1], emptyRowIndicator: d[2], reverseIndexMap: d[3] } } }); const si = (0, d.op)({ sparseReshape_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "inputIndices", "sparseReshape", "int32"), i = (0, c.YT)(t, "inputShape", "sparseReshape", "int32"), a = (0, c.YT)(n, "newShape", "sparseReshape", "int32"); if (2 !== r.rank) throw new Error(`Input indices should be Tensor2D but received shape\n ${r.shape}`); if (1 !== i.rank) throw new Error(`Input shape should be Tensor1D but received shape ${i.shape}`); if (1 !== a.rank) throw new Error(`New shape should be Tensor1D but received shape ${a.shape}`); const o = { inputIndices: r, inputShape: i, newShape: a }, s = u.T2.runKernel(l.BoJ, o); return { outputIndices: s[0], outputShape: s[1] } } }); const ui = (0, d.op)({ sparseSegmentMean_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "data", "sparseSegmentMean"), i = (0, c.YT)(t, "indices", "sparseSegmentMean", "int32"), a = (0, c.YT)(n, "segmentIds", "sparseSegmentMean", "int32"); if (r.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.rank) throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Segment ids should be Tensor1D but received shape\n ${a.shape}`); const o = { data: r, indices: i, segmentIds: a }; return u.T2.runKernel(l.L6G, o) } }); const li = (0, d.op)({ sparseSegmentSum_: /** * @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 (e, t, n) { const r = (0, c.YT)(e, "data", "sparseSegmentSum"), i = (0, c.YT)(t, "indices", "sparseSegmentSum", "int32"), a = (0, c.YT)(n, "segmentIds", "sparseSegmentSum", "int32"); if (r.rank < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.rank) throw new Error(`Indices should be Tensor1D but received shape\n ${i.shape}`); if (1 !== a.rank) throw new Error(`Segment ids should be Tensor1D but received shape\n ${a.shape}`); const o = { data: r, indices: i, segmentIds: a }; return u.T2.runKernel(l.DvZ, o) } }); const ci = (0, d.op)({ stringNGrams_: /** * @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 (e, t, n, r, i, a, o, s) { const h = (0, c.YT)(e, "data", "stringNGrams", "string"); if ("string" !== h.dtype) throw new Error("Data must be of datatype string"); if (1 !== h.shape.length) throw new Error(`Data must be a vector, saw: ${h.shape}`); const d = (0, c.YT)(t, "dataSplits", "stringNGrams"); if ("int32" !== d.dtype) throw new Error("Data splits must be of datatype int32"); const f = { separator: n, nGramWidths: r, leftPad: i, rightPad: a, padWidth: o, preserveShortSequences: s }, p = { data: h, dataSplits: d }, m = u.T2.runKernel(l.YAb, p, f); return { nGrams: m[0], nGramsSplits: m[1] } } }); const hi = (0, d.op)({ stringSplit_: /** * @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 (e, t, n = !0) { const r = (0, c.YT)(e, "input", "stringSplit", "string"), i = (0, c.YT)(t, "delimiter", "stringSplit", "string"); if (1 !== r.rank) throw new Error(`Input should be Tensor1D but received shape ${r.shape}`); if (0 !== i.rank) throw new Error(`Delimiter should be a scalar but received shape ${i.shape}`); const a = { skipEmpty: n }, o = { input: r, delimiter: i }, s = u.T2.runKernel(l.iW0, o, a); return { indices: s[0], values: s[1], shape: s[2] } } }); const di = (0, d.op)({ stringToHashBucketFast_: /** * @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 (e, t) { const n = (0, c.YT)(e, "input", "stringToHashBucketFast", "string"), r = { numBuckets: t }; if (t <= 0) throw new Error("Number of buckets must be at least 1"); const i = { input: n }; return u.T2.runKernel(l.$jE, i, r) } }); const fi = (0, d.op)({ staticRegexReplace_: /** * @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 (e, t, n, r = !0) { const i = (0, c.YT)(e, "input", "staticRegexReplace", "string"), a = { pattern: t, rewrite: n, replaceGlobal: r }; return u.T2.runKernel(l.GZp, { x: i }, a) } }), pi = { fft: wn.h, ifft: kn.K, rfft: _n.z, irfft: Sn.g }, mi = { hammingWindow: _r, hannWindow: Cr, frame: Ar, stft: Tr }, gi = { flipLeftRight: Nr, grayscaleToRGB: Ir, resizeNearestNeighbor: Ur.b, resizeBilinear: jr.v, rgbToGrayscale: Mr, rotateWithOffset: Fr, cropAndResize: Er, nonMaxSuppression: $r, nonMaxSuppressionAsync: Or, nonMaxSuppressionWithScore: zr, nonMaxSuppressionWithScoreAsync: Pr, nonMaxSuppressionPadded: Br, nonMaxSuppressionPaddedAsync: Lr, threshold: Wr, transform: Vr }, yi = { bandPart: Gr, gramSchmidt: Hr, qr: Xr }, bi = { absoluteDifference: Jr, computeWeightedLoss: Zr, cosineDistance: Qr, hingeLoss: ei, huberLoss: ti, logLoss: ni, meanSquaredError: ri, sigmoidCrossEntropy: ii, softmaxCrossEntropy: ai }, vi = { sparseFillEmptyRows: oi, sparseReshape: si, sparseSegmentMean: ui, sparseSegmentSum: li }, xi = { stringNGrams: ci, stringSplit: hi, stringToHashBucketFast: di, staticRegexReplace: fi } }, 5661: (e, t, n) => { "use strict"; n.d(t, { e: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ pad_: /** * @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 (e, t, n = 0) { const o = (0, a.YT)(e, "x", "pad"); if (0 === o.rank) throw new Error("pad(scalar) is not defined. Pass non-scalar to pad"); const s = { paddings: t, constantValue: n }, u = { x: o }; return r.T2.runKernel(i.ODT, u, s) } }) }, 7872: (e, t, n) => { "use strict"; n.d(t, { d: () => d }); var r = n(8189), i = n(5119), a = n(3909), o = n(9772), s = n(7195), u = n(6999), l = n(929), c = n(2302), h = n(776); const d = (0, l.op)({ pool_: /** * @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 (e, t, n, l, d, f, p) { null == d && (d = [1, 1]), null == f && (f = 1), 0 === l && (l = "valid"); const m = (0, r.YT)(e, "x", "maxPool"); let g = m, y = !1; 3 === m.rank && (y = !0, g = (0, c.t)(m, [1, m.shape[0], m.shape[1], m.shape[2]])), i.vA(s.G0(f, d), (() => `Error in pool: Either strides or dilations must be 1. Got strides ${f} and dilations '${d}'`)); const b = s.E6(g.shape, t, f, d, l), v = [b.dilationHeight, b.dilationWidth]; let x; x = "same" === l ? function (e, t) { const n = e.map(((e, n) => e + (e - 1) * (t[n] - 1))), r = n.map((e => e - 1)), i = r.map((e => Math.floor(e / 2))), a = r.map(((e, t) => e - i[t])); return r.map(((e, t) => [i[t], a[t]])) }([b.filterHeight, b.filterWidth], v) : [[0, 0], [0, 0]]; const w = 1 === v[0] && 1 === v[1], [k, S] = function (e, t, n) { const r = n.map((e => e[0])), i = n.map((e => e[1])), a = e.concat(r, i), o = t.map(((e, t) => (e - a[t] % e) % e)), s = i.map(((e, t) => e + o[t])), u = t.map(((e, t) => [r[t], s[t]])), l = t.map(((e, t) => [0, o[t]])); return [u, l] }([b.inHeight, b.inWidth], v, x), _ = w ? l : "valid", C = w ? g : (0, h.e)(g, v, k), A = ("avg" === n ? () => (0, a.$)(C, t, f, _, p) : () => (0, u.j)(C, t, f, _, p))(), T = w ? A : (0, o.G)(A, v, S); return y ? (0, c.t)(T, [T.shape[1], T.shape[2], T.shape[3]]) : T } }) }, 8990: (e, t, n) => { "use strict"; n.d(t, { n: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ pow_: /** * @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 (e, t) { let n = (0, o.YT)(e, "base", "pow"), s = (0, o.YT)(t, "exp", "pow");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.pyJ, u) } }) }, 4394: (e, t, n) => { "use strict"; n.d(t, { N: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ prelu_: /** * @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 (e, t) { const n = { x: (0, a.YT)(e, "x", "prelu"), alpha: (0, a.YT)(t, "alpha", "prelu") }; return r.T2.runKernel(i.Ncv, n) } }) }, 5295: (e, t, n) => { "use strict"; /** * @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 r(e, t = !1) { console.log(e.toString(t)) } n.d(t, { y: () => r }) }, 7771: (e, t, n) => { "use strict"; n.d(t, { _: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(9809); const s = (0, n(929).op)({ prod_: /** * @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 (e, t = null, n = !1) { let s = (0, a.YT)(e, "x", "prod"); "bool" === s.dtype && (s = (0, o.w)(s, "int32")); const u = { x: s }, l = { axis: t, keepDims: n }; return r.T2.runKernel(i.kdj, u, l) } }) }, 1902: (e, t, n) => { "use strict"; n.d(t, { x: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ real_: /** * @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 (e) { const t = { input: (0, a.YT)(e, "input", "real") }; return r.T2.runKernel(i.LRy, t) } }) }, 9870: (e, t, n) => { "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ reciprocal_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "reciprocal") }; return r.T2.runKernel(i.huO, t) } }) }, 112: (e, t, n) => { "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ relu_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "relu") }; return r.T2.runKernel(i.fUj, t) } }) }, 3732: (e, t, n) => { "use strict"; n.d(t, { j: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ relu6_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "relu6") }; return r.T2.runKernel(i.P_L, t) } }) }, 2302: (e, t, n) => { "use strict"; n.d(t, { t: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ reshape_: /** * @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 (e, t) { const n = { x: (0, a.YT)(e, "x", "reshape", "string_or_numeric") }, o = { shape: t }; return r.T2.runKernel(i.R23, n, o) } }) }, 3262: (e, t, n) => { "use strict"; n.d(t, { B: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ reverse_: /** * @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 (e, t) { const n = { x: (0, a.YT)(e, "x", "reverse") }, o = { dims: t }; return r.T2.runKernel(i.D7i, n, o) } }) }, 5912: (e, t, n) => { "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ round_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "round") }; return r.T2.runKernel(i.hVg, t) } }) }, 7820: (e, t, n) => { "use strict"; n.d(t, { Z: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ rsqrt_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "rsqrt", "float32") }; return r.T2.runKernel(i.TOR, t) } }) }, 5702: (e, t, n) => { "use strict"; n.d(t, { d: () => a }); var r = n(3879), i = n(9171); /** * @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 a(e, t) { if (((0, r.isTypedArray)(e) && "string" !== t || Array.isArray(e)) && "complex64" !== t) throw new Error("Error creating a new Scalar: value must be a primitive (number|boolean|string)"); if ("string" === t && (0, r.isTypedArray)(e) && !(e instanceof Uint8Array)) throw new Error("When making a scalar from encoded string, the value must be `Uint8Array`."); return (0, i.Q)(e, [], [], t) } }, 6170: (e, t, n) => { "use strict"; n.r(t), n.d(t, { calculateShapes: () => o, validateInput: () => a, validateUpdateShape: () => i }); var r = n(5119); function i(e, t, n) { const r = t.rank > 1 ? t.shape[t.rank - 1] : 1, i = t.rank > 1 ? t.rank - 1 : 1, a = `Must have updates.shape = indices.shape[:batchDim] + shape[sliceDim:], got updates.shape: ${n.shape}, indices.shape: ${t.shape}, shape: ${e}, sliceDim: ${r}, and batchDim: ${i}.`; if (n.rank < i) throw new Error(a + ` update.rank < ${i}. `); if (e.length < r + (n.rank - i)) throw new Error(a + ` Output shape length < ${r + (n.rank - i)}`); if (n.rank !== i + e.length - r) throw new Error(a + " update.rank != " + (i + e.length - r)); for (let e = 0; e < i; ++e)if (n.shape[e] !== t.shape[e]) throw new Error(a + ` updates.shape[${e}] (${n.shape[e]}) != indices.shape[${e}] (${t.shape[e]}).`); for (let t = 0; t < n.rank - i; ++t)if (n.shape[t + i] !== e[t + r]) throw new Error(a + ` updates.shape[${t + i}] (${n.shape[t + i]}) != shape[${t + i}] (${e[t + i]})`) } function a(e, t, n) { if (t.rank < 1) throw new Error(`tf.scatterND() expects the indices to be rank 1 or higher, but the rank was ${t.rank}.`); if (e.rank < 1) throw new Error(`tf.scatterND() expects the updates to be rank 1 or higher, but the rank was ${e.rank}.`); if ("int32" !== t.dtype) throw new Error(`The dtype of 'indices' should be int32, but got dtype: ${t.dtype}`); if (n.length < 1) throw new Error(`Output rank must be greater or equal to 1, but got shape: ${n}`); if (0 === n.length) { if (0 === t.size) throw new Error(`Indices specified for empty output. indices shape: ${t.shape}`); if (0 === e.size) throw new Error(`Updates specified for empty output. updates shape: ${e.shape}`) } i(n, t, e) } function o(e, t, n) { const i = t.shape.length, a = i > 1 ? t.shape[i - 1] : 1, o = n.length; let s = 1; for (let e = a; e < o; ++e)s *= n[e]; const u = a < 1 ? 1 : a; return { sliceRank: a, numUpdates: (0, r.Ze)(t.shape) / u, sliceSize: s, strides: [...(0, r.Ur)(n.slice(0, a)), 1], outputSize: (0, r.Ze)(n) } } }, 6325: (e, t, n) => { "use strict"; n.d(t, { W: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ selu_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "selu") }; return r.T2.runKernel(i.u$b, t) } }) }, 8576: (e, t, n) => { "use strict"; n.d(t, { X: () => i, j: () => r }); /** * @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 r = 1.7580993408473768, i = 1.0507009873554805 }, 9986: (e, t, n) => { "use strict"; n.d(t, { w: () => l }); var r = n(8189), i = n(5119), a = n(8794), o = n(676), s = n(929), u = n(2302); const l = (0, s.op)({ separableConv2d_: function (e, t, n, s, l, c = [1, 1], h = "NHWC") { const d = (0, r.YT)(e, "x", "separableConv2d"), f = (0, r.YT)(t, "depthwiseFilter", "separableConv2d"), p = (0, r.YT)(n, "pointwiseFilter", "separableConv2d"); let m = d, g = !1; if (3 === d.rank && (g = !0, m = (0, u.t)(d, [1, d.shape[0], d.shape[1], d.shape[2]])), "NCHW" === h) throw new Error("separableConv2d currently does not support dataFormat NCHW; only NHWC is supported"); i.vA(4 === m.rank, (() => `Error in separableConv2d: input must be rank 4, but got rank ${m.rank}.`)), i.vA(4 === f.rank, (() => `Error in separableConv2d: depthwise filter must be rank 4, but got rank ${f.rank}.`)), i.vA(4 === p.rank, (() => `Error in separableConv2d: pointwise filter must be rank 4, but got rank ${f.rank}.`)), i.vA(1 === p.shape[0], (() => `Error in separableConv2d: the first dimension of pointwise filter must be 1, but got ${p.shape[0]}.`)), i.vA(1 === p.shape[1], (() => `Error in separableConv2d: the second dimension of pointwise filter must be 1, but got ${p.shape[1]}.`)); const y = f.shape[2], b = f.shape[3]; i.vA(p.shape[2] === y * b, (() => `Error in separableConv2d: the third dimension of pointwise filter must be ${y * b}, but got ${p.shape[2]}.`)); const v = (0, o.G)(m, f, s, l, h, c), x = (0, a.X)(v, p, 1, "valid", h); return g ? (0, u.t)(x, [x.shape[1], x.shape[2], x.shape[3]]) : x } }) }, 8968: (e, t, n) => { "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ sigmoid_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "sigmoid", "float32") }; return r.T2.runKernel(i.vI1, t) } }) }, 1115: (e, t, n) => { "use strict"; n.d(t, { _: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ sign_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "sign") }; return r.T2.runKernel(i.YVe, t) } }) }, 3726: (e, t, n) => { "use strict"; n.d(t, { F: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ sin_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "sin", "float32") }; return r.T2.runKernel(i.hql, t) } }) }, 8276: (e, t, n) => { "use strict"; n.d(t, { L: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ sinh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "sinh") }; return r.T2.runKernel(i.J3C, t) } }) }, 7986: (e, t, n) => { "use strict"; n.d(t, { d: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ slice_: /** * @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 (e, t, n) { const o = (0, a.YT)(e, "x", "slice", "string_or_numeric"); if (0 === o.rank) throw new Error("Slicing scalar is not possible"); const s = { x: o }, u = { begin: t, size: n }; return r.T2.runKernel(i.JiE, s, u) } }) }, 4969: (e, t, n) => { "use strict"; n.r(t), n.d(t, { assertParamsValid: () => o, computeFlatOffset: () => v, computeOutShape: () => u, getNormalizedAxes: () => d, isSliceContinous: () => b, maskToAxes: () => s, parseSliceParams: () => x, sliceInfo: () => w, startForAxis: () => g, startIndicesWithElidedDims: () => f, stopForAxis: () => y, stopIndicesWithElidedDims: () => p, stridesForAxis: () => m, stridesWithElidedDims: () => l }); var r = n(5119); /** * @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 i = -2, a = -1; function o(e, t, n) { const i = e.shape.length; r.vA(i === t.length, (() => `Error in slice${i}D: Length of begin ${t} must match the rank of the array (${i}).`)), r.vA(i === n.length, (() => `Error in slice${i}D: Length of size ${n} must match the rank of the array (${i}).`)); for (let a = 0; a < i; ++a)r.vA(t[a] + n[a] <= e.shape[a], (() => `Error in slice${i}D: begin[${a}] + size[${a}] (${t[a] + n[a]}) would overflow input.shape[${a}] (${e.shape[a]})`)) } function s(e) { const t = []; let n = 0; for (; e > 0;)1 & e && t.push(n), e /= 2, n++; return t } function u(e, t, n) { const r = []; for (let i = 0; i < e.length; i++)r[i] = Math.ceil((t[i] - e[i]) / n[i]); return r } function l(e, t, n, r) { const i = [...e]; for (let e = i.length; e < r.length; e++)i.push(1); for (let e = 0; e < n; e++)0 === e ? i[t] = 1 : (i.splice(t, 0, 1), i.pop()); return i } function c(e, t, n) { return n <= e ? n : n - (t - 1) } function h(e, t) { const n = []; for (let r = 0; r < e; r++)n.push(t + r); return n } function d(e, t, n, r, i, a, o, s, u) { const c = e.length; let h = new Array(c), d = new Array(c), b = new Array(c); if (t.length && n > 0) { const u = t[0], c = n + 1; h = f(o, u, c, r, e), d = p(s, u, c, i, e), b = l(a, u, c, e) } else for (let t = 0; t < c; t++)h[t] = g(o, r, a, e, t, u), d[t] = y(s, i, a, e, t, u), b[t] = m(a, t, u); return { begin: h, end: d, strides: b } } function f(e, t, n, r, i) { const a = [...i], o = h(n, t); for (let i = 0; i < a.length; i++)if (o.indexOf(i) > -1) a[i] = 0; else { const o = c(t, n, i); let s = r[o]; e & 1 << o && (s = 0), a[i] = s } return a } function p(e, t, n, i, a) { const o = [...a], s = h(n, t); for (let r = 0; r < o.length; r++)if (s.indexOf(r) > -1) o[r] = Number.MAX_SAFE_INTEGER; else { const a = c(t, n, r); let s = i[a]; e & 1 << a && (s = Number.MAX_SAFE_INTEGER), o[r] = s } for (let e = 0; e < o.length; e++) { const t = a[e]; o[e] < 0 && (o[e] += t), o[e] = r.qE(0, o[e], a[e]) } return o } function m(e, t, n) { let r = e[t]; return (n & 1 << t || null == r) && (r = 1), r } function g(e, t, n, i, a, o) { let s = t[a]; const u = n[a] || 1; (e & 1 << a || o & 1 << a || null == s) && (s = u > 0 ? Number.MIN_SAFE_INTEGER : Number.MAX_SAFE_INTEGER); const l = i[a]; return s < 0 && (s += l), s = r.qE(0, s, l - 1), s } function y(e, t, n, i, a, o) { let s = t[a]; const u = n[a] || 1; (e & 1 << a || o & 1 << a || null == s) && (s = u > 0 ? Number.MAX_SAFE_INTEGER : Number.MIN_SAFE_INTEGER); const l = i[a]; return s < 0 && (s += l), s = u > 0 ? r.qE(0, s, l) : r.qE(-1, s, l - 1), s } function b(e, t, n) { let r = n.length; for (let e = 0; e < n.length; e++)if (n[e] > 1) { r = e; break } for (let i = r + 1; i < n.length; i++)if (t[i] > 0 || n[i] !== e[i]) return !1; return !0 } function v(e, t) { let n = e.length > 0 ? e[e.length - 1] : 1; for (let r = 0; r < e.length - 1; r++)n += e[r] * t[r]; return n } function x(e, t, n) { let i; const a = e.shape.length; let o; return i = "number" == typeof t ? [t, ...new Array(a - 1).fill(0)] : t.length < a ? t.concat(new Array(a - t.length).fill(0)) : t.slice(), i.forEach((e => { r.vA(-1 !== e, (() => "slice() does not support negative begin indexing.")) })), o = null == n ? new Array(a).fill(-1) : "number" == typeof n ? [n, ...new Array(a - 1).fill(-1)] : n.length < a ? n.concat(new Array(a - n.length).fill(-1)) : n, o = o.map(((t, n) => t >= 0 ? t : (r.vA(-1 === t, (() => `Negative size values should be exactly -1 but got ${t} for the slice() size at index ${n}.`)), e.shape[n] - i[n]))), [i, o] } function w(e, t, n, r, o, s, u, l, c) { let h; if (null == r ? (h = new Array(t.length), h.fill(1)) : h = r, null != u && u & u - 1) throw new Error("Multiple ellipses in slice is not allowed."); let d = !1; const f = { dims: h.length, numAddAxisAfterEllipsis: 0, begin: t.slice(), end: n.slice(), strides: h.slice(), beginMask: o, endMask: s, ellipsisMask: u, newAxisMask: l, shrinkAxisMask: c }; for (let e = 0; e < f.dims; e++)d && 1 << e & l && f.numAddAxisAfterEllipsis++, 1 << e & u && (d = !0); d || (f.ellipsisMask |= 1 << f.dims, f.dims++); const p = { dims: e.length, beginMask: 0, endMask: 0, beginValid: !1, endValid: !1 }; !function (e, t) { t.beginMask = 0, t.endMask = 0, t.shrinkAxisMask = 0; let n = 0; t.beginValid = null != e.begin, t.endValid = null != e.end, t.begin = new Array(t.dims), t.end = new Array(t.dims), t.strides = new Array(t.dims), t.finalShapeGatherIndices = [], t.finalShapeGatherIndicesSparse = [], t.inputShapeGatherIndicesSparse = new Array(t.dims); for (let r = 0; r < e.dims; r++)if (1 << r & e.ellipsisMask) { const i = Math.min(t.dims - (e.dims - r) + 1 + e.numAddAxisAfterEllipsis, t.dims); for (; n < i; n++)t.begin[n] = 0, t.end[n] = 0, t.strides[n] = 1, t.beginMask |= 1 << n, t.endMask |= 1 << n, t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(-1), t.inputShapeGatherIndicesSparse[n] = r } else if (1 << r & e.newAxisMask) t.finalShapeGatherIndices.push(i), t.finalShapeGatherIndicesSparse.push(-1); else { if (n === t.begin.length) throw Error(`Index out of range using input dim ${n}; input has only ${t.dims} dims, ${t.begin.length}.`); null != e.begin && (t.begin[n] = e.begin[r]), null != e.end && (t.end[n] = e.end[r]), t.strides[n] = e.strides[r], e.beginMask & 1 << r && (t.beginMask |= 1 << n), e.endMask & 1 << r && (t.endMask |= 1 << n), e.shrinkAxisMask & 1 << r ? (t.finalShapeGatherIndices.push(a), t.finalShapeGatherIndicesSparse.push(-1), t.shrinkAxisMask |= 1 << n) : (t.finalShapeGatherIndices.push(n), t.finalShapeGatherIndicesSparse.push(r)), t.inputShapeGatherIndicesSparse[n] = r, n++ } }(f, p); let m = !0, g = !0, y = !0; const b = [], v = []; for (let t = 0; t < e.length; ++t) { if (0 === p.strides[t]) throw Error(`strides[${t}] must be non-zero`); const n = !!(p.shrinkAxisMask & 1 << t), r = e[t]; if (-1 === r) { b.push(n ? 1 : -1); continue } const i = [p.beginMask & 1 << t, p.endMask & 1 << t], a = [p.strides[t] > 0 ? 0 : -1, p.strides[t] > 0 ? r : r - 1]; if (n && p.strides[t] <= 0) throw Error("only stride 1 allowed on non-range indexing."); y = y && 1 === p.strides[t]; const o = !!(p.beginMask & 1 << t && p.endMask & 1 << t); if (p.beginValid && p.endValid) { if (n) { const e = p.begin[t] < 0 ? r + p.begin[t] : p.begin[t]; if (p.begin[t] = e, p.end[t] = p.begin[t] + 1, e < 0 || e >= r) throw Error(`slice index ${p.begin[t]} of dimension ${t} out of bounds.`) } else p.begin[t] = k(p.begin[t], 0, p.strides[t], r, i, a), p.end[t] = k(p.end[t], 1, p.strides[t], r, i, a); const e = 1 === p.strides[t] && 0 === p.begin[t] && p.end[t] === r; m = m && e, g = g && (0 === t && 1 === p.strides[t] || e) } else m = m && 1 === p.strides[t] && o, g = g && (0 === t && 1 === p.strides[t] || o); let s, u = !1; if (p.beginValid && p.endValid ? (s = p.end[t] - p.begin[t], u = !0) : n ? (s = 1, u = !0) : o && r >= 0 && (s = p.strides[t] < 0 ? -r : r, u = !0), u) { let e; e = 0 === s || s < 0 != p.strides[t] < 0 ? 0 : Math.trunc(s / p.strides[t]) + (s % p.strides[t] != 0 ? 1 : 0), b.push(e) } else b.push(-1) } for (let e = 0; e < p.finalShapeGatherIndices.length; ++e) { const t = p.finalShapeGatherIndices[e]; t >= 0 ? v.push(b[t]) : t === i && v.push(1) } return { finalShapeSparse: v.filter(((e, t) => p.finalShapeGatherIndices[t] !== i)), finalShape: v, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: p.begin, end: p.end, strides: p.strides } } function k(e, t, n, r, i, a) { if (i[t]) return n > 0 ? a[t] : a[t + 1 & 1]; { const t = e < 0 ? r + e : e; return t < a[0] ? a[0] : t > a[1] ? a[1] : t } } }, 6346: (e, t, n) => { "use strict"; n.d(t, { V: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ softmax_: /** * @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 (e, t = -1) { const n = (0, a.YT)(e, "logits", "softmax", "float32"); if (-1 === t && (t = n.rank - 1), t !== n.rank - 1) throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${n.rank} and dim was ${t}`); const o = { logits: n }, s = { dim: t }; return r.T2.runKernel(i.rFG, o, s) } }) }, 6030: (e, t, n) => { "use strict"; n.d(t, { l: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ softplus_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "softplus") }; return r.T2.runKernel(i.Fin, t) } }) }, 776: (e, t, n) => { "use strict"; n.d(t, { e: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ spaceToBatchND_: /** * @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 (e, t, n) { const s = (0, a.YT)(e, "x", "spaceToBatchND"); o.vA(s.rank >= 1 + t.length, (() => `input rank ${s.rank} should be > than [blockShape] ${t.length}`)), o.vA(n.length === t.length, (() => `paddings.shape[0] ${n.length} must be equal to [blockShape] ${t.length}`)), o.vA(s.shape.reduce(((e, r, i) => i > 0 && i <= t.length ? e && (r + n[i - 1][0] + n[i - 1][1]) % t[i - 1] == 0 : e), !0), (() => `input spatial dimensions ${s.shape.slice(1)} with paddings ${n.toString()} must be divisible by blockShapes ${t.toString()}`)); const u = { x: s }, l = { blockShape: t, paddings: n }; return r.T2.runKernel(i.A8B, u, l) } }) }, 1361: (e, t, n) => { "use strict"; n.d(t, { h: () => o }); var r = n(1585), i = n(5441), a = n(5119); const o = (0, n(929).op)({ fft_: /** * @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 (e) { (0, a.vA)("complex64" === e.dtype, (() => `The dtype for tf.spectral.fft() must be complex64 but got ${e.dtype}.`)); const t = { input: e }; return r.T2.runKernel(i.rGP, t) } }) }, 3108: (e, t, n) => { "use strict"; n.d(t, { K: () => o }); var r = n(1585), i = n(5441), a = n(5119); const o = (0, n(929).op)({ ifft_: /** * @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 (e) { (0, a.vA)("complex64" === e.dtype, (() => `The dtype for tf.spectral.ifft() must be complex64 but got ${e.dtype}.`)); const t = { input: e }; return r.T2.runKernel(i.OAQ, t) } }) }, 2292: (e, t, n) => { "use strict"; n.d(t, { g: () => p }); var r = n(7148), i = n(5030), a = n(5040), o = n(9258), s = n(929), u = n(1902), l = n(2302), c = n(3262), h = n(5702), d = n(7986), f = n(3108); const p = (0, s.op)({ irfft_: /** * @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 (e) { const t = e.shape[e.shape.length - 1], n = e.size / t; let s; if (t <= 2) { const r = (0, l.t)(e, [n, t]); s = (0, f.K)(r) } else { const p = [n, 2 * (t - 1)], m = (0, l.t)((0, u.x)(e), [n, t]), g = (0, l.t)((0, a.n)(e), [n, t]), y = (0, c.B)((0, d.d)(m, [0, 1], [n, t - 2]), 1), b = (0, o.l)((0, c.B)((0, d.d)(g, [0, 1], [n, t - 2]), 1), (0, h.d)(-1)), v = (0, i.x)([m, y], 1), x = (0, i.x)([g, b], 1), w = (0, l.t)((0, r.f)(v, x), [p[0], p[1]]); s = (0, f.K)(w) } if (s = (0, u.x)(s), 3 === e.rank && 0 !== e.shape[0]) { const t = s, n = e.shape[0]; s = (0, l.t)(s, [n, s.shape[0] / n, s.shape[1]]), t.dispose() } return s } }) }, 8775: (e, t, n) => { "use strict"; n.d(t, { z: () => m }); var r = n(5119), i = n(7148), a = n(5030), o = n(5040), s = n(929), u = n(1902), l = n(2302), c = n(7986), h = n(6512), d = n(2855), f = n(5537), p = n(1361); const m = (0, s.op)({ rfft_: /** * @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 (e, t) { (0, r.vA)("float32" === e.dtype, (() => `The dtype for rfft() must be real value but got ${e.dtype}`)); let n = e.shape[e.shape.length - 1]; const s = e.size / n; let m; if (null != t && t < n) { const r = e.shape.map((e => 0)), i = e.shape.map((e => e)); i[e.shape.length - 1] = t, m = (0, c.d)(e, r, i), n = t } else if (null != t && t > n) { const r = e.shape.map((e => e)); r[e.shape.length - 1] = t - n, m = (0, a.x)([e, (0, d.U)(r)], e.shape.length - 1), n = t } else m = e; const g = (0, f.P)(m), y = (0, l.t)((0, i.f)(m, g), [s, n]), b = (0, p.h)(y), v = Math.floor(n / 2) + 1, x = (0, u.x)(b), w = (0, o.n)(b), k = (0, h.l)(x, [v, n - v], x.shape.length - 1), S = (0, h.l)(w, [v, n - v], w.shape.length - 1), _ = m.shape.slice(); return _[m.shape.length - 1] = v, (0, l.t)((0, i.f)(k[0], S[0]), _) } }) }, 6512: (e, t, n) => { "use strict"; n.d(t, { l: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ split_: /** * @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 (e, t, n = 0) { const o = { x: (0, a.YT)(e, "x", "split") }, s = { numOrSizeSplits: t, axis: n }; return r.T2.runKernel(i.Blb, o, s) } }) }, 9348: (e, t, n) => { "use strict"; n.d(t, { R: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ sqrt_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "sqrt", "float32") }; return r.T2.runKernel(i.dFH, t) } }) }, 5793: (e, t, n) => { "use strict"; n.d(t, { E: () => a }); var r = n(1585), i = n(8189); const a = (0, n(929).op)({ square_: /** * @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 (e) { const t = (0, i.YT)(e, "x", "square"); return r.T2.runKernel("Square", { x: t }, {}) } }) }, 3427: (e, t, n) => { "use strict"; n.d(t, { P: () => u }); var r = n(1585), i = n(5441), a = n(565), o = n(8189), s = n(2198); const u = (0, n(929).op)({ squaredDifference_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "squaredDifference"), u = (0, o.YT)(t, "b", "squaredDifference");[n, u] = (0, a.makeTypesMatch)(n, u), (0, s.assertAndGetBroadcastShape)(n.shape, u.shape); const l = { a: n, b: u }; return r.T2.runKernel(i.Ddj, l, {}) } }) }, 5932: (e, t, n) => { "use strict"; n.d(t, { r: () => s }); var r = n(8189), i = n(5119), a = n(929), o = n(2302); const s = (0, a.op)({ squeeze_: /** * @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 (e, t) { const n = (0, r.YT)(e, "x", "squeeze", "string_or_numeric"); return (0, o.t)(n, (0, i.gx)(n.shape, t).newShape) } }) }, 4268: (e, t, n) => { "use strict"; n.d(t, { t: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ stack_: /** * @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 (e, t = 0) { const n = (0, a.j1)(e, "tensors", "stack", "string_or_numeric"); o.vA(n.length >= 1, (() => "Pass at least one tensor to tf.stack")), n.length > 0 && o.vA(t <= n[0].rank, (() => "Axis must be <= rank of the tensor")); const s = n, u = { axis: t }; return r.T2.runKernel(i.mM$, s, u) } }) }, 700: (e, t, n) => { "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ step_: /** * @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 (e, t = 0) { const n = { x: (0, a.YT)(e, "x", "step") }, o = { alpha: t }; return r.T2.runKernel(i.pnw, n, o) } }) }, 5894: (e, t, n) => { "use strict"; n.d(t, { Y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ stridedSlice_: /** * @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 (e, t, n, o, s = 0, u = 0, l = 0, c = 0, h = 0) { const d = { x: (0, a.YT)(e, "x", "stridedSlice", "string_or_numeric") }, f = { begin: t, end: n, strides: o, beginMask: s, endMask: u, ellipsisMask: l, newAxisMask: c, shrinkAxisMask: h }; return r.T2.runKernel(i.UcO, d, f) } }) }, 7126: (e, t, n) => { "use strict"; n.d(t, { j: () => s }); var r = n(1585), i = n(5441), a = n(565), o = n(8189); const s = (0, n(929).op)({ sub_: /** * @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 (e, t) { let n = (0, o.YT)(e, "a", "sub"), s = (0, o.YT)(t, "b", "sub");[n, s] = (0, a.makeTypesMatch)(n, s); const u = { a: n, b: s }; return r.T2.runKernel(i.PbM, u) } }) }, 3791: (e, t, n) => { "use strict"; n.d(t, { c: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(9809); const s = (0, n(929).op)({ sum_: /** * @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 (e, t = null, n = !1) { let s = (0, a.YT)(e, "x", "sum"); "bool" === s.dtype && (s = (0, o.w)(s, "int32")); const u = { x: s }, l = { axis: t, keepDims: n }; return r.T2.runKernel(i.WuN, u, l) } }) }, 7823: (e, t, n) => { "use strict"; n.d(t, { M: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ tan_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "tan", "float32") }; return r.T2.runKernel(i.oFs, t) } }) }, 7311: (e, t, n) => { "use strict"; n.d(t, { y: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ tanh_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "tanh", "float32") }; return r.T2.runKernel(i.iuW, t) } }) }, 4027: (e, t, n) => { "use strict"; n.d(t, { O: () => a }); var r = n(8189), i = n(9171); /** * @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 a(e, t, n) { const a = (0, r.MZ)(e, n); return (0, i.Q)(e, t, a, n) } }, 2768: (e, t, n) => { "use strict"; n.d(t, { $: () => o }); var r = n(8189), i = n(5119), a = n(9171); /** * @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 o(e, t, n) { if ((0, i.HO)(e), null != t && 3 !== t.length) throw new Error("tensor3d() requires shape to have three numbers"); const o = (0, r.MZ)(e, n); if (3 !== o.length && 1 !== o.length) throw new Error("tensor3d() requires values to be number[][][] or flat/TypedArray"); if (1 === o.length && null == t) throw new Error("tensor3d() requires shape to be provided when `values` are a flat array"); return (0, a.Q)(e, t, o, n) } }, 9171: (e, t, n) => { "use strict"; n.d(t, { Q: () => s }); var r = n(1585), i = n(2046), a = n(5119), o = n(3879); /** * @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 s(e, t, n, s) { if (null == s) s = (0, a.X$)(e); else if ("complex64" === s) throw new Error("Cannot construct a complex64 tensor directly. Please use tf.complex(real, imag)."); if ((0, i.Nw)(e) || (0, i.Oj)(e)) { if ("float32" !== s && "int32" !== s) throw new Error(`Creating tensor from GPU data only supports 'float32'|'int32' dtype, while the dtype is ${s}.`); return r.T2.backend.createTensorFromGPUData(e, t || n, s) } if (!(0, o.isTypedArray)(e) && !Array.isArray(e) && "number" != typeof e && "boolean" != typeof e && "string" != typeof e) throw new Error("values passed to tensor(values) must be a number/boolean/string or an array of numbers/booleans/strings, or a TypedArray"); if (null != t) { (0, a.SA)(t); const e = (0, a.Ze)(t), r = (0, a.Ze)(n); (0, a.vA)(e === r, (() => `Based on the provided shape, [${t}], the tensor should have ${e} values but has ${r}`)); for (let e = 0; e < n.length; ++e) { const r = n[e], i = e !== n.length - 1 || r !== (0, a.Ze)(t.slice(e)); (0, a.vA)(n[e] === t[e] || !i, (() => `Error creating a new Tensor. Inferred shape (${n}) does not match the provided shape (${t}). `)) } } return (0, o.isTypedArray)(e) || Array.isArray(e) || (e = [e]), t = t || n, e = "string" !== s ? (0, o.toTypedArray)(e, s) : (0, o.flatten)(e, [], !0), r.T2.makeTensor(e, t, s) } }, 4826: (e, t, n) => { "use strict"; n.d(t, { V: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ tile_: /** * @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 (e, t) { const n = (0, a.YT)(e, "x", "tile", "string_or_numeric"); o.vA(n.rank === t.length, (() => `Error in transpose: rank of input ${n.rank} must match length of reps ${t}.`)); const s = { x: n }, u = { reps: t }; return r.T2.runKernel(i.FAs, s, u) } }) }, 1190: (e, t, n) => { "use strict"; n.d(t, { r: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ topk_: /** * @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 (e, t = 1, n = !0) { const o = (0, a.YT)(e, "x", "topk"); if (0 === o.rank) throw new Error("topk() expects the input to be of rank 1 or higher"); const s = o.shape[o.shape.length - 1]; if (t < 0) throw new Error(`'k' passed to topk() must be >= 0 but got ${t}`); if (t > s) throw new Error(`'k' passed to topk() must be <= the last dimension (${s}) but got ${t}`); const u = { x: o }, l = { k: t, sorted: n }, [c, h] = r.T2.runKernel(i.TBb, u, l); return { values: c, indices: h } } }) }, 7703: (e, t, n) => { "use strict"; n.d(t, { m: () => f }); var r = n(1585), i = n(5287), a = n(5441), o = n(8189), s = n(5119), u = n(7148), l = n(5040), c = n(6522), h = n(929), d = n(1902); const f = (0, h.op)({ transpose_: /** * @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 (e, t, n) { const h = (0, o.YT)(e, "x", "transpose"); if (null == t && (t = h.shape.map(((e, t) => t)).reverse()), s.vA(h.rank === t.length, (() => `Error in transpose: rank of input ${h.rank} must match length of perm ${t}.`)), t.forEach((e => { s.vA(e >= 0 && e < h.rank, (() => "All entries in 'perm' must be between 0 and " + (h.rank - 1) + ` but got ${t}`)) })), h.rank <= 1) return h.clone(); const f = { x: h }, p = { perm: t }; return "complex64" === h.dtype ? (0, i.DZ)((() => { let e = (0, d.x)(h), t = (0, l.n)(h); return e = r.T2.runKernel(a.wx0, { x: e }, p), t = r.T2.runKernel(a.wx0, { x: t }, p), n && (t = (0, c.H)(t)), (0, u.f)(e, t) })) : r.T2.runKernel(a.wx0, f, p) } }) }, 3937: (e, t, n) => { "use strict"; n.d(t, { A: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ unique_: /** * @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 (e, t = 0) { const n = (0, a.YT)(e, "x", "unique", "string_or_numeric"); (0, o.vA)(n.rank > 0, (() => "The input tensor must be at least 1D")); const s = { x: n }, u = { axis: t }, [l, c] = r.T2.runKernel(i.EwU, s, u); return { values: l, indices: c } } }) }, 7706: (e, t, n) => { "use strict"; n.d(t, { z: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ unsortedSegmentSum_: /** * @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 (e, t, n) { const s = (0, a.YT)(e, "x", "unsortedSegmentSum"), u = (0, a.YT)(t, "segmentIds", "unsortedSegmentSum", "int32"); (0, o.vA)((0, o.E6)(n), (() => "numSegments must be of dtype int")); const l = { x: s, segmentIds: u }, c = { numSegments: n }; return r.T2.runKernel(i.pPe, l, c) } }) }, 7261: (e, t, n) => { "use strict"; n.d(t, { K: () => s }); var r = n(1585), i = n(5441), a = n(8189), o = n(5119); const s = (0, n(929).op)({ unstack_: /** * @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 (e, t = 0) { const n = (0, a.YT)(e, "x", "unstack", "string_or_numeric"); o.vA(t >= -n.shape.length && t < n.shape.length, (() => `Axis = ${t} is not in [-${n.shape.length}, ${n.shape.length})`)); const s = { value: n }, u = { axis: t }; return r.T2.runKernel(i.dXR, s, u) } }) }, 2151: (e, t, n) => { "use strict"; n.d(t, { _: () => u }); var r = n(1585), i = n(5441), a = n(8189), o = n(3567), s = n(2198); const u = (0, n(929).op)({ where_: /** * @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 (e, t, n) { const u = (0, a.YT)(t, "a", "where"), l = (0, a.YT)(n, "b", "where"), c = (0, a.YT)(e, "condition", "where", "bool"), h = (0, s.assertAndGetBroadcastShape)((0, s.assertAndGetBroadcastShape)(c.shape, u.shape), l.shape), d = { condition: (0, o.h)(c, h), t: (0, o.h)(u, h), e: (0, o.h)(l, h) }; return r.T2.runKernel(i.l6P, d) } }) }, 2855: (e, t, n) => { "use strict"; n.d(t, { U: () => o }); var r = n(1585), i = n(5119), a = n(7148); /** * @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 o(e, t = "float32") { if ((0, i.SA)(e), "complex64" === t) { const t = o(e, "float32"), n = o(e, "float32"); return (0, a.f)(t, n) } const n = (0, i.Ty)((0, i.Ze)(e), t); return r.T2.makeTensor(n, e, t) } }, 5537: (e, t, n) => { "use strict"; n.d(t, { P: () => o }); var r = n(1585), i = n(5441), a = n(8189); const o = (0, n(929).op)({ zerosLike_: /** * @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 (e) { const t = { x: (0, a.YT)(e, "x", "zerosLike") }; return r.T2.runKernel(i.xJ3, t) } }) }, 6448: (e, t, n) => { "use strict"; /** * @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 r(e) { return e instanceof Float32Array || e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray } n.d(t, { Y: () => r }) }, 455: (e, t, n) => { "use strict"; var r = n(4888), i = n(259); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.abs = function () { return this.throwIfDisposed(), (0, r.t)(this) }; var a = n(2804); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.acos = function () { return this.throwIfDisposed(), (0, a.H)(this) }; var o = n(7558); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.acosh = function () { return this.throwIfDisposed(), (0, o.F)(this) }; var s = n(7523); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.add = function (e) { return this.throwIfDisposed(), (0, s.W)(this, e) }; var u = n(2307); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.all = function (e, t) { return this.throwIfDisposed(), (0, u.Q)(this, e, t) }; var l = n(9326); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.any = function (e, t) { return this.throwIfDisposed(), (0, l.b)(this, e, t) }; var c = n(897); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.argMax = function (e) { return this.throwIfDisposed(), (0, c.F)(this, e) }; var h = n(4339); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.argMin = function (e) { return this.throwIfDisposed(), (0, h.X)(this, e) }; var d = n(2302), f = n(5119); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.asScalar = function () { return this.throwIfDisposed(), (0, f.vA)(1 === this.size, (() => "The array must have only 1 element.")), (0, d.t)(this, []) }; var p = n(9809); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.asType = function (e) { return this.throwIfDisposed(), (0, p.w)(this, e) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.as1D = function () { return this.throwIfDisposed(), (0, d.t)(this, [this.size]) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.as2D = function (e, t) { return this.throwIfDisposed(), (0, d.t)(this, [e, t]) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.as3D = function (e, t, n) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n]) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.as4D = function (e, t, n, r) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n, r]) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.as5D = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, d.t)(this, [e, t, n, r, i]) }; var m = n(6841); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.asin = function () { return this.throwIfDisposed(), (0, m.q)(this) }; var g = n(269); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.asinh = function () { return this.throwIfDisposed(), (0, g.y)(this) }; var y = n(9580); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.atan = function () { return this.throwIfDisposed(), (0, y.r)(this) }; var b = n(1404); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.atan2 = function (e) { return this.throwIfDisposed(), (0, b.F)(this, e) }; var v = n(3774); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.atanh = function () { return this.throwIfDisposed(), (0, v.r)(this) }; var x = n(3909); (0, i.tp)().prototype.avgPool = function (e, t, n, r) { return this.throwIfDisposed(), (0, x.$)(this, e, t, n, r) }; var w = n(9772); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.batchToSpaceND = function (e, t) { return this.throwIfDisposed(), (0, w.G)(this, e, t) }; var k = n(9160); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.batchNorm = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, k.$)(this, e, t, n, r, i) }; var S = n(3567); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.broadcastTo = function (e) { return this.throwIfDisposed(), (0, S.h)(this, e) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.cast = function (e) { return this.throwIfDisposed(), (0, p.w)(this, e) }; var _ = n(855); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.ceil = function () { return this.throwIfDisposed(), (0, _.m)(this) }; var C = n(6928); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.clipByValue = function (e, t) { return this.throwIfDisposed(), (0, C.z)(this, e, t) }; var A = n(5030); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.concat = function (e, t) { return this.throwIfDisposed(), e instanceof i.qY && (e = [e]), (0, A.x)([this, ...e], t) }; var T = n(3701); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.conv1d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, T.k)(this, e, t, n, r, i, a) }; var E = n(1106); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.conv2dTranspose = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, E.w)(this, e, t, n, r, i) }; var N = n(8794); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.conv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, N.X)(this, e, t, n, r, i, a) }; var I = n(9907); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.cos = function () { return this.throwIfDisposed(), (0, I.g)(this) }; var M = n(7451); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.cosh = function () { return this.throwIfDisposed(), (0, M.y)(this) }; var F = n(302); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.cumprod = function (e, t, n) { return this.throwIfDisposed(), (0, F.L)(this, e, t, n) }; var D = n(6808); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.cumsum = function (e, t, n) { return this.throwIfDisposed(), (0, D.r)(this, e, t, n) }; var $ = n(1216); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.depthToSpace = function (e, t) { return this.throwIfDisposed(), (0, $.R)(this, e, t) }; var R = n(676); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.depthwiseConv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, R.G)(this, e, t, n, r, i, a) }; var O = n(3002); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.dilation2d = function (e, t, n, r, i) { return this.throwIfDisposed(), (0, O.X)(this, e, t, n, r, i) }; var z = n(919); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.divNoNan = function (e) { return this.throwIfDisposed(), (0, z.e)(this, e) }; var P = n(9359); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.div = function (e) { return this.throwIfDisposed(), (0, P.y)(this, e) }; var B = n(9759); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.dot = function (e) { return this.throwIfDisposed(), (0, B.O)(this, e) }; var L = n(3416); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.elu = function () { return this.throwIfDisposed(), (0, L.P)(this) }; var j = n(3020); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.equal = function (e) { return this.throwIfDisposed(), (0, j.L)(this, e) }; var U = n(5207); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.erf = function () { return this.throwIfDisposed(), (0, U.Y)(this) }; var W = n(4881); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.euclideanNorm = function (e, t) { return this.throwIfDisposed(), (0, W.p)(this, e, t) }; var V = n(8631); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.exp = function () { return this.throwIfDisposed(), (0, V.o)(this) }; var G = n(8710); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.expandDims = function (e) { return this.throwIfDisposed(), (0, G.U)(this, e) }; var H = n(517); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.expm1 = function () { return this.throwIfDisposed(), (0, H.I)(this) }; var q = n(1361); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.fft = function () { return this.throwIfDisposed(), (0, q.h)(this) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.flatten = function () { return this.throwIfDisposed(), (0, d.t)(this, [this.size]) }; var Y = n(5606); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.floor = function () { return this.throwIfDisposed(), (0, Y.R)(this) }; var X = n(8991); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.floorDiv = function (e) { return this.throwIfDisposed(), (0, X.w)(this, e) }; var K = n(8229); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.gather = function (e, t, n) { return this.throwIfDisposed(), (0, K.k)(this, e, t, n) }; var Z = n(3337); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.greaterEqual = function (e) { return this.throwIfDisposed(), (0, Z.D)(this, e) }; var J = n(2058); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.greater = function (e) { return this.throwIfDisposed(), (0, J.r)(this, e) }; var Q = n(3108); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.ifft = function () { return this.throwIfDisposed(), (0, Q.K)(this) }; var ee = n(2292); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.irfft = function () { return this.throwIfDisposed(), (0, ee.g)(this) }; var te = n(8318); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.isFinite = function () { return this.throwIfDisposed(), (0, te.M)(this) }; var ne = n(3454); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.isInf = function () { return this.throwIfDisposed(), (0, ne.E)(this) }; var re = n(6300); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.isNaN = function () { return this.throwIfDisposed(), (0, re.y)(this) }; var ie = n(6919); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.leakyRelu = function (e) { return this.throwIfDisposed(), (0, ie.H)(this, e) }; var ae = n(6508); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.lessEqual = function (e) { return this.throwIfDisposed(), (0, ae.I)(this, e) }; var oe = n(1303); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.less = function (e) { return this.throwIfDisposed(), (0, oe.M)(this, e) }; var se = n(3531); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.localResponseNormalization = function (e, t, n, r) { return this.throwIfDisposed(), (0, se.K)(this, e, t, n, r) }; var ue = n(5645); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logSigmoid = function () { return this.throwIfDisposed(), (0, ue.n)(this) }; var le = n(7991); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logSoftmax = function (e) { return this.throwIfDisposed(), (0, le.H)(this, e) }; var ce = n(3330); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logSumExp = function (e, t) { return this.throwIfDisposed(), (0, ce.V)(this, e, t) }; var he = n(4010); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.log = function () { return this.throwIfDisposed(), (0, he.R)(this) }; var de = n(2015); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.log1p = function () { return this.throwIfDisposed(), (0, de.K)(this) }; var fe = n(3789); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logicalAnd = function (e) { return this.throwIfDisposed(), (0, fe.n)(this, e) }; var pe = n(9881); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logicalNot = function () { return this.throwIfDisposed(), (0, pe.N)(this) }; var me = n(9879); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logicalOr = function (e) { return this.throwIfDisposed(), (0, me.z)(this, e) }; var ge = n(9925); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.logicalXor = function (e) { return this.throwIfDisposed(), (0, ge.r)(this, e) }; var ye = n(5703); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.matMul = function (e, t, n) { return this.throwIfDisposed(), (0, ye.N)(this, e, t, n) }; var be = n(6999); (0, i.tp)().prototype.maxPool = function (e, t, n, r) { return this.throwIfDisposed(), (0, be.j)(this, e, t, n, r) }; var ve = n(1938); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.max = function (e, t) { return this.throwIfDisposed(), (0, ve.T)(this, e, t) }; var xe = n(178); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.maximum = function (e) { return this.throwIfDisposed(), (0, xe.P)(this, e) }; var we = n(2611); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.mean = function (e, t) { return this.throwIfDisposed(), (0, we.i)(this, e, t) }; var ke = n(7436); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.min = function (e, t) { return this.throwIfDisposed(), (0, ke.j)(this, e, t) }; var Se = n(2644); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.minimum = function (e) { return this.throwIfDisposed(), (0, Se.B)(this, e) }; var _e = n(6567); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.mirrorPad = function (e, t) { return this.throwIfDisposed(), (0, _e.F)(this, e, t) }; var Ce = n(152); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.mod = function (e) { return this.throwIfDisposed(), (0, Ce.z)(this, e) }; var Ae = n(9258); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.mul = function (e) { return this.throwIfDisposed(), (0, Ae.l)(this, e) }; var Te = n(6522); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.neg = function () { return this.throwIfDisposed(), (0, Te.H)(this) }; var Ee = n(2596); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.norm = function (e, t, n) { return this.throwIfDisposed(), (0, Ee.x)(this, e, t, n) }; var Ne = n(2118); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.notEqual = function (e) { return this.throwIfDisposed(), (0, Ne.E)(this, e) }; var Ie = n(1760); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.oneHot = function (e, t = 1, n = 0) { return this.throwIfDisposed(), (0, Ie.M)(this, e, t, n) }; var Me = n(9885); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.onesLike = function () { return this.throwIfDisposed(), (0, Me.P)(this) }; var Fe = n(5661); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.pad = function (e, t) { return this.throwIfDisposed(), (0, Fe.e)(this, e, t) }; var De = n(7872); (0, i.tp)().prototype.pool = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, De.d)(this, e, t, n, r, i, a) }; var $e = n(8990); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.pow = function (e) { return this.throwIfDisposed(), (0, $e.n)(this, e) }; var Re = n(4394); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.prelu = function (e) { return this.throwIfDisposed(), (0, Re.N)(this, e) }; var Oe = n(7771); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.prod = function (e, t) { return this.throwIfDisposed(), (0, Oe._)(this, e, t) }; var ze = n(9870); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.reciprocal = function () { return this.throwIfDisposed(), (0, ze.V)(this) }; var Pe = n(112); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.relu = function () { return this.throwIfDisposed(), (0, Pe.V)(this) }; var Be = n(3732); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.relu6 = function () { return this.throwIfDisposed(), (0, Be.j)(this) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.reshapeAs = function (e) { return this.throwIfDisposed(), (0, d.t)(this, e.shape) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.reshape = function (e) { return this.throwIfDisposed(), (0, d.t)(this, e) }; var Le = n(4711); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.resizeBilinear = function (e, t, n) { return this.throwIfDisposed(), (0, Le.v)(this, e, t, n) }; var je = n(2954); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.resizeNearestNeighbor = function (e, t, n) { return this.throwIfDisposed(), (0, je.b)(this, e, t, n) }; var Ue = n(3262); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.reverse = function (e) { return this.throwIfDisposed(), (0, Ue.B)(this, e) }; var We = n(8775); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.rfft = function () { return this.throwIfDisposed(), (0, We.z)(this) }; var Ve = n(5912); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.round = function () { return this.throwIfDisposed(), (0, Ve.L)(this) }; var Ge = n(7820); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.rsqrt = function () { return this.throwIfDisposed(), (0, Ge.Z)(this) }; var He = n(6325); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.selu = function () { return this.throwIfDisposed(), (0, He.W)(this) }; var qe = n(9986); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.separableConv2d = function (e, t, n, r, i, a) { return this.throwIfDisposed(), (0, qe.w)(this, e, t, n, r, i, a) }; var Ye = n(8968); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sigmoid = function () { return this.throwIfDisposed(), (0, Ye.r)(this) }; var Xe = n(1115); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sign = function () { return this.throwIfDisposed(), (0, Xe._)(this) }; var Ke = n(3726); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sin = function () { return this.throwIfDisposed(), (0, Ke.F)(this) }; var Ze = n(8276); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sinh = function () { return this.throwIfDisposed(), (0, Ze.L)(this) }; var Je = n(7986); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.slice = function (e, t) { return this.throwIfDisposed(), (0, Je.d)(this, e, t) }; var Qe = n(6346); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.softmax = function (e) { return this.throwIfDisposed(), (0, Qe.V)(this, e) }; var et = n(6030); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.softplus = function () { return this.throwIfDisposed(), (0, et.l)(this) }; var tt = n(776); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.spaceToBatchND = function (e, t) { return this.throwIfDisposed(), (0, tt.e)(this, e, t) }; var nt = n(6512); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.split = function (e, t) { return this.throwIfDisposed(), (0, nt.l)(this, e, t) }; var rt = n(9348); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sqrt = function () { return this.throwIfDisposed(), (0, rt.R)(this) }; var it = n(5793); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.square = function () { return this.throwIfDisposed(), (0, it.E)(this) }; var at = n(3427); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.squaredDifference = function (e) { return this.throwIfDisposed(), (0, at.P)(this, e) }; var ot = n(5932); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.squeeze = function (e) { return this.throwIfDisposed(), (0, ot.r)(this, e) }; var st = n(4268); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.stack = function (e, t) { this.throwIfDisposed(); const n = e instanceof i.qY ? [this, e] : [this, ...e]; return (0, st.t)(n, t) }; var ut = n(700); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.step = function (e) { return this.throwIfDisposed(), (0, ut.P)(this, e) }; var lt = n(5894); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.stridedSlice = function (e, t, n, r, i, a, o, s) { return this.throwIfDisposed(), (0, lt.Y)(this, e, t, n, r, i, a, o, s) }; var ct = n(7126); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sub = function (e) { return this.throwIfDisposed(), (0, ct.j)(this, e) }; var ht = n(3791); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.sum = function (e, t) { return this.throwIfDisposed(), (0, ht.c)(this, e, t) }; var dt = n(7823); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.tan = function () { return this.throwIfDisposed(), (0, dt.M)(this) }; var ft = n(7311); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.tanh = function () { return this.throwIfDisposed(), (0, ft.y)(this) }; var pt = n(4826); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.tile = function (e) { return this.throwIfDisposed(), (0, pt.V)(this, e) }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.toBool = function () { return this.throwIfDisposed(), (0, p.w)(this, "bool") }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.toFloat = function () { return this.throwIfDisposed(), (0, p.w)(this, "float32") }, /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.toInt = function () { return this.throwIfDisposed(), (0, p.w)(this, "int32") }; var mt = n(1190); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.topk = function (e, t) { return this.throwIfDisposed(), (0, mt.r)(this, e, t) }; var gt = n(7703); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.transpose = function (e) { return this.throwIfDisposed(), (0, gt.m)(this, e) }; var yt = n(3937); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.unique = function (e) { return this.throwIfDisposed(), (0, yt.A)(this, e) }; var bt = n(7706); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.unsortedSegmentSum = function (e, t) { return this.throwIfDisposed(), (0, bt.z)(this, e, t) }; var vt = n(7261); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.unstack = function (e) { return this.throwIfDisposed(), (0, vt.K)(this, e) }; var xt = n(2151); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.where = function (e, t) { return this.throwIfDisposed(), (0, xt._)(e, this, t) }; var wt = n(5537); /** * @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. * ============================================================================= */ /** * @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. * ============================================================================= */ (0, i.tp)().prototype.zerosLike = function () { return this.throwIfDisposed(), (0, wt.P)(this) } } /** * @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. * ============================================================================= */, 259: (e, t, n) => { "use strict"; n.d(t, { qY: () => b, yl: () => h, rT: () => x, tp: () => v, B4: () => y, Q5: () => g, qP: () => m }); var r = n(1743), i = n(5119); function a(e, t, n, r) { const a = (0, i.Ur)(t), s = function (e, t, n, r) { const a = (0, i.Ze)(t), s = r[r.length - 1], u = new Array(s).fill(0), c = t.length, h = "complex64" === n ? l(e) : e; if (c > 1) for (let e = 0; e < a / s; e++) { const t = e * s; for (let e = 0; e < s; e++)u[e] = Math.max(u[e], o(h[t + e], 0, n).length) } return u }(e, t, n, a), c = t.length, h = u(e, t, n, a, s), d = ["Tensor"]; return r && (d.push(` dtype: ${n}`), d.push(` rank: ${c}`), d.push(` shape: [${t}]`), d.push(" values:")), d.push(h.map((e => " " + e)).join("\n")), d.join("\n") } function o(e, t, n) { let r; return r = Array.isArray(e) ? `${parseFloat(e[0].toFixed(7))} + ${parseFloat(e[1].toFixed(7))}j` : (0, i.Kg)(e) ? `'${e}'` : "bool" === n ? s(e) : parseFloat(e.toFixed(7)).toString(), (0, i.av)(r, t) } function s(e) { return 0 === e ? "false" : "true" } function u(e, t, n, r, i, a = !0) { const c = "complex64" === n ? 2 : 1, h = t[0], d = t.length; if (0 === d) { if ("complex64" === n) { return [o(l(e)[0], 0, n)] } return "bool" === n ? [s(e[0])] : [e[0].toString()] } if (1 === d) { if (h > 20) { const t = 3 * c; let r = Array.from(e.slice(0, t)), a = Array.from(e.slice((h - 3) * c, h * c)); return "complex64" === n && (r = l(r), a = l(a)), ["[" + r.map(((e, t) => o(e, i[t], n))).join(", ") + ", ..., " + a.map(((e, t) => o(e, i[h - 3 + t], n))).join(", ") + "]"] } return ["[" + ("complex64" === n ? l(e) : Array.from(e)).map(((e, t) => o(e, i[t], n))).join(", ") + "]"] } const f = t.slice(1), p = r.slice(1), m = r[0] * c, g = []; if (h > 20) { for (let t = 0; t < 3; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, !1)) } g.push("..."); for (let t = h - 3; t < h; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, t === h - 1)) } } else for (let t = 0; t < h; t++) { const r = t * m, a = r + m; g.push(...u(e.slice(r, a), f, n, p, i, t === h - 1)) } const y = 2 === d ? "," : ""; g[0] = "[" + (h > 0 ? g[0] + y : ""); for (let e = 1; e < g.length - 1; e++)g[e] = " " + g[e] + y; let b = ",\n"; for (let e = 2; e < d; e++)b += "\n"; return g[g.length - 1] = " " + g[g.length - 1] + "]" + (a ? "" : b), g } function l(e) { const t = []; for (let n = 0; n < e.length; n += 2)t.push([e[n], e[n + 1]]); return t } var c = n(3879); /** * @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. * ============================================================================= */ class h { constructor(e, t, n) { if (this.dtype = t, this.shape = e.slice(), this.size = i.Ze(e), null != n) { const e = n.length; i.vA(e === this.size, (() => `Length of values '${e}' does not match the size inferred by the shape '${this.size}'.`)) } if ("complex64" === t) throw new Error("complex64 dtype TensorBuffers are not supported. Please create a TensorBuffer for the real and imaginary parts separately and call tf.complex(real, imag)."); this.values = n || i.Ab(t, this.size), this.strides = (0, i.Ur)(e) } set(e, ...t) { 0 === t.length && (t = [0]), i.vA(t.length === this.rank, (() => `The number of provided coordinates (${t.length}) must match the rank (${this.rank})`)); const n = this.locToIndex(t); this.values[n] = e } get(...e) { 0 === e.length && (e = [0]); let t = 0; for (const n of e) { if (n < 0 || n >= this.shape[t]) { const t = `Requested out of range element at ${e}. Buffer shape=${this.shape}`; throw new Error(t) } t++ } let n = e[e.length - 1]; for (let t = 0; t < e.length - 1; ++t)n += this.strides[t] * e[t]; return this.values[n] } locToIndex(e) { if (0 === this.rank) return 0; if (1 === this.rank) return e[0]; let t = e[e.length - 1]; for (let n = 0; n < e.length - 1; ++n)t += this.strides[n] * e[n]; return t } indexToLoc(e) { if (0 === this.rank) return []; if (1 === this.rank) return [e]; const t = new Array(this.shape.length); for (let n = 0; n < t.length - 1; ++n)t[n] = Math.floor(e / this.strides[n]), e -= t[n] * this.strides[n]; return t[t.length - 1] = e, t } get rank() { return this.shape.length } toTensor() { return d().makeTensor(this.values, this.shape, this.dtype) } } let d = null, f = null, p = null; function m(e) { d = e } function g(e) { f = e } function y(e) { p = e } class b { constructor(e, t, n, r) { this.kept = !1, this.isDisposedInternal = !1, this.shape = e.slice(), this.dtype = t || "float32", this.size = i.Ze(e), this.strides = (0, i.Ur)(e), this.dataId = n, this.id = r, this.rankType = this.rank < 5 ? this.rank.toString() : "higher" } get rank() { return this.shape.length } async buffer() { const e = await this.data(); return f.buffer(this.shape, this.dtype, e) } bufferSync() { return f.buffer(this.shape, this.dtype, this.dataSync()) } async array() { const e = await this.data(); return (0, i.yw)(this.shape, e, "complex64" === this.dtype) } arraySync() { return (0, i.yw)(this.shape, this.dataSync(), "complex64" === this.dtype) } async data() { this.throwIfDisposed(); const e = d().read(this.dataId); if ("string" === this.dtype) { const t = await e; try { return t.map((e => c.decodeString(e))) } catch (e) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().") } } return e } dataToGPU(e) { return this.throwIfDisposed(), d().readToGPU(this.dataId, e) } dataSync() { this.throwIfDisposed(); const e = d().readSync(this.dataId); if ("string" === this.dtype) try { return e.map((e => c.decodeString(e))) } catch (e) { throw new Error("Failed to decode the string bytes into utf-8. To get the original bytes, call tensor.bytes().") } return e } async bytes() { this.throwIfDisposed(); const e = await d().read(this.dataId); return "string" === this.dtype ? e : new Uint8Array(e.buffer) } dispose() { this.isDisposed || (this.kerasMask && this.kerasMask.dispose(), d().disposeTensor(this), this.isDisposedInternal = !0) } get isDisposed() { return this.isDisposedInternal } throwIfDisposed() { if (this.isDisposed) throw new Error("Tensor is disposed.") } print(e = !1) { return f.print(this, e) } clone() { return this.throwIfDisposed(), f.clone(this) } toString(e = !1) { return a(this.dataSync(), this.shape, this.dtype, e) } cast(e) { return this.throwIfDisposed(), f.cast(this, e) } variable(e = !0, t, n) { return this.throwIfDisposed(), d().makeVariable(this, e, t, n) } } function v() { return (0, r.m)("Tensor", (() => b)) } Object.defineProperty(b, Symbol.hasInstance, { value: e => !!e && null != e.data && null != e.dataSync && null != e.throwIfDisposed }), v(); class x extends b { constructor(e, t, n, r) { super(e.shape, e.dtype, e.dataId, r), this.trainable = t, this.name = n } assign(e) { if (e.dtype !== this.dtype) throw new Error(`dtype of the new value (${e.dtype}) and previous value (${this.dtype}) must match`); if (!i.r1(e.shape, this.shape)) throw new Error(`shape of the new value (${e.shape}) and previous value (${this.shape}) must match`); d().disposeTensor(this), this.dataId = e.dataId, d().incRef(this, null) } dispose() { d().disposeVariable(this), this.isDisposedInternal = !0 } } Object.defineProperty(x, Symbol.hasInstance, { value: e => e instanceof b && null != e.assign && e.assign instanceof Function }) }, 565: (e, t, n) => { "use strict"; n.r(t), n.d(t, { assertTypesMatch: () => s, getTensorsInContainer: () => l, isTensorInList: () => u, makeTypesMatch: () => o }); var r = n(259), i = n(2046), a = n(5119); /** * @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 o(e, t) { if (e.dtype === t.dtype) return [e, t]; const n = (0, i.Tu)(e.dtype, t.dtype); return [e.cast(n), t.cast(n)] } function s(e, t) { (0, a.vA)(e.dtype === t.dtype, (() => `The dtypes of the first(${e.dtype}) and second(${t.dtype}) input must match`)) } function u(e, t) { return t.some((t => t.id === e.id)) } function l(e) { const t = []; return c(e, t, new Set), t } function c(e, t, n) { if (null == e) return; if (e instanceof r.qY) return void t.push(e); if (i = e, !Array.isArray(i) && "object" != typeof i) return; var i; const a = e; for (const e in a) { const r = a[e]; n.has(r) || (n.add(r), c(r, t, n)) } } }, 8189: (e, t, n) => { "use strict"; n.d(t, { MZ: () => l, YT: () => d, j1: () => f }); var r = n(1585), i = n(6574), a = n(259), o = n(2046), s = n(3879), u = n(5119); /** * @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 l(e, t) { let n = e; if ((0, s.isTypedArray)(e)) return "string" === t ? [] : [e.length]; if ((0, o.Oj)(e)) { const t = e.channels || "RGBA"; return [e.height, e.width * t.length] } if ((0, o.Nw)(e)) return [e.buffer.size / (null == t ? 4 : (0, u.jv)(t))]; if (!Array.isArray(e)) return []; const r = []; for (; Array.isArray(n) || (0, s.isTypedArray)(n) && "string" !== t;)r.push(n.length), n = n[0]; return Array.isArray(e) && (0, i._K)().getBool("TENSORLIKE_CHECK_SHAPE_CONSISTENCY") && c(e, r, []), r } function c(e, t, n) { if (n = n || [], !Array.isArray(e) && !(0, s.isTypedArray)(e)) return void (0, u.vA)(0 === t.length, (() => `Element arr[${n.join("][")}] is a primitive, but should be an array/TypedArray of ${t[0]} elements`)); (0, u.vA)(t.length > 0, (() => `Element arr[${n.join("][")}] should be a primitive, but is an array of ${e.length} elements`)), (0, u.vA)(e.length === t[0], (() => `Element arr[${n.join("][")}] should have ${t[0]} elements, but has ${e.length} elements`)); const r = t.slice(1); for (let t = 0; t < e.length; ++t)c(e[t], r, n.concat(t)) } function h(e, t, n, r) { if ("string_or_numeric" !== e) { if (null == e) throw new Error("Expected dtype cannot be null."); if ("numeric" !== e && e !== t || "numeric" === e && "string" === t) throw new Error(`Argument '${n}' passed to '${r}' must be ${e} tensor, but got ${t} tensor`) } } function d(e, t, n, i = "numeric") { if (e instanceof (0, a.tp)()) return h(i, e.dtype, t, n), e; let o = (0, u.X$)(e); if ("string" !== o && ["bool", "int32", "float32"].indexOf(i) >= 0 && (o = i), h(i, o, t, n), null == e || !(0, s.isTypedArray)(e) && !Array.isArray(e) && "number" != typeof e && "boolean" != typeof e && "string" != typeof e) { const r = null == e ? "null" : e.constructor.name; throw new Error(`Argument '${t}' passed to '${n}' must be a Tensor or TensorLike, but got '${r}'`) } const c = l(e, o); (0, s.isTypedArray)(e) || Array.isArray(e) || (e = [e]); const d = "string" !== o ? (0, s.toTypedArray)(e, o) : (0, s.flatten)(e, [], !0); return r.T2.makeTensor(d, c, o) } function f(e, t, n, r = "numeric") { if (!Array.isArray(e)) throw new Error(`Argument ${t} passed to ${n} must be a \`Tensor[]\` or \`TensorLike[]\``); return e.map(((e, i) => d(e, `${t}[${i}]`, n, r))) } }, 2046: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */ var r, i, a, o, s; n.d(t, { Nw: () => d, Oj: () => h, Tu: () => l, ch: () => c, rg: () => r }), function (e) { e.R0 = "R0", e.R1 = "R1", e.R2 = "R2", e.R3 = "R3", e.R4 = "R4", e.R5 = "R5", e.R6 = "R6" }(r || (r = {})), function (e) { e.float32 = "float32", e.int32 = "int32", e.bool = "int32", e.complex64 = "complex64" }(i || (i = {})), function (e) { e.float32 = "float32", e.int32 = "int32", e.bool = "bool", e.complex64 = "complex64" }(a || (a = {})), function (e) { e.float32 = "float32", e.int32 = "float32", e.bool = "float32", e.complex64 = "complex64" }(o || (o = {})), function (e) { e.float32 = "complex64", e.int32 = "complex64", e.bool = "complex64", e.complex64 = "complex64" }(s || (s = {})); const u = { float32: o, int32: i, bool: a, complex64: s }; function l(e, t) { if ("string" === e || "string" === t) { if ("string" === e && "string" === t) return "string"; throw new Error(`Can not upcast ${e} with ${t}`) } return u[e][t] } function c(e) { return l(e, "int32") } function h(e) { return null != e && "object" == typeof e && "texture" in e && e.texture instanceof WebGLTexture } function d(e) { return "undefined" != typeof GPUBuffer && null != e && "object" == typeof e && "buffer" in e && e.buffer instanceof GPUBuffer } }, 3879: (e, t, n) => { "use strict"; n.r(t), n.d(t, { arraysEqual: () => a.r1, arraysEqualWithNull: () => a.e_, assert: () => a.vA, assertNonNegativeIntegerDimensions: () => a.SA, assertNonNull: () => a.HO, assertShapesMatch: () => a.O3, bytesFromStringArray: () => a.SL, bytesPerElement: () => a.jv, checkConversionForErrors: () => a.nd, clamp: () => a.qE, computeStrides: () => a.Ur, convertBackendValuesAndArrayBuffer: () => a.o2, createScalarValue: () => x, createShuffledIndices: () => a.P8, decodeString: () => C, distSquared: () => a.oO, encodeString: () => _, fetch: () => S, fingerPrint64: () => v, flatten: () => T, getArrayFromDType: () => a.Ab, getTypedArrayFromDType: () => a.ce, hasEncodingLoss: () => a.BE, hexToLong: () => u, indexToLoc: () => a._k, inferDtype: () => a.X$, inferFromImplicitShape: () => a.XT, isBoolean: () => a.Lm, isFunction: () => a.Tn, isInt: () => a.E6, isNumber: () => a.Et, isPromise: () => a.yL, isScalarShape: () => a.Sf, isString: () => a.Kg, isTypedArray: () => A, isValidDtype: () => a.xn, locToIndex: () => a.sX, makeOnesTypedArray: () => a.FZ, makeZerosNestedTypedArray: () => a.c7, makeZerosTypedArray: () => a.Ty, nearestDivisor: () => a.lK, nearestLargerEven: () => a.eV, now: () => k, parseAxisParam: () => a.Y6, randUniform: () => a.so, repeatedTry: () => a._q, rightPad: () => a.av, shuffle: () => a.k4, shuffleCombo: () => a.a0, sizeFromShape: () => a.Ze, sizeToSquarishShape: () => a.gS, squeezeShape: () => a.gx, sum: () => a.cz, swap: () => a.wg, tanh: () => a.ym, toNestedArray: () => a.yw, toTypedArray: () => w }); var r = n(6574), i = n(6448), a = n(5119), o = n(8570); /** * @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 s = n.n(o)() || o; function u(e) { return s.fromString(e, !0, 16) } const l = u("c3a5c85c97cb3127"), c = u("b492b66fbe98f273"), h = u("9ae16a3b2f90404f"); function d(e) { return e.xor(e.shru(47)) } function f(e, t, n) { const r = e.slice(t, t + n); return s.fromBytes(Array.from(r), !0, !0) } function p(e, t) { return f(e, t, 8) } function m(e, t) { return f(e, t, 4) } function g(e, t) { return 0 === t ? e : e.shru(t).or(e.shl(64 - t)) } function y(e, t, n = u("9ddfea08eb382d69")) { let r = e.xor(t).mul(n); r = r.xor(r.shru(47)); let i = t.xor(r).mul(n); return i = i.xor(i.shru(47)), i = i.mul(n), i } function b(e, t, n, r) { return function (e, t, n, r, i, a) { i = i.add(e), a = g(a.add(i).add(r), 21); const o = i; return i = (i = i.add(t)).add(n), a = a.add(g(i, 44)), [i.add(r), a.add(o)] }(p(e, t), p(e, t + 8), p(e, t + 16), p(e, t + 24), n, r) } function v(e, t = e.length) { const n = s.fromNumber(81, !0); if (t <= 32) return t <= 16 ? function (e, t = e.length) { if (t >= 8) { const n = h.add(2 * t), r = p(e, 0).add(h), i = p(e, t - 8); return y(g(i, 37).mul(n).add(r), g(r, 25).add(i).mul(n), n) } if (t >= 4) { const n = h.add(2 * t); return y(m(e, 0).shl(3).add(t), m(e, t - 4), n) } if (t > 0) { const n = e[0] + (e[t >> 1] << 8), r = t + (e[t - 1] << 2); return d(h.mul(n).xor(l.mul(r))).mul(h) } return h }(e, t) : function (e, t = e.length) { const n = h.add(2 * t), r = p(e, 0).mul(c), i = p(e, 8), a = p(e, t - 8).mul(n), o = p(e, t - 16).mul(h); return y(g(r.add(i), 43).add(g(a, 30)).add(o), r.add(g(i.add(h), 18)).add(a), n) }(e, t); if (t <= 64) return function (e, t = e.length) { const n = h.add(2 * t), r = p(e, 0).mul(h), i = p(e, 8), a = p(e, t - 8).mul(n), o = p(e, t - 16).mul(h), s = g(r.add(i), 43).add(g(a, 30)).add(o), u = y(s, r.add(g(i.add(h), 18)).add(a), n), l = p(e, 16).mul(n), c = p(e, 24), d = s.add(p(e, t - 32)).mul(n), f = u.add(p(e, t - 24)).mul(n); return y(g(l.add(c), 43).add(g(d, 30)).add(f), l.add(g(c.add(r), 18)).add(d), n) }(e, t); let r = n, i = n.mul(c).add(113), a = d(i.mul(h).add(113)).mul(h), o = [s.UZERO, s.UZERO], u = [s.UZERO, s.UZERO]; r = r.mul(h).add(p(e, 0)); let f = 0; const v = 64 * (t - 1 >> 6), x = v + (t - 1 & 63) - 63; do { r = g(r.add(i).add(o[0]).add(p(e, f + 8)), 37).mul(c), i = g(i.add(o[1]).add(p(e, f + 48)), 42).mul(c), r = r.xor(u[1]), i = i.add(o[0]).add(p(e, f + 40)), a = g(a.add(u[0]), 33).mul(c), o = b(e, f, o[1].mul(c), r.add(u[0])), u = b(e, f + 32, a.add(u[1]), i.add(p(e, f + 16))), [a, r] = [r, a], f += 64 } while (f !== v); const w = c.add(a.and(255).shl(1)); return f = x, u[0] = u[0].add(t - 1 & 63), o[0] = o[0].add(u[0]), u[0] = u[0].add(o[0]), r = g(r.add(i).add(o[0]).add(p(e, f + 8)), 37).mul(w), i = g(i.add(o[1]).add(p(e, f + 48)), 42).mul(w), r = r.xor(u[1].mul(9)), i = i.add(o[0].mul(9).add(p(e, f + 40))), a = g(a.add(u[0]), 33).mul(w), o = b(e, f, o[1].mul(w), r.add(u[0])), u = b(e, f + 32, a.add(u[1]), i.add(p(e, f + 16))), [a, r] = [r, a], y(y(o[0], u[0], w).add(d(i).mul(l)).add(a), y(o[1], u[1], w).add(r), w) } /** * @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. * ============================================================================= */ function x(e, t) { return "string" === t ? _(e) : w([e], t) } function w(e, t) { if ("string" === t) throw new Error("Cannot convert a string[] to a TypedArray"); if (Array.isArray(e) && (e = T(e)), (0, r._K)().getBool("DEBUG") && a.nd(e, t), function (e, t) { return e instanceof Float32Array && "float32" === t || e instanceof Int32Array && "int32" === t || e instanceof Uint8Array && "bool" === t }(e, t)) return e; if (null == t || "float32" === t || "complex64" === t) return new Float32Array(e); if ("int32" === t) return new Int32Array(e); if ("bool" === t) { const t = new Uint8Array(e.length); for (let n = 0; n < t.length; ++n)0 !== Math.round(e[n]) && (t[n] = 1); return t } throw new Error(`Unknown data type ${t}`) } function k() { return (0, r._K)().platform.now() } function S(e, t) { return (0, r._K)().platform.fetch(e, t) } function _(e, t = "utf-8") { return t = t || "utf-8", (0, r._K)().platform.encode(e, t) } function C(e, t = "utf-8") { return t = t || "utf-8", (0, r._K)().platform.decode(e, t) } function A(e) { return null != (0, r._K)().platform.isTypedArray ? (0, r._K)().platform.isTypedArray(e) : (0, i.Y)(e) } function T(e, t = [], n = !1) { if (null == t && (t = []), "boolean" == typeof e || "number" == typeof e || "string" == typeof e || a.yL(e) || null == e || A(e) && n) t.push(e); else if (Array.isArray(e) || A(e)) for (let r = 0; r < e.length; ++r)T(e[r], t, n); else { let r = -1; for (const t of Object.keys(e)) /^([1-9]+[0-9]*|0)$/.test(t) && (r = Math.max(r, Number(t))); for (let i = 0; i <= r; i++)T(e[i], t, n) } return t } }, 5119: (e, t, n) => { "use strict"; /** * @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 r(e) { let t = e.length, n = 0; for (; t > 0;)n = Math.random() * t | 0, t--, s(e, t, n) } function i(e, t) { if (e.length !== t.length) throw new Error(`Array sizes must match to be shuffled together First array length was ${e.length}Second array length was ${t.length}`); let n = e.length, r = 0; for (; n > 0;)r = Math.random() * n | 0, n--, s(e, n, r), s(t, n, r) } function a(e, t, n) { return Math.max(e, Math.min(t, n)) } function o(e) { return e % 2 == 0 ? e : e + 1 } function s(e, t, n) { const r = e[t]; e[t] = e[n], e[n] = r } function u(e) { let t = 0; for (let n = 0; n < e.length; n++)t += e[n]; return t } function l(e, t) { const n = Math.random(); return t * n + (1 - n) * e } function c(e, t) { let n = 0; for (let r = 0; r < e.length; r++) { const i = Number(e[r]) - Number(t[r]); n += i * i } return n } function h(e, t) { if (!e) throw new Error("string" == typeof t ? t : t()) } function d(e, t, n = "") { h(y(e, t), (() => n + ` Shapes ${e} and ${t} must match`)) } function f(e) { h(null != e, (() => "The input to the tensor constructor must be a non-null value.")) } function p(e) { if (0 === e.length) return 1; let t = e[0]; for (let n = 1; n < e.length; n++)t *= e[n]; return t } function m(e) { return 0 === e.length } function g(e, t) { if (e === t) return !0; if (null == e || null == t) return !1; if (e.length !== t.length) return !1; for (let n = 0; n < e.length; n++)if (null !== e[n] && null !== t[n] && e[n] !== t[n]) return !1; return !0 } function y(e, t) { if (e === t) return !0; if (null == e || null == t) return !1; if (e.length !== t.length) return !1; for (let n = 0; n < e.length; n++)if (e[n] !== t[n]) return !1; return !0 } function b(e) { return e % 1 == 0 } function v(e) { if (null != Math.tanh) return Math.tanh(e); if (e === 1 / 0) return 1; if (e === -1 / 0) return -1; { const t = Math.exp(2 * e); return (t - 1) / (t + 1) } } function x(e) { const t = Math.ceil(Math.sqrt(e)); return [t, Math.ceil(e / t)] } function w(e) { const t = new Uint32Array(e); for (let n = 0; n < e; ++n)t[n] = n; return r(t), t } function k(e, t) { return t <= e.length ? e : e + " ".repeat(t - e.length) } function S(e, t = e => 0, n, r) { return new Promise(((i, a) => { let o = 0; const s = () => { if (e()) return void i(); o++; const u = t(o); null != n && o >= n ? a() : null != r ? r(s, u) : setTimeout(s, u) }; s() })) } function _(e, t) { let n = 1, r = -1; for (let t = 0; t < e.length; ++t)if (e[t] >= 0) n *= e[t]; else if (-1 === e[t]) { if (-1 !== r) throw Error(`Shapes can only have 1 implicit size. Found -1 at dim ${r} and dim ${t}`); r = t } else if (e[t] < 0) throw Error(`Shapes can not be < 0. Found ${e[t]} at dim ${t}`); if (-1 === r) { if (t > 0 && t !== n) throw Error(`Size(${t}) must match the product of shape ${e}`); return e } if (0 === n) throw Error(`Cannot infer the missing size in [${e}] when there are 0 elements`); if (t % n != 0) throw Error(`The implicit shape can't be a fractional number. Got ${t} / ${n}`); const i = e.slice(); return i[r] = t / n, i } function C(e, t) { const n = t.length; return h((e = null == e ? t.map(((e, t) => t)) : [].concat(e)).every((e => e >= -n && e < n)), (() => `All values in axis param must be in range [-${n}, ${n}) but got axis ${e}`)), h(e.every((e => b(e))), (() => `All values in axis param must be integers but got axis ${e}`)), e.map((e => e < 0 ? n + e : e)) } function A(e, t) { const n = [], r = [], i = null != t && Array.isArray(t) && 0 === t.length, a = null == t || i ? null : C(t, e).sort(); let o = 0; for (let t = 0; t < e.length; ++t) { if (null != a) { if (a[o] === t && 1 !== e[t]) throw new Error(`Can't squeeze axis ${t} since its dim '${e[t]}' is not 1`); (null == a[o] || a[o] > t) && 1 === e[t] && (n.push(e[t]), r.push(t)), a[o] <= t && o++ } 1 !== e[t] && (n.push(e[t]), r.push(t)) } return { newShape: n, keptDims: r } } function T(e, t) { return E(e, t) } function E(e, t) { let n = null; if (null == e || "float32" === e) n = new Float32Array(t); else if ("int32" === e) n = new Int32Array(t); else if ("bool" === e) n = new Uint8Array(t); else { if ("string" !== e) throw new Error(`Unknown data type ${e}`); n = new Array(t) } return n } function N(e, t) { for (let n = 0; n < e.length; n++) { const r = e[n]; if (isNaN(r) || !isFinite(r)) throw Error(`A tensor of type ${t} being uploaded contains ${r}.`) } } function I(e) { return "bool" === e || "complex64" === e || "float32" === e || "int32" === e || "string" === e } function M(e, t) { return "complex64" !== t && (("float32" !== t || "complex64" === e) && (("int32" !== t || "float32" === e || "complex64" === e) && ("bool" !== t || "bool" !== e))) } function F(e) { if ("float32" === e || "int32" === e) return 4; if ("complex64" === e) return 8; if ("bool" === e) return 1; throw new Error(`Unknown dtype ${e}`) } function D(e) { if (null == e) return 0; let t = 0; return e.forEach((e => t += e.length)), t } function $(e) { return "string" == typeof e || e instanceof String } function R(e) { return "boolean" == typeof e } function O(e) { return "number" == typeof e } function z(e) { return Array.isArray(e) ? z(e[0]) : e instanceof Float32Array ? "float32" : e instanceof Int32Array || e instanceof Uint8Array || e instanceof Uint8ClampedArray ? "int32" : O(e) ? "float32" : $(e) ? "string" : R(e) ? "bool" : "float32" } function P(e) { return !!(e && e.constructor && e.call && e.apply) } function B(e, t) { for (let n = t; n < e; ++n)if (e % n == 0) return n; return e } function L(e) { const t = e.length; if (t < 2) return []; const n = new Array(t - 1); n[t - 2] = e[t - 1]; for (let r = t - 3; r >= 0; --r)n[r] = n[r + 1] * e[r + 1]; return n } function j(e, t, n, r = !1) { const i = new Array; if (1 === t.length) { const a = t[0] * (r ? 2 : 1); for (let t = 0; t < a; t++)i[t] = n[e + t] } else { const a = t[0], o = t.slice(1), s = o.reduce(((e, t) => e * t)) * (r ? 2 : 1); for (let t = 0; t < a; t++)i[t] = j(e + t * s, o, n, r) } return i } function U(e, t, n = !1) { if (0 === e.length) return t[0]; const r = e.reduce(((e, t) => e * t)) * (n ? 2 : 1); if (0 === r) return []; if (r !== t.length) throw new Error(`[${e}] does not match the input size ${t.length}${n ? " for a complex tensor" : ""}.`); return j(0, e, t, n) } function W(e, t) { if (Array.isArray(e)) return e; if ("float32" === t) return e instanceof Float32Array ? e : new Float32Array(e); if ("int32" === t) return e instanceof Int32Array ? e : new Int32Array(e); if ("bool" === t || "string" === t) return Uint8Array.from(new Int32Array(e)); throw new Error(`Unknown dtype ${t}`) } function V(e, t) { const n = G(e, t); for (let e = 0; e < n.length; e++)n[e] = 1; return n } function G(e, t) { if (null == t || "float32" === t || "complex64" === t) return new Float32Array(e); if ("int32" === t) return new Int32Array(e); if ("bool" === t) return new Uint8Array(e); throw new Error(`Unknown data type ${t}`) } function H(e, t) { const n = e.reduce(((e, t) => e * t), 1); if (null == t || "float32" === t) return U(e, new Float32Array(n)); if ("int32" === t) return U(e, new Int32Array(n)); if ("bool" === t) return U(e, new Uint8Array(n)); throw new Error(`Unknown data type ${t}`) } function q(e) { e.forEach((t => { h(Number.isInteger(t) && t >= 0, (() => `Tensor must have a shape comprised of positive integers but got shape [${e}].`)) })) } function Y(e, t, n) { if (0 === t) return 0; if (1 === t) return e[0]; let r = e[e.length - 1]; for (let t = 0; t < e.length - 1; ++t)r += n[t] * e[t]; return r } function X(e, t, n) { if (0 === t) return []; if (1 === t) return [e]; const r = new Array(t); for (let t = 0; t < r.length - 1; ++t)r[t] = Math.floor(e / n[t]), e -= r[t] * n[t]; return r[r.length - 1] = e, r } function K(e) { return e && e.then && "function" == typeof e.then } n.d(t, { Ab: () => E, BE: () => M, E6: () => b, Et: () => O, FZ: () => V, HO: () => f, Kg: () => $, Lm: () => R, O3: () => d, P8: () => w, SA: () => q, SL: () => D, Sf: () => m, Tn: () => P, Ty: () => G, Ur: () => L, X$: () => z, XT: () => _, Y6: () => C, Ze: () => p, _k: () => X, _q: () => S, a0: () => i, av: () => k, c7: () => H, ce: () => T, cz: () => u, eV: () => o, e_: () => g, gS: () => x, gx: () => A, jv: () => F, k4: () => r, lK: () => B, nd: () => N, o2: () => W, oO: () => c, qE: () => a, r1: () => y, sX: () => Y, so: () => l, vA: () => h, wg: () => s, xn: () => I, yL: () => K, ym: () => v, yw: () => U }) }, 1936: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205); class a extends r.Component { componentDidMount() { const { name: e, tab: t } = this.props; this.props.registerSurface(e, t, this) } componentDidUpdate() { return !1 } render() { const { name: e, visible: t, styles: n } = this.props, o = Object.assign({}, a.defaultStyles, n), { width: s, height: u } = o; let { maxHeight: l, maxWidth: c } = o; l = u === a.defaultStyles.height ? l : u, c = s === a.defaultStyles.width ? c : s; const h = i.css({ display: t ? "block" : "none", backgroundColor: "white", marginTop: "10px", marginBottom: "10px", boxShadow: "0 0 6px -3px #777", padding: "10px !important", height: u, width: s, maxHeight: l, maxWidth: c, overflow: "auto" }), d = i.css({ backgroundColor: "white", boxSizing: "border-box", borderBottom: "1px solid #357EDD", lineHeight: "2em", marginBottom: "20px", fontWeight: "600", textAlign: "center" }), f = i.css({ boxSizing: "border-box" }); return r.h("div", { className: `${h} tf-surface`, ref: e => this.container = e, "data-visible": t }, r.h("div", { className: `${d} tf-label`, ref: e => this.label = e }, e), r.h("div", { className: `${f} tf-draw-area`, ref: e => this.drawArea = e })) } } a.defaultStyles = { maxWidth: "550px", maxHeight: "580px", height: "auto", width: "auto" }, t.SurfaceComponent = a }, 9779: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205); class a extends r.Component { render() { const { tabNames: e, activeTab: t, handleClick: n } = this.props, a = e.length > 0 ? e.map((e => r.h(o, { key: e, id: e, handleClick: n, isActive: e === t }, e))) : null, s = i.css({ overflowX: "scroll", overflowY: "hidden", whiteSpace: "nowrap", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "#eee", paddingBottom: "1rem", marginTop: "1rem" }); return r.h("div", { className: `${s} visor-tabs` }, a) } } t.Tabs = a; class o extends r.Component { render() { const { children: e, isActive: t, handleClick: n, id: a } = this.props, o = i.css({ borderBottomColor: t ? "#357EDD" : "#AAAAAA", borderBottomWidth: "1px", borderBottomStyle: "solid", cursor: "pointer", ":hover": { color: "#357EDD" }, display: "inline-block", marginRight: "1rem", padding: ".5rem", fontSize: "1rem", fontWeight: "bold" }); return r.h("a", { className: `${o} tf-tab`, "data-isactive": t, onClick: () => n(a) }, e) } } }, 5976: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(5237), i = n(8205), a = n(1936), o = n(9779); class s extends r.Component { static render(e, t, n) { return r.render(r.h(s, Object.assign({}, n)), e, t) } constructor(e) { super(e), this.surfaces = new Map; const t = null == e.startOpen || e.startOpen; this.state = { isOpen: t, isFullscreen: !1, activeTab: null, tabs: new Set }, this.keyHandler = this.keyHandler.bind(this) } close() { this.setState({ isOpen: !1 }) } open() { this.setState({ isOpen: !0 }) } toggle() { this.setState({ isOpen: !this.state.isOpen }) } toggleFullScreen() { this.setState({ isFullscreen: !this.state.isFullscreen }) } isOpen() { return this.state.isOpen } isFullscreen() { return this.state.isFullscreen } getSurface(e, t) { const n = this.surfaceId(e, t); let r; if (!this.surfaces.has(n)) throw Error(`Surface not found with id: ${n}`); return r = this.surfaces.get(n), { container: r.container, label: r.label, drawArea: r.drawArea } } bindKeys() { document.addEventListener("keydown", this.keyHandler, !1) } unbindKeys() { document.removeEventListener("keydown", this.keyHandler) } surfaceId(e, t) { return e + t } setTabs(e) { const t = e.map((e => e.tab)), n = this.state.tabs; let r; for (const e of t) n.has(e) || (n.add(e), r = e); null != r && this.setState({ tabs: n, activeTab: r }) } getTabs() { return this.state.tabs } registerSurface(e, t, n) { const r = this.surfaceId(e, t); this.surfaces.set(r, n) } keyHandler(e) { 192 === e.keyCode && (e.shiftKey ? this.toggleFullScreen() : this.toggle()) } setActiveTab(e) { this.setState({ activeTab: e }) } componentDidMount() { this.bindKeys() } componentWillMount() { this.setTabs(this.props.surfaceList) } componentWillReceiveProps(e) { this.setTabs(e.surfaceList) } render() { const { isOpen: e, isFullscreen: t, activeTab: n } = this.state, { surfaceList: s } = this.props, l = Array.from(this.getTabs().values()), c = t ? "90vw" : "550px", h = i.css({ width: c, height: "100%", backgroundColor: "#fafafa", boxSizing: "border-box", padding: "10px", position: "fixed", top: "0px", transition: "right 0.5s cubic-bezier(0.645, 0.045, 0.355, 1), width 0.5s cubic-bezier(0.645, 0.045, 0.355, 1)", boxShadow: "0 2px 5px rgba(0, 0, 0, 0.12), 0 2px 5px rgba(0, 0, 0, 0.24)", overflow: "auto", fontFamily: "sans-serif", fontSize: "14px", zIndex: 1e3 }), d = i.css({ right: "0" }), f = i.css({ right: `calc(-${c} - 10px)` }), p = e ? d : f, m = i.css({}); return r.h("div", { className: `${h} ${p} visor`, "data-isopen": e, "data-isfullscreen": t }, r.h(u, { fullScreenHandler: this.toggleFullScreen.bind(this), closeHandler: this.close.bind(this), isFullScreen: t }), r.h(o.Tabs, { tabNames: l, activeTab: n, handleClick: this.setActiveTab.bind(this) }), r.h("div", { className: `${m} visor-surfaces` }, s.map((e => r.h(a.SurfaceComponent, { key: e.name + e.tab, name: e.name, tab: e.tab, styles: e.styles, registerSurface: this.registerSurface.bind(this), visible: n === e.tab }))))) } } function u(e) { const { isFullScreen: t, fullScreenHandler: n, closeHandler: a } = e, o = i.css({ display: "flex", backgroundColor: "white", border: "1px solid white", padding: "6px", paddingTop: "10px", marginBottom: "10px", borderRadius: "6px", marginTop: "-16px" }), s = i.css({ fontSize: ".875rem", borderRadius: ".25rem", paddingLeft: "1rem", paddingRight: "1rem", paddingTop: ".5rem", paddingBottom: ".5rem", textDecoration: "none", transition: "color .15s ease-in", color: "#111" }), u = i.css({ marginLeft: "auto" }); return r.h("div", { className: `${o} visor-controls` }, r.h("button", { className: `${s}`, onClick: n }, t ? "Minimize" : "Maximize"), r.h("button", { className: `${s} ${u}`, onClick: a }, "Hide")) } t.VisorComponent = s }, 9778: (e, t, n) => { "use strict"; Object.defineProperty(t, "__esModule", { value: !0 }), /** * @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. * ============================================================================= */ n(5838), n(455); const r = n(2784), i = n(3739), a = n(7483), o = n(5877), s = n(4857), u = n(898), l = n(9827), c = n(62), h = n(3559), d = n(5727), f = n(4853), p = n(2729), m = n(454); t.version_vis = m.version; const g = { barchart: r.barchart, table: l.table, histogram: o.histogram, linechart: s.linechart, scatterplot: u.scatterplot, confusionMatrix: i.confusionMatrix, heatmap: a.heatmap }; t.render = g; const y = { accuracy: p.accuracy, perClassAccuracy: p.perClassAccuracy, confusionMatrix: p.confusionMatrix }; t.metrics = y; const b = { history: c.history, fitCallbacks: c.fitCallbacks, perClassAccuracy: d.perClassAccuracy, valuesDistribution: f.valuesDistribution, layer: h.layer, modelSummary: h.modelSummary }; t.show = b; var v = n(4701); t.visor = v.visor, function (e) { for (var n in e) t.hasOwnProperty(n) || (t[n] = e[n]) }(n(5759)) }, 2784: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6857); t.barchart = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = s.getDrawArea(e), i = t, c = Object.assign({}, u, n); if (l.has(r)) { const e = l.get(r); if (s.shallowEquals(c, e.lastOptions)) { yield s.nextFrame(); const t = e.view, n = t.changeset().remove((() => !0)).insert(i); return void (yield t.change("values", n).runAsync()) } } const { xLabel: h, yLabel: d, xType: f, yType: p } = c; let m = null; null != h && (m = { title: h }); let g = null; null != d && (g = { title: d }); let y; y = null != c.color ? Array.isArray(c.color) ? { field: "index", type: "nominal", scale: { range: c.color } } : { value: c.color } : { value: "#4C78A0" }; const b = { width: c.width || o.getDefaultWidth(r), height: c.height || o.getDefaultHeight(r), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: c.fontSize, titleFontSize: c.fontSize }, text: { fontSize: c.fontSize }, legend: { labelFontSize: c.fontSize, titleFontSize: c.fontSize } }, data: { values: i, name: "values" }, mark: { type: "bar", tooltip: !0 }, encoding: { x: { field: "index", type: f, axis: m }, y: { field: "value", type: p, axis: g }, color: y } }; yield s.nextFrame(); const v = yield a.default(r, b, { actions: !1, mode: "vega-lite", defaultStyle: !1 }); l.set(r, { view: v.view, lastOptions: c }) })) }; const u = { xLabel: "", yLabel: "", xType: "ordinal", yType: "quantitative", fontSize: 11 }, l = new Map }, 3739: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6857); t.confusionMatrix = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = Object.assign({}, u, n), i = s.getDrawArea(e), l = [], c = t.values, h = t.tickLabels || [], d = 0 === h.length; let f = !0; for (let e = 0; e < c.length; e++) { const t = d ? `Class ${e}` : h[e]; d && h.push(t); for (let n = 0; n < c[e].length; n++) { const i = d ? `Class ${n}` : h[n], a = c[e][n]; e !== n || r.shadeDiagonal ? (l.push({ label: t, prediction: i, count: a, scaleCount: a }), 0 !== a && (f = !1)) : l.push({ label: t, prediction: i, count: a, noFill: !0 }) } } if (!r.shadeDiagonal && f) for (const e of l) !0 === e.noFill && (e.noFill = !1, e.scaleCount = e.count); const p = { width: r.width || o.getDefaultWidth(i), height: r.height || o.getDefaultHeight(i), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: r.fontSize, titleFontSize: r.fontSize }, text: { fontSize: r.fontSize }, legend: { labelFontSize: r.fontSize, titleFontSize: r.fontSize } }, data: { values: l }, encoding: { x: { field: "prediction", type: "ordinal", title: r.xLabel || "prediction", scale: { domain: h } }, y: { field: "label", type: "ordinal", title: r.yLabel || "label", scale: { domain: h } } }, layer: [{ transform: [{ filter: "datum.noFill != true" }], mark: { type: "rect" }, encoding: { color: { field: "scaleCount", type: "quantitative", scale: { range: r.colorMap } }, tooltip: [{ field: "label", type: "nominal" }, { field: "prediction", type: "nominal" }, { field: "count", type: "quantitative" }] } }] }; !1 === r.shadeDiagonal && p.layer.push({ transform: [{ filter: "datum.noFill == true" }], mark: { type: "rect", fill: "white" }, encoding: { tooltip: [{ field: "label", type: "nominal" }, { field: "prediction", type: "nominal" }, { field: "count", type: "quantitative" }] } }), r.showTextOverlay && p.layer.push({ mark: { type: "text", baseline: "middle" }, encoding: { text: { field: "count", type: "nominal" } } }); const m = "string" == typeof r.colorMap ? { scheme: r.colorMap } : r.colorMap; p.layer[0].encoding.color.scale.range = m, yield a.default(i, p, { actions: !1, mode: "vega-lite", defaultStyle: !1 }) })) }; const u = { xLabel: null, yLabel: null, xType: "nominal", yType: "nominal", shadeDiagonal: !0, fontSize: 12, showTextOverlay: !0, height: 400, colorMap: ["#f7fbff", "#4292c6"] } }, 7483: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importStar || function (e) { if (e && e.__esModule) return e; var t = {}; if (null != e) for (var n in e) Object.hasOwnProperty.call(e, n) && (t[n] = e[n]); return t.default = e, t }, a = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const o = i(n(5838)), s = a(n(8731)), u = n(8227), l = n(6286), c = n(6857); function h(e, t, n) { const r = e instanceof o.Tensor ? e.shape : [e.length, e[0].length]; 0 === n ? l.assert(r[0] === t.length, `Length of xTickLabels (${t.length}) must match number of rows (${r[0]})`) : 1 === n && l.assert(r[1] === t.length, `Length of yTickLabels (${t.length}) must match number of columns (${r[1]})`) } t.heatmap = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const i = Object.assign({}, d, n), a = c.getDrawArea(e); let f = t.values; i.rowMajor && (f = yield function (e) { return r(this, void 0, void 0, (function* () { let t, n; e instanceof o.Tensor ? (t = e.shape, n = e.transpose()) : (t = [e.length, e[0].length], n = o.tidy((() => o.tensor2d(e).transpose()))), l.assert(2 === n.rank, "Input to renderHeatmap must be a 2d array or Tensor2d"); const r = yield n.array(); n.dispose(); const i = [r.length, r[0].length]; return l.assert(t[0] === i[1] && t[1] === i[0], `Unexpected transposed shape. Original ${t} : Transposed ${i}`), r })) }(t.values)); const { xTickLabels: p, yTickLabels: m } = t; if (null != p) { h(f, p, 0) } if (null != m) { h(f, m, 1) } const g = "@tfidx@", y = []; if (f instanceof o.Tensor) { l.assert(2 === f.rank, "Input to renderHeatmap must be a 2d array or Tensor2d"); const e = yield f.data(), [t, n] = f.shape; for (let r = 0; r < t; r++) { const t = p ? `${p[r]}${g}${r}` : r; for (let i = 0; i < n; i++) { const a = m ? `${m[i]}${g}${i}` : i, o = e[r * n + i]; y.push({ x: t, y: a, value: o }) } } } else { const e = f; for (let t = 0; t < e.length; t++) { const n = p ? `${p[t]}${g}${t}` : t; for (let r = 0; r < e[t].length; r++) { const i = m ? `${m[r]}${g}${r}` : r, a = e[t][r]; y.push({ x: n, y: i, value: a }) } } } const b = { actions: !1, mode: "vega-lite", defaultStyle: !1 }, v = { width: i.width || u.getDefaultWidth(a), height: i.height || u.getDefaultHeight(a), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, text: { fontSize: i.fontSize }, legend: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, scale: { bandPaddingInner: 0, bandPaddingOuter: 0 } }, data: { values: y }, mark: { type: "rect", tooltip: !0 }, encoding: { x: { field: "x", type: i.xType, title: i.xLabel, sort: !1 }, y: { field: "y", type: i.yType, title: i.yLabel, sort: !1 }, fill: { field: "value", type: "quantitative" } } }, x = `${g}\\d+$`, w = new RegExp(x); let k; switch (p && (v.encoding.x.axis = { labelExpr: `replace(datum.value, regexp(/${x}/), '')` }), m && (v.encoding.y.axis = { labelExpr: `replace(datum.value, regexp(/${x}/), '')` }), (p || m) && (b.tooltip = { sanitize: e => String(e).replace(w, "") }), i.colorMap) { case "blues": k = ["#f7fbff", "#4292c6"]; break; case "greyscale": k = ["#000000", "#ffffff"]; break; default: k = "viridis" }if ("viridis" !== k) { v.encoding.fill.scale = { range: k } } if (i.domain) { const e = v.encoding.fill; null != e.scale ? e.scale = Object.assign({}, e.scale, { domain: i.domain }) : e.scale = { domain: i.domain } } yield s.default(a, v, b) })) }; const d = { xLabel: null, yLabel: null, xType: "ordinal", yType: "ordinal", colorMap: "viridis", fontSize: 12, domain: null, rowMajor: !1 } }, 5877: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = n(1934), o = i(n(8731)), s = n(8227), u = n(2729), l = n(9827), c = { maxBins: 12, fontSize: 11 }; t.histogram = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = function (e) { if (null == e.length) throw new Error("input data must be an array"); if (0 === e.length) return []; if ("object" == typeof e[0]) { if (null == e[0].value) throw new Error("input data must have a value field"); return e } { const t = Array(e.length); for (let n = 0; n < e.length; n++)t[n] = { value: e[n] }; return t } }(t), i = Object.assign({}, c, n), h = s.subSurface(e, "histogram"); if (!1 !== n.stats) { const t = s.subSurface(e, "stats", { prepend: !0 }); let o; o = n.stats ? n.stats : u.arrayStats(r.map((e => e.value))), function (e, t, n) { const r = a.format(",.4~f"), i = a.format(".4~p"), o = [], s = []; null != e.numVals && (o.push("Num Vals"), s.push(r(e.numVals))); null != e.min && (o.push("Min"), s.push(r(e.min))); null != e.max && (o.push("Max"), s.push(r(e.max))); if (null != e.numZeros) { o.push("# Zeros"); let t = ""; e.numVals && (t = e.numZeros > 0 ? `(${i(e.numZeros / e.numVals)})` : ""), s.push(`${r(e.numZeros)} ${t}`) } if (null != e.numNans) { o.push("# NaNs"); let t = ""; e.numVals && (t = e.numNans > 0 ? `(${i(e.numNans / e.numVals)})` : ""), s.push(`${r(e.numNans)} ${t}`) } if (null != e.numInfs) { o.push("# Infinity"); let t = ""; e.numVals && (t = e.numInfs > 0 ? `(${i(e.numInfs / e.numVals)})` : ""), s.push(`${r(e.numInfs)} ${t}`) } l.table(t, { headers: o, values: [s] }, n) }(o, t, { fontSize: i.fontSize }) } if (0 === r.length) return; const d = []; for (let e = 0; e < r.length; e++) { const t = r[e].value; null != t && isFinite(t) && d.push(r[e]) } const f = { width: i.width || s.getDefaultWidth(h), height: i.height || s.getDefaultHeight(h), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, data: { values: d }, mark: { type: "bar", tooltip: !0 }, config: { axis: { labelFontSize: i.fontSize, titleFontSize: i.fontSize }, text: { fontSize: i.fontSize }, legend: { labelFontSize: i.fontSize, titleFontSize: i.fontSize } }, encoding: { x: { bin: { maxbins: i.maxBins }, field: "value", type: "quantitative" }, y: { aggregate: "count", type: "quantitative" }, color: { value: i.color || "#001B44" } } }; return o.default(h, f, { actions: !1, mode: "vega-lite", defaultStyle: !1 }) })) } }, 4857: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6286), u = n(6857); t.linechart = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { const r = Array.isArray(t.values[0]) ? t.values : [t.values], i = r[0].length, c = t.series ? t.series : r.map(((e, t) => `Series ${t + 1}`)); s.assert(c.length === r.length, "Must have an equal number of series labels as there are data series"), null != n.seriesColors && s.assert(n.seriesColors.length === r.length, "Must have an equal number of series colors as there are data series"); const h = []; for (let e = 0; e < i; e++) { const t = { x: e }; c.forEach(((n, i) => { const a = r[i][e].y; t[n] = a, t[`${n}-name`] = n })), h.push(t) } const d = Object.assign({}, l, n), f = { x: { field: "x", type: d.xType, title: d.xLabel }, tooltip: [{ field: "x", type: "quantitative" }, ...c.map((e => ({ field: e, type: "quantitative" })))] }, p = c.map((e => ({ data: void 0, mark: { type: "line", clip: !0 }, encoding: { y: { field: e, type: d.yType, title: d.yLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.yAxisDomain ? { domain: d.yAxisDomain } : void 0 }, color: { field: `${e}-name`, type: "nominal", legend: { values: c, title: null }, scale: { range: d.seriesColors } } } }))), m = u.getDrawArea(e), g = { width: d.width || o.getDefaultWidth(m), height: d.height || o.getDefaultHeight(m), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: d.fontSize, titleFontSize: d.fontSize }, text: { fontSize: d.fontSize }, legend: { labelFontSize: d.fontSize, titleFontSize: d.fontSize } }, data: { values: h }, encoding: f, layer: [...p, { mark: "rule", selection: { hover: { type: "single", on: "mouseover", nearest: !0, clear: "mouseout" } }, encoding: { color: { value: "grey", condition: { selection: { not: "hover" }, value: "transparent" } } } }] }; return yield a.default(m, g, { actions: !1, mode: "vega-lite", defaultStyle: !1 }), Promise.resolve() })) }; const l = { xLabel: "x", yLabel: "y", xType: "quantitative", yType: "quantitative", zoomToFit: !1, fontSize: 11 } }, 6857: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5759), a = n(4701); t.getDrawArea = function (e) { if (e instanceof HTMLElement) return e; if (i.isSurface(e)) return e.drawArea; if (i.isSurfaceInfo(e)) { return a.visor().surface({ name: e.name, tab: e.tab, styles: e.styles }).drawArea } throw new Error("Not a drawable") }, t.shallowEquals = function (e, t) { const n = Object.getOwnPropertyNames(e), r = Object.getOwnPropertyNames(t); if (n.length !== r.length) return !1; for (let r = 0; r < n.length; r++) { const i = n[r]; if (e[i] !== t[i]) return !1 } return !0 }, t.nextFrame = function () { return r(this, void 0, void 0, (function* () { yield new Promise((e => requestAnimationFrame(e))) })) } }, 898: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }, i = this && this.__importDefault || function (e) { return e && e.__esModule ? e : { default: e } }; Object.defineProperty(t, "__esModule", { value: !0 }); const a = i(n(8731)), o = n(8227), s = n(6286), u = n(6857); t.scatterplot = function (e, t, n = {}) { return r(this, void 0, void 0, (function* () { let r = t.values; const i = null == t.series ? [] : t.series; r = Array.isArray(r[0]) ? r : [r]; const c = []; r.forEach(((e, t) => { const n = null != i[t] ? i[t] : `Series ${t + 1}`, r = e.map((e => Object.assign({}, e, { series: n }))); c.push(...r) })), null != n.seriesColors && s.assert(n.seriesColors.length === r.length, "Must have an equal number of series colors as there are data series"); const h = u.getDrawArea(e), d = Object.assign({}, l, n), f = { width: d.width || o.getDefaultWidth(h), height: d.height || o.getDefaultHeight(h), padding: 0, autosize: { type: "fit", contains: "padding", resize: !0 }, config: { axis: { labelFontSize: d.fontSize, titleFontSize: d.fontSize }, text: { fontSize: d.fontSize }, legend: { labelFontSize: d.fontSize, titleFontSize: d.fontSize } }, data: { values: c }, mark: { type: "point", clip: !0, tooltip: { content: "data" } }, encoding: { x: { field: "x", type: d.xType, title: d.xLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.xAxisDomain ? { domain: d.xAxisDomain } : void 0 }, y: { field: "y", type: d.yType, title: d.yLabel, scale: d.zoomToFit ? { zero: !1 } : null != d.yAxisDomain ? { domain: d.yAxisDomain } : void 0 }, color: { field: "series", type: "nominal", scale: { range: d.seriesColors } }, shape: { field: "series", type: "nominal" } } }; return yield a.default(h, f, { actions: !1, mode: "vega-lite", defaultStyle: !1 }), Promise.resolve() })) }; const l = { xLabel: "x", yLabel: "y", xType: "quantitative", yType: "quantitative", zoomToFit: !1, fontSize: 11 } }, 9827: (e, t, n) => { "use strict"; /** * @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. * ============================================================================= */Object.defineProperty(t, "__esModule", { value: !0 }); const r = n(1934), i = n(716), a = n(8205), o = n(6857); t.table = function (e, t, n = {}) { if (t && null == t.headers) throw new Error('Data to render must have a "headers" property'); if (t && null == t.values) throw new Error('Data to render must have a "values" property'); const u = o.getDrawArea(e), l = Object.assign({}, s, n); let c = i.select(u).select("table.tf-table"); const h = a.css({ fontSize: l.fontSize || ".875rem", width: "100%", maxWidth: "64rem", marginRight: "auto", marginLeft: "auto" }); if (0 === c.size() && (c = i.select(u).append("table"), c.attr("class", ` ${h} tf-table`), c.append("thead").append("tr"), c.append("tbody")), 1 !== c.size()) throw new Error("Error inserting table"); const d = a.css({ fontWeight: "600", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "rgba( 0, 0, 0, .2 )", textAlign: "left", paddingBottom: "1rem", paddingRight: "1rem", backgroundColor: "#fff" }), f = c.select("thead").select("tr").selectAll("th").data(t.headers), p = f.enter().append("th").attr("class", `${d}`); f.merge(p).html((e => e)), f.exit().remove(); const m = r.format(",.4~f"), g = c.select("tbody").selectAll("tr").data(t.values), y = g.enter().append("tr"), b = a.css({ padding: "0.25rem", borderBottomStyle: "solid", borderBottomWidth: "1px", borderColor: "rgba( 0, 0, 0, .2 )" }), v = g.merge(y).selectAll("td").data((e => e)), x = v.enter().append("td").attr("class", `${b}`); v.merge(x).html((e => "number" == typeof e ? m(e) : e)), v.exit().remove(), g.exit().remove() }; const s = { fontSize: 14 } }, 62: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(4857), a = n(6857), o = n(8227); function s(e, t, n, s = {}) { return r(this, void 0, void 0, (function* () { const r = a.getDrawArea(e), c = {}; for (const e of n) if (/val_/.test(e)) { const r = e.replace("val_", ""); u(c, r); const i = l(t, e, n.indexOf(e)); c[r].series.push(e), c[r].values.push(i) } else { const r = l(t, e, n.indexOf(e)); u(c, e), c[e].series.push(e), c[e].values.push(r) } const h = Object.keys(c), d = Object.assign({}, { xLabel: "Iteration", yLabel: "Value" }, s), f = []; for (const e of h) { const t = o.subSurface(r, e), n = c[e].series, a = c[e].values; n.every((e => Boolean(e.match("acc")))) && (d.zoomToFitAccuracy ? d.zoomToFit = !0 : (d.yAxisDomain = [0, 1], delete d.zoomToFit)); const s = i.linechart(t, { values: a, series: n }, d); f.push(s) } yield Promise.all(f) })) } function u(e, t) { null == e[t] && (e[t] = { series: [], values: [] }) } function l(e, t, n) { if (Array.isArray(e)) { const r = Array.isArray(e[0]) ? e[n] : e, i = []; for (let e = 0; e < r.length; e++) { const n = r[e]; i.push({ x: e, y: n[t] }) } return i } return e.history[t].map(((e, t) => ({ x: t, y: e }))) } function c(e, t, n) { return null == e[t] && (e[t] = {}), null == e[t][n] && (e[t][n] = []), e[t][n] } t.history = s, t.fitCallbacks = function (e, t, n = {}) { const i = {}, u = n.callbacks || ["onEpochEnd", "onBatchEnd"], l = a.getDrawArea(e), h = Object.assign({}, n); delete h.callbacks; const d = {}; return u.forEach((e => { d[e] = function (e) { return (n, u) => r(this, void 0, void 0, (function* () { /batch/i.test(e) ? h.xLabel = "Batch" : /epoch/i.test(e) && (h.xLabel = "Epoch"); const n = [], r = []; for (const a of t) if (null != u[a]) { r.push(a); const t = c(i, e, a); t.push({ [a]: u[a] }), n.push(t) } s(o.subSurface(l, e, { title: e }), n, r, h), yield a.nextFrame() })) }(e) })), d } }, 3559: function (e, t, n) { "use strict"; /** * @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. * ============================================================================= */var r = this && this.__awaiter || function (e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { e.done ? i(e.value) : new n((function (t) { t(e.value) })).then(o, s) } u((r = r.apply(e, t || [])).next()) })) }; Object.defineProperty(t, "__esModule", { value: !0 }); const i = n(5877), a = n(6857), o = n(9827), s = n(8227), u = n(2729); function l(e) { let t; if (Array.isArray(e.outputShape[0])) { t = `[${e.outputShape.map((e => c(e))).join(", ")}]` } else t = c(e.outputShape); return { name: e.name, trainable: e.trainable, parameters: e.countParams(), outputShape: t } } function c(e) { const t = e.slice(); return 0 === t.length ? "Scalar" : (null === t[0] && (t[0] = "batch"), `[${t.join(",")}]`) } t.modelSummary = function (e, t) { return r(this, void 0, void 0, (function* () { const n = a.getDrawArea(e), r = function (e) { return { layers: e.layers.map(l) } }(t), i = r.layers.map((e => [e.name, e.outputShape, e.parameters, e.trainable])); o.table(n, { headers: ["Layer Name", "Output Shape", "# Of Params", "Trainable"], values: i }) })) }, t.layer = function (e, t) { return r(this, void 0, void 0, (function* () { const n = a.getDrawArea(e), l = yield function (e) { return r(this, void 0, void 0, (function* () { const t = e.getWeights(), n = e.weights, r = t.map(u.tensorStats), i = yield Promise.all(r), a = t.map((e => e.shape)); return t.map(((e, t) => ({ name: n[t].name, stats: i[t], shape: c(a[t]), weight: e }))) })) }(t), h = s.subSurface(n, "layer-weights-info"), d = l.map((e => [e.name, e.shape, e.stats.min, e.stats.max, e.weight.size, e.stats.numZeros, e.stats.numNans, e.stats.numInfs])); o.table(h, { headers: ["Weight Name", "Shape", "Min", "Max", "# Params", "# Zeros", "# NaNs", "# Infinity"], values: d }); const f = s.subSurface(n, "select-layer"), p = s.subSurface(n, "param-distribution"); !function (e, t, n) { const r = `\n \n `, i = `
| ${t(e)}: | ${t(i)} |
`, a = `${n}`, o = window.open(""); o.document.write(i + e + a), o.document.title = `${Kje[r]} JSON Source` } function nUe(e, t) { var n; if (e.$schema) { const r = ILe(e.$schema); t && t !== r.library && console.warn(`The given visualization spec is written in ${Kje[r.library]}, but mode argument sets ${null !== (n = Kje[t]) && void 0 !== n ? n : t}.`); const i = r.library; return (0, te.satisfies)(Zje[i], `^${r.version.slice(1)}`) || console.warn(`The input spec uses ${Kje[i]} ${r.version}, but the current version of ${Kje[i]} is v${Zje[i]}.`), i } return "mark" in e || "encoding" in e || "layer" in e || "hconcat" in e || "vconcat" in e || "facet" in e || "repeat" in e ? "vega-lite" : "marks" in e || "signals" in e || "scales" in e || "axes" in e ? "vega" : null != t ? t : "vega" } function rUe(e) { return (t = e) && "load" in t ? e : Gje.loader(e); var t } function iUe(e) { var t; return null !== (t = e.usermeta && e.usermeta.embedOptions) && void 0 !== t ? t : {} } function aUe(e, t) { var n; return Lje(this, void 0, void 0, (function* () { const r = wt(e.config) ? JSON.parse(yield t.load(e.config)) : null !== (n = e.config) && void 0 !== n ? n : {}, i = wt(e.patch) ? JSON.parse(yield t.load(e.patch)) : e.patch; return Object.assign(Object.assign(Object.assign({}, e), i ? { patch: i } : {}), r ? { config: r } : {}) })) } const oUe = function (e, t, n = {}) { var r, i, a; return Lje(this, void 0, void 0, (function* () { let o, s; wt(t) ? (s = rUe(n.loader), o = JSON.parse(yield s.load(t))) : o = t; const u = iUe(o).loader; s && !u || (s = rUe(null !== (r = n.loader) && void 0 !== r ? r : u)); const l = yield aUe(iUe(o), s), c = yield aUe(n, s), h = Object.assign(Object.assign({}, Wje(c, l)), { config: Te(null !== (i = c.config) && void 0 !== i ? i : {}, null !== (a = l.config) && void 0 !== a ? a : {}) }); return yield function (e, t, n = {}, r) { var i, a, o, s, u, l; return Lje(this, void 0, void 0, (function* () { const c = n.theme ? Te(k[n.theme], null !== (i = n.config) && void 0 !== i ? i : {}) : n.config, h = gt(n.actions) ? n.actions : Wje({}, Yje, null !== (a = n.actions) && void 0 !== a ? a : {}), d = Object.assign(Object.assign({}, Xje), n.i18n), f = null !== (o = n.renderer) && void 0 !== o ? o : "canvas", p = null !== (s = n.logLevel) && void 0 !== s ? s : Gje.Warn, m = null !== (u = n.downloadFileName) && void 0 !== u ? u : "visualization", g = "string" == typeof e ? document.querySelector(e) : e; if (!g) throw new Error(`${e} does not exist`); if (!1 !== n.defaultStyle) { const e = "vega-embed-style", { root: t, rootContainer: r } = function (e) { var t; const n = e.getRootNode ? e.getRootNode() : document; return n instanceof ShadowRoot ? { root: n, rootContainer: n } : { root: document, rootContainer: null !== (t = document.head) && void 0 !== t ? t : document.body } }(g); if (!t.getElementById(e)) { const t = document.createElement("style"); t.id = e, t.innerText = void 0 === n.defaultStyle || !0 === n.defaultStyle ? Uje.toString() : n.defaultStyle, r.appendChild(t) } } const y = nUe(t, n.mode); let b = Jje[y](t, c); if ("vega-lite" === y && b.$schema) { const e = ILe(b.$schema); (0, te.satisfies)(Zje.vega, `^${e.version.slice(1)}`) || console.warn(`The compiled spec uses Vega ${e.version}, but current version is v${Zje.vega}.`) } g.classList.add("vega-embed"), h && g.classList.add("has-actions"), g.innerHTML = ""; let v = g; if (h) { const e = document.createElement("div"); e.classList.add(eUe), g.appendChild(e), v = e } const x = n.patch; x && (b = x instanceof Function ? x(b) : L(b, x, !0, !1).newDocument), n.formatLocale && Gje.formatLocale(n.formatLocale), n.timeFormatLocale && Gje.timeFormatLocale(n.timeFormatLocale); const { ast: w } = n, S = Gje.parse(b, "vega-lite" === y ? {} : c, { ast: w }), _ = new (n.viewClass || Gje.View)(S, Object.assign({ loader: r, logLevel: p, renderer: f }, w ? { expr: Gje.expressionInterpreter } : {})); if (!1 !== n.tooltip) { let e; e = function (e) { return "function" == typeof e }(n.tooltip) ? n.tooltip : new Bje(!0 === n.tooltip ? {} : n.tooltip).call, _.tooltip(e) } let C, { hover: A } = n; if (void 0 === A && (A = "vega" === y), A) { const { hoverSet: e, updateSet: t } = "boolean" == typeof A ? {} : A; _.hover(e, t) } if (n && (null != n.width && _.width(n.width), null != n.height && _.height(n.height), null != n.padding && _.padding(n.padding)), yield _.initialize(v, n.bind).runAsync(), !1 !== h) { let e = g; if (!1 !== n.defaultStyle) { const t = document.createElement("details"); t.title = d.CLICK_TO_VIEW_ACTIONS, g.append(t), e = t; const n = document.createElement("summary"); n.innerHTML = Qje, t.append(n), C = e => { t.contains(e.target) || t.removeAttribute("open") }, document.addEventListener("click", C) } const r = document.createElement("div"); if (e.append(r), r.classList.add("vega-actions"), !0 === h || !1 !== h.export) for (const e of ["svg", "png"]) if (!0 === h || !0 === h.export || h.export[e]) { const t = d[`${e.toUpperCase()}_ACTION`], i = document.createElement("a"); i.text = t, i.href = "#", i.target = "_blank", i.download = `${m}.${e}`, i.addEventListener("mousedown", (function (t) { return Lje(this, void 0, void 0, (function* () { t.preventDefault(); const r = yield _.toImageURL(e, n.scaleFactor); this.href = r })) })), r.append(i) } if (!0 === h || !1 !== h.source) { const e = document.createElement("a"); e.text = d.SOURCE_ACTION, e.href = "#", e.addEventListener("click", (function (e) { var r, i; tUe(ee()(t), null !== (r = n.sourceHeader) && void 0 !== r ? r : "", null !== (i = n.sourceFooter) && void 0 !== i ? i : "", y), e.preventDefault() })), r.append(e) } if ("vega-lite" === y && (!0 === h || !1 !== h.compiled)) { const e = document.createElement("a"); e.text = d.COMPILED_ACTION, e.href = "#", e.addEventListener("click", (function (e) { var t, r; tUe(ee()(b), null !== (t = n.sourceHeader) && void 0 !== t ? t : "", null !== (r = n.sourceFooter) && void 0 !== r ? r : "", "vega"), e.preventDefault() })), r.append(e) } if (!0 === h || !1 !== h.editor) { const e = null !== (l = n.editorUrl) && void 0 !== l ? l : "https://vega.github.io/editor/", i = document.createElement("a"); i.text = d.EDITOR_ACTION, i.href = "#", i.addEventListener("click", (function (n) { !function (e, t, n) { const r = e.open(t), { origin: i } = new URL(t); let a = 40; e.addEventListener("message", (function t(n) { n.source === r && (a = 0, e.removeEventListener("message", t, !1)) }), !1), setTimeout((function e() { a <= 0 || (r.postMessage(n, i), setTimeout(e, 250), a -= 1) }), 250) }(window, e, { config: c, mode: y, renderer: f, spec: ee()(t) }), n.preventDefault() })), r.append(i) } } function T() { C && document.removeEventListener("click", C), _.finalize() } return { view: _, spec: t, vgSpec: b, finalize: T } })) }(e, o, h, s) })) }
}, 147: (e, t, n) => { const r = Symbol("SemVer ANY"); class i { static get ANY() { return r } constructor(e, t) { if (t = a(t), e instanceof i) { if (e.loose === !!t.loose) return e; e = e.value } e = e.trim().split(/\s+/).join(" "), l("comparator", e, t), this.options = t, this.loose = !!t.loose, this.parse(e), this.semver === r ? this.value = "" : this.value = this.operator + this.semver.version, l("comp", this) } parse(e) { const t = this.options.loose ? o[s.COMPARATORLOOSE] : o[s.COMPARATOR], n = e.match(t); if (!n) throw new TypeError(`Invalid comparator: ${e}`); this.operator = void 0 !== n[1] ? n[1] : "", "=" === this.operator && (this.operator = ""), n[2] ? this.semver = new c(n[2], this.options.loose) : this.semver = r } toString() { return this.value } test(e) { if (l("Comparator.test", e, this.options.loose), this.semver === r || e === r) return !0; if ("string" == typeof e) try { e = new c(e, this.options) } catch (e) { return !1 } return u(e, this.operator, this.semver, this.options) } intersects(e, t) { if (!(e instanceof i)) throw new TypeError("a Comparator is required"); return "" === this.operator ? "" === this.value || new h(e.value, t).test(this.value) : "" === e.operator ? "" === e.value || new h(this.value, t).test(e.semver) : (!(t = a(t)).includePrerelease || "<0.0.0-0" !== this.value && "<0.0.0-0" !== e.value) && (!(!t.includePrerelease && (this.value.startsWith("<0.0.0") || e.value.startsWith("<0.0.0"))) && (!(!this.operator.startsWith(">") || !e.operator.startsWith(">")) || (!(!this.operator.startsWith("<") || !e.operator.startsWith("<")) || (!(this.semver.version !== e.semver.version || !this.operator.includes("=") || !e.operator.includes("=")) || (!!(u(this.semver, "<", e.semver, t) && this.operator.startsWith(">") && e.operator.startsWith("<")) || !!(u(this.semver, ">", e.semver, t) && this.operator.startsWith("<") && e.operator.startsWith(">"))))))) } } e.exports = i; const a = n(8324), { safeRe: o, t: s } = n(6063), u = n(4806), l = n(9847), c = n(6283), h = n(2894) }, 2894: (e, t, n) => { const r = /\s+/g; class i { constructor(e, t) { if (t = o(t), e instanceof i) return e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease ? e : new i(e.raw, t); if (e instanceof s) return this.raw = e.value, this.set = [[e]], this.formatted = void 0, this; if (this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease, this.raw = e.trim().replace(r, " "), this.set = this.raw.split("||").map((e => this.parseRange(e.trim()))).filter((e => e.length)), !this.set.length) throw new TypeError(`Invalid SemVer Range: ${this.raw}`); if (this.set.length > 1) { const e = this.set[0]; if (this.set = this.set.filter((e => !y(e[0]))), 0 === this.set.length) this.set = [e]; else if (this.set.length > 1) for (const e of this.set) if (1 === e.length && b(e[0])) { this.set = [e]; break } } this.formatted = void 0 } get range() { if (void 0 === this.formatted) { this.formatted = ""; for (let e = 0; e < this.set.length; e++) { e > 0 && (this.formatted += "||"); const t = this.set[e]; for (let e = 0; e < t.length; e++)e > 0 && (this.formatted += " "), this.formatted += t[e].toString().trim() } } return this.formatted } format() { return this.range } toString() { return this.range } parseRange(e) { const t = ((this.options.includePrerelease && m) | (this.options.loose && g)) + ":" + e, n = a.get(t); if (n) return n; const r = this.options.loose, i = r ? c[h.HYPHENRANGELOOSE] : c[h.HYPHENRANGE]; e = e.replace(i, I(this.options.includePrerelease)), u("hyphen replace", e), e = e.replace(c[h.COMPARATORTRIM], d), u("comparator trim", e), e = e.replace(c[h.TILDETRIM], f), u("tilde trim", e), e = e.replace(c[h.CARETTRIM], p), u("caret trim", e); let o = e.split(" ").map((e => x(e, this.options))).join(" ").split(/\s+/).map((e => N(e, this.options))); r && (o = o.filter((e => (u("loose invalid filter", e, this.options), !!e.match(c[h.COMPARATORLOOSE]))))), u("range list", o); const l = new Map, b = o.map((e => new s(e, this.options))); for (const e of b) { if (y(e)) return [e]; l.set(e.value, e) } l.size > 1 && l.has("") && l.delete(""); const v = [...l.values()]; return a.set(t, v), v } intersects(e, t) { if (!(e instanceof i)) throw new TypeError("a Range is required"); return this.set.some((n => v(n, t) && e.set.some((e => v(e, t) && n.every((n => e.every((e => n.intersects(e, t))))))))) } test(e) { if (!e) return !1; if ("string" == typeof e) try { e = new l(e, this.options) } catch (e) { return !1 } for (let t = 0; t < this.set.length; t++)if (M(this.set[t], e, this.options)) return !0; return !1 } } e.exports = i; const a = new (n(4967)), o = n(8324), s = n(147), u = n(9847), l = n(6283), { safeRe: c, t: h, comparatorTrimReplace: d, tildeTrimReplace: f, caretTrimReplace: p } = n(6063), { FLAG_INCLUDE_PRERELEASE: m, FLAG_LOOSE: g } = n(3101), y = e => "<0.0.0-0" === e.value, b = e => "" === e.value, v = (e, t) => { let n = !0; const r = e.slice(); let i = r.pop(); for (; n && r.length;)n = r.every((e => i.intersects(e, t))), i = r.pop(); return n }, x = (e, t) => (u("comp", e, t), e = _(e, t), u("caret", e), e = k(e, t), u("tildes", e), e = A(e, t), u("xrange", e), e = E(e, t), u("stars", e), e), w = e => !e || "x" === e.toLowerCase() || "*" === e, k = (e, t) => e.trim().split(/\s+/).map((e => S(e, t))).join(" "), S = (e, t) => { const n = t.loose ? c[h.TILDELOOSE] : c[h.TILDE]; return e.replace(n, ((t, n, r, i, a) => { let o; return u("tilde", e, t, n, r, i, a), w(n) ? o = "" : w(r) ? o = `>=${n}.0.0 <${+n + 1}.0.0-0` : w(i) ? o = `>=${n}.${r}.0 <${n}.${+r + 1}.0-0` : a ? (u("replaceTilde pr", a), o = `>=${n}.${r}.${i}-${a} <${n}.${+r + 1}.0-0`) : o = `>=${n}.${r}.${i} <${n}.${+r + 1}.0-0`, u("tilde return", o), o })) }, _ = (e, t) => e.trim().split(/\s+/).map((e => C(e, t))).join(" "), C = (e, t) => { u("caret", e, t); const n = t.loose ? c[h.CARETLOOSE] : c[h.CARET], r = t.includePrerelease ? "-0" : ""; return e.replace(n, ((t, n, i, a, o) => { let s; return u("caret", e, t, n, i, a, o), w(n) ? s = "" : w(i) ? s = `>=${n}.0.0${r} <${+n + 1}.0.0-0` : w(a) ? s = "0" === n ? `>=${n}.${i}.0${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.0${r} <${+n + 1}.0.0-0` : o ? (u("replaceCaret pr", o), s = "0" === n ? "0" === i ? `>=${n}.${i}.${a}-${o} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}-${o} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a}-${o} <${+n + 1}.0.0-0`) : (u("no pr"), s = "0" === n ? "0" === i ? `>=${n}.${i}.${a}${r} <${n}.${i}.${+a + 1}-0` : `>=${n}.${i}.${a}${r} <${n}.${+i + 1}.0-0` : `>=${n}.${i}.${a} <${+n + 1}.0.0-0`), u("caret return", s), s })) }, A = (e, t) => (u("replaceXRanges", e, t), e.split(/\s+/).map((e => T(e, t))).join(" ")), T = (e, t) => { e = e.trim(); const n = t.loose ? c[h.XRANGELOOSE] : c[h.XRANGE]; return e.replace(n, ((n, r, i, a, o, s) => { u("xRange", e, n, r, i, a, o, s); const l = w(i), c = l || w(a), h = c || w(o), d = h; return "=" === r && d && (r = ""), s = t.includePrerelease ? "-0" : "", l ? n = ">" === r || "<" === r ? "<0.0.0-0" : "*" : r && d ? (c && (a = 0), o = 0, ">" === r ? (r = ">=", c ? (i = +i + 1, a = 0, o = 0) : (a = +a + 1, o = 0)) : "<=" === r && (r = "<", c ? i = +i + 1 : a = +a + 1), "<" === r && (s = "-0"), n = `${r + i}.${a}.${o}${s}`) : c ? n = `>=${i}.0.0${s} <${+i + 1}.0.0-0` : h && (n = `>=${i}.${a}.0${s} <${i}.${+a + 1}.0-0`), u("xRange return", n), n })) }, E = (e, t) => (u("replaceStars", e, t), e.trim().replace(c[h.STAR], "")), N = (e, t) => (u("replaceGTE0", e, t), e.trim().replace(c[t.includePrerelease ? h.GTE0PRE : h.GTE0], "")), I = e => (t, n, r, i, a, o, s, u, l, c, h, d) => `${n = w(r) ? "" : w(i) ? `>=${r}.0.0${e ? "-0" : ""}` : w(a) ? `>=${r}.${i}.0${e ? "-0" : ""}` : o ? `>=${n}` : `>=${n}${e ? "-0" : ""}`} ${u = w(l) ? "" : w(c) ? `<${+l + 1}.0.0-0` : w(h) ? `<${l}.${+c + 1}.0-0` : d ? `<=${l}.${c}.${h}-${d}` : e ? `<${l}.${c}.${+h + 1}-0` : `<=${u}`}`.trim(), M = (e, t, n) => { for (let n = 0; n < e.length; n++)if (!e[n].test(t)) return !1; if (t.prerelease.length && !n.includePrerelease) { for (let n = 0; n < e.length; n++)if (u(e[n].semver), e[n].semver !== s.ANY && e[n].semver.prerelease.length > 0) { const r = e[n].semver; if (r.major === t.major && r.minor === t.minor && r.patch === t.patch) return !0 } return !1 } return !0 } }, 6283: (e, t, n) => { const r = n(9847), { MAX_LENGTH: i, MAX_SAFE_INTEGER: a } = n(3101), { safeRe: o, t: s } = n(6063), u = n(8324), { compareIdentifiers: l } = n(8884); class c { constructor(e, t) { if (t = u(t), e instanceof c) { if (e.loose === !!t.loose && e.includePrerelease === !!t.includePrerelease) return e; e = e.version } else if ("string" != typeof e) throw new TypeError(`Invalid version. Must be a string. Got type "${typeof e}".`); if (e.length > i) throw new TypeError(`version is longer than ${i} characters`); r("SemVer", e, t), this.options = t, this.loose = !!t.loose, this.includePrerelease = !!t.includePrerelease; const n = e.trim().match(t.loose ? o[s.LOOSE] : o[s.FULL]); if (!n) throw new TypeError(`Invalid Version: ${e}`); if (this.raw = e, this.major = +n[1], this.minor = +n[2], this.patch = +n[3], this.major > a || this.major < 0) throw new TypeError("Invalid major version"); if (this.minor > a || this.minor < 0) throw new TypeError("Invalid minor version"); if (this.patch > a || this.patch < 0) throw new TypeError("Invalid patch version"); n[4] ? this.prerelease = n[4].split(".").map((e => { if (/^[0-9]+$/.test(e)) { const t = +e; if (t >= 0 && t < a) return t } return e })) : this.prerelease = [], this.build = n[5] ? n[5].split(".") : [], this.format() } format() { return this.version = `${this.major}.${this.minor}.${this.patch}`, this.prerelease.length && (this.version += `-${this.prerelease.join(".")}`), this.version } toString() { return this.version } compare(e) { if (r("SemVer.compare", this.version, this.options, e), !(e instanceof c)) { if ("string" == typeof e && e === this.version) return 0; e = new c(e, this.options) } return e.version === this.version ? 0 : this.compareMain(e) || this.comparePre(e) } compareMain(e) { return e instanceof c || (e = new c(e, this.options)), l(this.major, e.major) || l(this.minor, e.minor) || l(this.patch, e.patch) } comparePre(e) { if (e instanceof c || (e = new c(e, this.options)), this.prerelease.length && !e.prerelease.length) return -1; if (!this.prerelease.length && e.prerelease.length) return 1; if (!this.prerelease.length && !e.prerelease.length) return 0; let t = 0; do { const n = this.prerelease[t], i = e.prerelease[t]; if (r("prerelease compare", t, n, i), void 0 === n && void 0 === i) return 0; if (void 0 === i) return 1; if (void 0 === n) return -1; if (n !== i) return l(n, i) } while (++t) } compareBuild(e) { e instanceof c || (e = new c(e, this.options)); let t = 0; do { const n = this.build[t], i = e.build[t]; if (r("build compare", t, n, i), void 0 === n && void 0 === i) return 0; if (void 0 === i) return 1; if (void 0 === n) return -1; if (n !== i) return l(n, i) } while (++t) } inc(e, t, n) { switch (e) { case "premajor": this.prerelease.length = 0, this.patch = 0, this.minor = 0, this.major++, this.inc("pre", t, n); break; case "preminor": this.prerelease.length = 0, this.patch = 0, this.minor++, this.inc("pre", t, n); break; case "prepatch": this.prerelease.length = 0, this.inc("patch", t, n), this.inc("pre", t, n); break; case "prerelease": 0 === this.prerelease.length && this.inc("patch", t, n), this.inc("pre", t, n); break; case "major": 0 === this.minor && 0 === this.patch && 0 !== this.prerelease.length || this.major++, this.minor = 0, this.patch = 0, this.prerelease = []; break; case "minor": 0 === this.patch && 0 !== this.prerelease.length || this.minor++, this.patch = 0, this.prerelease = []; break; case "patch": 0 === this.prerelease.length && this.patch++, this.prerelease = []; break; case "pre": { const e = Number(n) ? 1 : 0; if (!t && !1 === n) throw new Error("invalid increment argument: identifier is empty"); if (0 === this.prerelease.length) this.prerelease = [e]; else { let r = this.prerelease.length; for (; --r >= 0;)"number" == typeof this.prerelease[r] && (this.prerelease[r]++, r = -2); if (-1 === r) { if (t === this.prerelease.join(".") && !1 === n) throw new Error("invalid increment argument: identifier already exists"); this.prerelease.push(e) } } if (t) { let r = [t, e]; !1 === n && (r = [t]), 0 === l(this.prerelease[0], t) ? isNaN(this.prerelease[1]) && (this.prerelease = r) : this.prerelease = r } break } default: throw new Error(`invalid increment argument: ${e}`) }return this.raw = this.format(), this.build.length && (this.raw += `+${this.build.join(".")}`), this } } e.exports = c }, 9479: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e.trim().replace(/^[=v]+/, ""), t); return n ? n.version : null } }, 4806: (e, t, n) => { const r = n(2314), i = n(6638), a = n(4311), o = n(2228), s = n(528), u = n(7645); e.exports = (e, t, n, l) => { switch (t) { case "===": return "object" == typeof e && (e = e.version), "object" == typeof n && (n = n.version), e === n; case "!==": return "object" == typeof e && (e = e.version), "object" == typeof n && (n = n.version), e !== n; case "": case "=": case "==": return r(e, n, l); case "!=": return i(e, n, l); case ">": return a(e, n, l); case ">=": return o(e, n, l); case "<": return s(e, n, l); case "<=": return u(e, n, l); default: throw new TypeError(`Invalid operator: ${t}`) } } }, 5177: (e, t, n) => { const r = n(6283), i = n(7262), { safeRe: a, t: o } = n(6063); e.exports = (e, t) => { if (e instanceof r) return e; if ("number" == typeof e && (e = String(e)), "string" != typeof e) return null; let n = null; if ((t = t || {}).rtl) { const r = t.includePrerelease ? a[o.COERCERTLFULL] : a[o.COERCERTL]; let i; for (; (i = r.exec(e)) && (!n || n.index + n[0].length !== e.length);)n && i.index + i[0].length === n.index + n[0].length || (n = i), r.lastIndex = i.index + i[1].length + i[2].length; r.lastIndex = -1 } else n = e.match(t.includePrerelease ? a[o.COERCEFULL] : a[o.COERCE]); if (null === n) return null; const s = n[2], u = n[3] || "0", l = n[4] || "0", c = t.includePrerelease && n[5] ? `-${n[5]}` : "", h = t.includePrerelease && n[6] ? `+${n[6]}` : ""; return i(`${s}.${u}.${l}${c}${h}`, t) } }, 4320: (e, t, n) => { const r = n(6283); e.exports = (e, t, n) => { const i = new r(e, n), a = new r(t, n); return i.compare(a) || i.compareBuild(a) } }, 6330: (e, t, n) => { const r = n(9349); e.exports = (e, t) => r(e, t, !0) }, 9349: (e, t, n) => { const r = n(6283); e.exports = (e, t, n) => new r(e, n).compare(new r(t, n)) }, 9127: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, null, !0), i = r(t, null, !0), a = n.compare(i); if (0 === a) return null; const o = a > 0, s = o ? n : i, u = o ? i : n, l = !!s.prerelease.length; if (!!u.prerelease.length && !l) return u.patch || u.minor ? s.patch ? "patch" : s.minor ? "minor" : "major" : "major"; const c = l ? "pre" : ""; return n.major !== i.major ? c + "major" : n.minor !== i.minor ? c + "minor" : n.patch !== i.patch ? c + "patch" : "prerelease" } }, 2314: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => 0 === r(e, t, n) }, 4311: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) > 0 }, 2228: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) >= 0 }, 5810: (e, t, n) => { const r = n(6283); e.exports = (e, t, n, i, a) => { "string" == typeof n && (a = i, i = n, n = void 0); try { return new r(e instanceof r ? e.version : e, n).inc(t, i, a).version } catch (e) { return null } } }, 528: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) < 0 }, 7645: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(e, t, n) <= 0 }, 9823: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).major }, 3915: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).minor }, 6638: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => 0 !== r(e, t, n) }, 7262: (e, t, n) => { const r = n(6283); e.exports = (e, t, n = !1) => { if (e instanceof r) return e; try { return new r(e, t) } catch (e) { if (!n) return null; throw e } } }, 3236: (e, t, n) => { const r = n(6283); e.exports = (e, t) => new r(e, t).patch }, 7810: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, t); return n && n.prerelease.length ? n.prerelease : null } }, 4989: (e, t, n) => { const r = n(9349); e.exports = (e, t, n) => r(t, e, n) }, 6920: (e, t, n) => { const r = n(4320); e.exports = (e, t) => e.sort(((e, n) => r(n, e, t))) }, 5435: (e, t, n) => { const r = n(2894); e.exports = (e, t, n) => { try { t = new r(t, n) } catch (e) { return !1 } return t.test(e) } }, 3616: (e, t, n) => { const r = n(4320); e.exports = (e, t) => e.sort(((e, n) => r(e, n, t))) }, 2348: (e, t, n) => { const r = n(7262); e.exports = (e, t) => { const n = r(e, t); return n ? n.version : null } }, 6392: (e, t, n) => { const r = n(6063), i = n(3101), a = n(6283), o = n(8884), s = n(7262), u = n(2348), l = n(9479), c = n(5810), h = n(9127), d = n(9823), f = n(3915), p = n(3236), m = n(7810), g = n(9349), y = n(4989), b = n(6330), v = n(4320), x = n(3616), w = n(6920), k = n(4311), S = n(528), _ = n(2314), C = n(6638), A = n(2228), T = n(7645), E = n(4806), N = n(5177), I = n(147), M = n(2894), F = n(5435), D = n(6718), $ = n(5753), R = n(7939), O = n(3802), z = n(7569), P = n(8584), B = n(7508), L = n(4285), j = n(5929), U = n(6076), W = n(1969); e.exports = { parse: s, valid: u, clean: l, inc: c, diff: h, major: d, minor: f, patch: p, prerelease: m, compare: g, rcompare: y, compareLoose: b, compareBuild: v, sort: x, rsort: w, gt: k, lt: S, eq: _, neq: C, gte: A, lte: T, cmp: E, coerce: N, Comparator: I, Range: M, satisfies: F, toComparators: D, maxSatisfying: $, minSatisfying: R, minVersion: O, validRange: z, outside: P, gtr: B, ltr: L, intersects: j, simplifyRange: U, subset: W, SemVer: a, re: r.re, src: r.src, tokens: r.t, SEMVER_SPEC_VERSION: i.SEMVER_SPEC_VERSION, RELEASE_TYPES: i.RELEASE_TYPES, compareIdentifiers: o.compareIdentifiers, rcompareIdentifiers: o.rcompareIdentifiers } }, 3101: e => { const t = Number.MAX_SAFE_INTEGER || 9007199254740991; e.exports = { MAX_LENGTH: 256, MAX_SAFE_COMPONENT_LENGTH: 16, MAX_SAFE_BUILD_LENGTH: 250, MAX_SAFE_INTEGER: t, RELEASE_TYPES: ["major", "premajor", "minor", "preminor", "patch", "prepatch", "prerelease"], SEMVER_SPEC_VERSION: "2.0.0", FLAG_INCLUDE_PRERELEASE: 1, FLAG_LOOSE: 2 } }, 9847: e => { const t = "object" == typeof process && process.env && process.env.NODE_DEBUG && /\bsemver\b/i.test(process.env.NODE_DEBUG) ? (...e) => console.error("SEMVER", ...e) : () => { }; e.exports = t }, 8884: e => { const t = /^[0-9]+$/, n = (e, n) => { const r = t.test(e), i = t.test(n); return r && i && (e = +e, n = +n), e === n ? 0 : r && !i ? -1 : i && !r ? 1 : e < n ? -1 : 1 }; e.exports = { compareIdentifiers: n, rcompareIdentifiers: (e, t) => n(t, e) } }, 4967: e => { e.exports = class { constructor() { this.max = 1e3, this.map = new Map } get(e) { const t = this.map.get(e); return void 0 === t ? void 0 : (this.map.delete(e), this.map.set(e, t), t) } delete(e) { return this.map.delete(e) } set(e, t) { if (!this.delete(e) && void 0 !== t) { if (this.map.size >= this.max) { const e = this.map.keys().next().value; this.delete(e) } this.map.set(e, t) } return this } } }, 8324: e => { const t = Object.freeze({ loose: !0 }), n = Object.freeze({}); e.exports = e => e ? "object" != typeof e ? t : e : n }, 6063: (e, t, n) => { const { MAX_SAFE_COMPONENT_LENGTH: r, MAX_SAFE_BUILD_LENGTH: i, MAX_LENGTH: a } = n(3101), o = n(9847), s = (t = e.exports = {}).re = [], u = t.safeRe = [], l = t.src = [], c = t.t = {}; let h = 0; const d = "[a-zA-Z0-9-]", f = [["\\s", 1], ["\\d", a], [d, i]], p = (e, t, n) => { const r = (e => { for (const [t, n] of f) e = e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`); return e })(t), i = h++; o(e, i, t), c[e] = i, l[i] = t, s[i] = new RegExp(t, n ? "g" : void 0), u[i] = new RegExp(r, n ? "g" : void 0) }; p("NUMERICIDENTIFIER", "0|[1-9]\\d*"), p("NUMERICIDENTIFIERLOOSE", "\\d+"), p("NONNUMERICIDENTIFIER", `\\d*[a-zA-Z-]${d}*`), p("MAINVERSION", `(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})\\.(${l[c.NUMERICIDENTIFIER]})`), p("MAINVERSIONLOOSE", `(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})\\.(${l[c.NUMERICIDENTIFIERLOOSE]})`), p("PRERELEASEIDENTIFIER", `(?:${l[c.NUMERICIDENTIFIER]}|${l[c.NONNUMERICIDENTIFIER]})`), p("PRERELEASEIDENTIFIERLOOSE", `(?:${l[c.NUMERICIDENTIFIERLOOSE]}|${l[c.NONNUMERICIDENTIFIER]})`), p("PRERELEASE", `(?:-(${l[c.PRERELEASEIDENTIFIER]}(?:\\.${l[c.PRERELEASEIDENTIFIER]})*))`), p("PRERELEASELOOSE", `(?:-?(${l[c.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${l[c.PRERELEASEIDENTIFIERLOOSE]})*))`), p("BUILDIDENTIFIER", `${d}+`), p("BUILD", `(?:\\+(${l[c.BUILDIDENTIFIER]}(?:\\.${l[c.BUILDIDENTIFIER]})*))`), p("FULLPLAIN", `v?${l[c.MAINVERSION]}${l[c.PRERELEASE]}?${l[c.BUILD]}?`), p("FULL", `^${l[c.FULLPLAIN]}$`), p("LOOSEPLAIN", `[v=\\s]*${l[c.MAINVERSIONLOOSE]}${l[c.PRERELEASELOOSE]}?${l[c.BUILD]}?`), p("LOOSE", `^${l[c.LOOSEPLAIN]}$`), p("GTLT", "((?:<|>)?=?)"), p("XRANGEIDENTIFIERLOOSE", `${l[c.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`), p("XRANGEIDENTIFIER", `${l[c.NUMERICIDENTIFIER]}|x|X|\\*`), p("XRANGEPLAIN", `[v=\\s]*(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:\\.(${l[c.XRANGEIDENTIFIER]})(?:${l[c.PRERELEASE]})?${l[c.BUILD]}?)?)?`), p("XRANGEPLAINLOOSE", `[v=\\s]*(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:\\.(${l[c.XRANGEIDENTIFIERLOOSE]})(?:${l[c.PRERELEASELOOSE]})?${l[c.BUILD]}?)?)?`), p("XRANGE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAIN]}$`), p("XRANGELOOSE", `^${l[c.GTLT]}\\s*${l[c.XRANGEPLAINLOOSE]}$`), p("COERCEPLAIN", `(^|[^\\d])(\\d{1,${r}})(?:\\.(\\d{1,${r}}))?(?:\\.(\\d{1,${r}}))?`), p("COERCE", `${l[c.COERCEPLAIN]}(?:$|[^\\d])`), p("COERCEFULL", l[c.COERCEPLAIN] + `(?:${l[c.PRERELEASE]})?` + `(?:${l[c.BUILD]})?(?:$|[^\\d])`), p("COERCERTL", l[c.COERCE], !0), p("COERCERTLFULL", l[c.COERCEFULL], !0), p("LONETILDE", "(?:~>?)"), p("TILDETRIM", `(\\s*)${l[c.LONETILDE]}\\s+`, !0), t.tildeTrimReplace = "$1~", p("TILDE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAIN]}$`), p("TILDELOOSE", `^${l[c.LONETILDE]}${l[c.XRANGEPLAINLOOSE]}$`), p("LONECARET", "(?:\\^)"), p("CARETTRIM", `(\\s*)${l[c.LONECARET]}\\s+`, !0), t.caretTrimReplace = "$1^", p("CARET", `^${l[c.LONECARET]}${l[c.XRANGEPLAIN]}$`), p("CARETLOOSE", `^${l[c.LONECARET]}${l[c.XRANGEPLAINLOOSE]}$`), p("COMPARATORLOOSE", `^${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]})$|^$`), p("COMPARATOR", `^${l[c.GTLT]}\\s*(${l[c.FULLPLAIN]})$|^$`), p("COMPARATORTRIM", `(\\s*)${l[c.GTLT]}\\s*(${l[c.LOOSEPLAIN]}|${l[c.XRANGEPLAIN]})`, !0), t.comparatorTrimReplace = "$1$2$3", p("HYPHENRANGE", `^\\s*(${l[c.XRANGEPLAIN]})\\s+-\\s+(${l[c.XRANGEPLAIN]})\\s*$`), p("HYPHENRANGELOOSE", `^\\s*(${l[c.XRANGEPLAINLOOSE]})\\s+-\\s+(${l[c.XRANGEPLAINLOOSE]})\\s*$`), p("STAR", "(<|>)?=?\\s*\\*"), p("GTE0", "^\\s*>=\\s*0\\.0\\.0\\s*$"), p("GTE0PRE", "^\\s*>=\\s*0\\.0\\.0-0\\s*$") }, 7508: (e, t, n) => { const r = n(8584); e.exports = (e, t, n) => r(e, t, ">", n) }, 5929: (e, t, n) => { const r = n(2894); e.exports = (e, t, n) => (e = new r(e, n), t = new r(t, n), e.intersects(t, n)) }, 4285: (e, t, n) => { const r = n(8584); e.exports = (e, t, n) => r(e, t, "<", n) }, 5753: (e, t, n) => { const r = n(6283), i = n(2894); e.exports = (e, t, n) => { let a = null, o = null, s = null; try { s = new i(t, n) } catch (e) { return null } return e.forEach((e => { s.test(e) && (a && -1 !== o.compare(e) || (a = e, o = new r(a, n))) })), a } }, 7939: (e, t, n) => { const r = n(6283), i = n(2894); e.exports = (e, t, n) => { let a = null, o = null, s = null; try { s = new i(t, n) } catch (e) { return null } return e.forEach((e => { s.test(e) && (a && 1 !== o.compare(e) || (a = e, o = new r(a, n))) })), a } }, 3802: (e, t, n) => { const r = n(6283), i = n(2894), a = n(4311); e.exports = (e, t) => { e = new i(e, t); let n = new r("0.0.0"); if (e.test(n)) return n; if (n = new r("0.0.0-0"), e.test(n)) return n; n = null; for (let t = 0; t < e.set.length; ++t) { const i = e.set[t]; let o = null; i.forEach((e => { const t = new r(e.semver.version); switch (e.operator) { case ">": 0 === t.prerelease.length ? t.patch++ : t.prerelease.push(0), t.raw = t.format(); case "": case ">=": o && !a(t, o) || (o = t); break; case "<": case "<=": break; default: throw new Error(`Unexpected operation: ${e.operator}`) } })), !o || n && !a(n, o) || (n = o) } return n && e.test(n) ? n : null } }, 8584: (e, t, n) => { const r = n(6283), i = n(147), { ANY: a } = i, o = n(2894), s = n(5435), u = n(4311), l = n(528), c = n(7645), h = n(2228); e.exports = (e, t, n, d) => { let f, p, m, g, y; switch (e = new r(e, d), t = new o(t, d), n) { case ">": f = u, p = c, m = l, g = ">", y = ">="; break; case "<": f = l, p = h, m = u, g = "<", y = "<="; break; default: throw new TypeError('Must provide a hilo val of "<" or ">"') }if (s(e, t, d)) return !1; for (let n = 0; n < t.set.length; ++n) { const r = t.set[n]; let o = null, s = null; if (r.forEach((e => { e.semver === a && (e = new i(">=0.0.0")), o = o || e, s = s || e, f(e.semver, o.semver, d) ? o = e : m(e.semver, s.semver, d) && (s = e) })), o.operator === g || o.operator === y) return !1; if ((!s.operator || s.operator === g) && p(e, s.semver)) return !1; if (s.operator === y && m(e, s.semver)) return !1 } return !0 } }, 6076: (e, t, n) => { const r = n(5435), i = n(9349); e.exports = (e, t, n) => { const a = []; let o = null, s = null; const u = e.sort(((e, t) => i(e, t, n))); for (const e of u) { r(e, t, n) ? (s = e, o || (o = e)) : (s && a.push([o, s]), s = null, o = null) } o && a.push([o, null]); const l = []; for (const [e, t] of a) e === t ? l.push(e) : t || e !== u[0] ? t ? e === u[0] ? l.push(`<=${t}`) : l.push(`${e} - ${t}`) : l.push(`>=${e}`) : l.push("*"); const c = l.join(" || "), h = "string" == typeof t.raw ? t.raw : String(t); return c.length < h.length ? c : t } }, 1969: (e, t, n) => { const r = n(2894), i = n(147), { ANY: a } = i, o = n(5435), s = n(9349), u = [new i(">=0.0.0-0")], l = [new i(">=0.0.0")], c = (e, t, n) => { if (e === t) return !0; if (1 === e.length && e[0].semver === a) { if (1 === t.length && t[0].semver === a) return !0; e = n.includePrerelease ? u : l } if (1 === t.length && t[0].semver === a) { if (n.includePrerelease) return !0; t = l } const r = new Set; let i, c, f, p, m, g, y; for (const t of e) ">" === t.operator || ">=" === t.operator ? i = h(i, t, n) : "<" === t.operator || "<=" === t.operator ? c = d(c, t, n) : r.add(t.semver); if (r.size > 1) return null; if (i && c) { if (f = s(i.semver, c.semver, n), f > 0) return null; if (0 === f && (">=" !== i.operator || "<=" !== c.operator)) return null } for (const e of r) { if (i && !o(e, String(i), n)) return null; if (c && !o(e, String(c), n)) return null; for (const r of t) if (!o(e, String(r), n)) return !1; return !0 } let b = !(!c || n.includePrerelease || !c.semver.prerelease.length) && c.semver, v = !(!i || n.includePrerelease || !i.semver.prerelease.length) && i.semver; b && 1 === b.prerelease.length && "<" === c.operator && 0 === b.prerelease[0] && (b = !1); for (const e of t) { if (y = y || ">" === e.operator || ">=" === e.operator, g = g || "<" === e.operator || "<=" === e.operator, i) if (v && e.semver.prerelease && e.semver.prerelease.length && e.semver.major === v.major && e.semver.minor === v.minor && e.semver.patch === v.patch && (v = !1), ">" === e.operator || ">=" === e.operator) { if (p = h(i, e, n), p === e && p !== i) return !1 } else if (">=" === i.operator && !o(i.semver, String(e), n)) return !1; if (c) if (b && e.semver.prerelease && e.semver.prerelease.length && e.semver.major === b.major && e.semver.minor === b.minor && e.semver.patch === b.patch && (b = !1), "<" === e.operator || "<=" === e.operator) { if (m = d(c, e, n), m === e && m !== c) return !1 } else if ("<=" === c.operator && !o(c.semver, String(e), n)) return !1; if (!e.operator && (c || i) && 0 !== f) return !1 } return !(i && g && !c && 0 !== f) && (!(c && y && !i && 0 !== f) && (!v && !b)) }, h = (e, t, n) => { if (!e) return t; const r = s(e.semver, t.semver, n); return r > 0 ? e : r < 0 || ">" === t.operator && ">=" === e.operator ? t : e }, d = (e, t, n) => { if (!e) return t; const r = s(e.semver, t.semver, n); return r < 0 ? e : r > 0 || "<" === t.operator && "<=" === e.operator ? t : e }; e.exports = (e, t, n = {}) => { if (e === t) return !0; e = new r(e, n), t = new r(t, n); let i = !1; e: for (const r of e.set) { for (const e of t.set) { const t = c(r, e, n); if (i = i || null !== t, t) continue e } if (i) return !1 } return !0 } }, 6718: (e, t, n) => { const r = n(2894); e.exports = (e, t) => new r(e, t).set.map((e => e.map((e => e.value)).join(" ").trim().split(" "))) }, 7569: (e, t, n) => { const r = n(2894); e.exports = (e, t) => { try { return new r(e, t).range || "*" } catch (e) { return null } } }, 7571: () => { }, 7006: () => { }, 5817: () => { }, 8590: () => { }, 4530: () => { }, 8108: () => { }, 551: () => { }, 1234: () => { }, 8487: e => { "use strict"; var t = /("(?:[^\\"]|\\.)*")|[:,]/g; e.exports = function (e, n) { var r, i, a; return n = n || {}, r = JSON.stringify([1], void 0, void 0 === n.indent ? 2 : n.indent).slice(2, -3), i = "" === r ? 1 / 0 : void 0 === n.maxLength ? 80 : n.maxLength, a = n.replacer, function e(n, o, s) { var u, l, c, h, d, f, p, m, g, y, b, v; if (n && "function" == typeof n.toJSON && (n = n.toJSON()), void 0 === (b = JSON.stringify(n, a))) return b; if (p = i - o.length - s, b.length <= p && (g = b.replace(t, (function (e, t) { return t || e + " " }))).length <= p) return g; if (null != a && (n = JSON.parse(b), a = void 0), "object" == typeof n && null !== n) { if (m = o + r, c = [], l = 0, Array.isArray(n)) for (y = "[", u = "]", p = n.length; l < p; l++)c.push(e(n[l], m, l === p - 1 ? 0 : 1) || "null"); else for (y = "{", u = "}", p = (f = Object.keys(n)).length; l < p; l++)h = f[l], d = JSON.stringify(h) + ": ", void 0 !== (v = e(n[h], m, d.length + (l === p - 1 ? 0 : 1))) && c.push(d + v); if (c.length > 0) return [y, r + c.join(",\n" + m), u].join("\n" + o) } return b }(e, "", 0) } }
}, t = {}; function n(r) { var i = t[r]; if (void 0 !== i) return i.exports; var a = t[r] = { id: r, loaded: !1, exports: {} }; return e[r].call(a.exports, a, a.exports, n), a.loaded = !0, a.exports } n.amdD = function () { throw new Error("define cannot be used indirect") }, n.amdO = {}, n.n = e => { var t = e && e.__esModule ? () => e.default : () => e; return n.d(t, { a: t }), t }, n.d = (e, t) => { for (var r in t) n.o(t, r) && !n.o(e, r) && Object.defineProperty(e, r, { enumerable: !0, get: t[r] }) }, n.g = function () { if ("object" == typeof globalThis) return globalThis; try { return this || new Function("return this")() } catch (e) { if ("object" == typeof window) return window } }(), n.o = (e, t) => Object.prototype.hasOwnProperty.call(e, t), n.r = e => { "undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 }) }, n.nmd = e => (e.paths = [], e.children || (e.children = []), e); var r = {}; return (() => {
"use strict"; n.d(r, { default: () => OK }); var e = {}; n.r(e), n.d(e, { maxNorm: () => va, minMaxNorm: () => ka, nonNeg: () => wa, unitNorm: () => xa }); var t = {}; n.r(t), n.d(t, { constant: () => Ca, glorotNormal: () => Fa, glorotUniform: () => Ma, heNormal: () => Da, heUniform: () => $a, identity: () => Na, leCunNormal: () => Ra, leCunUniform: () => Oa, ones: () => _a, orthogonal: () => za, randomNormal: () => Ta, randomUniform: () => Aa, truncatedNormal: () => Ea, varianceScaling: () => Ia, zeros: () => Sa }); var i = {}; n.r(i), n.d(i, { Layer: () => Ji, RNN: () => uu, RNNCell: () => lu, activation: () => Ul, add: () => Zl, alphaDropout: () => jc, average: () => Jl, averagePooling1d: () => sc, averagePooling2d: () => cc, averagePooling3d: () => fc, avgPool1d: () => uc, avgPool2d: () => hc, avgPool3d: () => pc, avgPooling1d: () => lc, avgPooling2d: () => dc, avgPooling3d: () => mc, batchNormalization: () => ic, bidirectional: () => Dc, categoryEncoding: () => Hc, centerCrop: () => Vc, concatenate: () => Ql, conv1d: () => Dl, conv2d: () => $l, conv2dTranspose: () => Rl, conv3d: () => Ol, conv3dTranspose: () => zl, convLstm2d: () => Nc, convLstm2dCell: () => Ic, cropping2D: () => Bl, dense: () => Wl, depthwiseConv2d: () => jl, dot: () => rc, dropout: () => Vl, elu: () => Tl, embedding: () => Kl, flatten: () => Hl, gaussianDropout: () => Lc, gaussianNoise: () => Bc, globalAveragePooling1d: () => gc, globalAveragePooling2d: () => yc, globalMaxPool1d: () => Rc, globalMaxPool2d: () => Oc, globalMaxPooling1d: () => bc, globalMaxPooling2d: () => vc, gru: () => Sc, gruCell: () => _c, input: () => as, inputLayer: () => Al, layerNormalization: () => ac, leakyReLU: () => Nl, lstm: () => Cc, lstmCell: () => Ac, masking: () => Uc, maxPool1d: () => zc, maxPool2d: () => Pc, maxPooling1d: () => xc, maxPooling2d: () => wc, maxPooling3d: () => kc, maximum: () => ec, minimum: () => tc, multiply: () => nc, permute: () => Xl, prelu: () => Il, randomWidth: () => qc, reLU: () => El, repeatVector: () => ql, rescaling: () => Wc, reshape: () => Yl, resizing: () => Gc, rnn: () => Mc, separableConv2d: () => Pl, simpleRNN: () => Tc, simpleRNNCell: () => Ec, softmax: () => Ml, spatialDropout1d: () => Gl, stackedRNNCells: () => Fc, thresholdedReLU: () => Fl, timeDistributed: () => $c, upSampling2d: () => Ll, zeroPadding2d: () => oc }); var a = {}; n.r(a), n.d(a, { MAPE: () => ih, MSE: () => sh, binaryAccuracy: () => Yc, binaryCrossentropy: () => Xc, categoricalAccuracy: () => Zc, categoricalCrossentropy: () => Jc, cosineProximity: () => th, mape: () => ah, meanAbsoluteError: () => nh, meanAbsolutePercentageError: () => rh, meanSquaredError: () => oh, mse: () => uh, precision: () => Qc, r2Score: () => lh, recall: () => eh, sparseCategoricalAccuracy: () => Kc }); var o = {}; n.r(o), n.d(o, { modelFromJSON: () => es }); var s = {}; n.r(s), n.d(s, { l1: () => hh, l1l2: () => ch, l2: () => dh }); var u = {}; n.r(u), n.d(u, { json: () => Dh }); var l = {}; n.r(l), n.d(l, { json: () => $h }); var c = {}; n.r(c), n.d(c, { json: () => Rh }); var h = {}; n.r(h), n.d(h, { json: () => Oh }); var d = {}; n.r(d), n.d(d, { json: () => zh }); var f = {}; n.r(f), n.d(f, { json: () => Ph }); var p = {}; n.r(p), n.d(p, { json: () => Bh }); var m = {}; n.r(m), n.d(m, { json: () => Lh }); var g = {}; n.r(g), n.d(g, { json: () => jh }); var y = {}; n.r(y), n.d(y, { json: () => Uh }); var b = {}; n.r(b), n.d(b, { json: () => Wh }); var v = {}; n.r(v), n.d(v, { json: () => Vh }); var x = {}; n.r(x), n.d(x, { json: () => Gh }); var w = {}; n.r(w), n.d(w, { json: () => Hh }); var k = {}; n.r(k), n.d(k, { json: () => qh }); var S = {}; n.r(S), n.d(S, { json: () => Yh }); var _ = {}; n.r(_), n.d(_, { json: () => Xh }); var C = {}; n.r(C), n.d(C, { json: () => Kh }); var A = {}; n.r(A), n.d(A, { json: () => Zh }); var T = {}; n.r(T), n.d(T, { OP_SCOPE_SUFFIX: () => pd.BTT, abs: () => pd.tnl, acos: () => pd.HQu, acosh: () => pd.FqL, add: () => pd.WQq, addN: () => pd.QiD, all: () => pd.Q7R, any: () => pd.bzn, argMax: () => pd.FLi, argMin: () => pd.XRg, asin: () => pd.qRo, asinh: () => pd.yHs, atan: () => pd.rYl, atan2: () => pd.FPz, atanh: () => pd.rfv, avgPool: () => pd.$jT, avgPool3d: () => pd.sub, basicLSTMCell: () => pd.lZX, batchNorm: () => pd.$v7, batchNorm2d: () => pd.BFc, batchNorm3d: () => pd.kSi, batchNorm4d: () => pd.T5N, batchToSpaceND: () => pd.GTe, bincount: () => pd.HbZ, bitwiseAnd: () => pd.vjT, booleanMaskAsync: () => pd.ftb, broadcastArgs: () => pd.ROE, broadcastTo: () => pd.hOW, buffer: () => pd.ra8, cast: () => pd.wgE, ceil: () => pd.mkO, clipByValue: () => pd.zQh, clone: () => pd.o8B, complex: () => pd.faB, concat: () => pd.xWs, concat1d: () => pd.I1m, concat2d: () => pd.RPU, concat3d: () => pd.O5O, concat4d: () => pd.P1l, conv1d: () => pd.kA9, conv2d: () => pd.Xtf, conv2dTranspose: () => pd.wX9, conv3d: () => pd.IPL, conv3dTranspose: () => pd.jIJ, cos: () => pd.gnS, cosh: () => pd.yIG, cosineWindow: () => pd._jP, cumprod: () => pd.Lp0, cumsum: () => pd.rCv, denseBincount: () => pd.aOp, depthToSpace: () => pd.Rj8, depthwiseConv2d: () => pd.Gl3, diag: () => pd.smy, dilation2d: () => pd.X7t, div: () => pd.y4m, divNoNan: () => pd.ek5, dot: () => pd.Omf, dropout: () => pd.EZY, einsum: () => pd._3C, elu: () => pd.Pqc, enclosingPowerOfTwo: () => pd.FJY, ensureShape: () => pd.QP2, equal: () => pd.LCg, erf: () => pd.Y12, euclideanNorm: () => pd.p4S, exp: () => pd.oNF, expandDims: () => pd.UG6, expm1: () => pd.IYd, eye: () => pd.y5U, fft: () => pd.hVP, fill: () => pd.GSj, floor: () => pd.RIf, floorDiv: () => pd.wh_, fused: () => pd.cZk, gather: () => pd.kgh, gatherND: () => pd.SY9, greater: () => pd.rhj, greaterEqual: () => pd.DQN, ifft: () => pd.KGM, imag: () => pd.ngS, image: () => pd.Slp, inTopKAsync: () => pd.U4u, irfft: () => pd.ggX, isFinite: () => pd.MIs, isInf: () => pd.EN4, isNaN: () => pd.yrW, leakyRelu: () => pd.H8d, less: () => pd.M7h, lessEqual: () => pd.InN, linalg: () => pd.mPL, linspace: () => pd.mT8, localResponseNormalization: () => pd.Kgs, log: () => pd.Rm2, log1p: () => pd.Kko, logSigmoid: () => pd.nqI, logSoftmax: () => pd.HPB, logSumExp: () => pd.VZ, logicalAnd: () => pd.n76, logicalNot: () => pd.NSZ, logicalOr: () => pd.ztW, logicalXor: () => pd.rxB, losses: () => pd.YYh, lowerBound: () => pd.yzS, matMul: () => pd.NoW, max: () => pd.T9B, maxPool: () => pd.jgi, maxPool3d: () => pd.NYV, maxPoolWithArgmax: () => pd.RO, maximum: () => pd.PhQ, mean: () => pd.i2o, meshgrid: () => pd.OYQ, min: () => pd.jkA, minimum: () => pd.BpO, mirrorPad: () => pd.FFZ, mod: () => pd.ziu, moments: () => pd.Clk, movingAverage: () => pd.CRk, mul: () => pd.lKK, multiRNNCell: () => pd.YDF, multinomial: () => pd.OjQ, neg: () => pd.HZy, norm: () => pd.xbf, notEqual: () => pd.Ec, oneHot: () => pd.Mw0, ones: () => pd.SaS, onesLike: () => pd.P61, op: () => pd.op, outerProduct: () => pd.X4o, pad: () => pd.eVF, pad1d: () => pd.BZs, pad2d: () => pd.grY, pad3d: () => pd.XHu, pad4d: () => pd.WLX, pool: () => pd.dzn, pow: () => pd.n7C, prelu: () => pd.NsG, print: () => pd.yyV, prod: () => pd._eU, raggedGather: () => pd.whe, raggedRange: () => pd.iyU, raggedTensorToTensor: () => pd.Q0_, rand: () => pd._9M, randomGamma: () => pd.pR9, randomNormal: () => pd.FE$, randomStandardNormal: () => pd.m0H, randomUniform: () => pd.YeY, randomUniformInt: () => pd.HYA, range: () => pd.y17, real: () => pd.xav, reciprocal: () => pd.VOZ, relu: () => pd.VVh, relu6: () => pd.j__, reshape: () => pd.tQQ, reverse: () => pd.BEg, reverse1d: () => pd.QD2, reverse2d: () => pd.LMr, reverse3d: () => pd.I2l, reverse4d: () => pd.JYU, rfft: () => pd.z8$, round: () => pd.LIG, rsqrt: () => pd.Z$r, scalar: () => pd.d_2, scatterND: () => pd.NFr, searchSorted: () => pd.sZg, selu: () => pd.WfX, separableConv2d: () => pd.wdz, setdiff1dAsync: () => pd.F12, sigmoid: () => pd.ry7, sign: () => pd._SZ, signal: () => pd.vPA, sin: () => pd.F8e, sinh: () => pd.L0l, slice: () => pd.dik, slice1d: () => pd.Q$M, slice2d: () => pd.zAd, slice3d: () => pd.wck, slice4d: () => pd.R0O, softmax: () => pd.Vs9, softplus: () => pd.lw0, spaceToBatchND: () => pd.eDJ, sparse: () => pd.lMo, sparseToDense: () => pd.Zhr, spectral: () => pd.lOn, split: () => pd.lDo, sqrt: () => pd.RZD, square: () => pd.EwI, squaredDifference: () => pd.Pbu, squeeze: () => pd.r2V, stack: () => pd.t$z, step: () => pd.PMw, stridedSlice: () => pd.Ym9, string: () => pd.YjP, sub: () => pd.jbE, sum: () => pd.czq, tan: () => pd.Mlm, tanh: () => pd.ymU, tensor: () => pd.OEK, tensor1d: () => pd.tGX, tensor2d: () => pd.KtR, tensor3d: () => pd.$_$, tensor4d: () => pd.g9W, tensor5d: () => pd.Lpo, tensor6d: () => pd.yxw, tensorScatterUpdate: () => pd.NNh, tile: () => pd.Vsq, topk: () => pd.rfw, transpose: () => pd.mgz, truncatedNormal: () => pd.efE, unique: () => pd.AmM, unsortedSegmentSum: () => pd.zAU, unstack: () => pd.K$i, upperBound: () => pd.rni, variable: () => pd.bvq, where: () => pd._M9, whereAsync: () => pd.YJN, zeros: () => pd.Ul9, zerosLike: () => pd.POl }); var E = {}; n.r(E), n.d(E, { CSVDataset: () => zf, Dataset: () => Cf, FileDataSource: () => Kf, TextLineDataset: () => If, URLDataSource: () => Zf, array: () => Tf, csv: () => Jf, func: () => Qf, generator: () => ep, microphone: () => np, version_data: () => rp, webcam: () => tp, zip: () => Ef }); var N = {}; n.r(N), n.d(N, { addImpl: () => kp, bincountImpl: () => Ap, bincountReduceImpl: () => Tp, bitwiseAndImpl: () => Ep, castImpl: () => yp, ceilImpl: () => $p, concatImpl: () => zp, equalImpl: () => Pp, expImpl: () => jp, expm1Impl: () => Vp, floorDivImpl: () => Kp, floorImpl: () => qp, gatherNdImpl: () => Qp, gatherV2Impl: () => em, greaterEqualImpl: () => im, greaterImpl: () => tm, lessEqualImpl: () => cm, lessImpl: () => sm, linSpaceImpl: () => fm, logImpl: () => pm, maxImpl: () => ym, maximumImpl: () => bm, minimumImpl: () => wm, multiplyImpl: () => _m, negImpl: () => Em, notEqualImpl: () => Im, prodImpl: () => Om, raggedGatherImpl: () => jm, raggedRangeImpl: () => Wm, raggedTensorToTensorImpl: () => Ym, rangeImpl: () => Xm, rsqrtImpl: () => Km, scatterImpl: () => Qm, sigmoidImpl: () => eg, simpleAbsImpl: () => sp, sliceImpl: () => rg, sparseFillEmptyRowsImpl: () => og, sparseReshapeImpl: () => sg, sparseSegmentReductionImpl: () => ug, sqrtImpl: () => lg, squaredDifferenceImpl: () => dg, staticRegexReplaceImpl: () => mg, stridedSliceImpl: () => bg, stringNGramsImpl: () => xg, stringSplitImpl: () => kg, stringToHashBucketFastImpl: () => Sg, subImpl: () => _g, tileImpl: () => Eg, topKImpl: () => Mg, transposeImpl: () => Dm, uniqueImpl: () => Fg }); var I = {}; n.r(I), n.d(I, { assertNotComplex: () => Zw, bindCanvasToFramebuffer: () => Cw, bindColorTextureToFramebuffer: () => Aw, bindTextureToProgramUniformSampler: () => _w, bindTextureUnit: () => xw, bindVertexBufferToProgramAttribute: () => vw, callAndCheck: () => ew, canBeRepresented: () => rw, createFragmentShader: () => sw, createFramebuffer: () => bw, createProgram: () => cw, createStaticIndexBuffer: () => pw, createStaticVertexBuffer: () => fw, createTexture: () => gw, createVertexShader: () => ow, getBatchDim: () => Fw, getExtensionOrThrow: () => aw, getFramebufferErrorMessage: () => Nw, getMaxTexturesInShader: () => Ww, getNumChannels: () => mw, getProgramUniformLocation: () => Sw, getProgramUniformLocationOrThrow: () => kw, getRowsCols: () => Dw, getShapeAs3D: () => $w, getTextureShapeFromLogicalShape: () => Rw, getWebGLDisjointQueryTimerVersion: () => Vw, getWebGLErrorMessage: () => iw, getWebGLMaxTextureSize: () => Lw, hasExtension: () => Gw, isCapableOfRenderingToFloatTexture: () => qw, isDownloadFloatTextureEnabled: () => Yw, isReshapeFree: () => zw, isWebGLFenceEnabled: () => Kw, isWebGLVersionEnabled: () => Hw, linkProgram: () => hw, logShaderSourceAndInfoLog: () => lw, resetMaxTextureSize: () => jw, resetMaxTexturesInShader: () => Uw, unbindColorTextureFromFramebuffer: () => Tw, unbindTextureUnit: () => ww, validateFramebuffer: () => Ew, validateProgram: () => dw, validateTextureSize: () => yw }); var M = {}; n.r(M), n.d(M, { bindVertexProgramAttributeStreams: () => Vk, createBufferFromOutputTexture: () => qk, createFloat16MatrixTexture: () => zk, createFloat16PackedMatrixTexture: () => Wk, createFloat32MatrixTexture: () => Rk, createIndexBuffer: () => Fk, createPackedMatrixTexture: () => jk, createUnsignedBytesMatrixTexture: () => Bk, createVertexBuffer: () => Mk, createVertexShader: () => Ik, downloadByteEncodedFloatMatrixFromOutputTexture: () => Xk, downloadFloat32MatrixFromBuffer: () => Yk, downloadMatrixFromPackedOutputTexture: () => Zk, downloadPackedMatrixFromBuffer: () => Kk, getInternalFormatForFloat16MatrixTexture: () => Ok, getInternalFormatForFloat16PackedMatrixTexture: () => Uk, getInternalFormatForFloat32MatrixTexture: () => $k, getInternalFormatForPackedMatrixTexture: () => Lk, getInternalFormatForUnsignedBytesMatrixTexture: () => Pk, uploadDenseMatrixToTexture: () => Gk, uploadPixelDataToTexture: () => Hk }); var F = {}; n.r(F), n.d(F, { Abs: () => P.Abs, Acos: () => P.Acos, Acosh: () => P.Acosh, AdadeltaOptimizer: () => P.AdadeltaOptimizer, AdagradOptimizer: () => P.AdagradOptimizer, AdamOptimizer: () => P.AdamOptimizer, AdamaxOptimizer: () => P.AdamaxOptimizer, Add: () => P.Add, AddN: () => P.AddN, All: () => P.All, Any: () => P.Any, ArgMax: () => P.ArgMax, ArgMin: () => P.ArgMin, Asin: () => P.Asin, Asinh: () => P.Asinh, Atan: () => P.Atan, Atan2: () => P.Atan2, Atanh: () => P.Atanh, AvgPool: () => P.AvgPool, AvgPool3D: () => P.AvgPool3D, AvgPool3DGrad: () => P.AvgPool3DGrad, AvgPoolGrad: () => P.AvgPoolGrad, BatchMatMul: () => P.BatchMatMul, BatchToSpaceND: () => P.BatchToSpaceND, Bincount: () => P.Bincount, BitwiseAnd: () => P.BitwiseAnd, BroadcastArgs: () => P.BroadcastArgs, BroadcastTo: () => P.BroadcastTo, Callback: () => fh, CallbackList: () => Wa, Cast: () => P.Cast, Ceil: () => P.Ceil, ClipByValue: () => P.ClipByValue, Complex: () => P.Complex, ComplexAbs: () => P.ComplexAbs, Concat: () => P.Concat, Conv2D: () => P.Conv2D, Conv2DBackpropFilter: () => P.Conv2DBackpropFilter, Conv2DBackpropInput: () => P.Conv2DBackpropInput, Conv3D: () => P.Conv3D, Conv3DBackpropFilterV2: () => P.Conv3DBackpropFilterV2, Conv3DBackpropInputV2: () => P.Conv3DBackpropInputV2, Cos: () => P.Cos, Cosh: () => P.Cosh, CropAndResize: () => P.CropAndResize, Cumprod: () => P.Cumprod, Cumsum: () => P.Cumsum, CustomCallback: () => Ha, DataStorage: () => P.DataStorage, DenseBincount: () => P.DenseBincount, DepthToSpace: () => P.DepthToSpace, DepthwiseConv2dNative: () => P.DepthwiseConv2dNative, DepthwiseConv2dNativeBackpropFilter: () => P.DepthwiseConv2dNativeBackpropFilter, DepthwiseConv2dNativeBackpropInput: () => P.DepthwiseConv2dNativeBackpropInput, Diag: () => P.Diag, Dilation2D: () => P.Dilation2D, Dilation2DBackpropFilter: () => P.Dilation2DBackpropFilter, Dilation2DBackpropInput: () => P.Dilation2DBackpropInput, Draw: () => P.Draw, ENV: () => P.ENV, EarlyStopping: () => gh, Einsum: () => P.Einsum, Elu: () => P.Elu, EluGrad: () => P.EluGrad, Environment: () => P.Environment, Equal: () => P.Equal, Erf: () => P.Erf, Exp: () => P.Exp, ExpandDims: () => P.ExpandDims, Expm1: () => P.Expm1, FFT: () => P.FFT, Fill: () => P.Fill, FlipLeftRight: () => P.FlipLeftRight, Floor: () => P.Floor, FloorDiv: () => P.FloorDiv, FromPixels: () => P.FromPixels, FusedBatchNorm: () => P.FusedBatchNorm, FusedConv2D: () => P.FusedConv2D, FusedDepthwiseConv2D: () => P.FusedDepthwiseConv2D, GPGPUContext: () => Jk, GatherNd: () => P.GatherNd, GatherV2: () => P.GatherV2, GraphModel: () => jd, Greater: () => P.Greater, GreaterEqual: () => P.GreaterEqual, History: () => Ga, IFFT: () => P.IFFT, Identity: () => P.Identity, Imag: () => P.Imag, InputSpec: () => qi, IsFinite: () => P.IsFinite, IsInf: () => P.IsInf, IsNan: () => P.IsNan, KernelBackend: () => P.KernelBackend, LRN: () => P.LRN, LRNGrad: () => P.LRNGrad, LayerVariable: () => Vi, LayersModel: () => Jo, LeakyRelu: () => P.LeakyRelu, Less: () => P.Less, LessEqual: () => P.LessEqual, LinSpace: () => P.LinSpace, Log: () => P.Log, Log1p: () => P.Log1p, LogSoftmax: () => P.LogSoftmax, LogicalAnd: () => P.LogicalAnd, LogicalNot: () => P.LogicalNot, LogicalOr: () => P.LogicalOr, LogicalXor: () => P.LogicalXor, LowerBound: () => P.LowerBound, MathBackendCPU: () => op, MathBackendWebGL: () => f_, MatrixBandPart: () => P.MatrixBandPart, Max: () => P.Max, MaxPool: () => P.MaxPool, MaxPool3D: () => P.MaxPool3D, MaxPool3DGrad: () => P.MaxPool3DGrad, MaxPoolGrad: () => P.MaxPoolGrad, MaxPoolWithArgmax: () => P.MaxPoolWithArgmax, Maximum: () => P.Maximum, Mean: () => P.Mean, Min: () => P.Min, Minimum: () => P.Minimum, MirrorPad: () => P.MirrorPad, Mod: () => P.Mod, MomentumOptimizer: () => P.MomentumOptimizer, Multinomial: () => P.Multinomial, Multiply: () => P.Multiply, Neg: () => P.Neg, NonMaxSuppressionV3: () => P.NonMaxSuppressionV3, NonMaxSuppressionV4: () => P.NonMaxSuppressionV4, NonMaxSuppressionV5: () => P.NonMaxSuppressionV5, NotEqual: () => P.NotEqual, OP_SCOPE_SUFFIX: () => P.OP_SCOPE_SUFFIX, OneHot: () => P.OneHot, OnesLike: () => P.OnesLike, Optimizer: () => P.Optimizer, OptimizerConstructors: () => P.OptimizerConstructors, Pack: () => P.Pack, PadV2: () => P.PadV2, Pool: () => P.Pool, Pow: () => P.Pow, Prelu: () => P.Prelu, Prod: () => P.Prod, RMSPropOptimizer: () => P.RMSPropOptimizer, RNN: () => uu, RaggedGather: () => P.RaggedGather, RaggedRange: () => P.RaggedRange, RaggedTensorToTensor: () => P.RaggedTensorToTensor, Range: () => P.Range, Rank: () => P.Rank, Real: () => P.Real, RealDiv: () => P.RealDiv, Reciprocal: () => P.Reciprocal, Reduction: () => P.Reduction, Relu: () => P.Relu, Relu6: () => P.Relu6, Reshape: () => P.Reshape, ResizeBilinear: () => P.ResizeBilinear, ResizeBilinearGrad: () => P.ResizeBilinearGrad, ResizeNearestNeighbor: () => P.ResizeNearestNeighbor, ResizeNearestNeighborGrad: () => P.ResizeNearestNeighborGrad, Reverse: () => P.Reverse, RotateWithOffset: () => P.RotateWithOffset, Round: () => P.Round, Rsqrt: () => P.Rsqrt, SGDOptimizer: () => P.SGDOptimizer, ScatterNd: () => P.ScatterNd, SearchSorted: () => P.SearchSorted, Select: () => P.Select, Selu: () => P.Selu, Sequential: () => ns, Sigmoid: () => P.Sigmoid, Sign: () => P.Sign, Sin: () => P.Sin, Sinh: () => P.Sinh, Slice: () => P.Slice, Softmax: () => P.Softmax, Softplus: () => P.Softplus, SpaceToBatchND: () => P.SpaceToBatchND, SparseFillEmptyRows: () => P.SparseFillEmptyRows, SparseReshape: () => P.SparseReshape, SparseSegmentMean: () => P.SparseSegmentMean, SparseSegmentSum: () => P.SparseSegmentSum, SparseToDense: () => P.SparseToDense, SplitV: () => P.SplitV, Sqrt: () => P.Sqrt, Square: () => P.Square, SquaredDifference: () => P.SquaredDifference, StaticRegexReplace: () => P.StaticRegexReplace, Step: () => P.Step, StridedSlice: () => P.StridedSlice, StringNGrams: () => P.StringNGrams, StringSplit: () => P.StringSplit, StringToHashBucketFast: () => P.StringToHashBucketFast, Sub: () => P.Sub, Sum: () => P.Sum, SymbolicTensor: () => Yi, Tan: () => P.Tan, Tanh: () => P.Tanh, Tensor: () => P.Tensor, TensorBuffer: () => P.TensorBuffer, TensorScatterUpdate: () => P.TensorScatterUpdate, Tile: () => P.Tile, TopK: () => P.TopK, Transform: () => P.Transform, Transpose: () => P.Transpose, Unique: () => P.Unique, Unpack: () => P.Unpack, UnsortedSegmentSum: () => P.UnsortedSegmentSum, UpperBound: () => P.UpperBound, Variable: () => P.Variable, ZerosLike: () => P.ZerosLike, _FusedMatMul: () => P._FusedMatMul, abs: () => P.abs, acos: () => P.acos, acosh: () => P.acosh, add: () => P.add, addN: () => P.addN, all: () => P.all, any: () => P.any, argMax: () => P.argMax, argMin: () => P.argMin, asin: () => P.asin, asinh: () => P.asinh, atan: () => P.atan, atan2: () => P.atan2, atanh: () => P.atanh, avgPool: () => P.avgPool, avgPool3d: () => P.avgPool3d, backend: () => P.backend, backend_util: () => P.backend_util, basicLSTMCell: () => P.basicLSTMCell, batchNorm: () => P.batchNorm, batchNorm2d: () => P.batchNorm2d, batchNorm3d: () => P.batchNorm3d, batchNorm4d: () => P.batchNorm4d, batchToSpaceND: () => P.batchToSpaceND, bincount: () => P.bincount, bitwiseAnd: () => P.bitwiseAnd, booleanMaskAsync: () => P.booleanMaskAsync, broadcastArgs: () => P.broadcastArgs, broadcastTo: () => P.broadcastTo, broadcast_util: () => P.broadcast_util, browser: () => P.browser, buffer: () => P.buffer, callbacks: () => yh, cast: () => P.cast, ceil: () => P.ceil, clipByValue: () => P.clipByValue, clone: () => P.clone, complex: () => P.complex, concat: () => P.concat, concat1d: () => P.concat1d, concat2d: () => P.concat2d, concat3d: () => P.concat3d, concat4d: () => P.concat4d, constraints: () => e, conv1d: () => P.conv1d, conv2d: () => P.conv2d, conv2dTranspose: () => P.conv2dTranspose, conv3d: () => P.conv3d, conv3dTranspose: () => P.conv3dTranspose, copyRegisteredKernels: () => P.copyRegisteredKernels, cos: () => P.cos, cosh: () => P.cosh, cosineWindow: () => P.cosineWindow, cumprod: () => P.cumprod, cumsum: () => P.cumsum, customGrad: () => P.customGrad, data: () => E, denseBincount: () => P.denseBincount, deprecationWarn: () => P.deprecationWarn, depthToSpace: () => P.depthToSpace, depthwiseConv2d: () => P.depthwiseConv2d, deregisterOp: () => _h, device_util: () => P.device_util, diag: () => P.diag, dilation2d: () => P.dilation2d, disableDeprecationWarnings: () => P.disableDeprecationWarnings, dispose: () => P.dispose, disposeVariables: () => P.disposeVariables, div: () => P.div, divNoNan: () => P.divNoNan, dot: () => P.dot, dropout: () => P.dropout, einsum: () => P.einsum, elu: () => P.elu, enableDebugMode: () => P.enableDebugMode, enableProdMode: () => P.enableProdMode, enclosingPowerOfTwo: () => P.enclosingPowerOfTwo, engine: () => P.engine, ensureShape: () => P.ensureShape, env: () => P.env, equal: () => P.equal, erf: () => P.erf, euclideanNorm: () => P.euclideanNorm, exp: () => P.exp, expandDims: () => P.expandDims, expm1: () => P.expm1, eye: () => P.eye, fft: () => P.fft, fill: () => P.fill, findBackend: () => P.findBackend, findBackendFactory: () => P.findBackendFactory, floor: () => P.floor, floorDiv: () => P.floorDiv, forceHalfFloat: () => m_, fused: () => P.fused, gather: () => P.gather, gatherND: () => P.gatherND, gather_util: () => P.gather_util, getBackend: () => P.getBackend, getGradient: () => P.getGradient, getKernel: () => P.getKernel, getKernelsForBackend: () => P.getKernelsForBackend, gpgpu_util: () => M, grad: () => P.grad, grads: () => P.grads, greater: () => P.greater, greaterEqual: () => P.greaterEqual, ifft: () => P.ifft, imag: () => P.imag, image: () => P.image, inTopKAsync: () => P.inTopKAsync, initializers: () => t, input: () => as, io: () => P.io, irfft: () => P.irfft, isFinite: () => P.isFinite, isInf: () => P.isInf, isNaN: () => P.isNaN, keep: () => P.keep, kernel_impls: () => P.kernel_impls, layers: () => i, leakyRelu: () => P.leakyRelu, less: () => P.less, lessEqual: () => P.lessEqual, linalg: () => P.linalg, linspace: () => P.linspace, loadGraphModel: () => Ud, loadGraphModelSync: () => Wd, loadLayersModel: () => ts, localResponseNormalization: () => P.localResponseNormalization, log: () => P.log, log1p: () => P.log1p, logSigmoid: () => P.logSigmoid, logSoftmax: () => P.logSoftmax, logSumExp: () => P.logSumExp, logicalAnd: () => P.logicalAnd, logicalNot: () => P.logicalNot, logicalOr: () => P.logicalOr, logicalXor: () => P.logicalXor, losses: () => P.losses, lowerBound: () => P.lowerBound, matMul: () => P.matMul, math: () => P.math, max: () => P.max, maxPool: () => P.maxPool, maxPool3d: () => P.maxPool3d, maxPoolWithArgmax: () => P.maxPoolWithArgmax, maximum: () => P.maximum, mean: () => P.mean, memory: () => P.memory, meshgrid: () => P.meshgrid, metrics: () => a, min: () => P.min, minimum: () => P.minimum, mirrorPad: () => P.mirrorPad, mod: () => P.mod, model: () => rs, models: () => o, moments: () => P.moments, movingAverage: () => P.movingAverage, mul: () => P.mul, multiRNNCell: () => P.multiRNNCell, multinomial: () => P.multinomial, neg: () => P.neg, nextFrame: () => P.nextFrame, norm: () => P.norm, notEqual: () => P.notEqual, oneHot: () => P.oneHot, ones: () => P.ones, onesLike: () => P.onesLike, op: () => P.op, outerProduct: () => P.outerProduct, pad: () => P.pad, pad1d: () => P.pad1d, pad2d: () => P.pad2d, pad3d: () => P.pad3d, pad4d: () => P.pad4d, pool: () => P.pool, pow: () => P.pow, prelu: () => P.prelu, print: () => P.print, prod: () => P.prod, profile: () => P.profile, raggedGather: () => P.raggedGather, raggedRange: () => P.raggedRange, raggedTensorToTensor: () => P.raggedTensorToTensor, rand: () => P.rand, randomGamma: () => P.randomGamma, randomNormal: () => P.randomNormal, randomStandardNormal: () => P.randomStandardNormal, randomUniform: () => P.randomUniform, randomUniformInt: () => P.randomUniformInt, range: () => P.range, ready: () => P.ready, real: () => P.real, reciprocal: () => P.reciprocal, registerBackend: () => P.registerBackend, registerCallbackConstructor: () => os, registerGradient: () => P.registerGradient, registerKernel: () => P.registerKernel, registerOp: () => kh, regularizers: () => s, relu: () => P.relu, relu6: () => P.relu6, removeBackend: () => P.removeBackend, reshape: () => P.reshape, reverse: () => P.reverse, reverse1d: () => P.reverse1d, reverse2d: () => P.reverse2d, reverse3d: () => P.reverse3d, reverse4d: () => P.reverse4d, rfft: () => P.rfft, round: () => P.round, rsqrt: () => P.rsqrt, scalar: () => P.scalar, scatterND: () => P.scatterND, scatter_util: () => P.scatter_util, searchSorted: () => P.searchSorted, selu: () => P.selu, separableConv2d: () => P.separableConv2d, sequential: () => is, serialization: () => P.serialization, setBackend: () => P.setBackend, setPlatform: () => P.setPlatform, setWebGLContext: () => Ux, setdiff1dAsync: () => P.setdiff1dAsync, shared: () => N, sigmoid: () => P.sigmoid, sign: () => P.sign, signal: () => P.signal, sin: () => P.sin, sinh: () => P.sinh, slice: () => P.slice, slice1d: () => P.slice1d, slice2d: () => P.slice2d, slice3d: () => P.slice3d, slice4d: () => P.slice4d, slice_util: () => P.slice_util, softmax: () => P.softmax, softplus: () => P.softplus, spaceToBatchND: () => P.spaceToBatchND, sparse: () => P.sparse, sparseToDense: () => P.sparseToDense, spectral: () => P.spectral, split: () => P.split, sqrt: () => P.sqrt, square: () => P.square, squaredDifference: () => P.squaredDifference, squeeze: () => P.squeeze, stack: () => P.stack, step: () => P.step, stridedSlice: () => P.stridedSlice, string: () => P.string, sub: () => P.sub, sum: () => P.sum, sumOutType: () => P.sumOutType, tan: () => P.tan, tanh: () => P.tanh, tensor: () => P.tensor, tensor1d: () => P.tensor1d, tensor2d: () => P.tensor2d, tensor3d: () => P.tensor3d, tensor4d: () => P.tensor4d, tensor5d: () => P.tensor5d, tensor6d: () => P.tensor6d, tensorScatterUpdate: () => P.tensorScatterUpdate, tensor_util: () => P.tensor_util, test_util: () => P.test_util, tidy: () => P.tidy, tile: () => P.tile, time: () => P.time, topk: () => P.topk, train: () => P.train, transpose: () => P.transpose, truncatedNormal: () => P.truncatedNormal, unique: () => P.unique, unregisterGradient: () => P.unregisterGradient, unregisterKernel: () => P.unregisterKernel, unsortedSegmentSum: () => P.unsortedSegmentSum, unstack: () => P.unstack, upcastType: () => P.upcastType, upperBound: () => P.upperBound, util: () => P.util, valueAndGrad: () => P.valueAndGrad, valueAndGrads: () => P.valueAndGrads, variable: () => P.variable, variableGrads: () => P.variableGrads, version: () => cM, version_converter: () => Vd, version_core: () => P.version_core, version_cpu: () => Dg, version_layers: () => Fo, version_webgl: () => p_, webgl: () => g_, webgl_util: () => I, where: () => P.where, whereAsync: () => P.whereAsync, zeros: () => P.zeros, zerosLike: () => P.zerosLike }); var D = {}; n.r(D), n.d(D, { hasBrowserEnv: () => jF, hasStandardBrowserEnv: () => WF, hasStandardBrowserWebWorkerEnv: () => VF, navigator: () => UF, origin: () => GF }); var $ = {}; n.r($), n.d($, { load: () => Eq, version: () => _q }); var R = {}; n.r(R), n.d(R, { Darknet: () => zq, load: () => Pq }); var O = {}; n.r(O), n.d(O, { Doodlenet: () => Uq, load: () => Wq }); var z = {}; n.r(z), n.d(z, { SpeechCommands: () => IY, load: () => MY }); var P = n(5838), B = n(5441), L = n(9809), j = n(9258), U = n(700);
/**
* @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.
* =============================================================================
*/
const W = { kernelName: B.ljI, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, U.P)((0, L.w)(n, "float32"), -1)) } } }; var V = n(9359), G = n(6522), H = n(5702), q = n(9348), Y = n(5793), X = n(7126);
/**
* @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.
* =============================================================================
*/
const K = { kernelName: B.Vvy, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, Y.E)((0, L.w)(n, "float32")), r = (0, q.R)((0, X.j)((0, H.d)(1), t)); return (0, G.H)((0, V.y)(e, r)) } } } }, Z = { kernelName: B.PH8, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, q.R)((0, X.j)((0, Y.E)((0, L.w)(n, "float32")), 1)); return (0, V.y)(e, t) } } } }; var J = n(2198), Q = n(2302), ee = n(3791);
/**
* @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.
* =============================================================================
*/
const te = { kernelName: B.OMN, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { let t = e; const r = J.getReductionAxes(n.shape, i); return r.length > 0 && (t = (0, ee.c)(t, r)), (0, Q.t)(t, n.shape) }, b: () => { let t = e; const n = J.getReductionAxes(r.shape, i); return n.length > 0 && (t = (0, ee.c)(t, n)), (0, Q.t)(t, r.shape) } } } }, ne = { kernelName: B.EkD, saveAllInputs: !0, gradFunc: (e, t) => { const n = {}; return t.forEach(((t, r) => { n[r] = () => e.clone() })), n } }; var re = n(5537);
/**
* @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.
* =============================================================================
*/
const ie = { kernelName: B.Jp_, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, re.P)(n) } } }, ae = { kernelName: B.p_m, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, re.P)(n) } } }, oe = { kernelName: B.QKF, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, q.R)((0, X.j)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32"))))) } } }; var se = n(7523);
/**
* @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.
* =============================================================================
*/
const ue = { kernelName: B.epO, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, q.R)((0, se.W)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32")))); return (0, V.y)(e, t) } } } }, le = { kernelName: B.lxb, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, se.W)((0, Y.E)(n), (0, Y.E)(r)); let a = (0, j.l)(e, (0, V.y)(r, t)); const o = (0, J.getReductionAxes)(n.shape, i); return o.length > 0 && (a = (0, ee.c)(a, o)), (0, Q.t)(a, n.shape) }, b: () => { const t = (0, se.W)((0, Y.E)(n), (0, Y.E)(r)); let a = (0, G.H)((0, j.l)(e, (0, V.y)(n, t))); const o = (0, J.getReductionAxes)(r.shape, i); return o.length > 0 && (a = (0, ee.c)(a, o)), (0, Q.t)(a, r.shape) } } } }, ce = { kernelName: B.TyE, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, se.W)((0, Y.E)((0, L.w)(n, "float32")), 1)) } } }, he = { kernelName: B.zP9, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, X.j)((0, H.d)(1), (0, Y.E)((0, L.w)(n, "float32")))) } } }; var de = n(1585), fe = n(8189), pe = n(5119), me = n(7195), ge = n(929); const ye = (0, ge.op)({
avgPool3dGrad_:
/**
* @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 (e, t, n, r, i, a) { const o = (0, fe.YT)(e, "dy", "avgPool3dGrad"), s = (0, fe.YT)(t, "input", "avgPool3dGrad"); let u = o, l = s, c = !1; 4 === s.rank && (c = !0, u = (0, Q.t)(o, [1, o.shape[0], o.shape[1], o.shape[2], o.shape[3]]), l = (0, Q.t)(s, [1, s.shape[0], s.shape[1], s.shape[2], s.shape[3]])), pe.vA(5 === u.rank, (() => `Error in avgPool3dGrad: dy must be rank 5 but got rank ${u.rank}.`)), pe.vA(5 === l.rank, (() => `Error in avgPool3dGrad: input must be rank 5 but got rank ${l.rank}.`)), (0, me.s_)("avgPool3dGrad", i, a); const h = { dy: u, input: l }, d = { filterSize: n, strides: r, pad: i, dimRoundingMode: a }, f = de.T2.runKernel(B.wwC, h, d); return c ? (0, Q.t)(f, [f.shape[1], f.shape[2], f.shape[3], f.shape[4]]) : f }
}), be = { kernelName: B.cS, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { filterSize: i, strides: a, pad: o, dimRoundingMode: s } = n; return { x: () => ye(e, r, i, a, o, s) } } }; const ve = (0, ge.op)({
avgPoolGrad_:
/**
* @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 (e, t, n, r, i) { const a = (0, fe.YT)(e, "dy", "avgPoolGrad"), o = (0, fe.YT)(t, "input", "avgPoolGrad"); pe.vA(o.rank === a.rank, (() => `Rank of input (${o.rank}) does not match rank of dy (${a.rank})`)); let s = o, u = a, l = !1; 3 === o.rank && (l = !0, s = (0, Q.t)(o, [1, o.shape[0], o.shape[1], o.shape[2]]), u = (0, Q.t)(a, [1, a.shape[0], a.shape[1], a.shape[2]])), pe.vA(4 === u.rank, (() => `Error in avgPoolGrad: dy must be rank 4 but got rank ${u.rank}.`)), pe.vA(4 === s.rank, (() => `Error in avgPoolGrad: input must be rank 4 but got rank ${s.rank}.`)); const c = { dy: u, input: s }, h = { filterSize: n, strides: r, pad: i }, d = de.T2.runKernel(B.VCH, c, h); return l ? (0, Q.t)(d, [d.shape[1], d.shape[2], d.shape[3]]) : d }
}), xe = { kernelName: B.ho8, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { filterSize: i, strides: a, pad: o } = n; return { x: () => ve(e, r, i, a, o) } } }; var we = n(5703);
/**
* @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.
* =============================================================================
*/
const ke = { kernelName: B.jAQ, inputsToSave: ["a", "b"], gradFunc: (e, t, n) => { const [r, i] = t, { transposeA: a, transposeB: o } = n; return a || o ? !a && o ? { a: () => (0, we.N)(e, i, !1, !1), b: () => (0, we.N)(e, r, !0, !1) } : a && !o ? { a: () => (0, we.N)(i, e, !1, !0), b: () => (0, we.N)(r, e, !1, !1) } : { a: () => (0, we.N)(i, e, !0, !0), b: () => (0, we.N)(e, r, !0, !0) } : { a: () => (0, we.N)(e, i, !1, !0), b: () => (0, we.N)(r, e, !0, !1) } } }; var Se = n(776);
/**
* @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.
* =============================================================================
*/
const _e = { kernelName: B.Ik2, gradFunc: (e, t, n) => { const { blockShape: r, crops: i } = n; return { x: () => (0, Se.e)(e, r, i) } } }, Ce = { kernelName: B.LB5, gradFunc: (e, t, n) => { const r = n, i = r.inputShape, a = r.shape, o = Array.from(a); for (let e = i.length - 1; e >= 0; e--)if (i[e] === a[e]) o[e] = 1; else if (1 !== i[e]) throw new Error(`broadcastTo(): [${i}] cannot be broadcast to [${a}].`); const s = []; for (let e = 0; e < o.length; e++)o[e] > 1 && s.push(e); return { x: () => (0, ee.c)(e, s, !0) } } }, Ae = { kernelName: B.KXH, gradFunc: e => ({ x: () => e.clone() }) }, Te = { kernelName: B.QDP, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var Ee = n(3337), Ne = n(6508), Ie = n(3789), Me = n(2151);
/**
* @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.
* =============================================================================
*/
const Fe = { kernelName: B.vaV, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { clipValueMin: i, clipValueMax: a } = n; return { x: () => (0, Me._)((0, Ie.n)((0, Ee.D)(r, i), (0, Ne.I)(r, a)), e, (0, re.P)(e)) } } }, De = { kernelName: B.$zE, inputsToSave: ["x"], gradFunc: W.gradFunc }; var $e = n(6512);
/**
* @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.
* =============================================================================
*/
const Re = { kernelName: B.$dB, saveAllInputs: !0, gradFunc: (e, t, n) => { const r = t.map((e => e.shape)), { axis: i } = n, a = (0, pe.Y6)(i, t[0].shape)[0], o = r.map((e => e[a])); return (0, $e.l)(e, o, a).map((e => () => e)) } }; var Oe = n(5248), ze = n(252);
/**
* @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.
* =============================================================================
*/
const Pe = { kernelName: B.p2J, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, { dilations: a, strides: o, pad: s, dataFormat: u } = n; return pe.vA(me.Dh(a), (() => `Error in gradient of conv2D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${a}'`)), { x: () => (0, ze.v)(r.shape, e, i, o, s, u), filter: () => (0, Oe.H)(r, e, i.shape, o, s, u) } } }; var Be = n(8794);
/**
* @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.
* =============================================================================
*/
const Le = { kernelName: B.jfg, inputsToSave: ["dy", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, { strides: a, pad: o, dataFormat: s, dimRoundingMode: u } = n; return { dy: () => (0, Be.X)(e, i, a, o, s, 1, u), filter: () => (0, Oe.H)(e, r, i.shape, a, o, s, u) } } }; const je = (0, ge.op)({
conv3DBackpropFilter_:
/**
* @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 (e, t, n, r, i) { let a = e; 4 === e.rank && (a = (0, Q.t)(e, [1, e.shape[0], e.shape[1], e.shape[2], e.shape[3]])); let o = t; 4 === o.rank && (o = (0, Q.t)(t, [1, t.shape[0], t.shape[1], t.shape[2], t.shape[3]])), pe.vA(5 === a.rank, (() => `Error in conv3dDerFilter: input must be rank 5, but got shape ${a.shape}.`)), pe.vA(5 === o.rank, (() => `Error in conv3dDerFilter: dy must be rank 5, but got shape ${o.shape}.`)), pe.vA(5 === n.length, (() => `Error in conv3dDerFilter: filterShape must be length 5, but got ${n}.`)), pe.vA(a.shape[4] === n[3], (() => `Error in conv3dDerFilter: depth of input ${a.shape[4]}) must match input depth in filter (${n[3]}.`)), pe.vA(o.shape[4] === n[4], (() => `Error in conv3dDerFilter: depth of dy (${o.shape[4]}) must match output depth for filter (${n[4]}).`)); const s = { x: a, dy: o }, u = { strides: r, pad: i, filterShape: n }; return de.T2.runKernel(B.iGz, s, u) }
}); var Ue = n(1895);
/**
* @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.
* =============================================================================
*/
const We = { kernelName: B.A1h, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const { dilations: r, strides: i, pad: a } = n; pe.vA((0, me.Dh)(r), (() => `Error in gradient of conv3D: dilation rates greater than 1 are not yet supported in gradients. Got dilations '${r}'`)); const [o, s] = t; return { x: () => (0, Ue.c)(o.shape, e, s, i, a), filter: () => je(o, e, s.shape, i, a) } } }; var Ve = n(3726);
/**
* @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.
* =============================================================================
*/
const Ge = { kernelName: B.Mn0, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, G.H)((0, Ve.F)((0, L.w)(n, "float32"))), e) } } }; var He = n(8276);
/**
* @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.
* =============================================================================
*/
const qe = { kernelName: B.MnK, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, He.L)((0, L.w)(n, "float32")), e) } } }; var Ye = n(1078), Xe = n(6808), Ke = n(7703);
/**
* @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.
* =============================================================================
*/
const Ze = { kernelName: B.nY8, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i, exclusive: a, reverse: o } = n; return { x: () => { const t = (0, Ye.Em)([i], r.rank); let n = (0, Xe.r)(e, i, a, !o); return null != t && (n = (0, Ke.m)(n, t)), n } } } }; var Je = n(1890), Qe = n(3134);
/**
* @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.
* =============================================================================
*/
const et = { kernelName: B.tGH, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const { dilations: r, strides: i, pad: a, dimRoundingMode: o } = n, s = null == r ? [1, 1] : r; pe.vA(me.Dh(s), (() => `Error in gradient of depthwiseConv2dNative: dilation rates greater than 1 are not yet supported. Got dilations '${s}'`)); const [u, l] = t; return pe.vA(4 === u.rank, (() => `Error in gradient of depthwiseConv2dNative: input must be rank 4, but got rank ${u.rank}.`)), pe.vA(4 === l.rank, (() => `Error in gradient of depthwiseConv2dNative: filter must be rank 4, but got rank ${l.rank}.`)), pe.vA(u.shape[3] === l.shape[2], (() => `Error in gradient of depthwiseConv2d: number of input channels (${u.shape[3]}) must match the inChannels dimension in filter ${l.shape[2]}.`)), pe.vA(me.G0(i, s), (() => `Error in gradient of depthwiseConv2d: Either strides or dilations must be 1. Got strides ${i} and dilations '${s}'.`)), me.s_("depthwiseConv2d", a, o), { x: () => (0, Qe.l)(u.shape, e, l, i, a, s, o), filter: () => (0, Je.x)(u, e, l.shape, i, a, s, o) } } }, tt = { kernelName: B.jxD, inputsToSave: ["x", "filter"], gradFunc: (e, t, n) => { const [r, i] = t, a = { x: r, filter: i, dy: e }, o = { x: r, filter: i, dy: e }; return { x: () => de.T2.runKernel(B.bP9, a, n), filter: () => de.T2.runKernel(B.pk0, o, n) } } }, nt = { kernelName: B.Pah, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t, r = { dy: e, y: n }; return { x: () => de.T2.runKernel(B.rsH, r) } } }; var rt = n(8631);
/**
* @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.
* =============================================================================
*/
const it = { kernelName: B._s9, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t, r = (0, j.l)((0, rt.o)((0, G.H)((0, Y.E)(n))), 2 / Math.sqrt(Math.PI)); return { x: () => (0, j.l)(e, r) } } }, at = { kernelName: B.ox3, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, n) } } }, ot = { kernelName: B.ybN, inputsToSave: ["input"], gradFunc: (e, t) => { const [n] = t; return { input: () => (0, Q.t)(e, n.shape) } } }, st = { kernelName: B.ybj, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, rt.o)(n)) } } }, ut = { kernelName: B.ZgB, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, lt = { kernelName: B.ElG, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, V.y)(e, (0, L.w)(r, "float32")), a = (0, J.getReductionAxes)(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { let t = (0, j.l)(e, (0, L.w)(n, "float32")); const a = (0, J.getReductionAxes)(r.shape, i); a.length > 0 && (t = (0, Q.t)((0, ee.c)(t, a), r.shape)); const o = (0, Y.E)(r); return (0, G.H)((0, V.y)(t, (0, L.w)(o, "float32"))) } } } }; var ct = n(7820), ht = n(4826);
/**
* @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.
* =============================================================================
*/
const dt = { kernelName: B.i5R, inputsToSave: ["x", "mean", "variance", "scale"], gradFunc: (e, t, n) => { const { varianceEpsilon: r } = n, [i, a, o, s] = t, u = null == s ? (0, H.d)(1) : s, l = (0, J.getReductionAxes)(a.shape, i.shape), c = []; if (1 === a.rank) { for (let e = 0; e < i.shape.length - 1; ++e)c.push(i.shape[e]); c.push(1) } const h = (0, X.j)(i, a), d = (0, j.l)(e, u), f = (0, ct.Z)((0, se.W)(o, (0, H.d)(r))), p = (0, j.l)((0, j.l)((0, j.l)(f, f), f), (0, H.d)(-.5)); return { x: () => 1 === a.rank ? (0, Q.t)((0, j.l)((0, j.l)(e, (0, ht.V)((0, Q.t)(f, [1, 1, 1, a.shape[0]]), c)), u), i.shape) : (0, Q.t)((0, j.l)((0, j.l)(e, f), u), i.shape), mean: () => { let e = (0, j.l)((0, j.l)(f, (0, H.d)(-1)), d); return 1 === a.rank && (e = (0, ee.c)(e, l)), (0, Q.t)(e, a.shape) }, variance: () => { let e = (0, j.l)((0, j.l)(p, h), d); return 1 === a.rank && (e = (0, ee.c)(e, l)), (0, Q.t)(e, a.shape) }, scale: () => { const t = (0, j.l)(h, f); let n = (0, j.l)(e, t); return 1 === a.rank && (n = (0, ee.c)(n, l)), (0, Q.t)(n, a.shape) }, offset: () => { let t = e; return 1 === a.rank && (t = (0, ee.c)(t, l)), (0, Q.t)(t, a.shape) } } } }; var ft = n(4268), pt = n(7706);
/**
* @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.
* =============================================================================
*/
const mt = { kernelName: B.mxL, inputsToSave: ["x", "indices"], gradFunc: (e, t, n) => { const [r, i] = t, { axis: a, batchDims: o } = n, s = (0, pe.Y6)(a, r.shape)[0], u = (e, t, n) => () => { const r = e.shape, i = t.size, o = r.slice(0, s), u = o.length, l = r.slice(a, r.length).slice(1), c = l.length, h = gt(0, u), d = gt(u + 1, u + 1 + c), f = yt([o, [i], l]), p = (0, Q.t)(n, f), m = (0, Q.t)(t, [i]), g = yt([[u], h, d]), y = (0, Ke.m)(p, g); let b = (0, pt.z)(y, m, e.shape[s]); const v = (0, Ye.gx)(g); return b = (0, Ke.m)(b, v), b }; if (1 === o) { const t = r.shape[0], n = r.split(t, 0); return { x: () => { const t = (0, ft.t)(n.map(((t, n) => u(t, i.slice(n, 1), e.slice(n, 1))()))); return t.reshape(r.shape) }, indices: () => i } } return { x: u(r, i, e), indices: () => i } } }; function gt(e, t) { const n = []; for (let r = e; r < t; ++r)n.push(r); return n } function yt(e) { const t = []; for (let n = 0; n < e.length; ++n)for (let r = 0; r < e[n].length; ++r)t.push(e[n][r]); return t }
/**
* @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.
* =============================================================================
*/
const bt = { kernelName: B.lLS, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, re.P)(n), b: () => (0, re.P)(r) } } }, vt = { kernelName: B.lzr, gradFunc: e => ({ x: () => (0, L.w)(e, "float32") }) }, xt = { kernelName: B.gIW, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, wt = { kernelName: B.E3$, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, kt = { kernelName: B.iPs, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var St = n(2058);
/**
* @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.
* =============================================================================
*/
const _t = { kernelName: B.X0$, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { alpha: i } = n, a = (0, St.r)(r, 0); return { x: () => (0, Me._)(a, e, (0, j.l)(e, i)) } } }, Ct = { kernelName: B.Cg$, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, se.W)(n, 1)) } } }, At = { kernelName: B.tG8, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, L.w)(n, "float32")) } } }, Tt = { kernelName: B.zfU, inputsToSave: [], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n; return { logits: () => { const t = (0, rt.o)(r); return (0, X.j)(e, (0, j.l)((0, ee.c)(e, i, !0), t)) } } } }; const Et = (0, ge.op)({
localResponseNormalizationBackprop_:
/**
* @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 (e, t, n, r = 5, i = 1, a = 1, o = .5) { const s = { x: e, y: t, dy: n }, u = { depthRadius: r, bias: i, alpha: a, beta: o }; return de.T2.runKernel(B.ToN, s, u) }
}), Nt = { kernelName: B.jM4, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { depthRadius: a, bias: o, alpha: s, beta: u } = n; return { x: () => Et(r, i, e, a, o, s, u) } } }; var It = n(3020);
/**
* @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 Mt(e, t, n, r) { return t.rank < n.rank && (t = (0, Q.t)(t, Ye.SM(t.shape, r))), e.rank < n.rank && (e = (0, Q.t)(e, Ye.SM(e.shape, r))), { x: () => (0, j.l)(e, (0, L.w)((0, It.L)(n, t), e.dtype)) } }
/**
* @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.
* =============================================================================
*/
const Ft = { kernelName: B.VAI, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const r = n, { reductionIndices: i } = r, a = t[0], o = Mt(e, t[1], a, pe.Y6(i, a.shape)); return { x: () => o.x() } } }; var Dt = n(1303);
/**
* @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.
* =============================================================================
*/
const $t = { kernelName: B.LDN, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, j.l)(e, (0, L.w)((0, Ee.D)(n, r), "float32")), b: () => (0, j.l)(e, (0, L.w)((0, Dt.M)(n, r), "float32")) } } }; const Rt = (0, ge.op)({
maxPool3dGrad_:
/**
* @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 (e, t, n, r, i, a, o) { const s = (0, fe.YT)(e, "dy", "maxPool3dGrad"), u = (0, fe.YT)(t, "input", "maxPool3dGrad"), l = (0, fe.YT)(n, "output", "maxPool3dGrad"); let c = s, h = u, d = l, f = !1; 4 === u.rank && (f = !0, c = (0, Q.t)(s, [1, s.shape[0], s.shape[1], s.shape[2], s.shape[3]]), h = (0, Q.t)(u, [1, u.shape[0], u.shape[1], u.shape[2], u.shape[3]]), d = (0, Q.t)(l, [1, l.shape[0], l.shape[1], l.shape[2], l.shape[3]])), pe.vA(5 === c.rank, (() => `Error in maxPool3dGrad: dy must be rank 5 but got rank ${c.rank}.`)), pe.vA(5 === h.rank, (() => `Error in maxPool3dGrad: input must be rank 5 but got rank ${h.rank}.`)), pe.vA(5 === d.rank, (() => `Error in maxPool3dGrad: output must be rank 5 but got rank ${d.rank}.`)), (0, me.s_)("maxPool3dGrad", a, o); const p = { dy: c, input: h, output: d }, m = { filterSize: r, strides: i, pad: a, dimRoundingMode: o }, g = de.T2.runKernel(B.cHb, p, m); return f ? (0, Q.t)(g, [g.shape[1], g.shape[2], g.shape[3], g.shape[4]]) : g }
}), Ot = { kernelName: B.ySp, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = n; return { x: () => Rt(e, r, i, a, o, s, u) } } }; const zt = (0, ge.op)({
maxPoolGrad_:
/**
* @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 (e, t, n, r, i, a, o) { const s = (0, fe.YT)(e, "dy", "maxPoolGrad"), u = (0, fe.YT)(t, "input", "maxPoolGrad"), l = (0, fe.YT)(n, "output", "maxPoolGrad"); pe.vA(u.rank === s.rank, (() => `Rank of input (${u.rank}) does not match rank of dy (${s.rank})`)), pe.vA(4 === s.rank, (() => `Error in maxPoolGrad: dy must be rank 4 but got rank ${s.rank}.`)), pe.vA(4 === u.rank, (() => `Error in maxPoolGrad: input must be rank 4 but got rank ${u.rank}.`)), me.s_("maxPoolGrad", a, o); const c = { dy: s, input: u, output: l }, h = { filterSize: r, strides: i, pad: a, dimRoundingMode: o }; return de.T2.runKernel(B.RXX, c, h) }
}), Pt = { kernelName: B.t3d, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const [r, i] = t, { filterSize: a, strides: o, pad: s } = n; return { x: () => zt(e, r, i, a, o, s) } } }; var Bt = n(1411);
/**
* @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.
* =============================================================================
*/
const Lt = { kernelName: B.g5A, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n, a = pe.Y6(i, r.shape), o = (0, Ye.lb)(r.shape, a)[1], s = pe.Ze(o); return { x: () => { const t = r.shape.slice(); a.forEach((e => { t[e] = 1 })); const n = (0, Q.t)(e, t); return (0, V.y)((0, j.l)(n, (0, Bt.S)(r.shape, "float32")), s) } } } }, jt = { kernelName: B.lNG, inputsToSave: ["x"], outputsToSave: [!0], gradFunc: (e, t, n) => { const r = n, { axis: i } = r, [a, o] = t, s = Mt(e, o, a, pe.Y6(i, a.shape)); return { x: () => s.x() } } }, Ut = { kernelName: B.LG0, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t; return { a: () => (0, j.l)(e, (0, L.w)((0, Ne.I)(n, r), "float32")), b: () => (0, j.l)(e, (0, L.w)((0, St.r)(n, r), "float32")) } } }; var Wt = n(7986);
/**
* @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.
* =============================================================================
*/
const Vt = { kernelName: B.x7F, inputsToSave: ["x"], gradFunc: (e, t, n) => { const r = t[0], { paddings: i } = n, a = i.map((e => e[0])); return { x: () => (0, Wt.d)(e, a, r.shape) } } }; var Gt = n(5606);
/**
* @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.
* =============================================================================
*/
const Ht = { kernelName: B.BLA, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, J.getReductionAxes)(n.shape, i); return t.length > 0 ? (0, Q.t)((0, ee.c)(e, t), n.shape) : e }, b: () => { const t = (0, j.l)(e, (0, G.H)((0, Gt.R)((0, V.y)(n, r)))), a = (0, J.getReductionAxes)(r.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), r.shape) : t } } } }, qt = { kernelName: B.xu7, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, J.assertAndGetBroadcastShape)(n.shape, r.shape); return { a: () => { const t = (0, j.l)(e, (0, L.w)(r, "float32")), a = (0, J.getReductionAxes)(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { const t = (0, j.l)(e, (0, L.w)(n, "float32")), a = (0, J.getReductionAxes)(r.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), r.shape) : t } } } }, Yt = { kernelName: B.l0G, gradFunc: e => ({ x: () => (0, G.H)(e) }) }; var Xt = n(2855);
/**
* @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.
* =============================================================================
*/
const Kt = { kernelName: B.urI, inputsToSave: ["indices"], gradFunc: (e, t) => { const n = t[0]; return { indices: () => (0, Xt.U)(n.shape, "float32") } } }, Zt = { kernelName: B.LWX, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var Jt = n(7261);
/**
* @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.
* =============================================================================
*/
const Qt = { kernelName: B.mM$, saveAllInputs: !0, gradFunc: (e, t, n) => { const { axis: r } = n; return (0, Jt.K)(e, r).map((e => () => e)) } }, en = { kernelName: B.ODT, inputsToSave: ["x"], gradFunc: (e, t, n) => { const r = t[0], { paddings: i } = n, a = i.map((e => e[0])); return { x: () => (0, Wt.d)(e, a, r.shape) } } }; var tn = n(4010), nn = n(8990);
/**
* @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.
* =============================================================================
*/
const rn = { kernelName: B.pyJ, inputsToSave: ["a", "b"], outputsToSave: [!0], gradFunc: (e, t) => { const [n, r, i] = t, a = n, o = r, s = J.assertAndGetBroadcastShape(a.shape, o.shape); return { a: () => { const t = (0, L.w)(o, "float32"); let n = (0, j.l)(e, (0, j.l)(t, (0, nn.n)(a, (0, X.j)(t, (0, H.d)(1))))); const r = J.getReductionAxes(a.shape, s); return r.length > 0 && (n = (0, ee.c)(n, r)), (0, Q.t)(n, a.shape) }, b: () => { const t = (0, St.r)(a, 0), n = (0, Me._)(t, (0, tn.R)(a), (0, re.P)(a)); let r = (0, j.l)(e, (0, j.l)(i, n)); const u = J.getReductionAxes(o.shape, s); return u.length > 0 && (r = (0, ee.c)(r, u)), (0, Q.t)(r, o.shape) } } } }, an = { kernelName: B.Ncv, inputsToSave: ["x", "alpha"], gradFunc: (e, t) => { const [n, r] = t, i = (0, St.r)(n, 0); return { x: () => (0, Me._)(i, e, (0, j.l)(e, r)), alpha: () => { let t = (0, Me._)(i, (0, re.P)(e), (0, j.l)(e, n)); const a = (0, J.getReductionAxes)(r.shape, e.shape); return a.length > 0 && (t = (0, ee.c)(t, a)), (0, Q.t)(t, r.shape) } } } }; var on = n(302); function sn(e, t, n) {
const r = e.shape.length, i = r - n.length, a = Ye.Em(n, r); let o = e; null != a && (o = (0, Ke.m)(e, a)); const s = o.shape.slice(), u = s.splice(r - n.length, n.length).reduce(((e, t) => e * t), 1); s.push(u); let l =
/**
* @license
* Copyright 2022 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 (e, t, n) { const r = e.shape.slice(); r[n] = 1; const i = (0, Q.t)(t, r), a = (0, on.L)(e, n, !0, !1), o = (0, on.L)(e, n, !0, !0), s = (0, j.l)(a, o); return (0, j.l)(i, s) }(o.reshape(s), t, i); if (l = l.reshape(o.shape), null != a) { const e = Ye.gx(a); l = (0, Ke.m)(l, e) } return l
} const un = { kernelName: B.kdj, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { axis: i } = n; let a = []; return a = null == i ? r.shape.map(((e, t) => t)) : "number" == typeof i ? [i] : i, { x: () => sn(r, e, a) } } }, ln = { kernelName: B.sDr, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { const t = (0, V.y)(e, (0, L.w)(r, "float32")), a = J.getReductionAxes(n.shape, i); return a.length > 0 ? (0, Q.t)((0, ee.c)(t, a), n.shape) : t }, b: () => { let t = (0, j.l)(e, (0, L.w)(n, "float32")); const a = J.getReductionAxes(r.shape, i); a.length > 0 && (t = (0, Q.t)((0, ee.c)(t, a), r.shape)); const o = (0, Y.E)(r); return (0, G.H)((0, V.y)(t, (0, L.w)(o, "float32"))) } } } }, cn = { kernelName: B.huO, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, G.H)((0, Y.E)(n))) } } }, hn = { kernelName: B.P_L, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t, r = (0, j.l)((0, Ne.I)(n, 6), (0, U.P)(n)); return { x: () => (0, j.l)(e, (0, L.w)(r, "float32")) } } }, dn = { kernelName: B.fUj, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, L.w)((0, U.P)(n), "float32")) } } }, fn = { kernelName: B.R23, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, Q.t)(e, n.shape) } } }, pn = { kernelName: B.hgw, inputsToSave: ["images"], gradFunc: (e, t, n) => { const [r] = t, i = { dy: e, images: r }; return { images: () => de.T2.runKernel(B.FCQ, i, n) } } }, mn = { kernelName: B.jOE, inputsToSave: ["images"], gradFunc: (e, t, n) => { const [r] = t, i = { dy: e, images: r }; return { images: () => de.T2.runKernel(B.XQy, i, n) } } }; var gn = n(3262);
/**
* @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.
* =============================================================================
*/
const yn = { kernelName: B.D7i, gradFunc: (e, t, n) => { const { dims: r } = n, i = (0, pe.Y6)(r, e.shape); return { x: () => (0, gn.B)(e, i) } } }, bn = { kernelName: B.hVg, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, vn = { kernelName: B.TOR, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, G.H)((0, V.y)(e, (0, j.l)((0, nn.n)(n, 1.5), 2))) } } }; var xn = n(9881);
/**
* @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.
* =============================================================================
*/
const wn = { kernelName: B.l6P, inputsToSave: ["condition"], gradFunc: (e, t) => { const [n] = t; return { condition: () => (0, L.w)((0, re.P)(n), "float32"), t: () => (0, j.l)(e, (0, L.w)(n, e.dtype)), e: () => (0, j.l)(e, (0, L.w)((0, xn.N)(n), e.dtype)) } } }; var kn = n(8576);
/**
* @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.
* =============================================================================
*/
const Sn = { kernelName: B.u$b, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => { const t = (0, St.r)(n, (0, H.d)(0)), r = (0, H.d)(kn.j), i = (0, H.d)(kn.X), a = (0, j.l)(e, i), o = (0, j.l)((0, j.l)(e, r), (0, rt.o)((0, L.w)(n, "float32"))); return (0, Me._)(t, a, o) } } } }, _n = { kernelName: B.vI1, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, j.l)(n, (0, X.j)((0, H.d)(1), n))) } } }, Cn = { kernelName: B.YVe, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var An = n(9907);
/**
* @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.
* =============================================================================
*/
const Tn = { kernelName: B.hql, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, An.g)((0, L.w)(n, "float32")), e) } } }; var En = n(7451);
/**
* @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.
* =============================================================================
*/
const Nn = { kernelName: B.J3C, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, En.y)((0, L.w)(n, "float32")), e) } } }; var In = n(5661), Mn = n(4969);
/**
* @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.
* =============================================================================
*/
const Fn = { kernelName: B.JiE, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { begin: i, size: a } = n, o = r.shape, [s, u] = (0, Mn.parseSliceParams)(r, i, a), l = []; for (let t = 0; t < e.rank; t++)l.push([s[t], o[t] - s[t] - u[t]]); return { x: () => (0, In.e)(e, l) } } }, Dn = { kernelName: B.rFG, outputsToSave: [!0], gradFunc: (e, t, n) => { const [r] = t, { dim: i } = n, a = (0, j.l)(e, r); return { logits: () => (0, X.j)(a, (0, j.l)((0, ee.c)(a, [i], true), r)) } } }; var $n = n(8968);
/**
* @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.
* =============================================================================
*/
const Rn = { kernelName: B.Fin, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, $n.r)(n)) } } }; var On = n(9772);
/**
* @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.
* =============================================================================
*/
const zn = { kernelName: B.A8B, gradFunc: (e, t, n) => { const { blockShape: r, paddings: i } = n; return { x: () => (0, On.G)(e, r, i) } } }; var Pn = n(5030);
/**
* @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.
* =============================================================================
*/
const Bn = { kernelName: B.Blb, gradFunc: (e, t, n) => { const { axis: r } = n; return { x: () => (0, Pn.x)(e, r) } } }, Ln = { kernelName: B.dFH, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, j.l)((0, q.R)((0, L.w)(n, "float32")), 2)) } } }, jn = { kernelName: B.M6A, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)(e, (0, j.l)((0, L.w)(n, "float32"), 2)) } } }, Un = { kernelName: B.Ddj, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = (0, H.d)(2); return { a: () => (0, j.l)(e, (0, j.l)(i, (0, X.j)(n, r))), b: () => (0, j.l)(e, (0, j.l)(i, (0, X.j)(r, n))) } } }, Wn = { kernelName: B.pnw, gradFunc: e => ({ x: () => (0, re.P)(e) }) }, Vn = { kernelName: B.PbM, inputsToSave: ["a", "b"], gradFunc: (e, t) => { const [n, r] = t, i = J.assertAndGetBroadcastShape(n.shape, r.shape); return { a: () => { let t = e; const r = J.getReductionAxes(n.shape, i); return r.length > 0 && (t = (0, ee.c)(t, r)), (0, Q.t)(t, n.shape) }, b: () => { let t = e; const n = J.getReductionAxes(r.shape, i); return n.length > 0 && (t = (0, ee.c)(t, n)), (0, Q.t)((0, G.H)(t), r.shape) } } } }, Gn = { kernelName: B.WuN, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, i = r.shape.slice(), { axis: a } = n; (0, pe.Y6)(a, r.shape).forEach((e => { i[e] = 1 })); const o = (0, Q.t)(e, i), s = (0, j.l)(o, (0, Bt.S)(r.shape, "float32")); return { x: () => s } } }, Hn = { kernelName: B.oFs, inputsToSave: ["x"], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, V.y)(e, (0, Y.E)((0, An.g)(n))) } } }, qn = { kernelName: B.iuW, outputsToSave: [!0], gradFunc: (e, t) => { const [n] = t; return { x: () => (0, j.l)((0, X.j)((0, H.d)(1), (0, Y.E)(n)), e) } } }, Yn = { kernelName: B.FAs, inputsToSave: ["x"], gradFunc: (e, t, n) => { const [r] = t, { reps: i } = n; return { x: () => { let t = (0, re.P)(r); if (1 === r.rank) for (let n = 0; n < i[0]; ++n)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0]], [r.shape[0]])); else if (2 === r.rank) for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1]], [r.shape[0], r.shape[1]])); else if (3 === r.rank) for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)for (let o = 0; o < i[2]; ++o)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1], o * r.shape[2]], [r.shape[0], r.shape[1], r.shape[2]])); else { if (4 !== r.rank) throw new Error(`Gradient for tile operation is not implemented for rank-${r.rank} tensors yet.`); for (let n = 0; n < i[0]; ++n)for (let a = 0; a < i[1]; ++a)for (let o = 0; o < i[2]; ++o)for (let s = 0; s < i[3]; ++s)t = (0, se.W)(t, (0, Wt.d)(e, [n * r.shape[0], a * r.shape[1], o * r.shape[2], s * r.shape[3]], [r.shape[0], r.shape[1], r.shape[2], r.shape[3]])) } return t } } } }, Xn = { kernelName: B.wx0, gradFunc: (e, t, n) => { const r = n, { perm: i } = r, a = Ye.gx(i); return { x: () => (0, Ke.m)(e, a) } } }, Kn = { kernelName: B.dXR, gradFunc: (e, t, n) => { const r = n, { axis: i } = r; return { value: () => (0, ft.t)(e, i) } } }; var Zn = n(8710), Jn = n(8229), Qn = n(178);
/**
* @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.
* =============================================================================
*/
const er = { kernelName: B.pPe, inputsToSave: ["segmentIds"], gradFunc: (e, t) => { const [n] = t; return { x: () => function (e, t) { const n = (0, Qn.P)(t, (0, re.P)(t)), r = (0, Jn.k)(e, n); let i = (0, Ee.D)(t, (0, H.d)(0, "int32")); const a = r.rank - i.rank; for (let e = 0; e < a; ++e)i = (0, Zn.U)(i, e + 1); i = (0, Ie.n)(i, (0, Bt.S)(r.shape, "bool")); const o = (0, re.P)(r); return (0, Me._)(i, r, o) }(e, n) } } };
/**
* @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.
* =============================================================================
*/
const tr = { kernelName: B.xJ3, gradFunc: e => ({ x: () => (0, re.P)(e) }) }; var nr = n(7074);
/**
* @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.
* =============================================================================
*/
const rr = [W, K, Z, te, ne, ie, ae, oe, ue, le, ce, he, be, xe, ke, _e, Ce, Ae, Te, Fe, De, Re, Le, Pe, We, Ge, qe, Ze, et, tt, ln, nt, it, at, ot, st, lt, ut, dt, mt, bt, vt, xt, wt, kt, _t, Ct, At, Tt, Nt, Ft, Ft, $t, Ot, Pt, Lt, jt, Ut, Vt, Ht, qt, Yt, Kt, Zt, Qt, en, en, rn, an, un, cn, hn, dn, fn, pn, mn, yn, bn, vn, wn, Sn, _n, Cn, Tn, Nn, Fn, Dn, Rn, zn, zn, Bn, Bn, Ln, Un, jn, Wn, Vn, Gn, Hn, qn, Yn, Xn, Kn, er, tr]; for (const e of rr) (0, nr.kr)(e); n(455);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ir extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ir.prototype) } } class ar extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ar.prototype) } } class or extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, or.prototype) } } class sr extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, sr.prototype) } } class ur extends Error { constructor(e) { super(e), Object.setPrototypeOf(this, ur.prototype) } } Error;
/**
* @license
* Copyright 2022 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class lr { constructor(e) { this.maxEntries = e || 100, this.cache = new Map } get(e) { let t; return this.cache.has(e) && (t = this.cache.get(e), this.cache.delete(e), this.cache.set(e, t)), t } put(e, t) { if (this.cache.has(e)) this.cache.delete(e); else if (this.cache.size >= this.maxEntries) { const e = this.cache.keys().next().value; this.cache.delete(e) } this.cache.set(e, t) } getMaxEntries() { return this.maxEntries } setMaxEntries(e) { if (e < 0) throw new Error(`The maxEntries of LRU caches must be at least 0, but got ${e}.`); if (this.maxEntries > e) for (let t = 0; t < this.maxEntries - e; t++) { const e = this.cache.keys().next().value; this.cache.delete(e) } this.maxEntries = e } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function cr(e, t) { if (Array.isArray(e)) { let n = []; for (let r = 0; r < t; r++)n = n.concat(e); return n } { const n = new Array(t); return n.fill(e), n } } function hr(e, t) { if (!e) throw new ur(t) } function dr(e, t) { let n = 0; for (const r of e) r === t && n++; return n } function fr(e) { return 1 === e.length ? e[0] : e } function pr(e) { return Array.isArray(e) ? e : [e] } function mr(e) { const t = e.replace(/(.)([A-Z][a-z0-9]+)/g, "$1_$2").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); return "_" !== t[0] ? t : "private" + t } function gr(e) { return e.length <= 1 || -1 === e.indexOf("_") ? e : e.replace(/[_]+(\w|$)/g, ((e, t) => t.toUpperCase())) } let yr = {}; function br(e) { if (null == e) return null; const t = {}; return t.className = e.getClassName(), t.config = e.getConfig(), t } function vr(e) { if (null != e && "object" == typeof e) if (Array.isArray(e)) e.forEach((e => vr(e))); else { const t = Object.keys(e); for (const n of t) { const t = e[n]; null != t && "object" == typeof t && (Array.isArray(t) || "ndarray" !== t.type || "number" != typeof t.value ? vr(t) : e[n] = t.value) } } } function xr(e, t = {}, n = {}, r = "object", i = !1) { if ("string" == typeof e) { const i = e; let a; if (i in n) a = n[i]; else if (i in yr) a = yr[i]; else if (a = t[i], null == a) throw new or(`Unknown ${r}: ${e}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`); return a } { const a = e; if (null == a.className || null == a.config) throw new or(`${r}: Improper config format: ${JSON.stringify(a)}.\n'className' and 'config' must set.`); const o = a.className; let s, u; if (o in n ? [s, u] = n[o] : o in yr ? [s, u] = yr.className : o in t && ([s, u] = t[o]), null == s) throw new or(`Unknown ${r}: ${o}. This may be due to one of the following reasons:\n1. The ${r} is defined in Python, in which case it needs to be ported to TensorFlow.js or your JavaScript code.\n2. The custom ${r} is defined in JavaScript, but is not registered properly with tf.serialization.registerClass().`); if (null != u) { const e = {}; for (const t of Object.keys(yr)) e[t] = yr[t]; for (const t of Object.keys(n)) e[t] = n[t]; a.config.customObjects = e; const t = Object.assign({}, yr); for (const e of Object.keys(n)) yr[e] = n[e]; vr(a.config); const r = u(s, a.config, n, i); return yr = Object.assign({}, t), r } { const e = Object.assign({}, yr); for (const e of Object.keys(n)) yr[e] = n[e]; const t = new s(a.config); return yr = Object.assign({}, e), t } } } function wr(e, t) { return -1 * function (e, t) { return e < t ? -1 : e > t ? 1 : 0 }(e, t) } function kr(e) { if (null == e) return e; const t = []; for (const n of e) -1 === t.indexOf(n) && t.push(n); return t } function Sr(e) { if (null == e) throw new or(`Invalid value in obj: ${JSON.stringify(e)}`); for (const t in e) if (e.hasOwnProperty(t)) return !1; return !0 } function _r(e, t, n) { if (null != n && e.indexOf(n) < 0) throw new or(`${n} is not a valid ${t}. Valid values are ${e} or null/undefined.`) } function Cr(e, t, n = 0, r = 1 / 0) { return hr(n >= 0), hr(r >= n), Array.isArray(e) && e.length >= n && e.length <= r && e.every((e => typeof e === t)) } function Ar(e, t) { Array.isArray(e) ? (P.util.assert(e.length > 0, (() => `${t} is unexpectedly an empty array.`)), e.forEach(((e, n) => Ar(e, `element ${n + 1} of ${t}`)))) : P.util.assert(Number.isInteger(e) && e > 0, (() => `Expected ${t} to be a positive integer, but got ${Tr(e)}.`)) } function Tr(e) { return null === e ? "null" : Array.isArray(e) ? "[" + e.map((e => Tr(e))).join(",") + "]" : "string" == typeof e ? `"${e}"` : `${e}` } function Er(e) { return "relu" === e ? "relu" : "linear" === e ? "linear" : "elu" === e ? "elu" : null }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
let Nr = 0; function Ir() { return Nr++ } const Mr = {}; function Fr(e = "") { return e in Mr || (Mr[e] = 0), Mr[e] += 1, e + Mr[e].toString() }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const Dr = ["channelsFirst", "channelsLast"], $r = ["nearest", "bilinear"], Rr = ["valid", "same", "causal"], Or = ["max", "avg"], zr = ["sum", "mul", "concat", "ave"], Pr = new Map; function Br(e) { _r(Dr, "DataFormat", e) } function Lr(e) { _r(Rr, "PaddingMode", e) } function jr(e) { _r(Or, "PoolMode", e) } const Ur = []; function Wr(e, t) { Ur.push(e); try { const e = t(); return Ur.pop(), e } catch (e) { throw Ur.pop(), e } } function Vr(e) { if (!qr(e)) throw new Error("Not a valid tensor name: '" + e + "'"); return (0 === Ur.length ? "" : Ur.join("/") + "/") + e } function Gr(e) { if (!qr(e)) throw new Error("Not a valid tensor name: '" + e + "'"); Pr.has(e) || Pr.set(e, 0); const t = Pr.get(e); if (Pr.set(e, Pr.get(e) + 1), t > 0) { const n = `${e}_${t}`; return Pr.set(n, 1), n } return e } const Hr = new RegExp(/^[A-Za-z0-9][-A-Za-z0-9\._\/]*$/); function qr(e) { return !!e.match(Hr) } function Yr(e, t, n) { null == t && (t = 0), null == n && (n = e.length); let r = 1; for (let i = t; i < n; ++i)r *= e[i]; return r } function Xr(e) { if (0 === e.length) return Number.NaN; let t = Number.POSITIVE_INFINITY; for (let n = 0; n < e.length; n++) { const r = e[n]; r < t && (t = r) } return t } function Kr(e) { if (0 === e.length) return Number.NaN; let t = Number.NEGATIVE_INFINITY; for (let n = 0; n < e.length; n++) { const r = e[n]; r > t && (t = r) } return t } function Zr(e, t) { if (t < e) throw new or(`end (${t}) < begin (${e}) is forbidden.`); const n = []; for (let r = e; r < t; ++r)n.push(r); return n }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
let Jr; function Qr() { return null == Jr && (Jr = (0, P.backend)().epsilon()), Jr } function ei(e, t) { return P.cast(e, t) } function ti(e, t = -1) { const n = e.shape.slice(); return t < 0 && (t = n.length + t + 1), n.splice(t, 0, 1), P.reshape(e, n) } function ni(e, t, n) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: return P.slice2d(e, [t, 0], [n, e.shape[1]]); case 3: return P.slice3d(e, [t, 0, 0], [n, e.shape[1], e.shape[2]]); case 4: return P.slice4d(e, [t, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3]]); case 5: return P.slice(e, [t, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4]]); case 6: return P.slice(e, [t, 0, 0, 0, 0, 0], [n, e.shape[1], e.shape[2], e.shape[3], e.shape[4], e.shape[5]]); default: throw new or(`sliceAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ri(e, t, n) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: return P.slice2d(e, [0, t], [e.shape[0], n]); case 3: return P.slice3d(e, [0, 0, t], [e.shape[0], e.shape[1], n]); case 4: return P.slice4d(e, [0, 0, 0, t], [e.shape[0], e.shape[1], e.shape[2], n]); default: throw new or(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ii(e, t, n, r) { return (0, P.tidy)((() => { switch (e.rank) { case 1: return P.slice1d(e, t, n); case 2: switch (r) { case 1: return ni(e, t, n); case 2: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }case 3: switch (r) { case 1: return ni(e, t, n); case 2: return P.slice3d(e, [0, t, 0], [e.shape[0], n, e.shape[2]]); case 3: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }case 4: switch (r) { case 1: return ni(e, t, n); case 2: return P.slice4d(e, [0, t, 0, 0], [e.shape[0], n, e.shape[2], e.shape[3]]); case 3: return P.slice4d(e, [0, 0, t, 0], [e.shape[0], e.shape[1], n, e.shape[3]]); case 4: return ri(e, t, n); default: throw new or(`The axis is not within the rank of the tensor ${r}`) }default: throw new or(`sliceAlongLastAxis() received an unsupported tensor rank: ${e.rank}`) } })) } function ai(e, t = -1) { let n; return t < 0 && (n = e[0].rank, t = 0 !== n ? n : 0), t === e[0].rank && (t = -1), P.concat(e, t) } function oi(e, t) { switch (e.rank) { case 1: return P.concat1d([e, t]); case 2: return P.concat2d([e, t], 0); case 3: return P.concat3d([e, t], 0); case 4: return P.concat4d([e, t], 0); default: throw new or(`concatAlongFirstAxis() received an unsupported tensor rank: ${e.rank}`) } } function si(e, t) { if (Array.isArray(t) || (t = [t]), e.rank !== t.length) throw new or(`The length of input n (${t.length}) does not match the number of dimensions in input x (${e.rank})`); return P.tile(e, t) } function ui(e, t = 0, n = 1, r, i) { return P.randomNormal(e, t, n, r, i) } function li(e, t, n, r) { if (e.rank < 2 || t.rank < 2) throw new sr(`dot requires both inputs to be rank >= 2 but got x shape = ${e.shape} and y shape = ${t.shape}`); if (t.rank >= 3) { if (e.shape.slice(-1)[0] !== t.shape.slice(-2)[0]) throw new sr(`If rank y >= 3, then the second last dim of y must equal the last dim of x but got x shape = ${e.shape} and y shape = ${t.shape}`) } if (2 === e.rank && 2 === t.rank) { const i = !1, a = !1; return P.fused.matMul({ a: e, b: t, transposeA: i, transposeB: a, bias: r ? di(e.rank, r, "channelsLast") : null, activation: n }) } { const i = e.shape.slice(), a = i.pop(); e = P.reshape(e, [-1, a]); const o = t.shape.slice(), s = o.pop(), u = o.pop(), l = [...o, s], c = Array.from({ length: t.rank }, ((e, n) => 0 === n ? t.rank - 2 : n <= t.rank - 2 ? n - 1 : n)); t = P.reshape(P.transpose(t, c), [u, -1]); const h = [...i, ...l], d = !1, f = !1; return P.reshape(P.fused.matMul({ a: e, b: t, transposeA: d, transposeB: f, bias: r ? di(e.rank, r, "channelsLast") : null, activation: n }), h) } } function ci(e, t, n) { return (0, P.tidy)((() => (t = Array.isArray(t) ? (0, P.tensor1d)(t, "int32") : P.cast(t, "int32"), P.gather(e, t, n)))) } function hi(e) { return P.mul(e, e) } function di(e, t, n) { const r = t.shape; if (1 !== t.rank && t.rank !== e) throw new or(`Unexpected bias dimensions: ${t.rank}; expected it to be 1 or ${e}`); if (5 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1, 1, 1]) : P.reshape(t, [1, r[3], r[0], r[1], r[2]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, 1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (4 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1, 1]) : P.reshape(t, [1, r[2], r[0], r[1]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (3 === e) { if ("channelsFirst" === n) return 1 === r.length ? P.reshape(t, [1, r[0], 1]) : P.reshape(t, [1, r[1], r[0]]); if ("channelsLast" === n) return 1 === r.length ? P.reshape(t, [1, 1, r[0]]) : P.reshape(t, [1].concat(r)) } else if (e < 3) return t; throw new or(`Unsupported input rank by biasAdd: ${t.rank}`) } function fi(e, t, n) { return (0, P.tidy)((() => (null == n && (n = "channelsLast"), Br(n), P.add(e, di(e.rank, t, n))))) } function pi(e, t, n, r) { return (0, P.tidy)((() => P.dropout(e, t, n, r))) } function mi(e, t, n = !1) { return n ? e() : t() }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const gi = ["fanIn", "fanOut", "fanAvg"], yi = ["normal", "uniform", "truncatedNormal"]; class bi extends P.serialization.Serializable { fromConfigUsesCustomObjects() { return !1 } getConfig() { return {} } } class vi extends bi { apply(e, t) { return (0, P.zeros)(e, t) } } vi.className = "Zeros", P.serialization.registerClass(vi); class xi extends bi { apply(e, t) { return (0, P.ones)(e, t) } } xi.className = "Ones", P.serialization.registerClass(xi); class wi extends bi { constructor(e) { if (super(), "object" != typeof e) throw new or(`Expected argument of type ConstantConfig but got ${e}`); if (void 0 === e.value) throw new or(`config must have value set but got ${e}`); this.value = e.value } apply(e, t) { return (0, P.tidy)((() => (0, P.mul)((0, P.scalar)(this.value), (0, P.ones)(e, t)))) } getConfig() { return { value: this.value } } } wi.className = "Constant", P.serialization.registerClass(wi); class ki extends bi { constructor(e) { super(), this.DEFAULT_MINVAL = -.05, this.DEFAULT_MAXVAL = .05, this.minval = e.minval || this.DEFAULT_MINVAL, this.maxval = e.maxval || this.DEFAULT_MAXVAL, this.seed = e.seed } apply(e, t) { return (0, P.randomUniform)(e, this.minval, this.maxval, t, this.seed) } getConfig() { return { minval: this.minval, maxval: this.maxval, seed: this.seed } } } ki.className = "RandomUniform", P.serialization.registerClass(ki); class Si extends bi { constructor(e) { super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = .05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed } apply(e, t) { if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`randomNormal does not support dType ${t}.`); return ui(e, this.mean, this.stddev, t, this.seed) } getConfig() { return { mean: this.mean, stddev: this.stddev, seed: this.seed } } } Si.className = "RandomNormal", P.serialization.registerClass(Si); class _i extends bi { constructor(e) { super(), this.DEFAULT_MEAN = 0, this.DEFAULT_STDDEV = .05, this.mean = e.mean || this.DEFAULT_MEAN, this.stddev = e.stddev || this.DEFAULT_STDDEV, this.seed = e.seed } apply(e, t) { if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`truncatedNormal does not support dType ${t}.`); return (0, P.truncatedNormal)(e, this.mean, this.stddev, t, this.seed) } getConfig() { return { mean: this.mean, stddev: this.stddev, seed: this.seed } } } _i.className = "TruncatedNormal", P.serialization.registerClass(_i); class Ci extends bi { constructor(e) { super(), this.gain = null != e.gain ? e.gain : 1 } apply(e, t) { return (0, P.tidy)((() => { if (2 !== e.length || e[0] !== e[1]) throw new or("Identity matrix initializer can only be used for 2D square matrices."); return (0, P.mul)(this.gain, (0, P.eye)(e[0])) })) } getConfig() { return { gain: this.gain } } } Ci.className = "Identity", P.serialization.registerClass(Ci); class Ai extends bi {
constructor(e) {
if (super(), e.scale < 0) throw new or(`scale must be a positive float. Got: ${e.scale}`);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var t; this.scale = null == e.scale ? 1 : e.scale, this.mode = null == e.mode ? "fanIn" : e.mode, t = this.mode, _r(gi, "FanMode", t), this.distribution = null == e.distribution ? "normal" : e.distribution, function (e) { _r(yi, "Distribution", e) }(this.distribution), this.seed = e.seed
} apply(e, t) { const n = function (e, t = "channelsLast") { let n, r; if (Br(t), 2 === e.length) n = e[0], r = e[1]; else if (-1 !== [3, 4, 5].indexOf(e.length)) { if ("channelsFirst" === t) { const t = Yr(e, 2); n = e[1] * t, r = e[0] * t } else if ("channelsLast" === t) { const t = Yr(e, 0, e.length - 2); n = e[e.length - 2] * t, r = e[e.length - 1] * t } } else { const t = Yr(e); n = Math.sqrt(t), r = Math.sqrt(t) } return [n, r] }(e), r = n[0], i = n[1]; let a = this.scale; if ("fanIn" === this.mode ? a /= Math.max(1, r) : "fanOut" === this.mode ? a /= Math.max(1, i) : a /= Math.max(1, (r + i) / 2), "normal" === this.distribution) { const n = Math.sqrt(a); if ("float32" !== (t = t || "float32") && "int32" !== t) throw new sr(`${this.getClassName()} does not support dType ${t}.`); return (0, P.truncatedNormal)(e, 0, n, t, this.seed) } { const n = Math.sqrt(3 * a); return (0, P.randomUniform)(e, -n, n, t, this.seed) } } getConfig() { return { scale: this.scale, mode: this.mode, distribution: this.distribution, seed: this.seed } }
} Ai.className = "VarianceScaling", P.serialization.registerClass(Ai); class Ti extends Ai { constructor(e) { super({ scale: 1, mode: "fanAvg", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ti.className = "GlorotUniform", P.serialization.registerClass(Ti); class Ei extends Ai { constructor(e) { super({ scale: 1, mode: "fanAvg", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ei.className = "GlorotNormal", P.serialization.registerClass(Ei); class Ni extends Ai { constructor(e) { super({ scale: 2, mode: "fanIn", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ni.className = "HeNormal", P.serialization.registerClass(Ni); class Ii extends Ai { constructor(e) { super({ scale: 2, mode: "fanIn", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Ii.className = "HeUniform", P.serialization.registerClass(Ii); class Mi extends Ai { constructor(e) { super({ scale: 1, mode: "fanIn", distribution: "normal", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Mi.className = "LeCunNormal", P.serialization.registerClass(Mi); class Fi extends Ai { constructor(e) { super({ scale: 1, mode: "fanIn", distribution: "uniform", seed: null == e ? null : e.seed }) } getClassName() { return Ai.className } } Fi.className = "LeCunUniform", P.serialization.registerClass(Fi); class Di extends bi { constructor(e) { super(), this.DEFAULT_GAIN = 1, this.ELEMENTS_WARN_SLOW = 2e3, this.gain = null == e.gain ? this.DEFAULT_GAIN : e.gain, this.seed = e.seed } apply(e, t) { return (0, P.tidy)((() => { if (e.length < 2) throw new sr("Shape must be at least 2D."); if ("int32" !== t && "float32" !== t && void 0 !== t) throw new TypeError(`Unsupported data type ${t}.`); const n = P.util.sizeFromShape(e.slice(0, -1)), r = e[e.length - 1], i = n * r; i > this.ELEMENTS_WARN_SLOW && console.warn(`Orthogonal initializer is being called on a matrix with more than ${this.ELEMENTS_WARN_SLOW} (${i}) elements: Slowness may result.`); const a = ui([Math.max(r, n), Math.min(r, n)], 0, 1, t, this.seed), o = P.linalg.qr(a, !1); let s = o[0]; const u = o[1].flatten().stridedSlice([0], [Math.min(r, n) * Math.min(r, n)], [Math.min(r, n) + 1]); return s = (0, P.mul)(s, u.sign()), n < r && (s = s.transpose()), (0, P.mul)((0, P.scalar)(this.gain), s.reshape(e)) })) } getConfig() { return { gain: this.gain, seed: this.seed } } } Di.className = "Orthogonal", P.serialization.registerClass(Di); const $i = { constant: "Constant", glorotNormal: "GlorotNormal", glorotUniform: "GlorotUniform", heNormal: "HeNormal", heUniform: "HeUniform", identity: "Identity", leCunNormal: "LeCunNormal", leCunUniform: "LeCunUniform", ones: "Ones", orthogonal: "Orthogonal", randomNormal: "RandomNormal", randomUniform: "RandomUniform", truncatedNormal: "TruncatedNormal", varianceScaling: "VarianceScaling", zeros: "Zeros" }; function Ri(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "initializer") } function Oi(e) { return br(e) } function zi(e) { if ("string" == typeof e) { const t = e in $i ? $i[e] : e; if ("GlorotNormal" === t) return new Ei; if ("GlorotUniform" === t) return new Ti; if ("HeNormal" === t) return new Ni; if ("HeUniform" === t) return new Ii; if ("LeCunNormal" === t) return new Mi; if ("LeCunUniform" === t) return new Fi; { const e = {}; return e.className = t, e.config = {}, Ri(e) } } return e instanceof bi ? e : Ri(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Pi(e) { return Array.isArray(e) && Array.isArray(e[0]) } function Bi(e) { return 0 === e.length ? [] : Array.isArray(e[0]) ? e : [e] } function Li(e) { let t; if (Array.isArray(e)) { if (1 !== e.length) throw new or(`Expected Tensor length to be 1; got ${e.length}`); t = e[0] } else t = e; return t } function ji(e) { if (Array.isArray(e) && Array.isArray(e[0])) { if (1 === e.length) return e[0]; throw new or(`Expected exactly 1 Shape; got ${e.length}`) } return e }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ui(e) { let t = 0; for (const n of e) 0 === n.shape.length ? t += 1 : t += n.shape.reduce(((e, t) => e * t)); return t }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const Wi = "Variable"; class Vi { constructor(e, t = "float32", n = Wi, r = !0, i = null) { this.dtype = null == t ? "float32" : t, this.shape = e.shape, this.id = Ir(), n = null == n ? Wi : n, this.originalName = Vr(n), this.name = Gr(this.originalName), this.trainable_ = r, this.constraint = i, this.val = P.variable(e, this.trainable_, this.name, this.dtype) } read() { return this.assertNotDisposed(), this.val } write(e) { return this.assertNotDisposed(), function (e, t) { if (e.shape.toString() !== t.shape.toString()) throw new Error("Shape mismatch: " + JSON.stringify(e.shape) + " vs. " + JSON.stringify(t.shape)) }(this.val, e), this.val.id !== e.id && (this.val.assign(e), null != this.constraint && this.val.assign(this.constraint.apply(this.val))), this } dispose() { this.assertNotDisposed(), this.val.dispose() } assertNotDisposed() { if (this.val.isDisposed) throw new Error(`LayersVariable ${this.name} is already disposed.`) } get trainable() { return this.trainable_ } set trainable(e) { this.trainable_ = e, this.val.trainable = e } } function Gi(e) { return e.map((e => e.read())) } function Hi(e) { e.forEach((e => { e[0].write(e[1]) })) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class qi { constructor(e) { this.dtype = e.dtype, this.shape = e.shape, null != e.shape ? this.ndim = e.shape.length : this.ndim = e.ndim, this.maxNDim = e.maxNDim, this.minNDim = e.minNDim, this.axes = e.axes || {} } } class Yi { constructor(e, t, n, r, i, a, o) { this.dtype = e, this.shape = t, this.sourceLayer = n, this.inputs = r, this.callArgs = i, this.outputTensorIndex = o, this.id = Ir(), null != a && (this.originalName = Vr(a), this.name = Gr(this.originalName)), this.rank = t.length } } let Xi = 0; class Ki { constructor(e, t) { this.callArgs = t, this.id = Xi++, this.outboundLayer = e.outboundLayer, this.inboundLayers = e.inboundLayers, this.nodeIndices = e.nodeIndices, this.tensorIndices = e.tensorIndices, this.inputTensors = e.inputTensors, this.outputTensors = e.outputTensors, this.inputMasks = e.inputMasks, this.outputMasks = e.outputMasks, this.inputShapes = e.inputShapes, this.outputShapes = e.outputShapes; for (const t of e.inboundLayers) null != t && t.outboundNodes.push(this); e.outboundLayer.inboundNodes.push(this) } getConfig() { const e = []; for (const t of this.inboundLayers) null != t ? e.push(t.name) : e.push(null); return { outboundLayer: this.outboundLayer ? this.outboundLayer.name : null, inboundLayers: e, nodeIndices: this.nodeIndices, tensorIndices: this.tensorIndices } } } let Zi = 0; class Ji extends P.serialization.Serializable { constructor(e = {}) { super(), this._callHook = null, this._addedWeightNames = [], this._stateful = !1, this.id = Zi++, this.activityRegularizer = null, this.inputSpec = null, this.supportsMasking = !1, this._trainableWeights = [], this._nonTrainableWeights = [], this._losses = [], this._updates = [], this._built = !1, this.inboundNodes = [], this.outboundNodes = []; let t = e.name; if (!t) { const e = this.getClassName(); t = mr(e) + "_" + Fr(e) } if (this.name = t, this.trainable_ = null == e.trainable || e.trainable, null != e.inputShape || null != e.batchInputShape) { let t; if (null != e.batchInputShape) t = e.batchInputShape; else if (null != e.inputShape) { let n = null; null != e.batchSize && (n = e.batchSize), t = [n].concat(e.inputShape) } this.batchInputShape = t; let n = e.dtype; null == n && (n = e.inputDType), null == n && (n = "float32"), this.dtype = n } null != e.weights ? this.initialWeights = e.weights : this.initialWeights = null, this._refCount = null, this.fastWeightInitDuringBuild = !1 } static nodeKey(e, t) { return e.name + "_ib-" + t.toString() } getNodeAtIndex(e, t) { if (0 === this.inboundNodes.length) throw new ar(`The layer has never been called and thus has no defined ${t}.`); if (this.inboundNodes.length <= e) throw new or(`Asked to get ${t} at node ${e}, but the layer has only ${this.inboundNodes.length} inbound nodes.`); return this.inboundNodes[e] } getInputAt(e) { return fr(this.getNodeAtIndex(e, "input").inputTensors) } getOutputAt(e) { return fr(this.getNodeAtIndex(e, "output").outputTensors) } get input() { if (this.inboundNodes.length > 1) throw new ir(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer input" is ill-defined. Use \`getInputAt(nodeIndex)\` instead.`); if (0 === this.inboundNodes.length) throw new ir(`Layer ${this.name} is not connected, no input to return.`); return fr(this.getNodeAtIndex(0, "input").inputTensors) } get output() { if (0 === this.inboundNodes.length) throw new ir(`Layer ${this.name} has no inbound nodes.`); if (this.inboundNodes.length > 1) throw new ir(`Layer ${this.name} has multiple inbound nodes, hence the notion of "layer output" is ill-defined. Use \`getOutputAt(nodeIndex)\` instead.`); return fr(this.getNodeAtIndex(0, "output").outputTensors) } get losses() { return this._losses } calculateLosses() { return this.losses.map((e => e())) } get updates() { return this._updates } get built() { return this._built } set built(e) { this._built = e } get trainable() { return this.trainable_ } set trainable(e) { this._trainableWeights.forEach((t => t.trainable = e)), this.trainable_ = e } get trainableWeights() { return this.trainable_ ? this._trainableWeights.filter((e => e.trainable)) : [] } set trainableWeights(e) { this._trainableWeights = e } get nonTrainableWeights() { return this.trainable ? this._trainableWeights.filter((e => !e.trainable)).concat(this._nonTrainableWeights) : this._trainableWeights.concat(this._nonTrainableWeights) } set nonTrainableWeights(e) { this._nonTrainableWeights = e } get weights() { return this.trainableWeights.concat(this.nonTrainableWeights) } get stateful() { return this._stateful } resetStates() { if (!this.stateful) throw new Error("Cannot call the resetStates() method of a non-stateful Layer object.") } assertInputCompatibility(e) { const t = pr(e); if (null == this.inputSpec || 0 === this.inputSpec.length) return; const n = pr(this.inputSpec); if (t.length !== n.length) throw new or(`Layer ${this.name} expects ${n.length} inputs, but it received ${t.length} input tensors. Input received: ${e}`); for (let e = 0; e < t.length; e++) { const r = t[e], i = n[e]; if (null == i) continue; const a = r.rank; if (null != i.ndim && a !== i.ndim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected ndim=${i.ndim}, found ndim=${a}`); if (null != i.maxNDim && a > i.maxNDim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected max_ndim=${i.maxNDim}, found ndim=${a}`); if (null != i.minNDim && a < i.minNDim) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected min_ndim=${i.minNDim}, found ndim=${a}.`); if (null != i.dtype && r.dtype !== i.dtype) throw new or(`Input ${e} is incompatible with layer ${this.name} : expected dtype=${i.dtype}, found dtype=${r.dtype}.`); if (i.axes) { const t = r.shape; for (const n in i.axes) { const r = Number(n), a = i.axes[n], o = r >= 0 ? t[r] : t[t.length + r]; if (null != a && -1 === [a, null].indexOf(o)) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected axis ${r} of input shape to have value ${a} but got shape ${t}.`) } } if (null != i.shape) for (let t = 0; t < i.shape.length; ++t) { const n = i.shape[t], a = r.shape[t]; if (null != n && null != a && n !== a) throw new or(`Input ${e} is incompatible with layer ${this.name}: expected shape=${i.shape}, found shape=${r.shape}.`) } } } call(e, t) { return e } invokeCallHook(e, t) { null != this._callHook && this._callHook(e, t) } setCallHook(e) { this._callHook = e } clearCallHook() { this._callHook = null } apply(e, t) { t = t || {}, this.assertNotDisposed(); const n = pr(e), r = function (e) { let t = !0; for (const n of pr(e)) if (!(n instanceof Yi)) { t = !1; break } return t }(e), i = function (e) { let t = !0; for (const n of pr(e)) if (n instanceof Yi) { t = !1; break } return t }(e); if (r === i) throw new or("Arguments to apply() must be all SymbolicTensors or all Tensors"); return Wr(this.name, (() => { if (!this.built) { this.assertInputCompatibility(e); const t = []; for (const n of pr(e)) t.push(n.shape); this.build(fr(t)), this.built = !0, this.initialWeights && this.setWeights(this.initialWeights), null === this._refCount && i && (this._refCount = 1) } if (this.assertInputCompatibility(e), i) { let r = this.call(e, t); this.supportsMasking && this.setMaskMetadata(e, r); const i = pr(r), a = []; for (let e of i) -1 !== n.indexOf(e) && (e = e.clone()), a.push(e); if (r = fr(a), null != this.activityRegularizer) throw new sr("Layer invocation in the presence of activity regularizer(s) is not supported yet."); return r } { const n = function (e) { e = pr(e); const t = []; for (const n of e) t.push(n.shape); return fr(t) }(e), r = this.computeOutputShape(n); let i; const a = "float32"; if (this.warnOnIncompatibleInputShape(Array.isArray(e) ? n[0] : n), i = null != r && r.length > 0 && Array.isArray(r[0]) ? r.map(((n, r) => new Yi(a, n, this, pr(e), t, this.name, r))) : new Yi(a, r, this, pr(e), t, this.name), this.addInboundNode(e, i, null, null, n, r, t), this._refCount++, null != this.activityRegularizer) throw new sr("Layer invocation in the presence of activity regularizer(s) is not supported yet."); return i } })) } warnOnIncompatibleInputShape(e) { if (null != this.batchInputShape) if (e.length !== this.batchInputShape.length) console.warn(`The rank of the input tensor provided (shape: ${JSON.stringify(e)}) does not match that of the batchInputShape (${JSON.stringify(this.batchInputShape)}) of the layer ${this.name}`); else { let t = !1; this.batchInputShape.forEach(((n, r) => { null != n && null != e[r] && e[r] !== n && (t = !0) })), t && console.warn(`The shape of the input tensor (${JSON.stringify(e)}) does not match the expectation of layer ${this.name}: ${JSON.stringify(this.batchInputShape)}`) } } get outputShape() { if (null == this.inboundNodes || 0 === this.inboundNodes.length) throw new ir(`The layer ${this.name} has never been called and thus has no defined output shape.`); const e = []; for (const t of this.inboundNodes) { const n = JSON.stringify(t.outputShapes); -1 === e.indexOf(n) && e.push(n) } if (1 === e.length) { const e = this.inboundNodes[0].outputShapes; return Array.isArray(e) && Array.isArray(e[0]) && 1 === e.length ? e[0] : e } throw new ir(`The layer ${this.name} has multiple inbound nodes with different output shapes. Hence the notion of "output shape" is ill-defined for the layer.`) } countParams() { if (!this.built) throw new ar(`You tried to call countParams() on ${this.name}, but the layer is not built yet. Build it first by calling build(batchInputShape).`); return Ui(this.weights) } build(e) { this.built = !0 } getWeights(e = !1) { return Gi(e ? this.trainableWeights : this.weights) } setWeights(e) { (0, P.tidy)((() => { const t = this.weights; if (t.length !== e.length) throw new or(`You called setWeights(weights) on layer "${this.name}" with a weight list of length ${e.length}, but the layer was expecting ${t.length} weights. Provided weights: ${e}...`); if (0 === t.length) return; const n = [], r = Gi(t); for (let i = 0; i < r.length; ++i) { const a = r[i], o = t[i], s = e[i]; if (!P.util.arraysEqual(a.shape, s.shape)) throw new or(`Layer weight shape ${a.shape} not compatible with provided weight shape ${s.shape}`); n.push([o, s]) } Hi(n) })) } addWeight(e, t, n, r, i, a, o, s) { if (-1 !== this._addedWeightNames.indexOf(e)) throw new or(`Duplicate weight name ${e} for layer ${this.name}`); this._addedWeightNames.push(e), null == n && (n = "float32"), this.fastWeightInitDuringBuild && (r = null != s ? s() : zi("zeros")); const u = r.apply(t, n), l = new Vi(u, n, e, a, o); return u.dispose(), null != i && this.addLoss((() => i.apply(l.read()))), null == a && (a = !0), a ? this._trainableWeights.push(l) : this._nonTrainableWeights.push(l), l } setFastWeightInitDuringBuild(e) { this.fastWeightInitDuringBuild = e } addLoss(e) { null == e || Array.isArray(e) && 0 === e.length || (e = pr(e), void 0 !== this._losses && null !== this._losses && this.losses.push(...e)) } computeOutputShape(e) { return e } computeMask(e, t) { if (!this.supportsMasking) { if (null != t) { if (!Array.isArray(t)) throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`); t.forEach((e => { if (null != e) throw new TypeError(`Layer ${this.name} does not support masking, but was passed an inputMask.`) })) } return null } return t } setMaskMetadata(e, t, n) { if (!this.supportsMasking) return; const r = this.computeMask(e, n), i = pr(t), a = pr(r); if (i.length !== a.length) throw new Error(`${this.name} outputs ${i.length} tensors but ${i.length} masks for those tensors`); for (let e = 0; e < i.length; e++)i[e].kerasMask = a[e] } addInboundNode(e, t, n, r, i, a, o = null) { const s = pr(e); t = pr(t), n = pr(n), r = pr(r), i = Bi(i), a = Bi(a); const u = [], l = [], c = []; for (const e of s) u.push(e.sourceLayer), l.push(e.nodeIndex), c.push(e.tensorIndex); new Ki({ outboundLayer: this, inboundLayers: u, nodeIndices: l, tensorIndices: c, inputTensors: s, outputTensors: t, inputMasks: n, outputMasks: r, inputShapes: i, outputShapes: a }, o); for (let e = 0; e < t.length; e++)t[e].sourceLayer = this, t[e].nodeIndex = this.inboundNodes.length - 1, t[e].tensorIndex = e } getConfig() { const e = { name: this.name, trainable: this.trainable }; return null != this.batchInputShape && (e.batchInputShape = this.batchInputShape), null != this.dtype && (e.dtype = this.dtype), e } disposeWeights() { return this.weights.forEach((e => e.dispose())), this.weights.length } assertNotDisposed() { if (0 === this._refCount) throw new Error(`Layer '${this.name}' is already disposed.`) } dispose() { if (!this.built) throw new Error(`Cannot dispose Layer ${this.name} because it has not been built yet.`); if (null === this._refCount) throw new Error(`Cannot dispose Layer ${this.name} because it has not been used yet.`); this.assertNotDisposed(); let e = 0; return 0 == --this._refCount && (e = this.disposeWeights()), { refCountAfterDispose: this._refCount, numDisposedVariables: e } } } function Qi(e, t, n) { if ((null == t || null != n && n > 0) && (t = e.sourceLayer, n = e.nodeIndex), 0 === t.inboundNodes.length) return [e]; { const e = t.inboundNodes[n]; if (0 === e.inboundLayers.length) return e.inputTensors; { const t = []; for (let n = 0; n < e.inboundLayers.length; n++) { const r = Qi(e.inputTensors[n], e.inboundLayers[n], e.nodeIndices[n]); for (const e of r) -1 === t.indexOf(e) && t.push(e) } return t } } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ea extends Ji { constructor(e) { if (super({ dtype: e.dtype, name: null != e.name ? e.name : Fr("input").toString() }), null == e.batchSize && (e.batchSize = null), null == e.sparse && (e.sparse = !1), this.trainable = !1, this.built = !0, this.sparse = e.sparse, null != e.inputShape && null != e.batchInputShape) throw new or("Only provide the inputShape OR batchInputShape argument to inputLayer, not both at the same time."); let t = e.batchInputShape; if (null == t) { if (null == e.inputShape) throw new or("An InputLayer should be passed either a `batchInputShape` or an `inputShape`."); t = [e.batchSize].concat(e.inputShape) } else if (null != e.batchSize) throw new or("Cannot specify batchSize if batchInputShape is specified when creating an InputLayer."); const n = e.dtype || "float32"; this.batchInputShape = t, this.dtype = n, this.inputSpec = [{ shape: t }]; const r = new Yi(this.dtype, this.batchInputShape, this, [], {}, this.name); r.nodeIndex = 0, r.tensorIndex = 0, new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: [r], outputTensors: [r], inputMasks: [null], outputMasks: [null], inputShapes: [t], outputShapes: [t] }) } apply(e, t) { throw new or(`Cannot pass any input to an InputLayer's apply() method. InputLayer name: ${this.name}`) } dispose() { return { refCountAfterDispose: this._refCount, numDisposedVariables: 0 } } getConfig() { return { batchInputShape: this.batchInputShape, dtype: this.dtype, sparse: this.sparse, name: this.name } } } function ta(e) { if (null == e.batchShape && null == e.shape) throw new Error("Please provide to Input either a `shape` or a `batchShape` argument. Note that `shape` does not include the batch dimension."); if (null != e.batchShape && null != e.shape) throw new or("Please provide either a `shape` or `batchShape` argument to Input, but not both."); let t = e.batchShape; null != e.shape && null == t && (t = [null].concat(e.shape)); let n = e.dtype; null == n && (n = "float32"); return new ea({ batchInputShape: t, name: e.name, dtype: n, sparse: e.sparse }).inboundNodes[0].outputTensors[0] } ea.className = "InputLayer", P.serialization.registerClass(ea); class na {
constructor(e) { if (this.id2Value = {}, this.id2Mask = {}, this.name2Id = {}, e instanceof na) for (const t in e.id2Value) this.id2Value[t] = e.id2Value[t], t in e.id2Mask && (this.id2Mask[t] = e.id2Mask[t]); else { if (null == e) return; for (const t of e) this.add(t.key, t.value) } } add(e, t, n) {
if (null != this.id2Value[e.id]) throw new or(`Duplicate key: name=${e.name}, id=${e.id}`); return this.id2Value[e.id] =
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function (e, t) { if (null == e.dtype || e.dtype === t.dtype) return t; try { return (0, P.cast)(t, e.dtype) } catch (n) { throw new or(`The dtype of the feed (${t.dtype}) can not be cast to the dtype of the key '${e.name}' (${e.dtype}).`) } }(e, t), this.name2Id[e.name] = e.id, null != n && (this.id2Mask[e.id] = n), this
} addFeed(e) { this.add(e.key, e.value) } hasKey(e) { return null != this.id2Value[e.id] } names() { return Object.keys(this.name2Id) } getValue(e) { if (e instanceof Yi) { if (null == this.id2Value[e.id]) throw new or(`Nonexistent key: ${e.name}`); return this.id2Value[e.id] } { const t = this.name2Id[e]; if (null == t) throw new or(`Feed dict has no SymbolicTensor name: ${e}`); return this.id2Value[t] } } getMask(e) { if (e instanceof Yi) { if (null == this.id2Value[e.id]) throw new or(`Nonexistent key: ${e.name}`); return this.id2Mask[e.id] } { const t = this.name2Id[e]; if (null == t) throw new or(`Feed dict has no SymbolicTensor name: ${e}`); return this.id2Mask[t] } } disposeMasks() { null != this.id2Mask && (0, P.dispose)(this.id2Mask) }
} const ra = new lr, ia = new lr; function aa(e, t, n, r) { const i = null != n && n.training, a = Array.isArray(e), o = a ? e : [e], s = o.map((e => e.name)), u = [], l = t.names(); for (const e of s) -1 !== l.indexOf(e) ? u.push(t.getValue(e)) : u.push(null); null != r && (r.maxNumTensors = -1 / 0, r.minNumTensors = 1 / 0); const c = s.join(",") + "|" + t.names().sort().join(","); let h, d = ra.get(c); if (null == d) { const e = function (e, t) { P.util.assert(null != e && e.length > 0, (() => "Expected at least one fetch, got none")); let n = [], r = {}; if (1 === e.length) { const i = sa(e[0], t); n = i.sorted, r = i.recipientMap } else { const i = new Set; for (const a of e) { const { sorted: e, recipientMap: o } = sa(a, t); for (const t of e) i.has(t.name) || (n.push(t), i.add(t.name)); for (const e in o) null == r[e] && (r[e] = new Set), o[e].forEach((t => r[e].add(t))) } } return { sorted: n, recipientCounts: oa(r) } }(o, t); d = e.sorted, h = e.recipientCounts, ra.put(c, d), ia.put(c, h) } h = {}, i || Object.assign(h, ia.get(c)); const f = new na(t); for (let e = 0; e < d.length; ++e) { if (null != r) { const e = (0, P.memory)().numTensors; e > r.maxNumTensors && (r.maxNumTensors = e), e < r.minNumTensors && (r.minNumTensors = e) } const a = d[e], o = a.sourceLayer; if (o instanceof ea) continue; const l = [], c = [], p = []; let m = !1; for (const e of a.inputs) { const n = f.getValue(e), r = f.getMask(e); l.push(n), c.push(r), null != r && (m = !0), i || (h[e.name]--, 0 !== h[e.name] || t.hasKey(e) || -1 !== s.indexOf(e.name) || n.isDisposed || !0 === e.sourceLayer.stateful || p.push(n)) } m && ((n = n || {}).mask = c[0]); const g = pr(o.apply(l, n)); let y = null; o.supportsMasking && (y = o.computeMask(l, c)); const b = ua(a), v = Array.isArray(b) ? b : [b]; for (let e = 0; e < v.length; ++e) { f.hasKey(v[e]) || f.add(v[e], g[e], Array.isArray(y) ? y[0] : y); const t = s.indexOf(v[e].name); -1 !== t && (u[t] = g[e]) } i || (0, P.dispose)(p) } return f.disposeMasks(), a ? u : u[0] } function oa(e) { const t = {}; for (const n in e) t[n] = e[n].size; return t } function sa(e, t) { const n = new Set, r = [], i = {}; for (const e of t.names()) n.add(e); const a = [], o = []; for (a.push(e); a.length > 0;) { const e = a[a.length - 1]; if (n.has(e.name)) { a.pop(); continue } const t = o[o.length - 1] === a.length - 1; if (0 === e.inputs.length || t) a.pop(), r.push(e), n.add(e.name), t && o.pop(); else { o.push(a.length - 1); for (const t of e.inputs) null == i[t.name] && (i[t.name] = new Set), i[t.name].add(e.name), n.has(t.name) || a.push(t) } } return { sorted: r, recipientMap: i } } function ua(e) { let t; if (1 === e.sourceLayer.inboundNodes.length) t = e.sourceLayer.output; else { let n = null; for (let t = 0; t < e.sourceLayer.inboundNodes.length; ++t)for (const r of e.sourceLayer.inboundNodes[t].outputTensors) if (r.id === e.id) { n = t; break } t = e.sourceLayer.getOutputAt(n) } return t }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function la(e, t) { return (0, P.tidy)((() => P.sqrt(P.sum(P.mul(e, e), t, !0)))) } (0, P.env)().registerFlag("TOPOLOGICAL_SORT_CACHE_MAX_ENTRIES", (() => 100), (function (e) { null != ra && ra.setMaxEntries(e), null != ia && ia.setMaxEntries(e) })); class ca extends P.serialization.Serializable { getConfig() { return {} } } class ha extends ca { constructor(e) { super(), this.defaultMaxValue = 2, this.defaultAxis = 0, this.maxValue = null != e.maxValue ? e.maxValue : this.defaultMaxValue, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => { const t = la(e, this.axis), n = P.clipByValue(t, 0, this.maxValue); return P.mul(e, P.div(n, P.add(Qr(), t))) })) } getConfig() { return { maxValue: this.maxValue, axis: this.axis } } } ha.className = "MaxNorm", P.serialization.registerClass(ha); class da extends ca { constructor(e) { super(), this.defaultAxis = 0, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => P.div(e, P.add(Qr(), la(e, this.axis))))) } getConfig() { return { axis: this.axis } } } da.className = "UnitNorm", P.serialization.registerClass(da); class fa extends ca { apply(e) { return P.relu(e) } } fa.className = "NonNeg", P.serialization.registerClass(fa); class pa extends ca { constructor(e) { super(), this.defaultMinValue = 0, this.defaultMaxValue = 1, this.defaultRate = 1, this.defaultAxis = 0, this.minValue = null != e.minValue ? e.minValue : this.defaultMinValue, this.maxValue = null != e.maxValue ? e.maxValue : this.defaultMaxValue, this.rate = null != e.rate ? e.rate : this.defaultRate, this.axis = null != e.axis ? e.axis : this.defaultAxis } apply(e) { return (0, P.tidy)((() => { const t = la(e, this.axis), n = P.add(P.mul(this.rate, P.clipByValue(t, this.minValue, this.maxValue)), P.mul(1 - this.rate, t)); return P.mul(e, P.div(n, P.add(Qr(), t))) })) } getConfig() { return { minValue: this.minValue, maxValue: this.maxValue, rate: this.rate, axis: this.axis } } } pa.className = "MinMaxNorm", P.serialization.registerClass(pa); const ma = { maxNorm: "MaxNorm", minMaxNorm: "MinMaxNorm", nonNeg: "NonNeg", unitNorm: "UnitNorm" }; function ga(e) { return br(e) } function ya(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "constraint") } function ba(e) { if (null == e) return null; if ("string" == typeof e) { return ya({ className: e in ma ? ma[e] : e, config: {} }) } return e instanceof ca ? e : ya(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function va(e) { return new ha(e) } function xa(e) { return new da(e) } function wa() { return new fa } function ka(e) { return new pa(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Sa() { return new vi } function _a() { return new xi } function Ca(e) { return new wi(e) } function Aa(e) { return new ki(e) } function Ta(e) { return new Si(e) } function Ea(e) { return new _i(e) } function Na(e) { return new Ci(e) } function Ia(e) { return new Ai(e) } function Ma(e) { return new Ti(e) } function Fa(e) { return new Ei(e) } function Da(e) { return new Ni(e) } function $a(e) { return new Ii(e) } function Ra(e) { return new Mi(e) } function Oa(e) { return new Fi(e) } function za(e) { return new Di(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
async function Pa(e) { if (null == e) return; const t = [], n = [], r = []; for (const i in e) { const a = e[i]; if ("number" != typeof a) { const e = a; t.push(e.data()), n.push(i), r.push(e) } } if (t.length > 0) { const i = await Promise.all(t); for (let t = 0; t < i.length; ++t)e[n[t]] = i[t][0]; (0, P.dispose)(r) } } function Ba(e) { if (null != e) for (const t in e) { const n = e[t]; "number" != typeof n && n.dispose() } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var La, ja; (ja = La || (La = {}))[ja.SILENT = 0] = "SILENT", ja[ja.VERBOSE = 1] = "VERBOSE"; class Ua { constructor() { this.validationData = null } setParams(e) { this.params = e } async onEpochBegin(e, t) { } async onEpochEnd(e, t) { } async onBatchBegin(e, t) { } async onBatchEnd(e, t) { } async onTrainBegin(e) { } async onTrainEnd(e) { } setModel(e) { } } class Wa { constructor(e, t = 10) { null == e && (e = []), this.callbacks = e, this.queueLength = t } append(e) { this.callbacks.push(e) } setParams(e) { for (const t of this.callbacks) t.setParams(e) } setModel(e) { for (const t of this.callbacks) t.setModel(e) } async onEpochBegin(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onEpochBegin(e, t) } async onEpochEnd(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onEpochEnd(e, t) } async onBatchBegin(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onBatchBegin(e, t) } async onBatchEnd(e, t) { null == t && (t = {}); for (const n of this.callbacks) await n.onBatchEnd(e, t) } async onTrainBegin(e) { null == e && (e = {}); for (const t of this.callbacks) await t.onTrainBegin(e) } async onTrainEnd(e) { null == e && (e = {}); for (const t of this.callbacks) await t.onTrainEnd(e) } } class Va extends Ua { constructor() { super() } async onEpochBegin(e) { this.seen = 0, this.totals = {} } async onBatchEnd(e, t) { null == t && (t = {}); const n = null == t.size ? 0 : t.size; this.seen += n; for (const e in t) { const r = t[e]; if ("number" == typeof r) this.totals.hasOwnProperty(e) || (this.totals[e] = 0), this.totals[e] = this.totals[e] + r * n; else { let t; e in this.totals ? t = this.totals[e] : this.totals[e] = 0; const i = (0, P.tidy)((() => (0, P.add)(this.totals[e], (0, P.mul)(r, n)))); this.totals[e] = i, null != t && t.dispose() } } } async onEpochEnd(e, t) { if (null != t) for (const e of this.params.metrics) null != this.totals[e] && ("number" == typeof this.totals[e] ? t[e] = this.totals[e] / this.seen : (0, P.tidy)((() => { const n = (0, P.mul)((0, P.div)(1, this.seen), this.totals[e]); t[e] = n, this.totals[e].dispose(), (0, P.keep)(t[e]) }))) } } class Ga extends Ua { async onTrainBegin(e) { this.epoch = [], this.history = {} } async onEpochEnd(e, t) { null == t && (t = {}), this.epoch.push(e); for (const e in t) null == this.history[e] && (this.history[e] = []), this.history[e].push(t[e]) } async syncData() { const e = [], t = [], n = []; for (const r in this.history) { const i = this.history[r]; for (let a = 0; a < i.length; ++a)if ("number" != typeof i[a]) { const o = i[a]; e.push(o.data()), t.push(r), n.push(a) } } const r = await Promise.all(e); for (let e = 0; e < r.length; ++e) { this.history[t[e]][n[e]].dispose(), this.history[t[e]][n[e]] = r[e][0] } } } class Ha extends Ua { constructor(e, t) { if (super(), this.currentEpoch = 0, this.nowFunc = e.nowFunc, this.nextFrameFunc = e.nextFrameFunc || P.nextFrame, this.yieldEvery = t || "auto", "auto" === this.yieldEvery && (this.yieldEvery = 125), "never" === this.yieldEvery && null != e.onYield) throw new Error("yieldEvery is `never` but you provided an `onYield` callback. Either change `yieldEvery` or remove the callback"); P.util.isNumber(this.yieldEvery) && (this.maybeWait = function (e, t, n) { let r, i = null != n ? n() : P.util.now(); return (...a) => { const o = null != n ? n() : P.util.now(); return o - i < t || (i = o, r = e(...a)), r } }(this.maybeWait.bind(this), this.yieldEvery, this.nowFunc)), this.trainBegin = e.onTrainBegin, this.trainEnd = e.onTrainEnd, this.epochBegin = e.onEpochBegin, this.epochEnd = e.onEpochEnd, this.batchBegin = e.onBatchBegin, this.batchEnd = e.onBatchEnd, this.yield = e.onYield } async maybeWait(e, t, n) { const r = []; null != this.yield && (await Pa(n), r.push(this.yield(e, t, n))), r.push(this.nextFrameFunc()), await Promise.all(r) } async onEpochBegin(e, t) { this.currentEpoch = e, null != this.epochBegin && (await Pa(t), await this.epochBegin(e, t)) } async onEpochEnd(e, t) { const n = []; null != this.epochEnd && (await Pa(t), n.push(this.epochEnd(e, t))), "epoch" === this.yieldEvery && n.push(this.nextFrameFunc()), await Promise.all(n) } async onBatchBegin(e, t) { null != this.batchBegin && (await Pa(t), await this.batchBegin(e, t)) } async onBatchEnd(e, t) { const n = []; null != this.batchEnd && (await Pa(t), n.push(this.batchEnd(e, t))), "batch" === this.yieldEvery ? n.push(this.nextFrameFunc()) : P.util.isNumber(this.yieldEvery) && n.push(this.maybeWait(this.currentEpoch, e, t)), await Promise.all(n) } async onTrainBegin(e) { null != this.trainBegin && (await Pa(e), await this.trainBegin(e)) } async onTrainEnd(e) { null != this.trainEnd && (await Pa(e), await this.trainEnd(e)) } } function qa(e, t) { if (null == e && (e = {}), e instanceof Ua) return [e]; if (Array.isArray(e) && e[0] instanceof Ua) return e; return pr(e).map((e => new Ha(e, t))) } class Ya { constructor() { } static registerCallbackConstructor(e, t) { P.util.assert(e >= 0 && Number.isInteger(e), (() => `Verbosity level is expected to be an integer >= 0, but got ${e}`)), Ya.checkForDuplicate(t), null == Ya.constructors[e] && (Ya.constructors[e] = []), Ya.constructors[e].push(t) } static checkForDuplicate(e) { for (const t in Ya.constructors) { Ya.constructors[+t].forEach((t => { if (t === e) throw new or("Duplicate callback constructor.") })) } } static clear() { Ya.constructors = {} } static createCallbacks(e) { const t = []; for (const n in Ya.constructors) { const r = +n; e >= r && t.push(...Ya.constructors[r]) } return t.map((e => new e)) } } function Xa(e, t, n, r, i, a, o, s, u) { const l = new Ga, c = [new Va, ...Ya.createCallbacks(t)]; null != e && c.push(...e), c.push(l); const h = new Wa(c); return h.setParams({ epochs: n, initialEpoch: r, samples: i, steps: a, batchSize: o, verbose: t, doValidation: s, metrics: u }), { callbackList: h, history: l } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ka(e, t = {}, n = !1) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "layer", n) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Za(e, t) { return (0, P.tidy)((() => { "float32" !== e.dtype && (e = P.cast(e, "float32")); const n = P.sum(hi(e), t, !0), r = P.fill(n.shape, Qr()), i = P.sqrt(P.maximum(n, r)); return P.div(e, i) })) } function Ja(e, t) { return (0, P.tidy)((() => P.mean(hi(P.sub(t, e)), -1))) } function Qa(e, t) { return (0, P.tidy)((() => P.mean(P.abs(P.sub(t, e)), -1))) } function eo(e, t) { return (0, P.tidy)((() => { const n = P.sub(e, t), r = P.clipByValue(P.abs(e), Qr(), Number.MAX_VALUE), i = P.abs(P.div(n, r)); return P.mul(100, P.mean(i, -1)) })) } function to(e, t) { return (0, P.tidy)((() => { const n = P.clipByValue(t, Qr(), Number.MAX_VALUE), r = P.log(P.add(1, n)), i = P.clipByValue(e, Qr(), Number.MAX_VALUE), a = P.log(P.add(1, i)); return P.mean(hi(P.sub(r, a)), -1) })) } function no(e, t, n = !1) { return (0, P.tidy)((() => { if (n) t = P.softmax(t); else { const e = P.sum(t, t.shape.length - 1, !0); t = P.div(t, e) } return t = P.clipByValue(t, Qr(), 1 - Qr()), P.neg(P.sum(P.mul(P.cast(e, "float32"), P.log(t)), t.shape.length - 1)) })) } function ro(e, t, n = !1) { return (0, P.tidy)((() => { const r = P.cast(P.floor(function (e) { const t = [Yr(e.shape)]; return P.reshape(e, t) }(e)), "int32"), i = (t = P.clipByValue(t, Qr(), 1 - Qr())).shape; return no(P.reshape(P.oneHot(r, i[i.length - 1]), i), t, n) })) } function io(e, t) { return (0, P.tidy)((() => { let n; return n = P.clipByValue(t, Qr(), 1 - Qr()), n = P.log(P.div(n, P.sub(1, n))), P.mean(function (e, t) { if (!P.util.arraysEqual(e.shape, t.shape)) throw new or(`logits and labels must have the same shape, but got shapes ${JSON.stringify(e.shape)} and ${JSON.stringify(t.shape)}`); return (0, P.tidy)((() => { const n = P.relu(t), r = P.neg(P.abs(t)); return P.add(P.sub(n, P.mul(t, e)), P.log1p(P.exp(r))) })) }(e, n), -1) })) } function ao(e, t) { return (0, P.tidy)((() => { const n = P.clipByValue(e, Qr(), 1), r = P.clipByValue(t, Qr(), 1); return P.sum(P.mul(e, P.log(P.div(n, r))), -1) })) } function oo(e, t) { return (0, P.tidy)((() => { const n = Za(e, -1), r = Za(t, -1), i = P.mul(n, r); return P.neg(P.sum(i, -1)) })) } Ya.constructors = {}; const so = { meanSquaredError: Ja, meanAbsoluteError: Qa, meanAbsolutePercentageError: eo, meanSquaredLogarithmicError: to, squaredHinge: function (e, t) { return (0, P.tidy)((() => { const n = P.maximum(0, P.sub(1, P.mul(e, t))); return P.mean(hi(n), -1) })) }, hinge: function (e, t) { return (0, P.tidy)((() => { const n = P.maximum(0, P.sub(1, P.mul(e, t))); return P.mean(n, -1) })) }, categoricalHinge: function (e, t) { return (0, P.tidy)((() => { const n = P.sum(P.mul(e, t), -1), r = P.max(P.mul(P.sub(1, e), t), -1); return P.maximum(0, P.add(1, P.sub(r, n))) })) }, logcosh: function (e, t) { return (0, P.tidy)((() => { const n = Math.log(2), r = P.sub(t, e), i = P.sub(P.add(r, P.softplus(P.mul(-2, r))), n); return P.mean(i, -1) })) }, categoricalCrossentropy: no, sparseCategoricalCrossentropy: ro, binaryCrossentropy: io, kullbackLeiblerDivergence: ao, poisson: function (e, t) { return (0, P.tidy)((() => { const n = P.log(P.add(Qr(), t)); return P.mean(P.sub(t, P.mul(e, n)), -1) })) }, cosineProximity: oo }; function uo(e) { if ("string" == typeof e) { if (e in so) return so[e]; let t = `Unknown loss ${e}`; throw e.toLowerCase().includes("softmaxcrossentropy") && (t = `Unknown loss ${e}. Use "categoricalCrossentropy" as the string name for tf.losses.softmaxCrossEntropy`), new or(t) } return e }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function lo(e, t) { return (0, P.tidy)((() => { const n = P.mul(.5, P.onesLike(t)), r = ei(P.greater(t, n), e.dtype); return P.mean(P.equal(e, r), -1) })) } function co(e, t) { return (0, P.tidy)((() => ei(P.equal(P.argMax(e, -1), P.argMax(t, -1)), "float32"))) } function ho(e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 1), P.equal(t, 1))), "float32"))) } function fo(e, t) { return (0, P.tidy)((() => { const n = ho(e, t), r = function (e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 0), P.equal(t, 1))), "float32"))) }(e, t), i = P.add(n, r); return P.cast(P.where(P.greater(i, 0), P.div(n, i), 0), "float32") })) } function po(e, t) { return (0, P.tidy)((() => { const n = ho(e, t), r = function (e, t) { return (0, P.tidy)((() => P.cast(P.sum(P.logicalAnd(P.equal(e, 1), P.equal(t, 0))), "float32"))) }(e, t), i = P.add(n, r); return P.cast(P.where(P.greater(i, 0), P.div(n, i), 0), "float32") })) } function mo(e, t) { return io(e, t) } function go(e, t) { return e.rank === t.rank && (e = P.squeeze(e, [e.rank - 1])), (t = P.argMax(t, -1)).dtype !== e.dtype && (t = P.cast(t, e.dtype)), P.cast(P.equal(e, t), "float32") } const yo = no, bo = ro, vo = { binaryAccuracy: lo, categoricalAccuracy: co, precision: fo, categoricalCrossentropy: yo, sparseCategoricalCrossentropy: bo, mse: Ja, MSE: Ja, mae: Qa, MAE: Qa, mape: eo, MAPE: eo, cosine: oo }; function xo(e) { if ("string" == typeof e && e in vo) return vo[e]; if ("string" != typeof e && null != e) return e; throw new or(`Unknown metric ${e}`) } function wo(e) { if (hr(null !== e, `Unknown LossOrMetricFn ${e}`), "string" == typeof e) return e; { let t; for (const n of Object.keys(so)) if (so[n] === e) { t = n; break } if (void 0 !== t) return t; for (const n of Object.keys(vo)) if (vo[n] === e) { t = n; break } return void 0 !== t ? t : e.name } }
/**
* @license
* Copyright 2019 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const ko = 1048576; function So(e, t, n = !1) { if (null == e || "object" != typeof e || Object.getPrototypeOf(e) !== Object.prototype || !_o(e)) throw new Error("User-defined metadata is expected to be a JSON object, but is not."); if (n) { const n = JSON.stringify(e); n.length > ko && console.warn(`User-defined metadata of model "${t}" is too large in size (length=${n.length} when serialized). It is not recommended to store such large objects in user-defined metadata. Please make sure its serialized length is <= 1048576.`) } } function _o(e) { if (null === e) return !0; if ("object" == typeof e) { if (Object.getPrototypeOf(e) === Object.prototype) { const t = Object.keys(e); for (const n of t) { if ("string" != typeof n) return !1; if (!_o(e[n])) return !1 } return !0 } if (Array.isArray(e)) { for (const t of e) if (!_o(t)) return !1; return !0 } return !1 } { const t = typeof e; return "string" === t || "number" === t || "boolean" === t } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Co(e, t, n, r = console.log) { const i = function (e) { let t = !0; const n = [], r = []; for (const t in e.nodesByDepth) n.push(e.nodesByDepth[t]); for (const e of n) { if (e.length > 1 || 1 === e.length && e[0].inboundLayers.length > 1) { t = !1; break } r.push(...e) } if (t) for (const n of e.layers) { let e = !1; for (const i of n.inboundNodes) if (-1 !== r.indexOf(i)) { if (e) { t = !1; break } e = !0 } if (!t) break } return t }(e), a = ["Layer (type)", "Input Shape", "Output shape", "Param #"]; let o; if (i ? (t = t || 90, n = n || [.32, .61, .89, 1]) : (t = t || 115, n = n || [.24, .48, .7, .8, 1]), n[n.length - 1] <= 1 && (n = n.map((e => Math.floor(t * e)))), !i) { a.push("Receives inputs"), o = []; for (const t in e.nodesByDepth) o.push(...e.nodesByDepth[t]) } r("_".repeat(t)), Ao(a, n, r), r("=".repeat(t)); const s = e.layers; for (let e = 0; e < s.length; ++e)i ? To(s[e], n, r) : Eo(s[e], n, o, r), r((e === s.length - 1 ? "=" : "_").repeat(t)); e.checkTrainableWeightsConsistency(); const u = function (e) { let t; t = null != e.collectedTrainableWeights ? Ui(e.collectedTrainableWeights) : Ui(e.trainableWeights); return t }(e), l = Ui(e.nonTrainableWeights); r(`Total params: ${u + l}`), r(`Trainable params: ${u}`), r(`Non-trainable params: ${l}`), r("_".repeat(t)) } function Ao(e, t, n = console.log) { let r = ""; for (let n = 0; n < e.length; ++n)n > 0 && (r = r.slice(0, r.length - 1) + " "), r += e[n], r = r.slice(0, t[n]), r += " ".repeat(t[n] - r.length); n(r) } function To(e, t, n) { let r, i; try { i = e.inboundNodes.map((e => JSON.stringify(e.inputShapes))).join(",") } catch (e) { i = "multiple" } try { r = JSON.stringify(e.outputShape) } catch (e) { r = "multiple" } Ao([`${e.name} (${e.getClassName()})`, i, r, e.countParams().toString()], t, n) } function Eo(e, t, n, r) { let i, a; try { a = e.inboundNodes.map((e => JSON.stringify(e.inputShapes))).join(",") } catch (e) { a = "multiple" } try { i = JSON.stringify(e.outputShape) } catch (e) { i = "multiple" } const o = []; for (const t of e.inboundNodes) if (!(null != n && n.length > 0 && -1 === n.indexOf(t))) for (let e = 0; e < t.inboundLayers.length; ++e) { const n = t.inboundLayers[e].name, r = t.nodeIndices[e], i = t.tensorIndices[e]; o.push(`${n}[${r}][${i}]`) } const s = e.name, u = e.getClassName(), l = 0 === o.length ? "" : o[0]; Ao([`${s} (${u})`, a, i, e.countParams().toString(), l], t, r); for (let e = 1; e < o.length; ++e)Ao(["", "", "", "", o[e]], t, r) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function No(e, t, n) { return ("inboundNodes" === e || "outputLayers" === e || "inputLayers" === e) && 0 === t && "string" == typeof n } function Io(e, t) { if (null === e) return null; if ("string" == typeof e) return gr(e); if ("number" == typeof e || "boolean" == typeof e) return e; if (e instanceof Array) { const n = [], r = e.length; for (let i = 0; i < r; ++i) { const r = e[i]; No(t, i, r) ? n.push(r) : n.push(Io(r, t)) } return n } { const t = {}; for (const n of Object.keys(e)) { const r = e[n]; if ("name" === n && "string" == typeof r) t[n] = r; else { const e = gr(n); t[e] = Io(r, e) } } return t } } function Mo(e, t) { if (null == e) return null; if ("string" == typeof e) return mr(e); if ("number" == typeof e || "boolean" == typeof e) return e; if (e instanceof Array) { const n = [], r = e.length; for (let i = 0; i < r; ++i) { const r = e[i]; No(t, i, r) ? n.push(r) : n.push(Mo(r, t)) } return n } { const t = {}; for (const n of Object.keys(e)) { const r = e[n], i = mr(n); t[i] = "name" !== n && "className" !== n || "string" != typeof r ? Mo(r, n) : r } return t } }
/** @license See the LICENSE file. */
const Fo = "4.22.0"; class Do extends Ji { constructor(e) { if (super({}), this.containerNodes = new Set, this.name = e.name, null == this.name) { const e = this.getClassName().toLowerCase(); this.name = Fr(e) } if (this.supportsMasking = !1, this.trainable_ = !0, Array.isArray(e.inputs) ? this.inputs = e.inputs.slice() : this.inputs = [e.inputs], Array.isArray(e.outputs) ? this.outputs = e.outputs.slice() : this.outputs = [e.outputs], kr(this.inputs).length !== this.inputs.length) throw new or(`The list of inputs passed to the model is redundant. All inputs should only appear once. Found: ${this.inputs.map((e => e.name))}`); kr(this.outputs).length !== this.outputs.length && console.warn(`The list of outputs passed to the model is redundant. All outputs should only appear once. Found: ${this.outputs.map((e => e.name))}`), this.inputLayers = [], this.inputLayersNodeIndices = [], this.inputLayersTensorIndices = [], this.outputLayers = [], this.outputLayersNodeIndices = [], this.outputLayersTensorIndices = [], this.layers = [], this.internalContainerRefs = []; for (const e of this.outputs) { const t = e.sourceLayer, n = e.nodeIndex, r = e.tensorIndex; this.outputLayers.push(t), this.outputLayersNodeIndices.push(n), this.outputLayersTensorIndices.push(r) } for (const e of this.inputs) { const t = e.sourceLayer, n = e.nodeIndex, r = e.tensorIndex; hr(0 === n, "input layer has >1 nodes"), hr(0 === r, "input layer has >1 tensors"), this.inputLayers.push(t), this.inputLayersNodeIndices.push(n), this.inputLayersTensorIndices.push(r) } this.inputNames = [], this.outputNames = [], this.feedInputShapes = [], this.feedInputNames = [], this.feedOutputNames = []; for (let t = 0; t < this.inputLayers.length; t++) { const n = this.inputLayers[t]; if (!(n instanceof ea)) throw new TypeError(`Input layers to a LayersModel must be InputLayer objects. Received inputs: ${e.inputs}. Input ${t} (0-based) originates from layer type ${n.getClassName()}.`); this.inputNames.push(n.name), this.feedInputShapes.push(n.batchInputShape), this.feedInputNames.push(n.name) } for (const e of this.outputLayers) this.outputNames.push(e.name); this.internalInputShapes = this.inputs.map((e => e.shape)), this.internalOutputShapes = this.outputs.map((e => e.shape)); const t = {}, n = {}, r = {}, i = {}, a = {}, o = [], s = (e, t, n, r, i, u) => { null != r && null != i && null != u || (r = e.sourceLayer, i = e.nodeIndex, u = e.tensorIndex); const l = r.inboundNodes[i]; if (-1 !== n.indexOf(l)) throw new ar(`The tensor ${e.name} at layer "${r.name}" is part of a cycle.`); if (-1 !== t.indexOf(l)) return; this.containerNodes.add(Do.nodeKey(r, i)), r.id in a || (a[r.id] = Object.keys(a).length), -1 === n.indexOf(l) && n.push(l); const c = l.inboundLayers.length; for (let e = 0; e < c; e++) { const r = l.inputTensors[e], i = l.inboundLayers[e], a = l.nodeIndices[e], o = l.tensorIndices[e]; s(r, t, n, i, a, o) } for (t.push(l); n.indexOf(l) >= 0;)n.splice(n.indexOf(l), 1); o.push(l) }, u = [], l = []; for (const e of this.outputs) s(e, u, l); const c = o.slice().reverse(); for (const e of c) { n[e.id] = e, e.id in t || (t[e.id] = 0); let a = t[e.id]; const o = null == r[e.outboundLayer.id] ? 0 : r[e.outboundLayer.id]; a = Math.max(a, o), r[e.outboundLayer.id] = a, i[e.outboundLayer.id] = e.outboundLayer, t[e.id] = a; for (let r = 0; r < e.inboundLayers.length; r++) { const i = e.inboundLayers[r], o = e.nodeIndices[r], s = i.inboundNodes[o], u = null == t[s.id] ? 0 : t[s.id]; t[s.id] = Math.max(a + 1, u), n[s.id] = s } } const h = {}; for (const e in t) { const r = t[e]; r in h || (h[r] = []), h[r].push(n[e]) } const d = {}; for (const e in r) { const t = r[e]; t in d || (d[t] = []), d[t].push(i[e]) } let f = Object.keys(d).map((e => parseInt(e, 10))).sort(wr); this.layers = []; for (const e of f) { const t = d[e]; t.sort(((e, t) => { const n = a[e.id], r = a[t.id]; return n < r ? -1 : n > r ? 1 : 0 })); for (const e of t) e instanceof Do && this.internalContainerRefs.push(e), this.layers.push(e) } this.layersByDepth = d, f = Object.keys(h).map((e => parseInt(e, 10))).sort(wr); const p = this.inputs.slice(), m = []; for (const e of f) for (const t of h[e]) { const e = t.outboundLayer; if (null != e) { for (const n of t.inputTensors) if (-1 === p.indexOf(n)) throw new ar(`Graph disconnected: cannot obtain value for tensor ${n} at layer "${e.name}". The following previous layers were accessed without issue: ${m}`); for (const e of t.outputTensors) p.push(e); m.push(e.name) } } this.nodesByDepth = h; const g = this.layers.map((e => e.name)); for (const e of g) { const t = g.filter((t => t === e)).length; if (1 !== t) throw new ar(`The name "${e}" is used ${t} times in the model. All layer names should be unique. Layer names: ` + JSON.stringify(g)) } this.outboundNodes = [], this.inboundNodes = [], new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: this.inputs, outputTensors: this.outputs, inputMasks: this.inputs.map((e => null)), outputMasks: this.outputs.map((e => null)), inputShapes: this.inputs.map((e => e.shape)), outputShapes: this.outputs.map((e => e.shape)) }), this.built = !0, this._refCount = 1 } assertNotDisposed() { if (0 === this._refCount) throw new Error(`Container '${this.name}' is already disposed.`) } dispose() { this.assertNotDisposed(); const e = { refCountAfterDispose: null, numDisposedVariables: 0 }; if (0 == --this._refCount) { for (const t of this.layers) e.numDisposedVariables += t.dispose().numDisposedVariables; for (const t of this.internalContainerRefs) e.numDisposedVariables += t.dispose().numDisposedVariables } return e.refCountAfterDispose = this._refCount, e } get trainable() { return this.trainable_ } set trainable(e) { this.layers.forEach((t => { t._trainableWeights.forEach((t => t.trainable = e)) })), this.trainable_ = e } get trainableWeights() { if (this._trainableWeights.length > 0) throw new or("Container instance unexpectedly contains _trainableWeights.The trainable weights of a Container are a union of the trainable weights of its consituent Layers. Its own _trainableWeights must remain an empty Array."); if (!this.trainable) return []; let e = []; for (const t of this.layers) e = e.concat(t.trainableWeights); return e } get nonTrainableWeights() { const e = []; for (const t of this.layers) e.push(...t.nonTrainableWeights); if (!this.trainable) { const t = []; for (const e of this.layers) t.push(...e.trainableWeights); return t.concat(e) } return e } get weights() { return this.trainableWeights.concat(this.nonTrainableWeights) } loadWeights(e, t = !0) { const n = {}; let r = 0; const i = (e => { const t = Object.keys(e); if (0 === t.length) return !1; const n = t[0].split("/"); return !isNaN(parseInt(n[n.length - 1], 10)) })(e); i && this.parseWeights(e); for (const e of this.layers) for (const [t, a] of e.weights.entries()) { const e = i ? `${a.name.split("/").slice(0, -1).join("/") + "/"}${t}` : a.originalName; if (null != n[e]) throw new or(`Duplicate weight name: ${e}`); n[e] = a, r++ } const a = []; for (const r in e) { let i = r; if (null == n[r]) { const e = r.split("/"); i = e.slice(0, -2).concat([e[e.length - 1]]).join("/") } if (null != n[i]) a.push([n[i], e[r]]); else if (t) throw new or(`Provided weight data has no target variable: ${r}`); delete n[i] } if (t) { const e = []; for (const t in n) e.push(t); if (e.length > 0) throw new or(`${e.length} of ${r} weights are not set: ${e}`) } Hi(a) } parseWeights(e) { for (const t in Object.keys(e)) { const n = t.split("/"), r = ["vars", "layer_checkpoint_dependencies"], i = n.map((e => e.startsWith("_") ? e.slice(1) : e)).filter((e => !r.includes(e))).join("/"); i !== t && (e[i] = e[t], delete e[t]) } } updatedConfig() { const e = this.getConfig(), t = {}; return t.className = this.getClassName(), t.config = e, t.kerasVersion = `tfjs-layers ${Fo}`, t.backend = "TensorFlow.js", t } toJSON(e, t = !0) { const n = Mo(this.updatedConfig()); return t ? JSON.stringify(n) : n } call(e, t) { return (0, P.tidy)((() => { e = pr(e); const n = new na; for (let t = 0; t < this.inputs.length; ++t)n.add(this.inputs[t], e[t]); return aa(this.outputs, n, t) })) } computeMask(e, t) { return (0, P.tidy)((() => { let n; return e = pr(e), n = null == t ? cr(null, e.length) : pr(t), this.runInternalGraph(e, n)[1] })) } computeOutputShape(e) { const t = Bi(e); if (t.length !== this.inputLayers.length) throw new or(`Invalid inputShape argument ${e}: model has ${this.inputLayers.length} tensor inputs.`); const n = {}; for (let e = 0; e < t.length; e++) { const r = this.inputLayers[e], i = t[e]; n[r.name + "_0_0"] = i } const r = Object.keys(this.nodesByDepth).map((e => parseInt(e, 10))).sort(wr); if (r.length > 1) for (const e of r) { const t = this.nodesByDepth[e]; for (const e of t) { const t = e.outboundLayer; if (-1 !== this.inputLayers.map((e => e.id)).indexOf(t.id)) continue; const r = []; for (let t = 0; t < e.inboundLayers.length; t++) { const i = e.inboundLayers[t], a = e.nodeIndices[t], o = e.tensorIndices[t], s = n[`${i.name}_${a}_${o}`]; r.push(s) } const i = Bi(t.computeOutputShape(fr(r))), a = t.inboundNodes.indexOf(e); for (let e = 0; e < i.length; e++) { n[`${t.name}_${a}_${e}`] = i[e] } } } const i = [], a = []; for (let e = 0; e < this.outputLayers.length; e++) { const t = this.outputLayers[e], n = this.outputLayersNodeIndices[e], r = this.outputLayersTensorIndices[e], i = `${t.name}_${n}_${r}`; a.push(i) } for (let e = 0; e < a.length; e++) { const t = a[e]; hr(t in n), i.push(n[t]) } return fr(i) } runInternalGraph(e, t) { null == t && (t = cr(null, e.length)); const n = {}; for (let r = 0; r < this.inputs.length; ++r) { const i = this.inputs[r], a = e[r], o = t[r]; n[i.id] = [a, o] } const r = Object.keys(this.nodesByDepth).map((e => parseInt(e, 10))).sort(wr); for (const e of r) { const t = this.nodesByDepth[e]; for (const e of t) { const t = e.outboundLayer, r = e.inputTensors, i = e.outputTensors, a = new Array; for (const e of r) e.id in n && a.push(n[e.id]); if (a.length === r.length) { let r, o, s, u, l = {}; if (null != e.callArgs && (l = e.callArgs), 1 === a.length) { const [e, n] = a[0]; null == l.mask && (l.mask = n), s = pr(t.call(e, l)), u = pr(t.computeMask(e, n)), r = [e], o = [n] } else r = a.map((e => e[0])), o = a.map((e => e[1])), null == l.mask && (l.mask = o), s = pr(t.call(r, l)), u = pr(t.computeMask(r, o)); if (t.activityRegularizer) throw new sr("LayersModel invocation with concrete Tensor value(s) in the presence of activity regularizer(s) is not supported yet."); for (let e = 0; e < i.length; ++e) { const t = i[e], r = s[e], a = u[e]; n[t.id] = [r, a] } } } } const i = [], a = [], o = []; for (const e of this.outputs) { hr(e.id in n, `Could not compute output ${e.name} : ${e.id}`); const [t, r] = n[e.id]; o.push(t.shape), i.push(t), a.push(r) } return [i, a, o] } buildNodeConversionMap(e) { const t = {}; let n; for (const e of this.layers) { n = e instanceof Do ? 1 : 0; for (let r = 0; r < e.inboundNodes.length; r++) { const i = Do.nodeKey(e, r); this.containerNodes.has(i) && (t[i] = n, n += 1) } } return t } getLayer(e, t) { if (null != t) return this.findLayer(t); if (null == e) throw new or("Provide either a layer name or layer index"); if ("number" == typeof e) return this.findLayer(e); for (const t of this.layers) if (t.name === e) return t; throw new or(`No such layer: ${e}`) } findLayer(e) { if (this.layers.length <= e) throw new or(`Was asked to retrieve layer at index ${e}, but model only has ${this.layers.length} layer(s).`); return this.layers[e] } calculateLosses() { return (0, P.tidy)((() => { const e = []; for (const t of this.layers) for (let n = 0; n < t.inboundNodes.length; ++n) { const r = Do.nodeKey(t, n); this.containerNodes.has(r) && e.push(...t.calculateLosses()) } return e })) } getConfig() { const e = { name: this.name }, t = this.buildNodeConversionMap(this.layers), n = []; for (const e of this.layers) { const r = e.getClassName(), i = e.getConfig(), a = []; for (let n = 0; n < e.inboundNodes.length; n++) { const r = e.inboundNodes[n], i = Do.nodeKey(e, n); let o = {}; if (this.containerNodes.has(i)) { if (r.callArgs) try { JSON.stringify(r.callArgs), o = r.callArgs } catch (t) { console.warn(`Layer ${e.name} was passed non-serializable keyword arguments: ${r.callArgs}. They will not be included in the serialized model (and thus will be missing at deserialization time).`), o = {} } if (r.inboundLayers.length > 0) { const e = []; for (let n = 0; n < r.inboundLayers.length; n++) { const i = r.inboundLayers[n], a = r.nodeIndices[n], s = r.tensorIndices[n]; let u = t[Do.nodeKey(i, a)]; null == u && (u = 0), e.push([i.name, u, s, o]) } a.push(e) } } } const o = {}; o.name = e.name, o.className = r, o.config = i, o.inboundNodes = a, n.push(o) } e.layers = n; const r = []; for (let e = 0; e < this.inputLayers.length; e++) { const n = this.inputLayers[e], i = this.inputLayersNodeIndices[e], a = Do.nodeKey(n, i); if (!this.containerNodes.has(a)) continue; let o = t[a]; null == o && (o = 0); const s = this.inputLayersTensorIndices[e]; r.push([n.name, o, s]) } e.inputLayers = r; const i = []; for (let e = 0; e < this.outputLayers.length; e++) { const n = this.outputLayers[e], r = this.outputLayersNodeIndices[e], a = Do.nodeKey(n, r); if (!this.containerNodes.has(a)) continue; let o = t[a]; null == o && (o = 0); const s = this.outputLayersTensorIndices[e]; i.push([n.name, o, s]) } return e.outputLayers = i, e } static fromConfig(e, t, n = {}, r = !1) { const i = {}, a = {}; function o(e, t) { e.name in a ? a[e.name].push(t) : a[e.name] = [t] } function s(e, t) { const n = []; let r; for (const a of t) { const s = a[0], u = a[1], l = a[2]; if (r = null == a[3] ? {} : a[3], !(s in i)) return void o(e, t); const c = i[s]; if (c.inboundNodes.length <= u) return void o(e, t); const h = c.inboundNodes[u]; n.push(h.outputTensors[l]) } n.length > 0 && e.apply(fr(n), r) } function u(e) { const n = e.name, a = Ka(e, null != t.customObjects ? t.customObjects : {}); a.setFastWeightInitDuringBuild(r), i[n] = a; e.inboundNodes.forEach((e => { if (!(e instanceof Array)) throw new or(`Corrupted configuration, expected array for nodeData: ${e}`); o(a, e) })) } const l = t.name, c = t.layers; for (const e of c) u(e); for (; !Sr(a);)for (const e of c) { const t = i[e.name]; if (t.name in a) { const e = a[t.name]; delete a[t.name]; for (const n of e) s(t, n) } } const h = [], d = [], f = t.inputLayers; for (const e of f) { const t = e[0], n = e[1], r = e[2]; hr(t in i); const a = i[t].inboundNodes[n].outputTensors; h.push(a[r]) } const p = t.outputLayers; for (const e of p) { const t = e[0], n = e[1], r = e[2]; hr(t in i); const a = i[t].inboundNodes[n].outputTensors; d.push(a[r]) } return new e({ inputs: h, outputs: d, name: l }) } get stateful() { if (this._stateful) throw new or("Container instance unexpectedly has _stateful = true. The statefulness of a Container is determined by the Layers it contains. Its _stateful property must remain the default false."); for (const e of this.layers) if (e.stateful) return !0; return !1 } resetStates() { (0, P.tidy)((() => { this.layers.forEach((e => { e.stateful && e.resetStates() })) })) } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function $o(e, t, n) { const r = t.length; if (null == e || Array.isArray(e) && 0 === e.length) return t.map((e => null)); if (1 === r) return Array.isArray(e) && 1 === e.length ? e : "object" == typeof e && t[0] in e ? [e[t[0]]] : [e]; if (Array.isArray(e)) { if (e.length !== r) throw new Error(`Provided ${n} is an array of ${e.length} element(s), but the model has ${r} outputs. Make sure a set of weights is provided for each model output.`); return e } if ("object" == typeof e && Object.keys(e).length > 0 && "object" == typeof e[Object.keys(e)[0]]) { const n = []; return t.forEach((t => { t in e ? n.push(e[t]) : n.push(null) })), n } throw new Error(`The model has multiple (${r}) outputs, so ${n} must be either an array with ${r} elements or an object with ${t} keys. Provided ${n} not understood: ${JSON.stringify(e)}`) } function Ro(e, t) { return $o(e, t, "classWeight") } async function Oo(e, t, n, r) { if (null != t || null != r) throw new Error("Support sampleWeight is not implemented yet"); if (null != n) { const t = (0, P.tidy)((() => { if (1 === e.shape.length) return (0, P.clone)(e); if (2 === e.shape.length) { if (e.shape[1] > 1) { const t = 1; return (0, P.argMax)(e, t) } if (1 === e.shape[1]) return (0, P.reshape)(e, [e.shape[0]]); throw new Error(`Encountered unexpected last-dimension size (${e.shape[1]}) during handling of class weights. The size is expected to be >= 1.`) } throw new Error(`Unexpected rank of target (y) tensor (${e.rank}) during handling of class weights. The rank is expected to be 1 or 2.`) })), r = Array.from(await t.data()); (0, P.dispose)(t); const i = []; return r.forEach((e => { if (null == n[e]) throw new Error(`classWeight must contain all classes in the training data. The class ${e} exists in the data but not in classWeight`); i.push(n[e]) })), (0, P.tensor1d)(i, "float32") } return null } function zo(e, t) { return (0, P.mul)(e, t) } function Po(e, t) { let n, r; const i = t; n = i.xs, r = i.ys, P.util.assert(null != n && null != r, (() => `A Dataset iterator for fitDataset() is expected to generate objects of the form \`{xs: xVal, ys: yVal}\`, where the two values may be \`tf.Tensor\`, an array of Tensors, or a map of string to Tensor. The provided Dataset instead generates ${t}`)); const a = Bo("input", e.inputNames, n), o = Bo("output", e.outputNames, r), s = a[0].shape[0]; P.util.assert(a.length === e.inputs.length, (() => `LayersModel has ${e.inputs.length} inputs, but the dataset provides ${a.length} inputs. (Expected input keys: ${JSON.stringify(e.inputNames)})`)), P.util.assert(o.length === e.outputs.length, (() => `LayersModel has ${e.outputs.length} outputs, but the dataset provides ${o.length} outputs. (Expected output keys: ${JSON.stringify(e.outputNames)})`)); for (let t = 0; t < a.length; t++)P.util.assert(a[t].shape[0] === s, (() => `Batch size mismatch: input ${e.inputNames[t]} has ${a[t].shape[0]}; expected ${s} based on input ${e.inputNames[0]}.`)); for (let t = 0; t < o.length; t++)P.util.assert(o[t].shape[0] === s, (() => `Batch size mismatch: output ${e.outputNames[t]} has ${o[t].shape[0]}; expected ${s} based on input ${e.inputNames[0]}.`)); return { xs: a, ys: o } } function Bo(e, t, n) { if (n instanceof P.Tensor) return [n]; if (Array.isArray(n)) return P.util.assert(n.length === t.length, (() => `Received an array of ${n.length} Tensors, but expected ${t.length} to match the ${e} keys ${t}.`)), n; { const r = []; for (const i of t) { if (null == n[i]) throw new or(`The feature data generated by the dataset lacks the required ${e} key '${i}'.`); r.push(n[i]) } return r } } async function Lo(e, t, n) { const r = null != n.batchesPerEpoch; if (P.util.assert(null != e.optimizer, (() => "You must compile a model before training/testing. Use LayersModel.compile(modelCompileConfig).")), P.util.assert(null != n, (() => "For fitDataset(), the 2nd argument (config) is required, but it is not provided in this call.")), P.util.assert(null != n.epochs && n.epochs > 0 && Number.isInteger(n.epochs), (() => `For fitDataset(), config.epochs is expected to be a positive integer, but got ${n.epochs}`)), P.util.assert(!r || n.batchesPerEpoch > 0 && Number.isInteger(n.batchesPerEpoch), (() => `For fitDataset(), config.batchesPerEpoch is expected to be a positive integer if specified, but got ${n.batchesPerEpoch}`)), P.util.assert(null == n.validationSplit, (() => "`validationSplit` is not supported by `fitDataset()`. Use validationData instead.")), e.isTraining) throw new Error("Cannot start training because another fit() call is ongoing."); e.isTraining = !0; try { const i = null != n.validationData; let a, o; if (i) if (jo(n.validationData)) P.util.assert(null == n.validationBatches || n.validationBatches > 0 && Number.isInteger(n.validationBatches), (() => `For fitDataset() with dataset-based validation, config.validationBatches is expected not to be provided, or to be a positive integer, but got ${n.validationBatches}`)); else { const e = function (e) { if (3 === e.length) throw new sr("Validation with sample weights is not implemented yet."); return { xs: e[0], ys: e[1] } }(n.validationData); a = e.xs, o = e.ys } const s = e.makeTrainFunction(), u = e.getDedupedMetricsNames(); let l; l = i ? u.slice().concat(u.map((e => "val_" + e))) : u.slice(); const c = qa(n.callbacks, n.yieldEvery), h = null == n.verbose ? 1 : n.verbose, { callbackList: d, history: f } = Xa(c, h, n.epochs, null, null, function (e, t) { let n = null; null != t.batchesPerEpoch ? n = t.batchesPerEpoch : Number.isFinite(e.size) && (n = e.size); return n }(t, n), null, i, l); d.setModel(e), e.history = f, await d.onTrainBegin(), e.stopTraining_ = !1; let p = null == n.initialEpoch ? 0 : n.initialEpoch, m = await t.iterator(); for (; p < n.epochs;) { const l = {}; await d.onEpochBegin(p); let c = 0, h = 0; for (r || (m = await t.iterator()); !r || c < n.batchesPerEpoch;) { const t = await m.next(); if (r && t.done) { console.warn(`You provided \`batchesPerEpoch\` as ${n.batchesPerEpoch}, but your dataset iterator ran out of data after ${c} batches; interrupting training. Make sure that your dataset can generate at least \`batchesPerEpoch * epochs\` batches (in this case, ` + n.batchesPerEpoch * n.epochs + " batches). You may need to use the repeat() function when building your dataset."); break } if (null != t.value) { const { xs: r, ys: i } = Po(e, t.value), a = {}; a.batch = h, a.size = r[0].shape[0], await d.onBatchBegin(h, a); const o = []; if (null != n.classWeight) { const t = Ro(n.classWeight, e.outputNames); for (let e = 0; e < t.length; ++e)o.push(await Oo(i[e], null, t[e])) } const l = r.concat(i).concat(o), f = s(l); P.dispose(l); for (let e = 0; e < u.length; ++e) { const t = u[e], n = f[e]; a[t] = n, P.keep(n) } await d.onBatchEnd(h, a), Ba(a), h++, c++ } if (r ? c >= n.batchesPerEpoch : t.done) { if (i) { let t; t = jo(n.validationData) ? pr(await e.evaluateDataset(n.validationData, { batches: n.validationBatches })) : pr(e.evaluate(a, o, { batchSize: null == n.validationBatchSize ? 32 : n.validationBatchSize, verbose: 0 })); for (let n = 0; n < e.metricsNames.length; ++n)l[`val_${e.metricsNames[n]}`] = t[n] } break } if (e.stopTraining_) break } if (await d.onEpochEnd(p, l), p++, e.stopTraining_) break } return await d.onTrainEnd(), await e.history.syncData(), e.history } finally { e.isTraining = !1 } } function jo(e) { return "function" == typeof e.iterator }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Uo(e) { P.util.assert(e > 0 && Number.isInteger(e), (() => `batchSize is required to be a positive integer, but got ${e}`)) } function Wo(e, t, n) { return null == e ? [null] : Array.isArray(e) ? e.map((e => ni(e, t, n - t))) : ni(e, t, n - t) } function Vo(e, t) { return P.tidy((() => null == e ? null : Array.isArray(e) ? e.map((e => Vo(e, t))) : ci(e, "int32" === t.dtype ? t : P.cast(t, "int32")))) } function Go(e, t) { const n = []; let r = 0, i = null; for (; r < e;)i = r + t, i >= e && (i = e), n.push([r, i]), r = i; return n } function Ho(e) { const t = []; e instanceof P.Tensor && (e = [e]); for (let n = 0; n < e.length; ++n) { const r = e[n]; if (1 === r.rank) t.push(ti(r, 1)); else { if (0 === r.rank) throw new Error("Expected tensor to be at least 1D, but received a 0D tensor (scalar)."); t.push(r) } } return t } function qo(e, t) { if (null == e) return; const n = []; if (t instanceof P.Tensor) n.push(t.id); else if (Array.isArray(t)) t.forEach((e => n.push(e.id))); else if (null != t) for (const e in t) { const r = t[e]; n.push(r.id) } const r = []; if (e instanceof P.Tensor) -1 === n.indexOf(e.id) && r.push(e); else if (Array.isArray(e)) e.forEach((e => { -1 === n.indexOf(e.id) && r.push(e) })); else if (null != e) for (const t in e) { const i = e[t]; -1 === n.indexOf(i.id) && r.push(i) } r.forEach((e => { e.isDisposed || e.dispose() })) } function Yo(e) { return Array.isArray(e) } function Xo(e) {
return !
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function (e) { return e instanceof P.Tensor }(e) && !Yo(e)
} function Ko(e, t, n, r = !0, i = "") { if (null == t || 0 === t.length) { if (null != e) { let t = !1; if (Yo(e) && e.length > 0) t = !0; else if (Xo(e)) { for (const n in e) if (e.hasOwnProperty(n)) { t = !0; break } } else t = !0; if (t) throw new or(`Error when checking model ${i} expected no data, but got ${e}`) } return [] } if (null == e) return t.map((e => null)); let a; if (Xo(e)) { a = []; for (const n of t) { if (null == e[n]) throw new or(`No data provided for "${n}". Need data for each key in: ${t}`); a.push(e[n]) } } else if (Yo(e)) { if (e.length !== t.length) throw new or(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the model expected. Expected to see ${t.length} Tensor(s), but instead got the following list of Tensor(s): ${e}`); a = e } else { if (t.length > 1) throw new or(`The model ${i} expects ${t.length} Tensor(s), but only received one Tensor. Found: Tensor with shape ${e.shape}`); a = [e] } if (a = Ho(a), null != n) for (let e = 0; e < t.length; ++e) { if (null == n[e]) continue; const o = a[e]; if (o.shape.length !== n[e].length) throw new or(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s). but got array with shape ${o.shape}`); for (let t = 0; t < n[e].length; ++t) { if (0 === t && !r) continue; const a = o.shape[t], s = n[e][t]; if (null != s && s >= 0 && a !== s) throw new or(`${i} expected a batch of elements where each example has shape [${n[e].slice(1, n[e].length)}] (i.e.,tensor shape [*,${n[e].slice(1, n[e].length)}]) but the ${i} received an input with ${o.shape[0]} examples, each with shape [${o.shape.slice(1, o.shape.length)}] (tensor shape [${o.shape}])`) } } return a } function Zo(e, t, n, r = !0, i = "") { let a; if (Array.isArray(e)) { if (e.length !== t.length) throw new or(`Error when checking model ${i}: the Array of Tensors that you are passing to your model is not the size the the model expected. Expected to see ${t.length} Tensor(s), but instead got ${e.length} Tensors(s).`); a = e } else { if (t.length > 1) throw new or(`The model expects ${t.length} ${i} Tensors, but only received one Tensor. Found: array with shape ${JSON.stringify(e.shape)}.`); a = [e] } if (null != n) for (let e = 0; e < t.length; ++e) { if (null == n[e]) continue; const o = a[e]; if (o.shape.length !== n[e].length) throw new or(`Error when checking ${i}: expected ${t[e]} to have ${n[e].length} dimension(s), but got array with shape ${JSON.stringify(o.shape)}`); for (let a = 0; a < n[e].length; ++a) { if (0 === a && !r) continue; const s = o.shape[a], u = n[e][a]; if (null != u && u !== s) throw new or(`Error when checking ${i}: expected ${t[e]} to have shape ${JSON.stringify(n[e])} but got array with shape ${JSON.stringify(o.shape)}.`) } } } class Jo extends Do {
constructor(e) { super(e), this.isTraining = !1 } summary(e, t, n = console.log) { if (!this.built) throw new or("This model has never been called, thus its weights have not been created yet. So no summary can be displayed. Build the model first (e.g., by calling it on some test data)."); Co(this, e, t, n) } compile(e) {
if (null == e.loss && (e.loss = []), this.loss = e.loss, "string" == typeof e.optimizer) this.optimizer_ =
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function (e) { const t = { Adagrad: () => P.train.adagrad(.01), Adadelta: () => P.train.adadelta(1, .95, Qr()), Adam: () => P.train.adam(.001, .9, .999, Qr()), Adamax: () => P.train.adamax(.002, .9, .999, Qr(), 0), RMSProp: () => P.train.rmsprop(.001, .9, 0, Qr()), SGD: () => P.train.sgd(.01) }; if (t.adagrad = t.Adagrad, t.adadelta = t.Adadelta, t.adam = t.Adam, t.adamax = t.Adamax, t.rmsprop = t.RMSProp, t.sgd = t.SGD, e in t) return t[e](); throw new or(`Unknown Optimizer ${e}`) }(e.optimizer), this.isOptimizerOwned = !0; else { if (!(e.optimizer instanceof P.Optimizer)) throw new or("User-defined optimizer must be an instance of tf.Optimizer."); this.optimizer_ = e.optimizer, this.isOptimizerOwned = !1 } let t = []; if (Array.isArray(e.loss) || "string" == typeof e.loss || "function" == typeof e.loss) if (Array.isArray(e.loss)) { if (e.loss.length !== this.outputs.length) throw new or(`When passing an Array as loss, it should have one entry per model output. The model has ${this.outputs.length} output(s), but you passed loss=${e.loss}.`); const n = e.loss; t = n.map((e => uo(e))) } else { const n = uo(e.loss); this.outputs.forEach((e => { t.push(n) })) } else { e.loss = e.loss; for (const t in e.loss) if (-1 === this.outputNames.indexOf(t)) throw new or(`Unknown entry in loss dictionary: "${t}". Only expected the following keys: ${this.outputNames}`); for (const n of this.outputNames) null == e.loss[n] && console.warn(`Output "${n}" is missing from loss dictionary. We assume this was done on purpose, and we will not be expecting data to be passed to ${n} during training`), t.push(uo(e.loss[n])) } this.lossFunctions = t, this.feedOutputNames = [], this.feedOutputShapes = [], this.feedLossFns = []; for (let e = 0; e < this.outputs.length; ++e) { const t = this.internalOutputShapes[e], n = this.outputNames[e]; this.feedOutputNames.push(n), this.feedOutputShapes.push(t), this.feedLossFns.push(this.lossFunctions[e]) } const n = []; this.metrics = e.metrics, this.metricsNames = ["loss"], this.metricsTensors = [], Wr("loss", (() => { for (let e = 0; e < this.outputs.length; ++e) { if (-1 !== n.indexOf(e)) continue; const t = this.lossFunctions[e]; this.outputs.length > 1 && (this.metricsTensors.push([t, e]), this.metricsNames.push(this.outputNames[e] + "_loss")) } })); const r = function (e, t) { if (null == e || Array.isArray(e) && 0 === e.length) return t.map((e => [])); let n; if ("string" == typeof e || "function" == typeof e) n = [e]; else { if (!Array.isArray(e) && "object" != typeof e) throw new TypeError(`Type of metrics argument not understood. Expected an string,function, Array, or Object, found: ${e}`); n = e } if (Array.isArray(n)) return t.map((e => n)); { const e = []; for (const r of t) { let t = n.hasOwnProperty(r) ? n[r] : []; Array.isArray(t) || (t = [t]), e.push(t) } return e } }(e.metrics, this.outputNames), i = (e, t, n) => { this.outputNames.length > 1 && (t = this.outputNames[e] + "_" + t), this.metricsNames.push(t), this.metricsTensors.push([n, e]) }; Wr("metric", (() => { for (let e = 0; e < this.outputs.length; ++e) { if (-1 !== n.indexOf(e)) continue; (t => { let n, r, a; for (const o of t) { if ("string" == typeof o && -1 !== ["accuracy", "acc", "crossentropy", "ce"].indexOf(o)) { const t = this.internalOutputShapes[e]; let i; 1 === t[t.length - 1] || this.lossFunctions[e] === io ? -1 !== ["accuracy", "acc"].indexOf(o) ? r = lo : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = mo) : this.lossFunctions[e] === ro ? -1 !== ["accuracy", "acc"].indexOf(o) ? r = go : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = bo) : -1 !== ["accuracy", "acc"].indexOf(o) ? r = co : -1 !== ["crossentropy", "ce"].indexOf(o) && (r = yo), -1 !== ["accuracy", "acc"].indexOf(o) ? i = "acc" : -1 !== ["crossentropy", "ce"].indexOf(o) && (i = "ce"), a = r, n = "" + i } else { const e = xo(o); a = e, n = "" + wo(o) } let t; Wr(n, (() => { t = a })), i(e, n, t) } })(r[e]) } })), this.collectedTrainableWeights = this.trainableWeights
} checkTrainableWeightsConsistency() { null != this.collectedTrainableWeights && this.trainableWeights.length !== this.collectedTrainableWeights.length && console.warn("Discrepancy between trainableweights and collected trainable weights. Did you set `model.trainable` without calling `model.compile()` afterwards?") } evaluate(e, t, n = {}) { const r = null == n.batchSize ? 32 : n.batchSize; Uo(r); const i = this.standardizeUserDataXY(e, t, !0, r); try { const e = i[0].concat(i[1]); this.makeTestFunction(); const t = this.testFunction; return fr(this.testLoop(t, e, r, n.verbose, n.steps)) } finally { qo(i[0], e), qo(i[1], t) } } async evaluateDataset(e, t) { return this.makeTestFunction(), async function (e, t, n) { const r = null != (n = n || {}).batches, i = e.testFunction; let a = []; if (n.verbose > 0) throw new sr("Verbose mode is not implemented yet."); P.util.assert(!r || n.batches > 0 && Number.isInteger(n.batches), (() => `Test loop expects \`batches\` to be a positive integer, but received ${JSON.stringify(n.batches)}`)); const o = "function" == typeof t.next ? t : await t.iterator(); let s = 0, u = 0; for (; !r || u < n.batches;) { const t = await o.next(); if (a = P.tidy((() => { if (t.value) { const { xs: n, ys: r } = Po(e, t.value), o = n.concat(r), l = P.tidy((() => i(o))); if (P.dispose(o), 0 === u) for (let e = 0; e < l.length; ++e)a.push((0, P.scalar)(0)); const c = o[0].shape[0]; for (let e = 0; e < l.length; ++e) { const t = l[e], n = a[e]; a[e] = P.tidy((() => P.add(a[e], P.mul(c, t)))), u > 0 && P.dispose(n) } P.dispose(l), s += c, ++u } return a })), t.done) { r && console.warn(`Your dataset iterator ran out of data during evaluateDataset(). Interrupting evalution. Make sure that your dataset can generate at least \`batches\` batches (in this case, ${n.batches} batches). You may need to use the repeat() function when building your dataset.`); break } } for (let e = 0; e < a.length; ++e) { const t = a[e]; a[e] = P.div(a[e], s), P.dispose(t) } return fr(a) }(this, e, t) } checkNumSamples(e, t, n, r = "steps") { let i; if (null != n) { if (i = null, null != t) throw new or(`If ${r} is set, batchSize must be null or undefined.Got batchSize = ${t}`) } else { if (null == e) throw new or(`Either the input data should have a defined shape, or ${r} shoud be specified.`); i = Array.isArray(e) ? e[0].shape[0] : e.shape[0] } return i } execute(e, t) { if (Array.isArray(t) && 0 === t.length) throw new or("`outputs` is an empty Array, which is not allowed."); const n = Array.isArray(t), r = n ? t : [t], i = this.retrieveSymbolicTensors(r), a = new na; if (e instanceof P.Tensor && (e = [e]), Array.isArray(e)) { if (e.length !== this.inputs.length) throw new or(`The number of inputs provided (${e.length}) does not match the number of inputs of this model (${this.inputs.length}).`); for (let t = 0; t < this.inputs.length; ++t)a.add(this.inputs[t], e[t]) } else for (const t of this.inputs) { const n = e[t.name]; if (null == n) throw new or(`No value is provided for the model's input ${t.name}`); a.add(t, n) } const o = aa(i, a); return n ? o : o[0] } retrieveSymbolicTensors(e) { const t = cr(null, e.length); let n = e.length; for (const r of this.layers) { const i = Array.isArray(r.output) ? r.output : [r.output], a = i.map((e => e.name)); for (let r = 0; r < e.length; ++r) { const o = a.indexOf(e[r]); if (-1 !== o && (t[r] = i[o], n--), 0 === n) break } if (0 === n) break } if (n > 0) { const n = []; throw t.forEach(((t, r) => { null == t && n.push(e[r]) })), new or(`Cannot find SymbolicTensors for output name(s): ${JSON.stringify(n)}`) } return t } predictLoop(e, t = 32, n = !1) { return P.tidy((() => { const r = this.checkNumSamples(e); if (n) throw new sr("Verbose predictLoop() is not implemented yet."); const i = Go(r, t), a = this.outputs.map((e => [])); for (let t = 0; t < i.length; ++t) { P.tidy((() => { const n = i[t][0], r = i[t][1], a = Wo(e, n, r), o = []; if (Array.isArray(a)) for (let e = 0; e < a.length; ++e)o.push({ key: this.inputs[e], value: a[e] }); else o.push({ key: this.inputs[0], value: a }); const s = new na(o); return aa(this.outputs, s) })).forEach(((e, t) => a[t].push(e))) } return fr(a.map((e => P.concat(e, 0)))) })) } predict(e, t = {}) { const n = Ho(e); Zo(n, this.inputNames, this.feedInputShapes, !1); try { const e = null == t.batchSize ? 32 : t.batchSize; return Uo(e), this.predictLoop(n, e) } finally { qo(n, e) } } predictOnBatch(e) { Zo(e, this.inputNames, this.feedInputShapes, !0); const t = (Array.isArray(e) ? e[0] : e).shape[0]; return this.predictLoop(e, t) } standardizeUserDataXY(e, t, n = !0, r) { if (null == this.optimizer_) throw new ar("You must compile a model before training/testing. Use LayersModel.compile(modelCompileArgs)."); const i = []; for (let e = 0; e < this.feedOutputShapes.length; ++e) { const t = this.feedOutputShapes[e]; this.feedLossFns[e] === ro ? i.push(t.slice(0, t.length - 1).concat([1])) : i.push(t) } if (function (e, t) { const n = kr(e.map((e => e.shape[0]))); n.sort(); const r = kr(t.map((e => e.shape[0]))); if (r.sort(), n.length > 1) throw new or(`All input Tensors (x) should have the same number of samples. Got array shapes: ${JSON.stringify(e.map((e => e.shape)))}`); if (r.length > 1) throw new or(`All target Tensors (y) should have the same number of samples. Got array shapes: ${JSON.stringify(t.map((e => e.shape)))}`); if (n.length > 0 && r.length > 0 && !P.util.arraysEqual(n, r)) throw new or(`Input Tensors should have the same number of samples as target Tensors. Found ${n[0]} input sample(s) and ${r[0]} target sample(s).`) }(e = Ko(e, this.feedInputNames, this.feedInputShapes, !1, "input"), t = Ko(t, this.feedOutputNames, i, !1, "target")), function (e, t, n) { const r = [Ja, io, no]; for (let i = 0; i < e.length; ++i) { const a = e[i], o = t[i], s = n[i]; if (null != o) { if (o === no && 1 === a.shape[a.shape.length - 1]) throw new or(`You are passing a target array of shape ${a.shape} while using a loss 'categorical_crossentropy'. 'categorical_crossentropy'expects targets to be binary matrices (1s and 0s) of shape [samples, classes].`); if (-1 !== r.indexOf(o)) { const e = a.shape.slice(1), t = s.slice(1); for (let n = 0; n < e.length; ++n) { const r = e[n], i = t[n]; if (null != i && r !== i) throw new or(`A target Tensor with shape ${a.shape} was passed for an output of shape ${s}, while using a loss function that expects targets to have the same shape as the output.`) } } } } }(t, this.feedLossFns, this.feedOutputShapes), this.stateful && null != r && r > 0 && e[0].shape[0] % r != 0) throw new or(`In a stateful network, you should only pass inputs with a number of samples that is divisible by the batch size ${r}. Found: ${e[0].shape[0]} sample(s).`); return [e, t] } async standardizeUserData(e, t, n, r, i = !0, a) { const [o, s] = this.standardizeUserDataXY(e, t, i, a); if (null != n) throw new Error("sample weight is not supported yet."); let u = null; if (null != r) { const e = Ro(r, this.outputNames); u = []; for (let t = 0; t < e.length; ++t)u.push(await Oo(s[t], null, e[t])) } return [o, s, u] } testLoop(e, t, n, r = 0, i) { return P.tidy((() => { const a = this.checkNumSamples(t, n, i, "steps"), o = []; if (r > 0) throw new sr("Verbose mode is not implemented yet."); if (null != i) throw new sr("steps mode in testLoop() is not implemented yet"); { const r = Go(a, n), i = (0, P.tensor1d)(Zr(0, a)); for (let n = 0; n < r.length; ++n) { const a = r[n][0], s = r[n][1], u = ni(i, a, s - a), l = Vo(t, u), c = e(l); if (0 === n) for (let e = 0; e < c.length; ++e)o.push((0, P.scalar)(0)); for (let e = 0; e < c.length; ++e) { const t = c[e]; o[e] = P.add(o[e], P.mul(s - a, t)) } } for (let e = 0; e < o.length; ++e)o[e] = P.div(o[e], a) } return o })) } getDedupedMetricsNames() { const e = this.metricsNames, t = []; for (let n = 0; n < e.length; ++n) { const r = e[n]; let i = r; if (dr(e, r) > 1) { i += `_${dr(e.slice(0, n), r)}` } t.push(i) } return t } makeTrainFunction() { return e => { const t = [], n = e.slice(0, this.inputs.length), r = e.slice(this.inputs.length, this.inputs.length + this.outputs.length), i = e.slice(this.inputs.length + this.outputs.length, this.inputs.length + 2 * this.outputs.length), a = [], o = this.collectedTrainableWeights.map((e => e.read())); return [this.optimizer_.minimize((() => { const e = []; for (let t = 0; t < this.inputs.length; ++t)e.push({ key: this.inputs[t], value: n[t] }); const o = new na(e), s = aa(this.outputs, o, { training: !0 }); let u; for (let e = 0; e < this.lossFunctions.length; ++e) { let n = (0, this.lossFunctions[e])(r[e], s[e]); null != i[e] && (n = zo(n, i[e])); const a = P.mean(n); t.push(a), u = 0 === e ? n : P.add(u, n) } for (let e = 0; e < this.metricsTensors.length; ++e) { let n; if (this.outputs.length > 1 && e < this.outputs.length) n = t[e]; else { const t = this.metricsTensors[e][0], i = this.metricsTensors[e][1]; n = P.mean(t(r[i], s[i])) } P.keep(n), a.push(n) } return u = P.mean(u), this.calculateLosses().forEach((e => { u = P.add(u, e) })), u }), !0, o)].concat(a) } } makeTestFunction() { this.testFunction = e => P.tidy((() => { const t = []; let n; const r = e.slice(0, this.inputs.length), i = e.slice(this.inputs.length, this.inputs.length + this.outputs.length), a = []; for (let e = 0; e < this.inputs.length; ++e)a.push({ key: this.inputs[e], value: r[e] }); const o = new na(a), s = aa(this.outputs, o); for (let e = 0; e < this.lossFunctions.length; ++e) { const r = this.lossFunctions[e], a = P.mean(r(i[e], s[e])); n = 0 === e ? a : P.add(n, a), t.push(n) } for (let e = 0; e < this.metricsTensors.length; ++e) { const n = this.metricsTensors[e][0], r = this.metricsTensors[e][1], a = P.mean(n(i[r], s[r])); t.push(a) } return t })) } async fit(e, t, n = {}) { if (this.isTraining) throw new Error("Cannot start training because another fit() call is ongoing."); let r, i, a, o, s, u, l, c, h; this.isTraining = !0; try { const d = null == n.batchSize ? 32 : n.batchSize; Uo(d); const f = !1, p = await this.standardizeUserData(e, t, n.sampleWeight, n.classWeight, f, d); r = p[0], i = p[1], h = p[2]; let m, g = !1; if (null != n.validationData && n.validationData.length > 0) { if (g = !0, 2 !== n.validationData.length) throw 3 === n.validationData.length ? new sr("validationData including sample weights is not supported yet.") : new or(`When passing validation data, it must contain 2 (valX, valY) or 3 (valX, valY, valSampleWeight) items; ${n.validationData} is invalid.`); s = n.validationData[0], u = n.validationData[1]; const e = !0, t = await this.standardizeUserData(s, u, null, null, e, d); l = t[0], c = t[1], m = l.concat(c) } else if (null != n.validationSplit && n.validationSplit > 0 && n.validationSplit < 1) { g = !0; const e = Math.floor(r[0].shape[0] * (1 - n.validationSplit)), t = r[0].shape[0]; l = Wo(r, e, t), a = r, r = Wo(r, 0, e), c = Wo(i, e, t), o = i, i = Wo(i, 0, e), m = l.concat(c) } else null != n.validationSteps && (g = !0); const y = r.concat(i).concat(h); this.checkTrainableWeightsConsistency(); const b = this.makeTrainFunction(), v = this.getDedupedMetricsNames(); let x, w; g ? (this.makeTestFunction(), x = this.testFunction, w = v.slice().concat(v.map((e => "val_" + e)))) : (x = null, m = [], w = v.slice()); const k = qa(n.callbacks, n.yieldEvery); return await this.fitLoop(b, y, v, d, n.epochs, n.verbose, k, x, m, n.shuffle, w, n.initialEpoch, null, null) } finally { this.isTraining = !1, qo(r, e), qo(i, t), qo(a, e), qo(o, t), qo(l, s), qo(c, u), null != h && P.dispose(h) } } async fitLoop(e, t, n, r, i, a, o, s, u, l, c, h, d, f) { null == r && (r = 32), null == i && (i = 1), null == l && (l = !0), null == h && (h = 0); let p = !1; if (null != s && null != u && (p = !0), null != f && (p = !0, null == d)) throw new or("Can only use `validationSteps` when doing step-wise training, i.e., `stepsPerEpoch` must be set."); const m = this.checkNumSamples(t, r, d, "steps_per_epoch"); let g; null != m && (g = Zr(0, m)), null == a && (a = 1); const { callbackList: y, history: b } = Xa(o, a, i, h, m, d, r, p, c); y.setModel(this), this.history = b, await y.onTrainBegin(), this.stopTraining_ = !1; for (let a = h; a < i; ++a) { await y.onEpochBegin(a); const i = {}; if (null != d) throw new sr("stepsPerEpoch mode is not implemented yet."); { if ("batch" === l) throw new sr("batch shuffling is not implemneted yet"); l && P.util.shuffle(g); const a = (0, P.tensor1d)(g), o = Go(m, r); for (let l = 0; l < o.length; ++l) { const c = {}; if (await y.onBatchBegin(l, c), P.tidy((() => { const h = o[l][0], d = o[l][1], f = ni(a, h, d - h); c.batch = l, c.size = d - h; const m = Vo(t, f), g = e(m); for (let e = 0; e < n.length; ++e) { const t = n[e], r = g[e]; c[t] = r, P.keep(r) } if (l === o.length - 1 && p) { const e = this.testLoop(s, u, r); for (let t = 0; t < n.length; ++t) { const r = n[t], a = e[t]; P.keep(a), i["val_" + r] = a } } })), await y.onBatchEnd(l, c), Ba(c), this.stopTraining_) break } a.dispose() } if (await y.onEpochEnd(a, i), this.stopTraining_) break } return await y.onTrainEnd(), await this.history.syncData(), this.history } async fitDataset(e, t) { return Lo(this, e, t) } async trainOnBatch(e, t) { const n = await this.standardizeUserData(e, t), r = n[0], i = n[1], a = this.makeTrainFunction()(r.concat(i)), o = []; for (const e of a) { const t = await e.data(); o.push(t[0]) } return P.dispose(a), qo(n[0], e), qo(n[1], t), fr(o) } getNamedWeights(e) { const t = [], n = null != e && e.trainableOnly, r = n ? this.trainableWeights : this.weights, i = this.getWeights(n); for (let e = 0; e < r.length; ++e)n && !r[e].trainable || t.push({ name: r[e].originalName, tensor: i[e] }); return t } set stopTraining(e) { this.stopTraining_ = e } get stopTraining() { return this.stopTraining_ } get optimizer() { return this.optimizer_ } set optimizer(e) { this.optimizer_ !== e && (this.optimizer_ = e, this.isOptimizerOwned = !1) } dispose() { const e = super.dispose(); if (0 === e.refCountAfterDispose && null != this.optimizer && this.isOptimizerOwned) { const t = P.memory().numTensors; this.optimizer_.dispose(), e.numDisposedVariables += t - P.memory().numTensors } return e } getLossIdentifiers() { let e; if ("string" == typeof this.loss) e = mr(this.loss); else if (Array.isArray(this.loss)) { for (const e of this.loss) if ("string" != typeof e) throw new Error("Serialization of non-string loss is not supported."); e = this.loss.map((e => mr(e))) } else { const t = Object.keys(this.loss); e = {}; const n = this.loss; for (const r of t) { if ("string" != typeof n[r]) throw new Error("Serialization of non-string loss is not supported."); e[r] = mr(n[r]) } } return e } getMetricIdentifiers() { if ("string" == typeof this.metrics || "function" == typeof this.metrics) return [mr(wo(this.metrics))]; if (Array.isArray(this.metrics)) return this.metrics.map((e => mr(wo(e)))); { const e = {}; for (const t in this.metrics) e[t] = mr(wo(this.metrics[t])); return e } } getTrainingConfig() { return { loss: this.getLossIdentifiers(), metrics: this.getMetricIdentifiers(), optimizer_config: { class_name: this.optimizer.getClassName(), config: this.optimizer.getConfig() } } } loadTrainingConfig(e) { if (null != e.weighted_metrics) throw new Error("Loading weight_metrics is not supported yet."); if (null != e.loss_weights) throw new Error("Loading loss_weights is not supported yet."); if (null != e.sample_weight_mode) throw new Error("Loading sample_weight_mode is not supported yet."); const t = Ka(Io(e.optimizer_config)); let n, r; if ("string" == typeof e.loss) n = gr(e.loss); else if (Array.isArray(e.loss)) n = e.loss.map((e => gr(e))); else if (null != e.loss) { n = {}; for (const t in e.loss) n[t] = gr(e.loss[t]) } if (Array.isArray(e.metrics)) r = e.metrics.map((e => gr(e))); else if (null != e.metrics) { r = {}; for (const t in e.metrics) r[t] = gr(e.metrics[t]) } this.compile({ loss: n, metrics: r, optimizer: t }) } async save(e, t) { if ("string" == typeof e) { const t = P.io.getSaveHandlers(e); if (0 === t.length) throw new or(`Cannot find any save handlers for URL '${e}'`); if (t.length > 1) throw new or(`Found more than one (${t.length}) save handlers for URL '${e}'`); e = t[0] } if (null == e.save) throw new or("LayersModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined."); const n = await P.io.encodeWeights(this.getNamedWeights(t)), r = { modelTopology: this.toJSON(null, !1), format: "layers-model", generatedBy: `TensorFlow.js tfjs-layers v${Fo}`, convertedBy: null }; if (null != t && t.includeOptimizer && null != this.optimizer) { r.trainingConfig = this.getTrainingConfig(); const e = "optimizer", { data: t, specs: i } = await P.io.encodeWeights(await this.optimizer.getWeights(), e); n.specs.push(...i), n.data = P.io.concatenateArrayBuffers([n.data, t]) } if (null != this.userDefinedMetadata) { const e = !0; So(this.userDefinedMetadata, this.name, e), r.userDefinedMetadata = this.userDefinedMetadata } return r.weightData = n.data, r.weightSpecs = n.specs, e.save(r) } setUserDefinedMetadata(e) { So(e, this.name), this.userDefinedMetadata = e } getUserDefinedMetadata() { return this.userDefinedMetadata }
} Jo.className = "Model", P.serialization.registerClass(Jo); class Qo extends Jo { }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
async function es(e, t) { "modelTopology" in e || (e = { modelTopology: e }); let n = e.modelTopology; null != n.model_config && (n = n.model_config); const r = Ka(Io(n), t); if (null != e.weightsManifest) { const t = await P.io.loadWeights(e.weightsManifest, e.pathPrefix, r.weights.map((e => e.originalName))), n = {}; for (const e of r.weights) n[e.originalName] = t[e.originalName]; r.loadWeights(n), (0, P.dispose)(t) } return r } async function ts(e, t) { if (null == t && (t = {}), "string" == typeof e) { const n = P.io.getLoadHandlers(e, t); if (0 === n.length) n.push(P.io.browserHTTPRequest(e, t)); else if (n.length > 1) throw new or(`Found more than one (${n.length}) load handlers for URL '${e}'`); e = n[0] } return async function (e, t, n) { null == n && (n = {}); if (null == e.load) throw new or("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented."); const r = await e.load(); let i = r.modelTopology; null != i.model_config && (i = i.model_config); const a = null == n.strict || n.strict, o = null != r.weightData && null != r.weightSpecs && a, s = Ka(Io(i), t, o), u = r.trainingConfig; null != u && s.loadTrainingConfig(u); null != r.userDefinedMetadata && s.setUserDefinedMetadata(r.userDefinedMetadata); if (null != r.weightData) { if (null == r.weightSpecs) throw new or("LayersModel artifacts contains weight data, but not weight specs. Therefore loading of weights cannot proceed."); const { modelWeights: e, optimizerWeights: t } = function (e, t) { const n = P.io.decodeWeights(e, t), r = {}, i = []; return t.forEach((e => { "optimizer" === e.group ? i.push({ name: e.name, tensor: n[e.name] }) : r[e.name] = n[e.name] })), { modelWeights: r, optimizerWeights: i } }(r.weightData, r.weightSpecs); s.loadWeights(e, a), null != s.optimizer && t.length > 0 && await s.optimizer.setWeights(t), (0, P.dispose)(e), (0, P.dispose)(t.map((e => e.tensor))) } return s }(e, void 0, t) } Qo.className = "Functional", P.serialization.registerClass(Qo); class ns extends Jo { constructor(e) { if (super({ inputs: [], outputs: [] }), e = e || {}, this.trainable = !0, this.built = !1, this.name = null != e.name ? e.name : Fr("sequential_"), null != e.layers) for (const t of e.layers) this.add(t) } checkShape(e) { if (e.inboundNodes[0].outputTensors[0].shape.some((e => e < 0))) throw new or(`Negative dimension size caused by adding layer ${e.name} with input shape [${e.inboundNodes[0].inputTensors[0].shape}]`) } add(e) { const t = e instanceof ns || e instanceof Jo; let n; if (t) { if (n = e, 1 !== n.outputs.length) throw new or("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); if (1 !== n.inputs.length) throw new or("All layers in a Sequential model should have a single input tensor. For multi-input layers, use the functional API.") } if (0 === this.outputs.length) { if (0 === e.inboundNodes.length) { if (null == e.batchInputShape) throw new or("The first layer in a Sequential model must get an `inputShape` or `batchInputShape` argument."); const t = ta({ batchShape: e.batchInputShape, dtype: e.dtype, name: e.name + "_input" }); e.apply(t) } if (t) this.outputs = n.outputs, this.inputs = n.inputs; else { if (1 !== e.inboundNodes.length) throw new or(`A layer added to a Sequential model must not already be connected somewhere else. LayersModel received layer ${e.name} which has ${e.inboundNodes.length} pre-existing inbound connections.`); if (1 !== e.inboundNodes[0].outputTensors.length) throw new or("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); this.checkShape(e), this.outputs = [e.inboundNodes[0].outputTensors[0]], this.inputs = Qi(this.outputs[0]) } this.inboundNodes = [], new Ki({ outboundLayer: this, inboundLayers: [], nodeIndices: [], tensorIndices: [], inputTensors: this.inputs, outputTensors: this.outputs, inputMasks: cr(null, this.inputs.length), outputMasks: [null], inputShapes: this.inputs.map((e => e.shape)), outputShapes: this.outputs[0].shape }) } else { const t = e.apply(this.outputs[0]); if (Array.isArray(t)) throw new TypeError("All layers in a Sequential model should have a single output tensor. For multi-output layers, use the functional API."); this.checkShape(e), this.outputs = [t], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape] } this.layers.push(e), this.built = !1 } pop() { if (0 === this.layers.length) throw new TypeError("There are no layers in the model."); if (this.layers.pop(), 0 === this.layers.length) this.outputs = [], this.inboundNodes = [], this.outboundNodes = []; else { const e = this.layers.length - 1; this.layers[e].outboundNodes = [], this.outputs = [this.layers[e].output], this.inboundNodes[0].outputTensors = this.outputs, this.inboundNodes[0].outputShapes = [this.outputs[0].shape] } } call(e, t) { return null == this.model && this.build(), this.model.call(e, t) } build(e) { if (ji(e), 0 === this.inputs.length || 0 === this.outputs.length) throw new TypeError("Sequential model cannot be built: model is empty. Add some layers first."); this.model = new Jo({ inputs: this.inputs, outputs: this.outputs[0], name: this.name + "_model" }), this.model.trainable = this.trainable, this.supportsMasking = this.model.supportsMasking, this.inputLayers = this.model.inputLayers, this.inputLayersNodeIndices = this.model.inputLayersNodeIndices, this.inputLayersTensorIndices = this.model.inputLayersTensorIndices, this.outputLayers = this.model.outputLayers, this.outputLayersNodeIndices = this.model.outputLayersNodeIndices, this.outputLayersTensorIndices = this.model.outputLayersTensorIndices, this.nodesByDepth = this.model.nodesByDepth, this.containerNodes = this.model.containerNodes, this.outputNames = this.model.outputNames, this.inputNames = this.model.inputNames, this.built = !0 } countParams() { return this.built || this.build(), super.countParams() } summary(e, t, n = console.log) { this.built || this.build(), super.summary(e, t, n) } setWeights(e) { null == this.model && this.build(), this.model.setWeights(e) } evaluate(e, t, n = {}) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.evaluate(e, t, n) } async evaluateDataset(e, t) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.evaluateDataset(e, t) } predict(e, t = {}) { return null == this.model && this.build(), this.model.predict(e, t) } predictOnBatch(e) { return null == this.model && this.build(), this.model.predictOnBatch(e) } compile(e) { this.build(), this.model.compile(e), this.optimizer_ = this.model.optimizer, this.isOptimizerOwned = this.model.isOptimizerOwned, this.loss = this.model.loss, this.metrics = this.model.metrics, this.metricsTensors = this.model.metricsTensors, this.metricsNames = this.model.metricsNames } get optimizer() { return null == this.model ? void 0 : this.model.optimizer } set optimizer(e) { this.model.optimizer = e } async fit(e, t, n = {}) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.fit(e, t, n) } async fitDataset(e, t) { if (!this.built) throw new ar("The model needs to be compiled before being used."); return this.model.fitDataset(e, t) } async trainOnBatch(e, t) { return this.model.trainOnBatch(e, t) } static fromConfig(e, t, n = {}, r = !1) { let i, a = {}; if (t instanceof Array) { if (null == t[0].className || "Merge" === t[0].className) throw new or("Legacy serialization format not supported yet."); i = t } else P.util.assert(null != t.layers, (() => "When the config data for a Sequential model is not an Array, it must be an Object that contains the 'layers' field.")), i = t.layers, delete t.layers, a = t; const o = new e(a); if (!(o instanceof ns)) throw new sr(`Sequential.fromConfig called on non-Sequential input: ${o}`); for (const e of i) { const t = Ka(e, void 0, r); r && t.setFastWeightInitDuringBuild(!0), o.add(t) } return o } set stopTraining(e) { if (null == this.model) throw new or("Cannot set the stopTraining property of a sequential model before it is compiled."); this.model.stopTraining = e } get stopTraining() { if (null == this.model) throw new or("Cannot get the stopTraining property of a sequential model before it is compiled."); return this.model.stopTraining } getConfig() { const e = []; for (const t of this.layers) { const n = {}; n.className = t.getClassName(), n.config = t.getConfig(), e.push(n) } return { name: this.name, layers: e } } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function rs(e) { return new Jo(e) } function is(e) { return new ns(e) } function as(e) { return ta(e) } function os(e, t) { Ya.registerCallbackConstructor(e, t) } ns.className = "Sequential", P.serialization.registerClass(ns);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ss extends P.serialization.Serializable { getConfig() { return {} } } class us extends ss { apply(e, t = 1) { return function (e, t = 1) { if (1 !== t) throw new sr(`Support for alpha values other than 1 (${t}) is not implemented yet.`); return P.elu(e) }(e, t) } } us.className = "elu", P.serialization.registerClass(us); class ls extends ss { apply(e) { return P.selu(e) } } ls.className = "selu", P.serialization.registerClass(ls); class cs extends ss { apply(e) { return P.relu(e) } } cs.className = "relu", P.serialization.registerClass(cs); class hs extends ss { apply(e) { return (0, P.tidy)((() => P.minimum(6, P.relu(e)))) } } hs.className = "relu6", P.serialization.registerClass(hs); class ds extends ss { apply(e) { return e } } ds.className = "linear", P.serialization.registerClass(ds); class fs extends ss { apply(e) { return P.sigmoid(e) } } fs.className = "sigmoid", P.serialization.registerClass(fs); class ps extends ss { apply(e) { return function (e) { return (0, P.tidy)((() => { const t = P.add(.5, P.mul(.2, e)); return P.clipByValue(t, 0, 1) })) }(e) } } ps.className = "hardSigmoid", P.serialization.registerClass(ps); class ms extends ss { apply(e) { return P.softplus(e) } } ms.className = "softplus", P.serialization.registerClass(ms); class gs extends ss { apply(e) { return function (e) { return (0, P.tidy)((() => P.div(e, P.add(P.abs(e), 1)))) }(e) } } gs.className = "softsign", P.serialization.registerClass(gs); class ys extends ss { apply(e) { return P.tanh(e) } } ys.className = "tanh", P.serialization.registerClass(ys); class bs extends ss { apply(e, t = -1) { return P.softmax(e, t) } } bs.className = "softmax", P.serialization.registerClass(bs); class vs extends ss { apply(e, t = -1) { return P.logSoftmax(e, t) } } vs.className = "logSoftmax", P.serialization.registerClass(vs); class xs extends ss { apply(e) { return (0, P.tidy)((() => P.tidy((() => { const t = Math.sqrt(2), n = P.mul(.5, P.add(1, P.erf(P.div(e, t)))); return P.mul(e, n) })))) } } xs.className = "gelu", P.serialization.registerClass(xs); class ws extends ss { apply(e) { return (0, P.tidy)((() => P.mul(.5, P.mul(e, P.add(1, P.tanh(P.mul(P.sqrt(P.div(2, Math.PI)), P.add(e, P.mul(.044715, P.pow(e, 3)))))))))) } } ws.className = "gelu_new", P.serialization.registerClass(ws); class ks extends ss { apply(e) { return (0, P.tidy)((() => P.mul(e, P.tanh(P.softplus(e))))) } } ks.className = "mish", P.serialization.registerClass(ks); class Ss extends ss { apply(e, t = 1) { return (0, P.tidy)((() => P.mul(P.sigmoid(P.mul(e, t)), e))) } } function _s(e) { return e.getClassName() } function Cs(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "activation") } function As(e) { if (null == e) { const e = { className: "linear", config: {} }; return Cs(e) } if ("string" == typeof e) { const t = {}; return t.className = e, t.config = {}, Cs(t) } return e instanceof ss ? e : Cs(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ts(e) { if (null != e && "object" != typeof e) throw new Error(`Argument to L1L2 regularizer's constructor is expected to be an object, but received: ${e}`) } Ss.className = "swish", P.serialization.registerClass(Ss); class Es extends P.serialization.Serializable { } class Ns extends Es { constructor(e) { super(), Ts(e), this.l1 = null == e || null == e.l1 ? .01 : e.l1, this.l2 = null == e || null == e.l2 ? .01 : e.l2, this.hasL1 = 0 !== this.l1, this.hasL2 = 0 !== this.l2 } apply(e) { return (0, P.tidy)((() => { let t = (0, P.zeros)([1]); return this.hasL1 && (t = (0, P.add)(t, (0, P.sum)(P.mul(this.l1, (0, P.abs)(e))))), this.hasL2 && (t = (0, P.add)(t, (0, P.sum)(P.mul(this.l2, hi(e))))), P.reshape(t, []) })) } getConfig() { return { l1: this.l1, l2: this.l2 } } static fromConfig(e, t) { return new e({ l1: t.l1, l2: t.l2 }) } } Ns.className = "L1L2", P.serialization.registerClass(Ns); const Is = { l1l2: "L1L2" }; function Ms(e) { return br(e) } function Fs(e, t = {}) { return xr(e, P.serialization.SerializationMap.getMap().classNameMap, t, "regularizer") } function Ds(e) { if (null == e) return null; if ("string" == typeof e) { return Fs({ className: e in Is ? Is[e] : e, config: {} }) } return e instanceof Es ? e : Fs(e) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class $s extends Ji { constructor(e) { super(null == e ? {} : e), this.supportsMasking = !0, null != e && (this.maxValue = e.maxValue) } call(e, t) { e = Li(e); let n = (0, P.relu)(e); return null != this.maxValue && (n = (0, P.clipByValue)(n, 0, this.maxValue)), n } computeOutputShape(e) { return e } getConfig() { const e = { maxValue: this.maxValue }, t = super.getConfig(); return Object.assign(e, t), e } } $s.className = "ReLU", P.serialization.registerClass($s); class Rs extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_ALPHA = .3, null == e && (e = {}), this.alpha = null == e.alpha ? this.DEFAULT_ALPHA : e.alpha } call(e, t) { const n = Li(e); return (0, P.leakyRelu)(n, this.alpha) } computeOutputShape(e) { return e } getConfig() { const e = { alpha: this.alpha }, t = super.getConfig(); return Object.assign(e, t), e } } Rs.className = "LeakyReLU", P.serialization.registerClass(Rs); class Os extends Ji { constructor(e) { if (super(null == e ? {} : e), this.DEFAULT_ALPHA_INITIALIZER = "zeros", null == e && (e = {}), this.supportsMasking = !0, this.alphaInitializer = zi(e.alphaInitializer || this.DEFAULT_ALPHA_INITIALIZER), this.alphaRegularizer = Ds(e.alphaRegularizer), this.alphaConstraint = ba(e.alphaConstraint), null == e.sharedAxes) this.sharedAxes = null; else if (Array.isArray(e.sharedAxes)) this.sharedAxes = e.sharedAxes; else { if ("number" != typeof e.sharedAxes) throw new or(`Expected sharedAxes to be a number or an array of numbers, but got ${e.sharedAxes}`); this.sharedAxes = [e.sharedAxes] } } build(e) { const t = (e = ji(e)).slice(1); if (null != this.sharedAxes) for (const e of this.sharedAxes) t[e - 1] = 1; this.alpha = this.addWeight("alpha", t, "float32", this.alphaInitializer, this.alphaRegularizer, !0, this.alphaConstraint); const n = {}; if (null != this.sharedAxes) for (let t = 1; t < e.length; ++t)n[t] = e[t]; this.inputSpec = [new qi({ ndim: e.length, axes: n })], this.built = !0 } call(e, t) { return e = Li(e), (0, P.prelu)(e, this.alpha.read()) } getConfig() { const e = { alphaInitializer: Oi(this.alphaInitializer), alphaRegularizer: Ms(this.alphaRegularizer), alphaConstraint: ga(this.alphaConstraint), sharedAxes: this.sharedAxes }, t = super.getConfig(); return Object.assign(e, t), e } } Os.className = "PReLU", P.serialization.registerClass(Os); class zs extends Ji { constructor(e) { if (super(null == e ? {} : e), this.DEFAULT_ALPHA = 1, null == e && (e = {}), null != e.alpha && e.alpha !== this.DEFAULT_ALPHA) throw new sr(`Non-default alpha value (${e.alpha}) is not supported by the ELU layer yet.`); this.alpha = null == e.alpha ? this.DEFAULT_ALPHA : e.alpha } call(e, t) { const n = Li(e); return (0, P.elu)(n) } computeOutputShape(e) { return e } getConfig() { const e = { alpha: this.alpha }, t = super.getConfig(); return Object.assign(e, t), e } } zs.className = "ELU", P.serialization.registerClass(zs); class Ps extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_THETA = 1, null == e && (e = {}), this.theta = null == e.theta ? this.DEFAULT_THETA : e.theta } call(e, t) { const n = Li(e); return (0, P.mul)(n, (0, P.cast)((0, P.greater)(n, this.theta), "float32")) } computeOutputShape(e) { return e } getConfig() { const e = { theta: this.theta }, t = super.getConfig(); return Object.assign(e, t), e } } Ps.className = "ThresholdedReLU", P.serialization.registerClass(Ps); class Bs extends Ji { constructor(e) { super(null == e ? {} : e), this.DEFAULT_AXIS = 1, null == e && (e = {}), this.softmax = (new bs).apply, this.axis = null == e.axis ? this.DEFAULT_AXIS : e.axis } call(e, t) { return (0, P.tidy)((() => { let n = Li(e); const r = t.mask; if (null != r) { const e = (0, P.mul)((0, P.sub)((0, P.ones)(n.shape), (0, P.cast)(r, n.dtype)), (0, P.scalar)(-1e9)); n = (0, P.add)(n, e) } return this.axis instanceof Array ? this.axis.length > 1 ? (0, P.exp)((0, P.sub)(n, (0, P.logSumExp)(n, this.axis, !0))) : this.softmax(n, this.axis[0]) : this.softmax(n, this.axis) })) } computeOutputShape(e) { return e } getConfig() { const e = { axis: this.axis }, t = super.getConfig(); return Object.assign(e, t), e } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ls(e, t, n) {
if ("number" == typeof e) return cr(e, t); if (e.length !== t) throw new or(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${e.length} elements.`); for (let i = 0; i < t; ++i) { const a = e[i]; if ((r = a) !== parseInt(r.toString(), 10)) throw new or(`The ${n} argument must be an integer or tuple of ${t} integers. Received: ${JSON.stringify(e)} including a non-integer number ${a}`) } return e;
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var r
} function js(e, t, n, r, i = 1) { if (null == e) return e; let a; return a = "same" === n ? e : e - (t + (t - 1) * (i - 1)) + 1, Math.floor((a + r - 1) / r) } function Us(e, t, n, r) { if (null == e) return null; if ("valid" === r) e = e * t + Kr([n - t, 0]); else { if ("same" !== r) throw new or(`Unsupport padding mode: ${r}.`); e *= t } return e }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Ws(e, t) { return (0, P.tidy)((() => (Br(t), "channelsFirst" === t ? P.transpose(e, [0, 2, 3, 1]) : e))) } function Vs(e, t) { return (0, P.tidy)((() => (Br(t), "channelsFirst" === t ? P.transpose(e, [0, 2, 3, 4, 1]) : e))) } function Gs(e, t, n, r = 1, i = "valid", a, o = 1) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 3 !== e.shape.length) throw new or(`The input of a conv1dWithBias operation should be 3, but is ${e.shape.length} instead.`); if (3 !== t.shape.length) throw new or(`The kernel for a conv1dWithBias operation should be 3, but is ${t.shape.length} instead`); if (null != n && 1 !== n.shape.length) throw new or(`The bias for a conv1dWithBias operation should be 1, but is ${n.shape.length} instead`); if ("channelsFirst" === a && (e = P.transpose(e, [0, 2, 1])), "causal" === i) throw new sr("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet."); let s = P.conv1d(e, t, r, "same" === i ? "same" : "valid", "NWC", o); return null != n && (s = fi(s, n)), s })) } function Hs(e, t, n, r = [1, 1], i = "valid", a, o, s = null) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 3 !== e.rank && 4 !== e.rank) throw new or(`conv2dWithBiasActivation expects input to be of rank 3 or 4, but received ${e.rank}.`); if (3 !== t.rank && 4 !== t.rank) throw new or(`conv2dWithBiasActivation expects kernel to be of rank 3 or 4, but received ${e.rank}.`); let u = Ws(e, a); if ("causal" === i) throw new sr("The support for CAUSAL padding mode in conv1dWithBias is not implemented yet."); return u = P.fused.conv2d({ x: u, filter: t, strides: r, pad: "same" === i ? "same" : "valid", dilations: o, dataFormat: "NHWC", bias: n, activation: s }), "channelsFirst" === a && (u = P.transpose(u, [0, 3, 1, 2])), u })) } function qs(e, t, n, r = [1, 1, 1], i = "valid", a, o) { return (0, P.tidy)((() => { if (null == a && (a = "channelsLast"), Br(a), 4 !== e.rank && 5 !== e.rank) throw new or(`conv3dWithBias expects input to be of rank 4 or 5, but received ${e.rank}.`); if (4 !== t.rank && 5 !== t.rank) throw new or(`conv3dWithBias expects kernel to be of rank 4 or 5, but received ${e.rank}.`); let s = Vs(e, a); if ("causal" === i) throw new sr("The support for CAUSAL padding mode in conv3dWithBias is not implemented yet."); return s = P.conv3d(s, t, r, "same" === i ? "same" : "valid", "NDHWC", o), null != n && (s = fi(s, n)), "channelsFirst" === a && (s = P.transpose(s, [0, 4, 1, 2, 3])), s })) } Bs.className = "Softmax", P.serialization.registerClass(Bs); class Ys extends Ji { constructor(e, t) { if (super(t), this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", Ys.verifyArgs(t), this.rank = e, Ar(this.rank, "rank"), 1 !== this.rank && 2 !== this.rank && 3 !== this.rank) throw new sr(`Convolution layer for rank other than 1, 2, or 3 (${this.rank}) is not implemented yet.`); if (this.kernelSize = Ls(t.kernelSize, e, "kernelSize"), this.strides = Ls(null == t.strides ? 1 : t.strides, e, "strides"), this.padding = null == t.padding ? "valid" : t.padding, Lr(this.padding), this.dataFormat = null == t.dataFormat ? "channelsLast" : t.dataFormat, Br(this.dataFormat), this.activation = As(t.activation), this.useBias = null == t.useBias || t.useBias, this.biasInitializer = zi(t.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.biasConstraint = ba(t.biasConstraint), this.biasRegularizer = Ds(t.biasRegularizer), this.activityRegularizer = Ds(t.activityRegularizer), this.dilationRate = Ls(null == t.dilationRate ? 1 : t.dilationRate, e, "dilationRate"), 1 === this.rank && Array.isArray(this.dilationRate) && 1 !== this.dilationRate.length) throw new or(`dilationRate must be a number or an array of a single number for 1D convolution, but received ${JSON.stringify(this.dilationRate)}`); if (2 === this.rank) { if ("number" == typeof this.dilationRate) this.dilationRate = [this.dilationRate, this.dilationRate]; else if (2 !== this.dilationRate.length) throw new or(`dilationRate must be a number or array of two numbers for 2D convolution, but received ${JSON.stringify(this.dilationRate)}`) } else if (3 === this.rank) if ("number" == typeof this.dilationRate) this.dilationRate = [this.dilationRate, this.dilationRate, this.dilationRate]; else if (3 !== this.dilationRate.length) throw new or(`dilationRate must be a number or array of three numbers for 3D convolution, but received ${JSON.stringify(this.dilationRate)}`) } static verifyArgs(e) { if (hr("kernelSize" in e, "required key 'kernelSize' not in config"), "number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 3)) throw new or(`BaseConv expects config.kernelSize to be number or number[] with length 1, 2, or 3, but received ${JSON.stringify(e.kernelSize)}.`) } getConfig() { const e = { kernelSize: this.kernelSize, strides: this.strides, padding: this.padding, dataFormat: this.dataFormat, dilationRate: this.dilationRate, activation: _s(this.activation), useBias: this.useBias, biasInitializer: Oi(this.biasInitializer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), biasConstraint: ga(this.biasConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } class Xs extends Ys { constructor(e, t) { super(e, t), this.kernel = null, Xs.verifyArgs(t), this.filters = t.filters, Ar(this.filters, "filters"), this.kernelInitializer = zi(t.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.kernelConstraint = ba(t.kernelConstraint), this.kernelRegularizer = Ds(t.kernelRegularizer) } build(e) { e = ji(e); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or(`The channel dimension of the input should be defined. Found ${e[t]}`); const n = e[t], r = this.kernelSize.concat([n, this.filters]); this.kernel = this.addWeight("kernel", r, null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [{ ndim: this.rank + 2, axes: { [t]: n } }], this.built = !0 } call(e, t) { return (0, P.tidy)((() => { let t; e = Li(e); const n = null == this.bias ? null : this.bias.read(), r = Er(this.activation.getClassName()); if (null != r && 2 === this.rank) t = Hs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate, r); else { if (1 === this.rank) t = Gs(e, this.kernel.read(), n, this.strides[0], this.padding, this.dataFormat, this.dilationRate[0]); else if (2 === this.rank) t = Hs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate); else { if (3 !== this.rank) throw new sr("convolutions greater than 3D are not implemented yet."); t = qs(e, this.kernel.read(), n, this.strides, this.padding, this.dataFormat, this.dilationRate) } null != this.activation && (t = this.activation.apply(t)) } return t })) } computeOutputShape(e) { e = ji(e); const t = [], n = "channelsLast" === this.dataFormat ? e.slice(1, e.length - 1) : e.slice(2); for (let e = 0; e < n.length; ++e) { const r = js(n[e], this.kernelSize[e], this.padding, this.strides[e], "number" == typeof this.dilationRate ? this.dilationRate : this.dilationRate[e]); t.push(r) } let r = [e[0]]; return "channelsLast" === this.dataFormat ? (r = r.concat(t), r.push(this.filters)) : (r.push(this.filters), r = r.concat(t)), r } getConfig() { const e = { filters: this.filters, kernelInitializer: Oi(this.kernelInitializer), kernelRegularizer: Ms(this.kernelRegularizer), kernelConstraint: ga(this.kernelConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } static verifyArgs(e) { if (!("filters" in e) || "number" != typeof e.filters || e.filters < 1) throw new or(`Convolution layer expected config.filters to be a 'number' > 0 but got ${JSON.stringify(e.filters)}`) } } class Ks extends Xs { constructor(e) { super(2, e), Ks.verifyArgs(e) } getConfig() { const e = super.getConfig(); return delete e.rank, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 2)) throw new or(`Conv2D expects config.kernelSize to be number or number[] with length 1 or 2, but received ${JSON.stringify(e.kernelSize)}.`) } } Ks.className = "Conv2D", P.serialization.registerClass(Ks); class Zs extends Xs { constructor(e) { super(3, e), Zs.verifyArgs(e) } getConfig() { const e = super.getConfig(); return delete e.rank, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && (!Array.isArray(e.kernelSize) || 1 !== e.kernelSize.length && 3 !== e.kernelSize.length)) throw new or(`Conv3D expects config.kernelSize to be number or [number, number, number], but received ${JSON.stringify(e.kernelSize)}.`) } } Zs.className = "Conv3D", P.serialization.registerClass(Zs); class Js extends Ks { constructor(e) { if (super(e), this.inputSpec = [new qi({ ndim: 4 })], "same" !== this.padding && "valid" !== this.padding) throw new or(`Conv2DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`) } build(e) { if (4 !== (e = ji(e)).length) throw new or("Input should have rank 4; Received input shape: " + JSON.stringify(e)); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or("The channel dimension of the inputs should be defined. Found `None`."); const n = e[t], r = this.kernelSize.concat([this.filters, n]); this.kernel = this.addWeight("kernel", r, "float32", this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [new qi({ ndim: 4, axes: { [t]: n } })], this.built = !0 } call(e, t) { return P.tidy((() => { let t = Li(e); if (4 !== t.shape.length) throw new or(`Conv2DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`); const n = t.shape, r = n[0]; let i, a; "channelsFirst" === this.dataFormat ? (i = 2, a = 3) : (i = 1, a = 2); const o = n[i], s = n[a], u = this.kernelSize[0], l = this.kernelSize[1], c = this.strides[0], h = this.strides[1], d = [r, Us(o, c, u, this.padding), Us(s, h, l, this.padding), this.filters]; "channelsLast" !== this.dataFormat && (t = P.transpose(t, [0, 2, 3, 1])); let f = P.conv2dTranspose(t, this.kernel.read(), d, this.strides, this.padding); return "channelsLast" !== this.dataFormat && (f = P.transpose(f, [0, 3, 1, 2])), null != this.bias && (f = fi(f, this.bias.read(), this.dataFormat)), null != this.activation && (f = this.activation.apply(f)), f })) } computeOutputShape(e) { const t = (e = ji(e)).slice(); let n, r, i; "channelsFirst" === this.dataFormat ? (n = 1, r = 2, i = 3) : (n = 3, r = 1, i = 2); const a = this.kernelSize[0], o = this.kernelSize[1], s = this.strides[0], u = this.strides[1]; return t[n] = this.filters, t[r] = Us(t[r], s, a, this.padding), t[i] = Us(t[i], u, o, this.padding), t } getConfig() { const e = super.getConfig(); return delete e.dilationRate, e } } Js.className = "Conv2DTranspose", P.serialization.registerClass(Js); class Qs extends Zs { constructor(e) { if (super(e), this.inputSpec = [new qi({ ndim: 5 })], "same" !== this.padding && "valid" !== this.padding) throw new or(`Conv3DTranspose currently supports only padding modes 'same' and 'valid', but received padding mode ${this.padding}`) } build(e) { if (5 !== (e = ji(e)).length) throw new or("Input should have rank 5; Received input shape: " + JSON.stringify(e)); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t]) throw new or("The channel dimension of the inputs should be defined. Found `None`."); const n = e[t], r = this.kernelSize.concat([this.filters, n]); this.kernel = this.addWeight("kernel", r, "float32", this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint)), this.inputSpec = [new qi({ ndim: 5, axes: { [t]: n } })], this.built = !0 } call(e, t) { return P.tidy((() => { let t = Li(e); if (5 !== t.shape.length) throw new or(`Conv3DTranspose.call() expects input tensor to be rank-4, but received a tensor of rank-${t.shape.length}`); const n = t.shape, r = n[0]; let i, a, o; "channelsFirst" === this.dataFormat ? (o = 2, i = 3, a = 4) : (o = 1, i = 2, a = 3); const s = n[o], u = n[i], l = n[a], c = this.kernelSize[0], h = this.kernelSize[1], d = this.kernelSize[2], f = this.strides[0], p = this.strides[1], m = this.strides[2], g = [r, Us(s, f, c, this.padding), Us(u, p, h, this.padding), Us(l, m, d, this.padding), this.filters]; "channelsLast" !== this.dataFormat && (t = P.transpose(t, [0, 2, 3, 4, 1])); let y = P.conv3dTranspose(t, this.kernel.read(), g, this.strides, this.padding); return "channelsLast" !== this.dataFormat && (y = P.transpose(y, [0, 4, 1, 2, 3])), null !== this.bias && (y = fi(y, this.bias.read(), this.dataFormat)), null !== this.activation && (y = this.activation.apply(y)), y })) } computeOutputShape(e) { const t = (e = ji(e)).slice(); let n, r, i, a; "channelsFirst" === this.dataFormat ? (n = 1, r = 2, i = 3, a = 4) : (n = 4, r = 1, i = 2, a = 3); const o = this.kernelSize[0], s = this.kernelSize[1], u = this.kernelSize[2], l = this.strides[0], c = this.strides[1], h = this.strides[2]; return t[n] = this.filters, t[r] = Us(t[r], l, o, this.padding), t[i] = Us(t[i], c, s, this.padding), t[a] = Us(t[a], h, u, this.padding), t } getConfig() { const e = super.getConfig(); return delete e.dilationRate, e } } Qs.className = "Conv3DTranspose", P.serialization.registerClass(Qs); class eu extends Xs { constructor(e, t) { if (super(e, t), this.DEFAULT_DEPTHWISE_INITIALIZER = "glorotUniform", this.DEFAULT_POINTWISE_INITIALIZER = "glorotUniform", this.depthwiseKernel = null, this.pointwiseKernel = null, null == t.filters) throw new or("The `filters` configuration field is required by SeparableConv, but is unspecified."); if (null != t.kernelInitializer || null != t.kernelRegularizer || null != t.kernelConstraint) throw new or("Fields kernelInitializer, kernelRegularizer and kernelConstraint are invalid for SeparableConv2D. Use depthwiseInitializer, depthwiseRegularizer, depthwiseConstraint, pointwiseInitializer, pointwiseRegularizer and pointwiseConstraint instead."); if (null != t.padding && "same" !== t.padding && "valid" !== t.padding) throw new or(`SeparableConv${this.rank}D supports only padding modes: 'same' and 'valid', but received ${JSON.stringify(t.padding)}`); this.depthMultiplier = null == t.depthMultiplier ? 1 : t.depthMultiplier, this.depthwiseInitializer = zi(t.depthwiseInitializer || this.DEFAULT_DEPTHWISE_INITIALIZER), this.depthwiseRegularizer = Ds(t.depthwiseRegularizer), this.depthwiseConstraint = ba(t.depthwiseConstraint), this.pointwiseInitializer = zi(t.depthwiseInitializer || this.DEFAULT_POINTWISE_INITIALIZER), this.pointwiseRegularizer = Ds(t.pointwiseRegularizer), this.pointwiseConstraint = ba(t.pointwiseConstraint) } build(e) { if ((e = ji(e)).length < this.rank + 2) throw new or(`Inputs to SeparableConv${this.rank}D should have rank ${this.rank + 2}, but received input shape: ${JSON.stringify(e)}`); const t = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[t] || e[t] < 0) throw new or(`The channel dimension of the inputs should be defined, but found ${JSON.stringify(e[t])}`); const n = e[t], r = this.kernelSize.concat([n, this.depthMultiplier]), i = []; for (let e = 0; e < this.rank; ++e)i.push(1); i.push(n * this.depthMultiplier, this.filters); const a = !0; this.depthwiseKernel = this.addWeight("depthwise_kernel", r, "float32", this.depthwiseInitializer, this.depthwiseRegularizer, a, this.depthwiseConstraint), this.pointwiseKernel = this.addWeight("pointwise_kernel", i, "float32", this.pointwiseInitializer, this.pointwiseRegularizer, a, this.pointwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.filters], "float32", this.biasInitializer, this.biasRegularizer, a, this.biasConstraint) : this.bias = null, this.inputSpec = [new qi({ ndim: this.rank + 2, axes: { [t]: n } })], this.built = !0 } call(e, t) { return (0, P.tidy)((() => { let t; if (e = Li(e), 1 === this.rank) throw new sr("1D separable convolution is not implemented yet."); return 2 === this.rank && ("channelsFirst" === this.dataFormat && (e = P.transpose(e, [0, 2, 3, 1])), t = P.separableConv2d(e, this.depthwiseKernel.read(), this.pointwiseKernel.read(), this.strides, this.padding, this.dilationRate, "NHWC")), this.useBias && (t = fi(t, this.bias.read(), this.dataFormat)), null != this.activation && (t = this.activation.apply(t)), "channelsFirst" === this.dataFormat && (t = P.transpose(t, [0, 3, 1, 2])), t })) } getConfig() { const e = super.getConfig(); return delete e.rank, delete e.kernelInitializer, delete e.kernelRegularizer, delete e.kernelConstraint, e.depthwiseInitializer = Oi(this.depthwiseInitializer), e.pointwiseInitializer = Oi(this.pointwiseInitializer), e.depthwiseRegularizer = Ms(this.depthwiseRegularizer), e.pointwiseRegularizer = Ms(this.pointwiseRegularizer), e.depthwiseConstraint = ga(this.depthwiseConstraint), e.pointwiseConstraint = ga(this.pointwiseConstraint), e } } eu.className = "SeparableConv"; class tu extends eu { constructor(e) { super(2, e) } } tu.className = "SeparableConv2D", P.serialization.registerClass(tu); class nu extends Xs { constructor(e) { super(1, e), nu.verifyArgs(e), this.inputSpec = [{ ndim: 3 }] } getConfig() { const e = super.getConfig(); return delete e.rank, delete e.dataFormat, e } static verifyArgs(e) { if ("number" != typeof e.kernelSize && !Cr(e.kernelSize, "number", 1, 1)) throw new or(`Conv1D expects config.kernelSize to be number or number[] with length 1, but received ${JSON.stringify(e.kernelSize)}.`) } } nu.className = "Conv1D", P.serialization.registerClass(nu); class ru extends Ji { constructor(e) { super(e), "number" == typeof e.cropping ? this.cropping = [[e.cropping, e.cropping], [e.cropping, e.cropping]] : "number" == typeof e.cropping[0] ? this.cropping = [[e.cropping[0], e.cropping[0]], [e.cropping[1], e.cropping[1]]] : this.cropping = e.cropping, this.dataFormat = void 0 === e.dataFormat ? "channelsLast" : e.dataFormat, this.inputSpec = [{ ndim: 4 }] } computeOutputShape(e) { return "channelsFirst" === this.dataFormat ? [e[0], e[1], e[2] - this.cropping[0][0] - this.cropping[0][1], e[3] - this.cropping[1][0] - this.cropping[1][1]] : [e[0], e[1] - this.cropping[0][0] - this.cropping[0][1], e[2] - this.cropping[1][0] - this.cropping[1][1], e[3]] } call(e, t) { return (0, P.tidy)((() => { if (e = Li(e), "channelsLast" === this.dataFormat) { const t = ii(e, this.cropping[0][0], e.shape[1] - this.cropping[0][0] - this.cropping[0][1], 2); return ii(t, this.cropping[1][0], e.shape[2] - this.cropping[1][1] - this.cropping[1][0], 3) } { const t = ii(e, this.cropping[0][0], e.shape[2] - this.cropping[0][0] - this.cropping[0][1], 3); return ii(t, this.cropping[1][0], e.shape[3] - this.cropping[1][1] - this.cropping[1][0], 4) } })) } getConfig() { const e = { cropping: this.cropping, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } ru.className = "Cropping2D", P.serialization.registerClass(ru); class iu extends Ji { constructor(e) { var t; super(e), this.DEFAULT_SIZE = [2, 2], this.inputSpec = [{ ndim: 4 }], this.size = null == e.size ? this.DEFAULT_SIZE : e.size, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), this.interpolation = null == e.interpolation ? "nearest" : e.interpolation, t = this.interpolation, _r($r, "InterpolationFormat", t) } computeOutputShape(e) { if ("channelsFirst" === this.dataFormat) { const t = null == e[2] ? null : this.size[0] * e[2], n = null == e[3] ? null : this.size[1] * e[3]; return [e[0], e[1], t, n] } { const t = null == e[1] ? null : this.size[0] * e[1], n = null == e[2] ? null : this.size[1] * e[2]; return [e[0], t, n, e[3]] } } call(e, t) { return P.tidy((() => { let t = Li(e); const n = t.shape; if ("channelsFirst" === this.dataFormat) { t = P.transpose(t, [0, 2, 3, 1]); const e = this.size[0] * n[2], r = this.size[1] * n[3], i = "nearest" === this.interpolation ? P.image.resizeNearestNeighbor(t, [e, r]) : P.image.resizeBilinear(t, [e, r]); return P.transpose(i, [0, 3, 1, 2]) } { const e = this.size[0] * n[1], r = this.size[1] * n[2]; return "nearest" === this.interpolation ? P.image.resizeNearestNeighbor(t, [e, r]) : P.image.resizeBilinear(t, [e, r]) } })) } getConfig() { const e = { size: this.size, dataFormat: this.dataFormat, interpolation: this.interpolation }, t = super.getConfig(); return Object.assign(e, t), e } } iu.className = "UpSampling2D", P.serialization.registerClass(iu); class au extends Ys {
constructor(e) { super(2, e), this.depthwiseKernel = null, this.depthMultiplier = null == e.depthMultiplier ? 1 : e.depthMultiplier, this.depthwiseInitializer = zi(e.depthwiseInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.depthwiseConstraint = ba(e.depthwiseConstraint), this.depthwiseRegularizer = Ds(e.depthwiseRegularizer) } build(e) { if ((e = ji(e)).length < 4) throw new or(`Inputs to DepthwiseConv2D should have rank 4. Received input shape: ${JSON.stringify(e)}.`); const t = "channelsFirst" === this.dataFormat ? 1 : 3; if (null == e[t] || e[t] < 0) throw new or(`The channel dimension of the inputs to DepthwiseConv2D should be defined, but is not (${e[t]}).`); const n = e[t], r = [this.kernelSize[0], this.kernelSize[1], n, this.depthMultiplier]; this.depthwiseKernel = this.addWeight("depthwise_kernel", r, null, this.depthwiseInitializer, this.depthwiseRegularizer, !0, this.depthwiseConstraint), this.useBias ? this.bias = this.addWeight("bias", [n * this.depthMultiplier], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) {
return (0, P.tidy)((() => {
let t =
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function (e, t, n = [1, 1], r = "valid", i, a) { return (0, P.tidy)((() => { null == i && (i = "channelsLast"), Br(i); let o = Ws(e, i); if (4 !== e.rank) throw new or(`Input for depthwiseConv2d is required to be 4-D, but is instead ${e.rank}-D`); if (4 !== t.rank) throw new or(`depthwiseKernel is required to be 4-D, but is instead ${t.rank}-D`); return o = P.depthwiseConv2d(o, t, n, "same" === r ? "same" : "valid", "NHWC", a), "channelsFirst" === i && (o = P.transpose(o, [0, 3, 1, 2])), o })) }(e = Li(e), this.depthwiseKernel.read(), this.strides, this.padding, this.dataFormat, null); return this.useBias && (t = fi(t, this.bias.read(), this.dataFormat)), null != this.activation && (t = this.activation.apply(t)), t
}))
} computeOutputShape(e) { e = ji(e); const t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2], r = "channelsFirst" === this.dataFormat ? e[1] * this.depthMultiplier : e[3] * this.depthMultiplier, i = js(t, this.kernelSize[0], this.padding, this.strides[0]), a = js(n, this.kernelSize[1], this.padding, this.strides[1]); return "channelsFirst" === this.dataFormat ? [e[0], r, i, a] : [e[0], i, a, r] } getConfig() { const e = super.getConfig(); return e.depthMultiplier = this.depthMultiplier, e.depthwiseInitializer = Oi(this.depthwiseInitializer), e.depthwiseRegularizer = Ms(this.depthwiseRegularizer), e.depthwiseConstraint = ga(this.depthwiseRegularizer), e }
}
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function ou(e, t, n, r) { if (Array.isArray(e)) { if (null != t || null != n) throw new or("When inputs is an array, neither initialState or constants should be provided"); null != r && (n = e.slice(e.length - r, e.length), e = e.slice(0, e.length - r)), e.length > 1 && (t = e.slice(1, e.length)), e = e[0] } function i(e) { return null == e || Array.isArray(e) ? e : [e] } return { inputs: e, initialState: t = i(t), constants: n = i(n) } } function su(e, t, n, r = !1, i, a, o = !1, s = !1) { return P.tidy((() => { const u = t.shape.length; if (u < 3) throw new or(`Input should be at least 3D, but is ${u}D.`); const l = [1, 0].concat(Zr(2, u)); if (t = P.transpose(t, l), null != a) throw new sr("The rnn() functoin of the deeplearn.js backend does not support constants yet."); o && console.warn("Backend rnn(): the unroll = true option is not applicable to the imperative deeplearn.js backend."), null != i && ((i = P.cast(P.cast(i, "bool"), "float32")).rank === u - 1 && (i = P.expandDims(i, -1)), i = P.transpose(i, l)), r && (t = P.reverse(t, 0), null != i && (i = P.reverse(i, 0))); const c = []; let h, d = n; const f = t.shape[0], p = P.unstack(t); let m, g; null != i && (m = P.unstack(i)); for (let t = 0; t < f; ++t) { const n = p[t], r = P.tidy((() => e(n, d))); if (null == i) h = r[0], d = r[1]; else { const e = P.tidy((() => { const e = m[t], n = P.sub(P.onesLike(e), e); return { output: P.add(P.mul(r[0], e), P.mul(d[0], n)), newStates: d.map(((t, i) => P.add(P.mul(r[1][i], e), P.mul(t, n)))) } })); h = e.output, d = e.newStates } s && c.push(h) } if (s) { const e = 1; g = P.stack(c, e) } return [h, g, d] })) } au.className = "DepthwiseConv2D", P.serialization.registerClass(au); class uu extends Ji { constructor(e) { let t; if (super(e), null == e.cell) throw new or("cell property is missing for the constructor of RNN."); if (t = Array.isArray(e.cell) ? new gu({ cells: e.cell }) : e.cell, null == t.stateSize) throw new or("The RNN cell should have an attribute `stateSize` (tuple of integers, one integer per RNN state)."); this.cell = t, this.returnSequences = null != e.returnSequences && e.returnSequences, this.returnState = null != e.returnState && e.returnState, this.goBackwards = null != e.goBackwards && e.goBackwards, this._stateful = null != e.stateful && e.stateful, this.unroll = null != e.unroll && e.unroll, this.supportsMasking = !0, this.inputSpec = [new qi({ ndim: 3 })], this.stateSpec = null, this.states_ = null, this.numConstants = null, this.keptStates = [] } getStates() { if (null == this.states_) { return Zr(0, Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1).map((e => null)) } return this.states_ } setStates(e) { this.states_ = e } computeOutputShape(e) { Pi(e) && (e = e[0]); let t = this.cell.stateSize; Array.isArray(t) || (t = [t]); const n = t[0]; let r; if (r = this.returnSequences ? [e[0], e[1], n] : [e[0], n], this.returnState) { const n = []; for (const r of t) n.push([e[0], r]); return [r].concat(n) } return r } computeMask(e, t) { return P.tidy((() => { Array.isArray(t) && (t = t[0]); const e = this.returnSequences ? t : null; if (this.returnState) { const t = this.states.map((e => null)); return [e].concat(t) } return e })) } get states() { if (null == this.states_) { const e = Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1, t = []; for (let n = 0; n < e; ++n)t.push(null); return t } return this.states_ } set states(e) { this.states_ = e } build(e) { if (null != this.numConstants) throw new sr("Constants support is not implemented in RNN yet."); Pi(e) && (e = e[0]); const t = this.stateful ? e[0] : null, n = e.slice(2); this.inputSpec[0] = new qi({ shape: [t, null, ...n] }); const r = [e[0]].concat(e.slice(2)); let i; if (this.cell.build(r), i = Array.isArray(this.cell.stateSize) ? this.cell.stateSize : [this.cell.stateSize], null != this.stateSpec) { if (!P.util.arraysEqual(this.stateSpec.map((e => e.shape[e.shape.length - 1])), i)) throw new or(`An initialState was passed that is not compatible with cell.stateSize. Received stateSpec=${this.stateSpec}; However cell.stateSize is ${this.cell.stateSize}`) } else this.stateSpec = i.map((e => new qi({ shape: [null, e] }))); this.stateful && this.resetStates() } resetStates(e, t = !1) { (0, P.tidy)((() => { if (!this.stateful) throw new ir("Cannot call resetStates() on an RNN Layer that is not stateful."); const n = this.inputSpec[0].shape[0]; if (null == n) throw new or("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer."); if (null == this.states_) Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((e => P.zeros([n, e]))) : this.states_ = [P.zeros([n, this.cell.stateSize])]; else if (null == e) P.dispose(this.states_), null != this.keptStates && (P.dispose(this.keptStates), this.keptStates = []), Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((e => P.zeros([n, e]))) : this.states_[0] = P.zeros([n, this.cell.stateSize]); else { if (Array.isArray(e) || (e = [e]), e.length !== this.states_.length) throw new or(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`); !0 === t ? this.keptStates.push(this.states_.slice()) : P.dispose(this.states_); for (let t = 0; t < this.states_.length; ++t) { const r = e[t], i = Array.isArray(this.cell.stateSize) ? this.cell.stateSize[t] : this.cell.stateSize, a = [n, i]; if (!P.util.arraysEqual(r.shape, a)) throw new or(`State ${t} is incompatible with layer ${this.name}: expected shape=${a}, received shape=${r.shape}`); this.states_[t] = r } } this.states_ = this.states_.map((e => P.keep(e.clone()))) })) } apply(e, t) { let n = null == t ? null : t.initialState, r = null == t ? null : t.constants; null == t && (t = {}); const i = ou(e, n, r, this.numConstants); e = i.inputs, n = i.initialState, r = i.constants; let a = [], o = []; if (null != n) { t.initialState = n, a = a.concat(n), this.stateSpec = []; for (const e of n) this.stateSpec.push(new qi({ shape: e.shape })); o = o.concat(this.stateSpec) } null != r && (t.constants = r, a = a.concat(r), this.numConstants = r.length); if (a[0] instanceof Yi) { const n = [e].concat(a), r = this.inputSpec.concat(o), i = this.inputSpec; this.inputSpec = r; const s = super.apply(n, t); return this.inputSpec = i, s } return super.apply(e, t) } call(e, t) { return (0, P.tidy)((() => { const n = null == t ? null : t.mask, r = null == t ? null : t.training; let i = null == t ? null : t.initialState; e = Li(e), null == i && (i = this.stateful ? this.states_ : this.getInitialState(e)); const a = Array.isArray(this.cell.stateSize) ? this.cell.stateSize.length : 1; if (i.length !== a) throw new or(`RNN Layer has ${a} state(s) but was passed ${i.length} initial state(s).`); this.unroll && console.warn("Ignoring unroll = true for RNN layer, due to imperative backend."); const o = { training: r }, s = su(((e, t) => { const n = this.cell.call([e].concat(t), o); return [n[0], n.slice(1)] }), e, i, this.goBackwards, n, null, this.unroll, this.returnSequences), u = s[0], l = s[1], c = s[2]; this.stateful && this.resetStates(c, r); const h = this.returnSequences ? l : u; return this.returnState ? [h].concat(c) : h })) } getInitialState(e) { return (0, P.tidy)((() => { let t = P.zeros(e.shape); return t = P.sum(t, [1, 2]), t = ti(t), Array.isArray(this.cell.stateSize) ? this.cell.stateSize.map((e => e > 1 ? si(t, [1, e]) : t)) : this.cell.stateSize > 1 ? [si(t, [1, this.cell.stateSize])] : [t] })) } get trainableWeights() { return this.trainable ? this.cell.trainableWeights : [] } get nonTrainableWeights() { return this.trainable ? this.cell.nonTrainableWeights : this.cell.weights } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.cell && this.cell.setFastWeightInitDuringBuild(e) } getConfig() { const e = super.getConfig(), t = { returnSequences: this.returnSequences, returnState: this.returnState, goBackwards: this.goBackwards, stateful: this.stateful, unroll: this.unroll }; null != this.numConstants && (t.numConstants = this.numConstants); const n = this.cell.getConfig(); return this.getClassName() === uu.className && (t.cell = { className: this.cell.getClassName(), config: n }), Object.assign(Object.assign(Object.assign({}, n), e), t) } static fromConfig(e, t, n = {}) { const r = Ka(t.cell, n); return new e(Object.assign(t, { cell: r })) } } uu.className = "RNN", P.serialization.registerClass(uu); class lu extends Ji { } class cu extends lu { constructor(e) { super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Ar(this.units, "units"), this.activation = As(null == e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { e = ji(e), this.kernel = this.addWeight("kernel", [e[e.length - 1], this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) { return (0, P.tidy)((() => { if (2 !== e.length) throw new or(`SimpleRNNCell expects 2 input Tensors, got ${e.length}.`); let n = e[1]; e = e[0]; const r = null != t.training && t.training; let i; 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: r, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(n), rate: this.recurrentDropout, training: r, dropoutFunc: this.dropoutFunc })); const a = this.dropoutMask, o = this.recurrentDropoutMask; i = li(null != a ? P.mul(e, a) : e, this.kernel.read()), null != this.bias && (i = fi(i, this.bias.read())), null != o && (n = P.mul(n, o)); let s = P.add(i, li(n, this.recurrentKernel.read())); return null != this.activation && (s = this.activation.apply(s)), [s, s] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout }; return Object.assign(Object.assign({}, e), t) } } cu.className = "SimpleRNNCell", P.serialization.registerClass(cu); class hu extends uu { constructor(e) { e.cell = new cu(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return new e(t) } } hu.className = "SimpleRNN", P.serialization.registerClass(hu); class du extends lu { constructor(e) { if (super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", e.resetAfter) throw new or("GRUCell does not support reset_after parameter set to true."); this.units = e.units, Ar(this.units, "units"), this.activation = As(void 0 === e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = As(void 0 === e.recurrentActivation ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = this.units, this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { const t = (e = ji(e))[e.length - 1]; this.kernel = this.addWeight("kernel", [t, 3 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 3 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias ? this.bias = this.addWeight("bias", [3 * this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint) : this.bias = null, this.built = !0 } call(e, t) { return (0, P.tidy)((() => { if (2 !== e.length) throw new or(`GRUCell expects 2 input Tensors (inputs, h, c), got ${e.length}.`); const n = null != t.training && t.training; let r = e[1]; e = e[0], 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: n, count: 3, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(r), rate: this.recurrentDropout, training: n, count: 3, dropoutFunc: this.dropoutFunc })); const i = this.dropoutMask, a = this.recurrentDropoutMask; let o, s, u; 0 < this.dropout && this.dropout < 1 && (e = P.mul(e, i[0])); let l = li(e, this.kernel.read()); this.useBias && (l = fi(l, this.bias.read())), 0 < this.recurrentDropout && this.recurrentDropout < 1 && (r = P.mul(r, a[0])); const c = this.recurrentKernel.read(), [h, d] = P.split(c, [2 * this.units, this.units], c.rank - 1), f = li(r, h), [p, m, g] = P.split(l, 3, l.rank - 1), [y, b] = P.split(f, 2, f.rank - 1); o = this.recurrentActivation.apply(P.add(p, y)), s = this.recurrentActivation.apply(P.add(m, b)); const v = li(P.mul(s, r), d); u = this.activation.apply(P.add(g, v)); const x = P.add(P.mul(o, r), P.mul(P.add(1, P.neg(o)), u)); return [x, x] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), recurrentActivation: _s(this.recurrentActivation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout, implementation: this.implementation, resetAfter: !1 }; return Object.assign(Object.assign({}, e), t) } } du.className = "GRUCell", P.serialization.registerClass(du); class fu extends uu { constructor(e) { 0 === e.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new du(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return 0 === t.implmentation && (t.implementation = 1), new e(t) } } fu.className = "GRU", P.serialization.registerClass(fu); class pu extends lu { constructor(e) { super(e), this.DEFAULT_ACTIVATION = "tanh", this.DEFAULT_RECURRENT_ACTIVATION = "hardSigmoid", this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_RECURRENT_INITIALIZER = "orthogonal", this.DEFAULT_BIAS_INITIALIZER = "zeros", this.units = e.units, Ar(this.units, "units"), this.activation = As(void 0 === e.activation ? this.DEFAULT_ACTIVATION : e.activation), this.recurrentActivation = As(void 0 === e.recurrentActivation ? this.DEFAULT_RECURRENT_ACTIVATION : e.recurrentActivation), this.useBias = null == e.useBias || e.useBias, this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.recurrentInitializer = zi(e.recurrentInitializer || this.DEFAULT_RECURRENT_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.unitForgetBias = e.unitForgetBias, this.kernelRegularizer = Ds(e.kernelRegularizer), this.recurrentRegularizer = Ds(e.recurrentRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.kernelConstraint = ba(e.kernelConstraint), this.recurrentConstraint = ba(e.recurrentConstraint), this.biasConstraint = ba(e.biasConstraint), this.dropout = Xr([1, Kr([0, null == e.dropout ? 0 : e.dropout])]), this.recurrentDropout = Xr([1, Kr([0, null == e.recurrentDropout ? 0 : e.recurrentDropout])]), this.dropoutFunc = e.dropoutFunc, this.implementation = e.implementation, this.stateSize = [this.units, this.units], this.dropoutMask = null, this.recurrentDropoutMask = null } build(e) { var t; const n = (e = ji(e))[e.length - 1]; let r; if (this.kernel = this.addWeight("kernel", [n, 4 * this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.recurrentKernel = this.addWeight("recurrent_kernel", [this.units, 4 * this.units], null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias) { if (this.unitForgetBias) { const e = this.biasInitializer, n = this.units; r = new ((t = class extends bi { apply(t, r) { const i = e.apply([n]), a = (new xi).apply([n]), o = e.apply([2 * n]); return oi(oi(i, a), o) } }).className = "CustomInit", t) } else r = this.biasInitializer; this.bias = this.addWeight("bias", [4 * this.units], null, r, this.biasRegularizer, !0, this.biasConstraint) } else this.bias = null; this.built = !0 } call(e, t) { return (0, P.tidy)((() => { const n = null != t.training && t.training; if (3 !== e.length) throw new or(`LSTMCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`); let r = e[1]; const i = e[2]; e = e[0], 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(e), rate: this.dropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })), 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(r), rate: this.recurrentDropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const a = this.dropoutMask, o = this.recurrentDropoutMask; let s, u, l, c; 0 < this.dropout && this.dropout < 1 && (e = P.mul(e, a[0])); let h = li(e, this.kernel.read()); 0 < this.recurrentDropout && this.recurrentDropout < 1 && (r = P.mul(r, o[0])), h = P.add(h, li(r, this.recurrentKernel.read())), this.useBias && (h = fi(h, this.bias.read())); const [d, f, p, m] = P.split(h, 4, h.rank - 1); s = this.recurrentActivation.apply(d), u = this.recurrentActivation.apply(f), l = P.add(P.mul(u, i), P.mul(s, this.activation.apply(p))), c = this.recurrentActivation.apply(m); const g = P.mul(c, this.activation.apply(l)); return [g, g, l] })) } getConfig() { const e = super.getConfig(), t = { units: this.units, activation: _s(this.activation), recurrentActivation: _s(this.recurrentActivation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), recurrentInitializer: Oi(this.recurrentInitializer), biasInitializer: Oi(this.biasInitializer), unitForgetBias: this.unitForgetBias, kernelRegularizer: Ms(this.kernelRegularizer), recurrentRegularizer: Ms(this.recurrentRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), recurrentConstraint: ga(this.recurrentConstraint), biasConstraint: ga(this.biasConstraint), dropout: this.dropout, recurrentDropout: this.recurrentDropout, implementation: this.implementation }; return Object.assign(Object.assign({}, e), t) } } pu.className = "LSTMCell", P.serialization.registerClass(pu); class mu extends uu { constructor(e) { 0 === e.implementation && console.warn("`implementation=0` has been deprecated, and now defaults to `implementation=1`. Please update your layer call."), e.cell = new pu(e), super(e) } call(e, t) { return (0, P.tidy)((() => { null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } static fromConfig(e, t) { return 0 === t.implmentation && (t.implementation = 1), new e(t) } } mu.className = "LSTM", P.serialization.registerClass(mu); class gu extends lu { constructor(e) { super(e), this.cells = e.cells } get stateSize() { const e = []; for (const t of this.cells.slice().reverse()) Array.isArray(t.stateSize) ? e.push(...t.stateSize) : e.push(t.stateSize); return e } call(e, t) { return (0, P.tidy)((() => { let n = e.slice(1); const r = []; for (const e of this.cells.slice().reverse()) Array.isArray(e.stateSize) ? r.push(n.splice(0, e.stateSize.length)) : r.push(n.splice(0, 1)); r.reverse(); const i = []; let a; for (let o = 0; o < this.cells.length; ++o) { const s = this.cells[o]; n = r[o], a = 0 === o ? [e[0]].concat(n) : [a[0]].concat(n), a = s.call(a, t), i.push(a.slice(1)) } n = []; for (const e of i.slice().reverse()) n.push(...e); return [a[0]].concat(n) })) } build(e) { let t; Pi(e) && (e = e[0]), this.cells.forEach(((n, r) => { Wr(`RNNCell_${r}`, (() => { n.build(e), t = Array.isArray(n.stateSize) ? n.stateSize[0] : n.stateSize, e = [e[0], t] })) })), this.built = !0 } getConfig() { const e = super.getConfig(), t = { cells: this.cells.map((e => ({ className: e.getClassName(), config: e.getConfig() }))) }; return Object.assign(Object.assign({}, e), t) } static fromConfig(e, t, n = {}) { const r = []; for (const e of t.cells) r.push(Ka(e, n)); return new e({ cells: r }) } get trainableWeights() { if (!this.trainable) return []; const e = []; for (const t of this.cells) e.push(...t.trainableWeights); return e } get nonTrainableWeights() { const e = []; for (const t of this.cells) e.push(...t.nonTrainableWeights); if (!this.trainable) { const t = []; for (const e of this.cells) t.push(...e.trainableWeights); return t.concat(e) } return e } getWeights() { const e = []; for (const t of this.cells) e.push(...t.weights); return Gi(e) } setWeights(e) { const t = []; for (const n of this.cells) { const r = n.weights.length, i = e.splice(r); for (let e = 0; e < n.weights.length; ++e)t.push([n.weights[e], i[e]]) } Hi(t) } } function yu(e) { const { ones: t, rate: n, training: r = !1, count: i = 1, dropoutFunc: a } = e, o = () => null != a ? a(t(), n) : pi(t(), n), s = () => mi(o, t, r); if (!i || i <= 1) return P.keep(s().clone()); return Array(i).fill(void 0).map(s).map((e => P.keep(e.clone()))) } gu.className = "StackedRNNCells", P.serialization.registerClass(gu);
/**
* @license
* Copyright 2020 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
var bu = function (e, t) { var n = {}; for (var r in e) Object.prototype.hasOwnProperty.call(e, r) && t.indexOf(r) < 0 && (n[r] = e[r]); if (null != e && "function" == typeof Object.getOwnPropertySymbols) { var i = 0; for (r = Object.getOwnPropertySymbols(e); i < r.length; i++)t.indexOf(r[i]) < 0 && Object.prototype.propertyIsEnumerable.call(e, r[i]) && (n[r[i]] = e[r[i]]) } return n }; class vu extends uu { constructor(e) { if (e.unroll) throw new sr("Unrolling is not possible with convolutional RNNs."); if (Array.isArray(e.cell)) throw new sr("It is not possible at the moment to stack convolutional cells."); super(e), this.inputSpec = [new qi({ ndim: 5 })] } call(e, t) { return P.tidy((() => { if (null != this.cell.dropoutMask && (P.dispose(this.cell.dropoutMask), this.cell.dropoutMask = null), null != this.cell.recurrentDropoutMask && (P.dispose(this.cell.recurrentDropoutMask), this.cell.recurrentDropoutMask = null), t && t.constants) throw new or("ConvRNN2D cell does not support constants"); const n = null == t ? null : t.mask, r = null == t ? null : t.training, i = null == t ? null : t.initialState; return super.call(e, { mask: n, training: r, initialState: i }) })) } computeOutputShape(e) { let t = this.computeSingleOutputShape(e); return this.returnSequences || (t = [t[0], ...t.slice(2)]), this.returnState && (t = [t, ...Array(2).fill([e[0], ...t.slice(-3)])]), t } getInitialState(e) { return P.tidy((() => { const { stateSize: t } = this.cell, n = e.shape, r = this.computeSingleOutputShape(n), i = [r[0], ...r.slice(2)], a = P.zeros(i); return Array.isArray(t) ? Array(t.length).fill(a) : [a] })) } resetStates(e, t = !1) { P.tidy((() => { if (!this.stateful) throw new ir("Cannot call resetStates() on an RNN Layer that is not stateful."); const n = this.inputSpec[0].shape, r = this.computeSingleOutputShape(n), i = [r[0], ...r.slice(2)]; if (null == n[0]) throw new or("If an RNN is stateful, it needs to know its batch size. Specify the batch size of your input tensors: \n- If using a Sequential model, specify the batch size by passing a `batchInputShape` option to your first layer.\n- If using the functional API, specify the batch size by passing a `batchShape` option to your Input layer."); if (null == this.getStates()) Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((() => P.zeros(i))) : this.states_ = [P.zeros(i)]; else if (null == e) P.dispose(this.states_), null != this.keptStates && (P.dispose(this.keptStates), this.keptStates = []), Array.isArray(this.cell.stateSize) ? this.states_ = this.cell.stateSize.map((() => P.zeros(i))) : this.states_[0] = P.zeros(i); else { if (Array.isArray(e) || (e = [e]), e.length !== this.states_.length) throw new or(`Layer ${this.name} expects ${this.states_.length} state(s), but it received ${e.length} state value(s). Input received: ${e}`); t ? this.keptStates.push(this.states_.slice()) : P.dispose(this.states_); for (let t = 0; t < this.states_.length; ++t) { const n = e[t], r = i; if (!P.util.arraysEqual(n.shape, r)) throw new or(`State ${t} is incompatible with layer ${this.name}: expected shape=${r}, received shape=${n.shape}`); this.states_[t] = n } } this.states_ = this.states_.map((e => P.keep(e.clone()))) })) } computeSingleOutputShape(e) { const { dataFormat: t, filters: n, kernelSize: r, padding: i, strides: a, dilationRate: o } = this.cell, s = "channelsFirst" === t, u = e[s ? 3 : 2], l = e[s ? 4 : 3], c = js(u, r[0], i, a[0], o[0]), h = js(l, r[1], i, a[1], o[1]); return [...e.slice(0, 2), ...s ? [n, c, h] : [c, h, n]] } } vu.className = "ConvRNN2D"; class xu extends pu { constructor(e) { const { filters: t, kernelSize: n, strides: r, padding: i, dataFormat: a, dilationRate: o } = e; super(Object.assign(Object.assign({}, e), { units: t })), this.filters = t, Ar(this.filters, "filters"), this.kernelSize = Ls(n, 2, "kernelSize"), this.kernelSize.forEach((e => Ar(e, "kernelSize"))), this.strides = Ls(r || 1, 2, "strides"), this.strides.forEach((e => Ar(e, "strides"))), this.padding = i || "valid", Lr(this.padding), this.dataFormat = a || "channelsLast", Br(this.dataFormat), this.dilationRate = Ls(o || 1, 2, "dilationRate"), this.dilationRate.forEach((e => Ar(e, "dilationRate"))) } build(e) { var t; e = ji(e); const n = "channelsFirst" === this.dataFormat ? 1 : e.length - 1; if (null == e[n]) throw new or(`The channel dimension of the input should be defined. Found ${e[n]}`); const r = e[n], i = this.kernelSize.concat([r, 4 * this.filters]); this.kernel = this.addWeight("kernel", i, null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint); const a = this.kernelSize.concat([this.filters, 4 * this.filters]); if (this.recurrentKernel = this.addWeight("recurrent_kernel", a, null, this.recurrentInitializer, this.recurrentRegularizer, !0, this.recurrentConstraint), this.useBias) { let e; if (this.unitForgetBias) { const n = this.biasInitializer, r = this.filters; e = new ((t = class extends bi { apply(e, t) { return ai([n.apply([r]), P.ones([r]), n.apply([2 * r])]) } }).className = "CustomInit", t) } else e = this.biasInitializer; this.bias = this.addWeight("bias", [4 * this.filters], null, e, this.biasRegularizer, !0, this.biasConstraint) } this.built = !0 } call(e, t) { return P.tidy((() => { if (3 !== e.length) throw new or(`ConvLSTM2DCell expects 3 input Tensors (inputs, h, c), got ${e.length}.`); const n = t.training || !1, r = e[0], i = e[1], a = e[2]; 0 < this.dropout && this.dropout < 1 && null == this.dropoutMask && (this.dropoutMask = yu({ ones: () => P.onesLike(r), rate: this.dropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const o = this.dropoutMask, s = (e, t, n) => t && t[n] ? P.mul(t[n], e) : e; let u = s(r, o, 0), l = s(r, o, 1), c = s(r, o, 2), h = s(r, o, 3); 0 < this.recurrentDropout && this.recurrentDropout < 1 && null == this.recurrentDropoutMask && (this.recurrentDropoutMask = yu({ ones: () => P.onesLike(i), rate: this.recurrentDropout, training: n, count: 4, dropoutFunc: this.dropoutFunc })); const d = this.recurrentDropoutMask; let f = s(i, d, 0), p = s(i, d, 1), m = s(i, d, 2), g = s(i, d, 3); const [y, b, v, x] = P.split(this.kernel.read(), 4, 3), [w, k, S, _] = this.useBias ? P.split(this.bias.read(), 4) : [null, null, null, null]; u = this.inputConv(u, y, w, this.padding), l = this.inputConv(l, b, k, this.padding), c = this.inputConv(c, v, S, this.padding), h = this.inputConv(h, x, _, this.padding); const [C, A, T, E] = P.split(this.recurrentKernel.read(), 4, 3); f = this.recurrentConv(f, C), p = this.recurrentConv(p, A), m = this.recurrentConv(m, T), g = this.recurrentConv(g, E); const N = this.recurrentActivation.apply(P.add(u, f)), I = this.recurrentActivation.apply(P.add(l, p)), M = P.add(P.mul(I, a), P.mul(N, this.activation.apply(P.add(c, m)))), F = P.mul(this.recurrentActivation.apply(P.add(h, g)), this.activation.apply(M)); return [F, F, M] })) } getConfig() { const e = super.getConfig(), { units: t } = e, n = bu(e, ["units"]), r = { filters: this.filters, kernelSize: this.kernelSize, padding: this.padding, dataFormat: this.dataFormat, dilationRate: this.dilationRate, strides: this.strides }; return Object.assign(Object.assign({}, n), r) } inputConv(e, t, n, r) { const i = P.conv2d(e, t, this.strides, r || "valid", "channelsFirst" === this.dataFormat ? "NCHW" : "NHWC", this.dilationRate); return n ? fi(i, n, this.dataFormat) : i } recurrentConv(e, t) { return P.conv2d(e, t, 1, "same", "channelsFirst" === this.dataFormat ? "NCHW" : "NHWC") } } xu.className = "ConvLSTM2DCell", P.serialization.registerClass(xu); class wu extends vu { constructor(e) { const t = new xu(e); super(Object.assign(Object.assign({}, e), { cell: t })) } static fromConfig(e, t) { return new e(t) } } wu.className = "ConvLSTM2D", P.serialization.registerClass(wu);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ku extends Ji { constructor(e) { super(e), this.rate = Math.max(Math.min(e.rate, 1), 0), this.noiseShape = e.noiseShape, this.seed = e.seed, this.supportsMasking = !0 } getNoiseShape(e) { if (null == this.noiseShape) return this.noiseShape; const t = e.shape, n = []; for (let e = 0; e < this.noiseShape.length; ++e)n.push(null == this.noiseShape[e] ? t[e] : this.noiseShape[e]); return n } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); if (0 < this.rate && this.rate < 1) { const e = null != t.training && t.training, r = this.getNoiseShape(n); return mi((() => pi(n, this.rate, r, this.seed)), (() => n), e) } return e })) } getConfig() { const e = { rate: this.rate, noiseShape: this.noiseShape, seed: this.seed }, t = super.getConfig(); return Object.assign(e, t), e } dispose() { return super.dispose() } } ku.className = "Dropout", P.serialization.registerClass(ku); class Su extends ku { constructor(e) { super(e), this.inputSpec = [{ ndim: 3 }] } getNoiseShape(e) { const t = e.shape; return [t[0], 1, t[2]] } } Su.className = "SpatialDropout1D", P.serialization.registerClass(Su); class _u extends Ji { constructor(e) { if (super(e), this.activation = null, this.useBias = !0, this.kernel = null, this.bias = null, this.DEFAULT_KERNEL_INITIALIZER = "glorotNormal", this.DEFAULT_BIAS_INITIALIZER = "zeros", null == e.batchInputShape && null == e.inputShape && null != e.inputDim) { let t = null; null != e.batchSize && (t = e.batchSize), this.batchInputShape = [t, e.inputDim] } this.units = e.units, Ar(this.units, "units"), this.activation = As(e.activation), null != e.useBias && (this.useBias = e.useBias), this.kernelInitializer = zi(e.kernelInitializer || this.DEFAULT_KERNEL_INITIALIZER), this.biasInitializer = zi(e.biasInitializer || this.DEFAULT_BIAS_INITIALIZER), this.kernelConstraint = ba(e.kernelConstraint), this.biasConstraint = ba(e.biasConstraint), this.kernelRegularizer = Ds(e.kernelRegularizer), this.biasRegularizer = Ds(e.biasRegularizer), this.activityRegularizer = Ds(e.activityRegularizer), this.supportsMasking = !0, this.inputSpec = [{ minNDim: 2 }] } build(e) { const t = (e = ji(e))[e.length - 1]; null == this.kernel && (this.kernel = this.addWeight("kernel", [t, this.units], null, this.kernelInitializer, this.kernelRegularizer, !0, this.kernelConstraint), this.useBias && (this.bias = this.addWeight("bias", [this.units], null, this.biasInitializer, this.biasRegularizer, !0, this.biasConstraint))), this.inputSpec = [{ minNDim: 2, axes: { [-1]: t } }], this.built = !0 } computeOutputShape(e) { const t = (e = ji(e)).slice(); return t[t.length - 1] = this.units, t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = Er(this.activation.getClassName()); let i; return null != r ? i = li(n, this.kernel.read(), r, this.bias ? this.bias.read() : null) : (i = li(n, this.kernel.read()), null != this.bias && (i = fi(i, this.bias.read())), null != this.activation && (i = this.activation.apply(i))), i })) } getConfig() { const e = { units: this.units, activation: _s(this.activation), useBias: this.useBias, kernelInitializer: Oi(this.kernelInitializer), biasInitializer: Oi(this.biasInitializer), kernelRegularizer: Ms(this.kernelRegularizer), biasRegularizer: Ms(this.biasRegularizer), activityRegularizer: Ms(this.activityRegularizer), kernelConstraint: ga(this.kernelConstraint), biasConstraint: ga(this.biasConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } _u.className = "Dense", P.serialization.registerClass(_u); class Cu extends Ji { constructor(e) { super(e = e || {}), this.inputSpec = [{ minNDim: 3 }], this.dataFormat = e.dataFormat } computeOutputShape(e) { e = ji(e); for (const t of e.slice(1)) if (null == t) throw new or(`The shape of the input to "Flatten" is not fully defined (got ${e.slice(1)}). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.`); return [e[0], Yr(e, 1)] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); let n = Li(e); if ("channelsFirst" === this.dataFormat && n.rank > 1) { const e = [0]; for (let t = 2; t < n.rank; ++t)e.push(t); e.push(1), n = (0, P.transpose)(n, e) } return function (e) { if (e.rank <= 1) throw new or(`batchFlatten requires a minimum rank of 2. Got rank: ${e.rank}.`); const t = [e.shape[0], Yr(e.shape, 1)]; return P.reshape(e, t) }(n) })) } getConfig() { const e = {}; null != this.dataFormat && (e.dataFormat = this.dataFormat); const t = super.getConfig(); return Object.assign(e, t), e } } Cu.className = "Flatten", P.serialization.registerClass(Cu); class Au extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.activation = As(e.activation) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); return this.activation.apply(n) })) } getConfig() { const e = { activation: _s(this.activation) }, t = super.getConfig(); return Object.assign(e, t), e } } Au.className = "Activation", P.serialization.registerClass(Au); class Tu extends Ji { constructor(e) { super(e), this.n = e.n, this.inputSpec = [{ ndim: 2 }] } computeOutputShape(e) { return [e[0], this.n, e[1]] } call(e, t) { return (0, P.tidy)((() => function (e, t) { return (0, P.tidy)((() => { if (2 !== e.shape.length) throw new or(`repeat() expects a rank-2 tensor, but received a rank-${e.shape.length} tensor.`); return si(ti(e, 1), [1, t, 1]) })) }(e = Li(e), this.n))) } getConfig() { const e = { n: this.n }, t = super.getConfig(); return Object.assign(e, t), e } } Tu.className = "RepeatVector", P.serialization.registerClass(Tu); class Eu extends Ji { constructor(e) { super(e), this.targetShape = e.targetShape; for (let e = 0; e < this.targetShape.length; ++e)this.isUnknown(this.targetShape[e]) && (this.targetShape[e] = null) } isUnknown(e) { return e < 0 || null == e } fixUnknownDimension(e, t) { const n = "Total size of new array must be unchanged.", r = t.slice(); let i = 1, a = null; for (let e = 0; e < r.length; ++e) { const t = r[e]; if (this.isUnknown(t)) { if (null !== a) throw new or("Can only specifiy one unknown dimension."); a = e } else i *= t } const o = Yr(e); if (null !== a) { if (0 === i || o % i != 0) throw new or(n); r[a] = o / i } else if (o !== i) throw new or(n); return r } computeOutputShape(e) { let t = !1; for (let n = 0; n < e.length; ++n)if (this.isUnknown(e[n])) { t = !0; break } return t ? e.slice(0, 1).concat(this.targetShape) : e.slice(0, 1).concat(this.fixUnknownDimension(e.slice(1), this.targetShape)) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = n.shape, i = r.slice(0, 1).concat(this.fixUnknownDimension(r.slice(1), this.targetShape)); return (0, P.reshape)(n, i) })) } getConfig() { const e = { targetShape: this.targetShape }, t = super.getConfig(); return Object.assign(e, t), e } } Eu.className = "Reshape", P.serialization.registerClass(Eu); class Nu extends Ji { constructor(e) { if (super(e), null == e.dims) throw new Error("Required configuration field `dims` is missing during Permute constructor call."); if (!Array.isArray(e.dims)) throw new Error(`Permute constructor requires \`dims\` to be an Array, but received ${e.dims} instead.`); const t = Zr(1, e.dims.length + 1); if (!P.util.arraysEqual(e.dims.slice().sort(), t)) throw new Error("Invalid permutation `dims`: " + JSON.stringify(e.dims) + " `dims` must contain consecutive integers starting from 1."); this.dims = e.dims, this.dimsIncludingBatch = [0].concat(this.dims), this.inputSpec = [new qi({ ndim: this.dims.length + 1 })] } computeOutputShape(e) { const t = (e = ji(e)).slice(); return this.dims.forEach(((n, r) => { t[r + 1] = e[n] })), t } call(e, t) { return (0, P.transpose)(Li(e), this.dimsIncludingBatch) } getConfig() { const e = { dims: this.dims }, t = super.getConfig(); return Object.assign(e, t), e } } Nu.className = "Permute", P.serialization.registerClass(Nu); class Iu extends Ji { constructor(e) { super(null == e ? {} : e), this.supportsMasking = !0, this.maskValue = null != e ? null == e.maskValue ? 0 : e.maskValue : 0 } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { maskValue: this.maskValue }; return Object.assign(t, e), t } computeMask(e, t) { const n = Li(e); return (0, P.any)((0, P.notEqual)(n, this.maskValue), -1) } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e), r = (0, P.any)((0, P.notEqual)(n, this.maskValue), -1, !0); return (0, P.mul)(n, (0, P.cast)(r, n.dtype)) })) } } Iu.className = "Masking", P.serialization.registerClass(Iu);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class Mu extends Ji { constructor(e) { if (super(e), this.embeddings = null, this.DEFAULT_EMBEDDINGS_INITIALIZER = "randomUniform", null == e.batchInputShape && null == e.inputShape) { let t = null; null != e.batchSize && (t = e.batchSize), null == e.inputLength ? this.batchInputShape = [t, null] : this.batchInputShape = [t].concat(pr(e.inputLength)) } this.inputDim = e.inputDim, Ar(this.inputDim, "inputDim"), this.outputDim = e.outputDim, Ar(this.outputDim, "outputDim"), this.embeddingsInitializer = zi(e.embeddingsInitializer || this.DEFAULT_EMBEDDINGS_INITIALIZER), this.embeddingsRegularizer = Ds(e.embeddingsRegularizer), this.activityRegularizer = Ds(e.activityRegularizer), this.embeddingsConstraint = ba(e.embeddingsConstraint), this.maskZero = e.maskZero, this.supportsMasking = e.maskZero, this.inputLength = e.inputLength } build(e) { this.embeddings = this.addWeight("embeddings", [this.inputDim, this.outputDim], this.dtype, this.embeddingsInitializer, this.embeddingsRegularizer, !0, this.embeddingsConstraint), this.built = !0 } warnOnIncompatibleInputShape(e) { } computeMask(e, t) { return (0, P.tidy)((() => this.maskZero ? (e = Li(e), (0, P.notEqual)(e, (0, P.zerosLike)(e))) : null)) } computeOutputShape(e) { if (e = ji(e), null == this.inputLength) return [...e, this.outputDim]; const t = pr(this.inputLength); if (t.length !== e.length - 1) throw new or(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`); { let n = 0; for (let r = 0; r < t.length; ++r) { const i = t[r], a = e[r + 1]; if (null != i && null != a && i !== a) throw new or(`"inputLength" is ${this.inputLength}, but received input shape has shape ${e}`); null == i && (t[n] = a), n++ } } return [e[0], ...t, this.outputDim] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); let n = Li(e); "int32" !== n.dtype && (n = ei(n, "int32")); const r = ci(this.embeddings.read(), (0, P.reshape)(n, [n.size])); return (0, P.reshape)(r, ji(this.computeOutputShape(n.shape))) })) } getConfig() { const e = { inputDim: this.inputDim, outputDim: this.outputDim, embeddingsInitializer: Oi(this.embeddingsInitializer), embeddingsRegularizer: Ms(this.embeddingsRegularizer), activityRegularizer: Ms(this.activityRegularizer), embeddingsConstraint: ga(this.embeddingsConstraint), maskZero: this.maskZero, inputLength: this.inputLength }, t = super.getConfig(); return Object.assign(e, t), e } } Mu.className = "Embedding", P.serialization.registerClass(Mu);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class Fu extends Ji { constructor(e) { super(e || {}), this.supportsMasking = !0 } mergeFunction(e) { throw new sr } computeElementwiseOpOutputShape(e, t) { if (null == e || null == t) return null; if (e.length < t.length) return this.computeElementwiseOpOutputShape(t, e); if (0 === t.length) return e; const n = e.slice(0, e.length - t.length); for (let r = 0; r < t.length; ++r) { const i = e[e.length - t.length + r], a = t[r]; if (null == i || null == a || i < 0 || a < 0) n.push(null); else if (1 === i) n.push(a); else if (1 === a) n.push(i); else { if (i !== a) throw new or("Operands could not be broadcast together with shapes " + JSON.stringify(e) + " " + JSON.stringify(t)); n.push(i) } } return n } build(e) { if (Array.isArray(e) && !Array.isArray(e[0]) && (e = [ji(e)]), e.length < 2) throw new or(`A merge layer should be called on an Array of at least 2 inputs. Got ${e.length} input(s).`); let t = []; for (const n of e) null != n && null !== n[0] && t.push(n[0]); if (t = kr(t), t.length > 1) throw new or(`Can not merge tensors with different batch sizes. Got tensors with shapes: ${JSON.stringify(e)}.`); let n = null == e[0] ? null : e[0].slice(1); for (let t = 1; t < e.length; ++t) { const r = null == e[t] ? null : e[t].slice(1); n = this.computeElementwiseOpOutputShape(n, r) } const r = e.map((e => e.length)); -1 === e.indexOf(null) && 1 === kr(r).length ? this.reshapeRequired = !1 : this.reshapeRequired = !0 } call(e, t) { return (0, P.tidy)((() => { if (this.reshapeRequired) { const t = [], n = e.map((e => e.rank)); if (-1 === n.indexOf(null)) { const r = Kr(n); for (let n of e) { const e = n.rank; for (let t = 0; t < r - e; ++t)n = ti(n, 1); t.push(n) } return this.mergeFunction(t) } { let n = !1; for (const r of e) { const e = r.rank; if (null == e) { const e = r.shape, i = e[0], a = e.slice(1).concat([i]); let o = P.reshape(r, [i].concat(Yr(e.slice(1)))); o = P.transpose(o, [1, 0]), o = P.reshape(o, a), t.push(o), n = !0 } else if (e > 1) { const i = Zr(1, e).concat([0]); t.push(P.transpose(r, i)), n = !0 } else t.push(r) } let r = this.mergeFunction(t); const i = r.rank; if (n) if (null == i) { const e = r.shape, t = e[e.length - 1], n = [t].concat(e.slice(0, e.length - 1)); r = P.reshape(P.transpose(P.reshape(r, [-1, t]), [1, 0]), n) } else if (i > 1) { const e = [i - 1].concat(Zr(0, i - 1)); r = P.transpose(r, e) } return r } } return this.mergeFunction(e) })) } computeOutputShape(e) { let t; t = null == e[0] ? null : e[0].slice(1); for (let n = 1; n < e.length; ++n) { const r = null == e[n] ? null : e[n].slice(1); t = this.computeElementwiseOpOutputShape(t, r) } let n = []; for (const t of e) null != t && null !== t[0] && n.push(t[0]); return n = kr(n), t = 1 === n.length ? n.concat(t) : [null].concat(t), t } computeMask(e, t) { return P.tidy((() => { if (null == t) return null; if (!Array.isArray(t)) throw new or("`mask` should be an Array"); if (!Array.isArray(e)) throw new or("`inputs` should be an Array"); if (t.length !== e.length) throw new or(`The Array 'inputs' and 'mask' are expected to have the same length, but have different lengths (${e.length} vs ${t.length})`); if (t.every((e => null == e))) return null; let n = (t = t.map((e => null == e ? e : P.expandDims(e, 0))))[0]; for (let e = 1; e < t.length - 1; ++e)n = P.logicalAnd(n, t[e]); return n })) } } class Du extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.add(t, e[n]); return t })) } } Du.className = "Add", P.serialization.registerClass(Du); class $u extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.mul(t, e[n]); return t })) } } $u.className = "Multiply", P.serialization.registerClass($u); class Ru extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0].clone(); for (let n = 1; n < e.length; ++n)t = P.add(t, e[n]); return P.mul(1 / e.length, t) })) } } Ru.className = "Average", P.serialization.registerClass(Ru); class Ou extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0]; for (let n = 1; n < e.length; ++n)t = P.maximum(t, e[n]); return t })) } } Ou.className = "Maximum", P.serialization.registerClass(Ou); class zu extends Fu { constructor(e) { super(e) } mergeFunction(e) { return (0, P.tidy)((() => { let t = e[0]; for (let n = 1; n < e.length; ++n)t = P.minimum(t, e[n]); return t })) } } zu.className = "Minimum", P.serialization.registerClass(zu); class Pu extends Fu { constructor(e) { super(e), this.DEFAULT_AXIS = -1, null == e && (e = {}), this.axis = null == e.axis ? this.DEFAULT_AXIS : e.axis, this.supportsMasking = !0, this.reshapeRequired = !1 } build(e) { if (!Array.isArray(e) || !Array.isArray(e[0]) || 1 === e.length) throw new or("A `Concatenate` layer should be called on a list of at least 2 inputs"); let t = !0; for (const n of e) if (null != n) { t = !1; break } if (t) return; const n = []; for (let t = 0; t < e.length; ++t) { const r = e[t].slice(); r.splice(this.axis, 1); let i = !1; for (const e of n) if (P.util.arraysEqual(e, r)) { i = !0; break } i || n.push(r) } if (n.length > 1) throw new or("A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got input shapes: " + JSON.stringify(e)) } mergeFunction(e) { return (0, P.tidy)((() => ai(e, this.axis))) } computeOutputShape(e) { if (!Array.isArray(e) || !Array.isArray(e[0])) throw new or("A `Concatenate` layer should be called on a list of inputs."); const t = e, n = t[0].slice(), r = this.axis < 0 ? n.length + this.axis : this.axis; for (const e of t.slice(1)) { if (null == n[r] || null == e[r]) { n[r] = null; break } n[r] += e[r] } return n } computeMask(e, t) { if (null == t) return null; if (!Array.isArray(t)) throw new or("`mask` should be an array for Concatenate"); if (!Array.isArray(e)) throw new or("`inputs` should be an array for Concatenate"); if (t.length !== e.length) throw new or(`Mismatch in the length of mask (${t.length}) and the legnth of inputs (${e.length})`); return P.tidy((() => { let n = !0; if (t.forEach((e => { null == e || (n = !1) })), n) return null; const r = []; for (let n = 0; n < e.length; ++n)null == t[n] ? r.push(P.cast(P.onesLike(e[n]), "bool")) : t[n].rank < e[n].rank ? r.push(P.expandDims(t[n], -1)) : r.push(t[n]); const i = P.concat(r, this.axis); return P.all(i, -1, !1) })) } getConfig() { const e = { axis: this.axis }, t = super.getConfig(); return Object.assign(e, t), e } } function Bu(e, t) { for (; e < 0;)e += t; return e } Pu.className = "Concatenate", P.serialization.registerClass(Pu); class Lu extends Fu { constructor(e) { super(e), this.axes = e.axes, this.normalize = null != e.normalize && e.normalize, this.supportsMasking = !0, this.reshapeRequired = !1 } build(e) { P.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), (() => "A `Dot` layer should be called on a list of exactly 2 inputs.")); const t = e[0], n = e[1]; if (t.length > 3 || n.length > 3) throw new sr("Dot layer does not support tensors of 4D or higher rank yet."); const r = this.interpretAxes(t, n); if (t[r[0]] !== n[r[1]]) throw new or(`Dimension incompatibility: ${t[r[0]]} !== ${n[r[1]]}`) } mergeFunction(e) { if (2 !== e.length) throw new or(`A \`Dot\` layer must be called on exactly 2 inputs, but received ${e.length} input(s).`); let t, n = e[0], r = e[1]; return t = Array.isArray(this.axes) ? this.axes.map(((t, n) => Bu(t, e[n].shape.length))) : [Bu(this.axes, n.shape.length), Bu(this.axes, r.shape.length)], this.normalize && (n = Za(n, t[0]), r = Za(r, t[1])), function (e, t, n) { if (e.shape.length > 3 || t.shape.length > 3) throw new sr("batchDot is not implemented for tensors of 4D or higher rank yet"); if (P.util.assert(e.shape.length >= 2, (() => `batchDot requires the rank of x to be >= 2, but got ${e.shape.length}`)), P.util.assert(e.shape.length >= 2, (() => `batchDot requires the rank of y to be >= 2, but got ${t.shape.length}`)), "number" == typeof n && (n = [n, n]), "complex64" === e.dtype || "complex64" === t.dtype) throw new sr("batchDot is not implemented for complex64-type Tensors yet."); const r = e.shape.length, i = t.shape.length; null == n && (n = [r - 1, i - 2]); const a = n; return P.tidy((() => { let n, o; if (r > i) { n = r - i; const e = []; for (let t = 0; t < n; ++t)e.push(1); t = P.reshape(t, t.shape.concat(e)) } else if (i > r) { n = i - r; const t = []; for (let e = 0; e < n; ++e)t.push(1); e = P.reshape(e, e.shape.concat(t)) } else n = 0; if (2 === e.shape.length && 2 === t.shape.length) o = a[0] === a[1] ? P.sum(P.mul(e, t), a[0]) : P.sum(P.mul(P.transpose(e, [1, 0]), t), a[1]); else { const n = a[0] !== e.shape.length - 1, r = a[1] === t.shape.length - 1; o = P.matMul(e, t, n, r) } if (n > 0) { let e; e = r > i ? r + i - 3 : r - 1; const t = []; for (let r = e; r < e + n; ++r)t.push(r); o = P.squeeze(o, t) } return 1 === o.shape.length && (o = P.expandDims(o, 1)), o })) }(n, r, t) } interpretAxes(e, t) { let n; return n = Array.isArray(this.axes) ? this.axes : [Bu(this.axes, e.length), Bu(this.axes, t.length)], n } computeOutputShape(e) { P.util.assert(Array.isArray(e) && 2 === e.length && Array.isArray(e[0]) && Array.isArray(e[1]), (() => "A `Dot` layer should be called on a list of exactly 2 inputs.")); const t = e[0].slice(), n = e[1].slice(); if (t.length > 3 || n.length > 3) throw new sr("Dot layer does not support tensors of 4D or higher rank yet."); const r = this.interpretAxes(t, n); t.splice(r[0], 1), n.splice(r[1], 1), n.splice(0, 1); const i = t.concat(n); return 1 === i.length && i.push(1), i } computeMask(e, t) { return null } getConfig() { const e = { axes: this.axes, normalize: this.normalize }, t = super.getConfig(); return Object.assign(e, t), e } } Lu.className = "Dot", P.serialization.registerClass(Lu);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ju extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.stddev = e.stddev } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { stddev: this.stddev }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); return mi((() => (0, P.add)(ui(n.shape, 0, this.stddev), n)), (() => n), t.training || !1) })) } } ju.className = "GaussianNoise", P.serialization.registerClass(ju); class Uu extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.rate = e.rate } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { rate: this.rate }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t); const n = Li(e); if (this.rate > 0 && this.rate < 1) { return mi((() => { const e = Math.sqrt(this.rate / (1 - this.rate)); return (0, P.mul)(n, ui(n.shape, 1, e)) }), (() => n), t.training || !1) } return n })) } } Uu.className = "GaussianDropout", P.serialization.registerClass(Uu); class Wu extends Ji { constructor(e) { super(e), this.supportsMasking = !0, this.rate = e.rate, this.noiseShape = e.noiseShape } _getNoiseShape(e) { return this.noiseShape || Li(e).shape } computeOutputShape(e) { return e } getConfig() { const e = super.getConfig(), t = { rate: this.rate }; return Object.assign(t, e), t } call(e, t) { return (0, P.tidy)((() => { if (this.rate < 1 && this.rate > 0) { const n = this._getNoiseShape(e); return mi((() => { const t = Li(e), r = -1.7580993408473766; let i = (0, P.greaterEqual)((0, P.randomUniform)(n), this.rate); i = ei(i, "float32"); const a = ((1 - this.rate) * (1 + this.rate * r ** 2)) ** -.5, o = -a * r * this.rate, s = (0, P.add)((0, P.mul)(t, i), (0, P.mul)((0, P.add)(i, -1), r)); return (0, P.add)((0, P.mul)(s, a), o) }), (() => Li(e)), t.training || !1) } return e })) } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Vu(e, t, n, r, i, a = .001) { let o; if (2 === e.rank) o = P.batchNorm2d(e, t, n, r, i, a); else if (3 === e.rank) o = P.batchNorm3d(e, t, n, r, i, a); else { if (4 !== e.rank) throw new sr(`batchNormalization is not implemented for array of rank ${e.rank} yet`); o = P.batchNorm4d(e, t, n, r, i, a) } return o } function Gu(e, t, n, r, i = .001) { return P.util.arraysEqual(r.slice().sort(), Zr(0, e.rank - 1)) ? function (e, t, n, r, i = .001) { return (0, P.tidy)((() => { const a = P.moments(e, r), o = a.mean, s = a.variance; return [Vu(e, o, s, n, t, i), o, s] })) }(e, t, n, r, i) : function (e, t, n, r, i = .001) { return (0, P.tidy)((() => { const a = P.moments(e, r), o = a.mean, s = a.variance, u = []; for (const t of Zr(0, e.rank)) -1 !== r.indexOf(t) ? u.push(1) : u.push(e.shape[t]); const l = (0, P.reshape)(o, u), c = (0, P.reshape)(s, u), h = null == t ? null : (0, P.reshape)(t, u), d = null == n ? null : (0, P.reshape)(n, u); return [Vu(e, l, c, d, h, i), o, s] })) }(e, t, n, r, i) } Wu.className = "AlphaDropout", P.serialization.registerClass(Wu); class Hu extends Ji { constructor(e) { null == e && (e = {}), super(e), this.supportsMasking = !0, this.axis = null == e.axis ? -1 : e.axis, this.momentum = null == e.momentum ? .99 : e.momentum, this.epsilon = null == e.epsilon ? .001 : e.epsilon, this.center = null == e.center || e.center, this.scale = null == e.scale || e.scale, this.betaInitializer = zi(e.betaInitializer || "zeros"), this.gammaInitializer = zi(e.gammaInitializer || "ones"), this.movingMeanInitializer = zi(e.movingMeanInitializer || "zeros"), this.movingVarianceInitializer = zi(e.movingVarianceInitializer || "ones"), this.betaConstraint = ba(e.betaConstraint), this.gammaConstraint = ba(e.gammaConstraint), this.betaRegularizer = Ds(e.betaRegularizer), this.gammaRegularizer = Ds(e.gammaRegularizer) } build(e) { e = ji(e); const t = this.axis >= 0 ? this.axis : this.axis + e.length, n = e[t]; if (null == n) throw new or(`Axis ${t} of input tensor should have a defined dimension but the layer received an input with shape ${JSON.stringify(e)}.`); this.inputSpec = [new qi({ ndim: e.length, axes: { [t]: n } })]; const r = [n]; this.scale && (this.gamma = this.addWeight("gamma", r, null, this.gammaInitializer, this.gammaRegularizer, !0, this.gammaConstraint)), this.center && (this.beta = this.addWeight("beta", r, null, this.betaInitializer, this.betaRegularizer, !0, this.betaConstraint)), this.movingMean = this.addWeight("moving_mean", r, null, this.movingMeanInitializer, null, !1), this.movingVariance = this.addWeight("moving_variance", r, null, this.movingVarianceInitializer, null, !1), this.built = !0 } call(e, t) { return (0, P.tidy)((() => { const n = null != t.training && t.training, r = Li(e), i = r.shape, a = i.length, o = Zr(0, a), s = this.axis >= 0 ? this.axis : this.axis + a; o.splice(s, 1); const u = cr(1, a); u[s] = i[s]; const l = o.slice(); l.sort(); const c = !P.util.arraysEqual(l, Zr(0, a).slice(0, a - 1)); if (!n) return (() => { if (c) { const e = (0, P.reshape)(this.movingMean.read(), u), t = (0, P.reshape)(this.movingVariance.read(), u), n = this.center ? (0, P.reshape)(this.beta.read(), u) : null, i = this.scale ? (0, P.reshape)(this.gamma.read(), u) : null; return Vu(r, e, t, n, i, this.epsilon) } return Vu(r, this.movingMean.read(), this.movingVariance.read(), null == this.beta ? null : this.beta.read(), null == this.gamma ? null : this.gamma.read(), this.epsilon) })(); const [h, d, f] = Gu(r, this.gamma.read(), this.beta.read(), o, this.epsilon), p = (e, t, n) => { P.tidy((() => { const r = 1 - n, i = e.read(), a = P.mul(P.sub(i, t), r); e.write(P.sub(i, a)) })) }; return (() => { p(this.movingMean, d, this.momentum), p(this.movingVariance, f, this.momentum) })(), h })) } getConfig() { const e = { axis: this.axis, momentum: this.momentum, epsilon: this.epsilon, center: this.center, scale: this.scale, betaInitializer: Oi(this.betaInitializer), gammaInitializer: Oi(this.gammaInitializer), movingMeanInitializer: Oi(this.movingMeanInitializer), movingVarianceInitializer: Oi(this.movingVarianceInitializer), betaRegularizer: Ms(this.betaRegularizer), gammaRegularizer: Ms(this.gammaRegularizer), betaConstraint: ga(this.betaConstraint), gammaConstraint: ga(this.gammaConstraint) }, t = super.getConfig(); return Object.assign(e, t), e } } Hu.className = "BatchNormalization", P.serialization.registerClass(Hu); class qu extends Ji { constructor(e) { if (null == e && (e = {}), super(e), this.axis = null == e.axis ? -1 : e.axis, "number" == typeof this.axis) { if (!Number.isInteger(this.axis)) throw new Error(`Expected axis to be an integer, but received ${this.axis}`) } else { if (!Array.isArray(this.axis)) throw new Error(`Expected axis to be an integer or an array of integers, but received ${JSON.stringify(this.axis)}`); for (const e of this.axis) if (!Number.isInteger(e)) throw new Error(`Expected axis to be an array of integers, but received ${JSON.stringify(this.axis)}`) } this.epsilon = null == e.epsilon ? .001 : e.epsilon, this.center = null == e.center || e.center, this.scale = null == e.scale || e.scale, this.betaInitializer = zi(e.betaInitializer || "zeros"), this.gammaInitializer = zi(e.gammaInitializer || "ones"), this.betaRegularizer = Ds(e.betaRegularizer), this.gammaRegularizer = Ds(e.gammaRegularizer), this.supportsMasking = !0 } build(e) { const t = (e = ji(e)).length; "number" == typeof this.axis && (this.axis = [this.axis]); for (let e = 0; e < this.axis.length; ++e)this.axis[e] < 0 && (this.axis[e] += t); for (const e of this.axis) if (e < 0 || e >= t) throw new Error(`Invalid axis: ${e}`); if (this.axis.length !== kr(this.axis).length) throw new Error(`Found duplicate axes in: ${this.axis}`); const n = this.axis.map((t => e[t])), r = !0; this.scale ? this.gamma = this.addWeight("gamma", n, "float32", this.gammaInitializer, this.gammaRegularizer, r) : this.gamma = null, this.center ? this.beta = this.addWeight("beta", n, "float32", this.betaInitializer, this.betaRegularizer, r) : this.beta = null, this.built = !0 } call(e, t) { const n = Li(e), r = n.shape, i = r.length; return (0, P.tidy)((() => { let { mean: e, variance: t } = (0, P.moments)(n, this.axis, !0); const a = cr(1, i); for (const e of this.axis) a[e] = r[e]; const o = e => null != e && e.shape.length !== i ? P.reshape(e, a) : e; let s = this.scale ? o(this.gamma.read()) : null, u = this.center ? o(this.beta.read()) : null; const l = [], c = []; for (let e = 0; e < i; ++e)-1 !== this.axis.indexOf(e) ? (l.push(r[e]), c.push(1)) : (l.push(1), c.push(r[e])); return e = P.tile(e, l), t = P.tile(t, l), null != s && (s = P.tile(s, c)), null != u && (u = P.tile(u, c)), Vu(n, e, t, u, s, this.epsilon) })) } getConfig() { const e = { axis: this.axis, epsilon: this.epsilon, center: this.center, scale: this.scale, betaInitializer: Oi(this.betaInitializer), gammaInitializer: Oi(this.gammaInitializer), betaRegularizer: Ms(this.betaRegularizer), gammaRegularizer: Ms(this.gammaRegularizer) }, t = super.getConfig(); return Object.assign(e, t), e } } qu.className = "LayerNormalization", P.serialization.registerClass(qu); class Yu extends Ji { constructor(e) { if (null == e && (e = {}), super(e), this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, null == e.padding) this.padding = [[1, 1], [1, 1]]; else if ("number" == typeof e.padding) this.padding = [[e.padding, e.padding], [e.padding, e.padding]]; else { if (e.padding = e.padding, 2 !== e.padding.length) throw new or(`ZeroPadding2D expects padding to be a length-2 array, but received a length-${e.padding.length} array.`); let t, n; if ("number" == typeof e.padding[0]) t = [e.padding[0], e.padding[0]], n = [e.padding[1], e.padding[1]]; else { if (e.padding = e.padding, 2 !== e.padding[0].length) throw new or(`ZeroPadding2D expects height padding to be a length-2 array, but received a length-${e.padding[0].length} array.`); if (t = e.padding[0], 2 !== e.padding[1].length) throw new or(`ZeroPadding2D expects width padding to be a length-2 array, but received a length-${e.padding[1].length} array.`); n = e.padding[1] } this.padding = [t, n] } this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { let t, n; return e = ji(e), "channelsFirst" === this.dataFormat ? (t = null != e[2] && e[2] >= 0 ? e[2] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[3] && e[3] >= 0 ? e[3] + this.padding[1][0] + this.padding[1][1] : null, [e[0], e[1], t, n]) : (t = null != e[1] && e[1] >= 0 ? e[1] + this.padding[0][0] + this.padding[0][1] : null, n = null != e[2] && e[2] >= 0 ? e[2] + this.padding[1][0] + this.padding[1][1] : null, [e[0], t, n, e[3]]) } call(e, t) { return (0, P.tidy)((() => { return t = Li(e), n = this.padding, r = this.dataFormat, (0, P.tidy)((() => { if (4 !== t.rank) throw new or(`temporalPadding expects input tensor to be 4-D, but received a ${t.rank}-D tensor.`); if (null == n && (n = [[1, 1], [1, 1]]), 2 !== n.length || 2 !== n[0].length || 2 !== n[1].length) throw new or("spatial2dPadding expects `padding` to be an Array of two Arrays, each of which is an Array of two integers."); if (null == r && (r = "channelsLast"), "channelsLast" !== r && "channelsFirst" !== r) throw new or(`Unknown data format: ${r}. Supported data formats are 'channelsLast' and 'channelsFirst.`); let e; return e = "channelsFirst" === r ? [[0, 0], [0, 0], n[0], n[1]] : [[0, 0], n[0], n[1], [0, 0]], P.pad(t, e) })); var t, n, r })) } getConfig() { const e = { padding: this.padding, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Xu(e, t, n, r, i, a) { return (0, P.tidy)((() => { let o; Br(i), jr(a), Lr(r), null == n && (n = [1, 1]), null == r && (r = "valid"), null == i && (i = "channelsLast"), null == a && (a = "max"), e = Ws(e, i); const s = "same" === r ? "same" : "valid"; return o = "max" === a ? P.maxPool(e, t, n, s) : P.avgPool(e, t, n, s), "channelsFirst" === i && (o = P.transpose(o, [0, 3, 1, 2])), o })) } function Ku(e, t, n, r, i, a) { return (0, P.tidy)((() => { let o; Br(i), jr(a), Lr(r), null == n && (n = [1, 1, 1]), null == r && (r = "valid"), null == i && (i = "channelsLast"), null == a && (a = "max"), e = Vs(e, i); const s = "same" === r ? "same" : "valid"; return o = "max" === a ? P.maxPool3d(e, t, n, s) : P.avgPool3d(e, t, n, s), "channelsFirst" === i && (o = P.transpose(o, [0, 4, 1, 2, 3])), o })) } Yu.className = "ZeroPadding2D", P.serialization.registerClass(Yu); class Zu extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = 2), super(e), "number" == typeof e.poolSize) this.poolSize = [e.poolSize]; else { if (!Array.isArray(e.poolSize) || 1 !== e.poolSize.length || "number" != typeof e.poolSize[0]) throw new or(`poolSize for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.poolSize)}`); this.poolSize = e.poolSize } if (Ar(this.poolSize, "poolSize"), null == e.strides) this.strides = this.poolSize; else if ("number" == typeof e.strides) this.strides = [e.strides]; else { if (!Array.isArray(e.strides) || 1 !== e.strides.length || "number" != typeof e.strides[0]) throw new or(`strides for 1D convolutional layer must be a number or an Array of a single number, but received ${JSON.stringify(e.strides)}`); this.strides = e.strides } Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, Lr(this.padding), this.inputSpec = [new qi({ ndim: 3 })] } computeOutputShape(e) { const t = js((e = ji(e))[1], this.poolSize[0], this.padding, this.strides[0]); return [e[0], t, e[2]] } call(e, t) { return (0, P.tidy)((() => { this.invokeCallHook(e, t), e = ti(Li(e), 2); const n = this.poolingFunction(Li(e), [this.poolSize[0], 1], [this.strides[0], 1], this.padding, "channelsLast"); return P.squeeze(n, [2]) })) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides }, t = super.getConfig(); return Object.assign(e, t), e } } class Ju extends Zu { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "max") } } Ju.className = "MaxPooling1D", P.serialization.registerClass(Ju); class Qu extends Zu { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "avg") } } Qu.className = "AveragePooling1D", P.serialization.registerClass(Qu); class el extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = [2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize], null == e.strides) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (2 !== e.strides.length) throw new or(`If the strides property of a 2D pooling layer is an Array, it is expected to have a length of 2, but received length ${e.strides.length}.`); this.strides = e.strides } else this.strides = [e.strides, e.strides]; Ar(this.poolSize, "poolSize"), Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), Lr(this.padding), this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { e = ji(e); let t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2]; return t = js(t, this.poolSize[0], this.padding, this.strides[0]), n = js(n, this.poolSize[1], this.padding, this.strides[1]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n] : [e[0], t, n, e[3]] } call(e, t) { return (0, P.tidy)((() => (this.invokeCallHook(e, t), this.poolingFunction(Li(e), this.poolSize, this.strides, this.padding, this.dataFormat)))) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class tl extends el { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "max") } } tl.className = "MaxPooling2D", P.serialization.registerClass(tl); class nl extends el { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Xu(e, t, n, r, i, "avg") } } nl.className = "AveragePooling2D", P.serialization.registerClass(nl); class rl extends Ji { constructor(e) { if (null == e.poolSize && (e.poolSize = [2, 2, 2]), super(e), this.poolSize = Array.isArray(e.poolSize) ? e.poolSize : [e.poolSize, e.poolSize, e.poolSize], null == e.strides) this.strides = this.poolSize; else if (Array.isArray(e.strides)) { if (3 !== e.strides.length) throw new or(`If the strides property of a 3D pooling layer is an Array, it is expected to have a length of 3, but received length ${e.strides.length}.`); this.strides = e.strides } else this.strides = [e.strides, e.strides, e.strides]; Ar(this.poolSize, "poolSize"), Ar(this.strides, "strides"), this.padding = null == e.padding ? "valid" : e.padding, this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), Lr(this.padding), this.inputSpec = [new qi({ ndim: 5 })] } computeOutputShape(e) { e = ji(e); let t = "channelsFirst" === this.dataFormat ? e[2] : e[1], n = "channelsFirst" === this.dataFormat ? e[3] : e[2], r = "channelsFirst" === this.dataFormat ? e[4] : e[3]; return t = js(t, this.poolSize[0], this.padding, this.strides[0]), n = js(n, this.poolSize[1], this.padding, this.strides[1]), r = js(r, this.poolSize[2], this.padding, this.strides[2]), "channelsFirst" === this.dataFormat ? [e[0], e[1], t, n, r] : [e[0], t, n, r, e[4]] } call(e, t) { return (0, P.tidy)((() => (this.invokeCallHook(e, t), this.poolingFunction(Li(e), this.poolSize, this.strides, this.padding, this.dataFormat)))) } getConfig() { const e = { poolSize: this.poolSize, padding: this.padding, strides: this.strides, dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class il extends rl { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Ku(e, t, n, r, i, "max") } } il.className = "MaxPooling3D", P.serialization.registerClass(il); class al extends rl { constructor(e) { super(e) } poolingFunction(e, t, n, r, i) { return Br(i), Lr(r), Ku(e, t, n, r, i, "avg") } } al.className = "AveragePooling3D", P.serialization.registerClass(al); class ol extends Ji { constructor(e) { super(e), this.inputSpec = [new qi({ ndim: 3 })] } computeOutputShape(e) { return [e[0], e[2]] } call(e, t) { throw new sr } } class sl extends ol { constructor(e) { super(e || {}) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return P.mean(t, 1) })) } } sl.className = "GlobalAveragePooling1D", P.serialization.registerClass(sl); class ul extends ol { constructor(e) { super(e || {}) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return P.max(t, 1) })) } } ul.className = "GlobalMaxPooling1D", P.serialization.registerClass(ul); class ll extends Ji { constructor(e) { super(e), this.dataFormat = null == e.dataFormat ? "channelsLast" : e.dataFormat, Br(this.dataFormat), this.inputSpec = [new qi({ ndim: 4 })] } computeOutputShape(e) { return "channelsLast" === this.dataFormat ? [e[0], e[3]] : [e[0], e[1]] } call(e, t) { throw new sr } getConfig() { const e = { dataFormat: this.dataFormat }, t = super.getConfig(); return Object.assign(e, t), e } } class cl extends ll { call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return "channelsLast" === this.dataFormat ? P.mean(t, [1, 2]) : P.mean(t, [2, 3]) })) } } cl.className = "GlobalAveragePooling2D", P.serialization.registerClass(cl); class hl extends ll { call(e, t) { return (0, P.tidy)((() => { const t = Li(e); return "channelsLast" === this.dataFormat ? P.max(t, [1, 2]) : P.max(t, [2, 3]) })) } } hl.className = "GlobalMaxPooling2D", P.serialization.registerClass(hl);
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class dl extends Ji { constructor(e) { super(e), this.layer = e.layer } build(e) { this.built = !0 } get trainable() { return null != this.layer && this.layer.trainable } set trainable(e) { null != this.layer && (this.layer.trainable = e) } get trainableWeights() { return this.layer.trainableWeights } get nonTrainableWeights() { return this.layer.nonTrainableWeights } get updates() { return this.layer._updates } get losses() { return this.layer.losses } getWeights() { return this.layer.getWeights() } setWeights(e) { this.layer.setWeights(e) } getConfig() { const e = { layer: { className: this.layer.getClassName(), config: this.layer.getConfig() } }, t = super.getConfig(); return Object.assign(e, t), e } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.layer && this.layer.setFastWeightInitDuringBuild(e) } static fromConfig(e, t, n = {}) { const r = Ka(t.layer, n); delete t.layer; const i = { layer: r }; return Object.assign(i, t), new e(i) } } class fl extends dl { constructor(e) { super(e), this.supportsMasking = !0 } build(e) { if ((e = ji(e)).length < 3) throw new or(`TimeDistributed layer expects an input shape >= 3D, but received input shape ${JSON.stringify(e)}`); this.inputSpec = [{ shape: e }]; const t = [e[0]].concat(e.slice(2)); this.layer.built || (this.layer.build(t), this.layer.built = !0), super.build(e) } computeOutputShape(e) { const t = [(e = ji(e))[0]].concat(e.slice(2)), n = this.layer.computeOutputShape(t), r = e[1]; return [n[0], r].concat(n.slice(1)) } call(e, t) { return (0, P.tidy)((() => su(((e, n) => [Li(this.layer.call(e, t)), []]), e = Li(e), [], !1, null, null, !1, !0)[1])) } } fl.className = "TimeDistributed", P.serialization.registerClass(fl); class pl extends dl { constructor(e) { super(e); const t = e.layer.getConfig(), n = {}; n.className = e.layer.getClassName(), n.config = t, this.forwardLayer = Ka(n), t.goBackwards = !0 !== t.goBackwards; const r = {}; var i; if (r.className = e.layer.getClassName(), r.config = t, this.backwardLayer = Ka(r), this.forwardLayer.name = "forward_" + this.forwardLayer.name, this.backwardLayer.name = "backward_" + this.backwardLayer.name, this.mergeMode = void 0 === e.mergeMode ? "concat" : e.mergeMode, i = this.mergeMode, _r(zr, "BidirectionalMergeMode", i), e.weights) throw new sr("weights support is not implemented for Bidirectional layer yet."); this._stateful = e.layer.stateful, this.returnSequences = e.layer.returnSequences, this.returnState = e.layer.returnState, this.supportsMasking = !0, this._trainable = !0, this.inputSpec = e.layer.inputSpec, this.numConstants = null } get trainable() { return this._trainable } set trainable(e) { this._trainable = e, null != this.forwardLayer && (this.forwardLayer.trainable = e), null != this.backwardLayer && (this.backwardLayer.trainable = e) } getWeights() { return this.forwardLayer.getWeights().concat(this.backwardLayer.getWeights()) } setWeights(e) { const t = e.length, n = Math.floor(t / 2); this.forwardLayer.setWeights(e.slice(0, n)), this.backwardLayer.setWeights(e.slice(n)) } computeOutputShape(e) { let t, n, r, i = this.forwardLayer.computeOutputShape(e); return Array.isArray(i) && Array.isArray(i[0]) || (i = [i]), this.returnState ? (r = i.slice(1), t = i[0]) : t = i[0], "concat" === this.mergeMode ? (t[t.length - 1] *= 2, n = [t]) : n = null == this.mergeMode ? [t, t.slice()] : [t], this.returnState ? null == this.mergeMode ? n.concat(r).concat(r.slice()) : [t].concat(r).concat(r.slice()) : fr(n) } apply(e, t) { let n = null == t ? null : t.initialState, r = null == t ? null : t.constants; null == t && (t = {}); const i = ou(e, n, r, this.numConstants); if (e = i.inputs, n = i.initialState, r = i.constants, Array.isArray(e) && (n = e.slice(1), e = e[0]), (null == n || 0 === n.length) && null == r) return super.apply(e, t); const a = [], o = []; if (null != n) { const e = n.length; if (e % 2 > 0) throw new or("When passing `initialState` to a Bidrectional RNN, the state should be an Array containing the states of the underlying RNNs."); t.initialState = n, a.push(...n); const r = n.map((e => new qi({ shape: e.shape }))); this.forwardLayer.stateSpec = r.slice(0, e / 2), this.backwardLayer.stateSpec = r.slice(e / 2), o.push(...r) } if (null != r) throw new sr("Support for constants in Bidirectional layers is not implemented yet."); const s = a[0] instanceof Yi; for (const e of a) if (e instanceof Yi !== s) throw new or("The initial state of a Bidirectional layer cannot be specified as a mix of symbolic and non-symbolic tensors"); if (s) { const n = [e].concat(a), r = this.inputSpec.concat(o), i = this.inputSpec; this.inputSpec = r; const s = super.apply(n, t); return this.inputSpec = i, s } return super.apply(e, t) } call(e, t) { return (0, P.tidy)((() => { const n = t.initialState; let r, i, a, o; if (null == n) r = this.forwardLayer.call(e, t), i = this.backwardLayer.call(e, t); else { const a = n.slice(0, n.length / 2), o = n.slice(n.length / 2); r = this.forwardLayer.call(e, Object.assign(t, { initialState: a })), i = this.backwardLayer.call(e, Object.assign(t, { initialState: o })) } return this.returnState && (Array.isArray(r) && (a = r.slice(1).concat(i.slice(1))), r = r[0], i = i[0]), this.returnSequences && (i = P.reverse(i, 1)), "concat" === this.mergeMode ? o = ai([r, i]) : "sum" === this.mergeMode ? o = P.add(r, i) : "ave" === this.mergeMode ? o = P.mul(.5, P.add(r, i)) : "mul" === this.mergeMode ? o = P.mul(r, i) : null == this.mergeMode && (o = [r, i]), this.returnState ? null == this.mergeMode ? o.concat(a) : [o].concat(a) : o })) } resetStates(e) { this.forwardLayer.resetStates(), this.backwardLayer.resetStates() } build(e) { Wr(this.forwardLayer.name, (() => { this.forwardLayer.build(e) })), Wr(this.backwardLayer.name, (() => { this.backwardLayer.build(e) })), this.built = !0 } computeMask(e, t) { let n; if (Array.isArray(t) && (t = t[0]), n = this.returnSequences ? null == this.mergeMode ? [t, t] : t : null == this.mergeMode ? [null, null] : null, this.returnState) { const e = this.forwardLayer.states.map((e => null)); return Array.isArray(n) ? n.concat(e).concat(e) : [n].concat(e).concat(e) } return n } get trainableWeights() { return this.forwardLayer.trainableWeights.concat(this.backwardLayer.trainableWeights) } get nonTrainableWeights() { return this.forwardLayer.nonTrainableWeights.concat(this.backwardLayer.nonTrainableWeights) } setFastWeightInitDuringBuild(e) { super.setFastWeightInitDuringBuild(e), null != this.forwardLayer && this.forwardLayer.setFastWeightInitDuringBuild(e), null != this.backwardLayer && this.backwardLayer.setFastWeightInitDuringBuild(e) } getConfig() { const e = { mergeMode: this.mergeMode }, t = super.getConfig(); return Object.assign(e, t), e } static fromConfig(e, t) { const n = Ka(t.layer); if (delete t.layer, null != t.numConstants) throw new sr("Deserialization of a Bidirectional layer with numConstants present is not supported yet."); const r = t; return r.layer = n, new e(r) } } pl.className = "Bidirectional", P.serialization.registerClass(pl);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class ml extends Ji { constructor(e) { super(e), this.scale = e.scale, e.offset ? this.offset = e.offset : this.offset = 0 } getConfig() { const e = { scale: this.scale, offset: this.offset }, t = super.getConfig(); return Object.assign(e, t), e } call(e, t) { return (0, P.tidy)((() => ("float32" !== (e = Li(e)).dtype && (e = ei(e, "float32")), (0, P.add)((0, P.mul)(e, this.scale), this.offset)))) } } ml.className = "Rescaling", P.serialization.registerClass(ml);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const { resizeBilinear: gl, cropAndResize: yl } = P.image; class bl extends Ji { constructor(e) { super(e), this.height = e.height, this.width = e.width } centerCrop(e, t, n, r, i, a, o, s) { return (0, P.tidy)((() => { let u, l = !1; const c = [t / a, n / o, (r + t) / a, (i + n) / o], h = []; 3 === e.rank ? (l = !0, u = (0, P.stack)([e])) : u = e; for (let e = 0; e < u.shape[0]; e++)h.push(c); const d = (0, P.tensor)(h, [h.length, 4]), f = (0, P.range)(0, h.length, 1, "int32"), p = yl(u, d, f, [r, i], "nearest"); return ei(l ? Li((0, P.unstack)(p)) : p, s) })) } upsize(e, t, n, r) { return (0, P.tidy)((() => ei(gl(e, [t, n]), r))) } call(e, t) { return (0, P.tidy)((() => { const t = Li(e), n = t.dtype, r = t.shape, i = r[r.length - 3], a = r[r.length - 2]; let o = 0; i !== this.height && (o = Math.floor((i - this.height) / 2)); let s = 0; return a !== this.width && (s = Math.floor((a - this.width) / 2), 0 === s && (s = 1)), o >= 0 && s >= 0 ? this.centerCrop(t, o, s, this.height, this.width, i, a, n) : this.upsize(e, this.height, this.width, n) })) } getConfig() { const e = { height: this.height, width: this.width }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { const t = (e = ji(e)).length - 3, n = e.length - 2; return e[t] = this.height, e[n] = this.width, e } } bl.className = "CenterCrop", P.serialization.registerClass(bl);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class vl extends Ji {
constructor(e) { super(e), this.numTokens = e.numTokens, e.outputMode ? this.outputMode = e.outputMode : this.outputMode = "multiHot" } getConfig() { const e = { numTokens: this.numTokens, outputMode: this.outputMode }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { return null == (e = ji(e)) ? [this.numTokens] : "oneHot" === this.outputMode && 1 !== e[e.length - 1] ? (e.push(this.numTokens), e) : (e[e.length - 1] = this.numTokens, e) } call(e, t) {
return (0, P.tidy)((() => {
let n; if ("int32" !== (e = Li(e)).dtype && (e = ei(e, "int32")), void 0 !== t.countWeights) { if ("count" !== this.outputMode) throw new or(`countWeights is not used when outputMode !== count.\n Received countWeights=${t.countWeights}`); n = Li(t.countWeights) } const r = (0, P.max)(e), i = (0, P.min)(e), a = (0, P.greater)(this.numTokens, r).bufferSync().get(0), o = (0, P.greaterEqual)(i, 0).bufferSync().get(0); if (!a || !o) throw new or(`Input values must be between 0 < values <= numTokens with numTokens=${this.numTokens}`);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
return function (e, t, n, r) { let i = Li(e); if ("int32" !== i.dtype && (i = ei(i, "int32")), "int" === t) return i; const a = i.shape; if (0 === i.rank && (i = (0, P.expandDims)(i, -1)), "oneHot" === t && 1 !== i.shape[i.shape.length - 1] && (i = (0, P.expandDims)(i, -1)), i.rank > 2) throw new or(`When outputMode is not int, maximum output rank is 2 Received outputMode ${t} and input shape ${a} which would result in output rank ${i.rank}.`); const o = ["multiHot", "oneHot"].includes(t), s = i; let u; if (u = void 0 !== r && "count" === t ? (0, P.denseBincount)(s, r, n, o) : (0, P.denseBincount)(s, [], n, o), "tfIdf" !== t) return u; if (r) return (0, P.mul)(u, r); throw new or("When outputMode is 'tfIdf', weights must be provided.") }(e, this.outputMode, this.numTokens, n)
}))
}
} vl.className = "CategoryEncoding", P.serialization.registerClass(vl);
/**
* @license
* Copyright 2022 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const xl = new Set(["bilinear", "nearest"]); class wl extends Ji { constructor(e) { if (super(e), this.height = e.height, this.width = e.width, e.interpolation) { if (!xl.has(e.interpolation)) throw new or(`Invalid interpolation parameter: ${e.interpolation} is not implemented`); this.interpolation = e.interpolation } else this.interpolation = "bilinear"; this.cropToAspectRatio = Boolean(e.cropToAspectRatio) } computeOutputShape(e) { const t = (e = ji(e))[2]; return [this.height, this.width, t] } getConfig() { const e = { height: this.height, width: this.width, interpolation: this.interpolation, cropToAspectRatio: this.cropToAspectRatio }, t = super.getConfig(); return Object.assign(e, t), e } call(e, t) { return (0, P.tidy)((() => { const t = [this.height, this.width]; if ("bilinear" === this.interpolation) return P.image.resizeBilinear(e, t, !this.cropToAspectRatio); if ("nearest" === this.interpolation) return P.image.resizeNearestNeighbor(e, t, !this.cropToAspectRatio); throw new Error(`Interpolation is ${this.interpolation} but only ${[...xl]} are supported`) })) } } wl.className = "Resizing", P.serialization.registerClass(wl);
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class kl { constructor(e) { this.seed = e } next() { if (void 0 !== this.seed) return this.seed++ } } kl.className = "RandomSeed";
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class Sl extends Ji { constructor(e) { super(e), this.randomGenerator = new kl(e.seed) } getConfig() { const e = { seed: this.randomGenerator.seed }, t = super.getConfig(); return Object.assign(e, t), e } } Sl.className = "BaseRandomLayer";
/**
* @license
* Copyright 2023 CodeSmith LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
const _l = new Set(["bilinear", "nearest"]); class Cl extends Sl { constructor(e) { super(e); const { factor: t, interpolation: n = "bilinear" } = e; if (this.factor = t, Array.isArray(this.factor) && 2 === this.factor.length) this.widthLower = this.factor[0], this.widthUpper = this.factor[1]; else { if (Array.isArray(this.factor) || !(this.factor > 0)) throw new or(`Invalid factor: ${this.factor}. Must be positive number or tuple of 2 numbers`); this.widthLower = -this.factor, this.widthUpper = this.factor } if (this.widthLower < -1 || this.widthUpper < -1) throw new or(`factor must have values larger than -1. Got: ${this.factor}`); if (this.widthUpper < this.widthLower) throw new or(`factor cannot have upper bound less than lower bound.\n Got upper bound: ${this.widthUpper}.\n Got lower bound: ${this.widthLower}\n `); if (n) { if (!_l.has(n)) throw new or(`Invalid interpolation parameter: ${n} is not implemented`); this.interpolation = n } } getConfig() { const e = { factor: this.factor, interpolation: this.interpolation }, t = super.getConfig(); return Object.assign(e, t), e } computeOutputShape(e) { const t = (e = ji(e))[2]; return [this.imgHeight, -1, t] } call(e, t) { return (0, P.tidy)((() => { const t = Li(e); this.imgHeight = t.shape[t.shape.length - 3]; const n = t.shape[t.shape.length - 2]; this.widthFactor = (0, P.randomUniform)([1], 1 + this.widthLower, 1 + this.widthUpper, "float32", this.randomGenerator.next()); let r = this.widthFactor.dataSync()[0] * n; r = Math.round(r); const i = [this.imgHeight, r]; switch (this.interpolation) { case "bilinear": return P.image.resizeBilinear(e, i); case "nearest": return P.image.resizeNearestNeighbor(e, i); default: throw new Error(`Interpolation is ${this.interpolation}\n but only ${[..._l]} are supported`) } })) } }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function Al(e) { return new ea(e) } function Tl(e) { return new zs(e) } function El(e) { return new $s(e) } function Nl(e) { return new Rs(e) } function Il(e) { return new Os(e) } function Ml(e) { return new Bs(e) } function Fl(e) { return new Ps(e) } function Dl(e) { return new nu(e) } function $l(e) { return new Ks(e) } function Rl(e) { return new Js(e) } function Ol(e) { return new Zs(e) } function zl(e) { return new Qs(e) } function Pl(e) { return new tu(e) } function Bl(e) { return new ru(e) } function Ll(e) { return new iu(e) } function jl(e) { return new au(e) } function Ul(e) { return new Au(e) } function Wl(e) { return new _u(e) } function Vl(e) { return new ku(e) } function Gl(e) { return new Su(e) } function Hl(e) { return new Cu(e) } function ql(e) { return new Tu(e) } function Yl(e) { return new Eu(e) } function Xl(e) { return new Nu(e) } function Kl(e) { return new Mu(e) } function Zl(e) { return new Du(e) } function Jl(e) { return new Ru(e) } function Ql(e) { return new Pu(e) } function ec(e) { return new Ou(e) } function tc(e) { return new zu(e) } function nc(e) { return new $u(e) } function rc(e) { return new Lu(e) } function ic(e) { return new Hu(e) } function ac(e) { return new qu(e) } function oc(e) { return new Yu(e) } function sc(e) { return new Qu(e) } function uc(e) { return sc(e) } function lc(e) { return sc(e) } function cc(e) { return new nl(e) } function hc(e) { return cc(e) } function dc(e) { return cc(e) } function fc(e) { return new al(e) } function pc(e) { return fc(e) } function mc(e) { return fc(e) } function gc(e) { return new sl(e) } function yc(e) { return new cl(e) } function bc(e) { return new ul(e) } function vc(e) { return new hl(e) } function xc(e) { return new Ju(e) } function wc(e) { return new tl(e) } function kc(e) { return new il(e) } function Sc(e) { return new fu(e) } function _c(e) { return new du(e) } function Cc(e) { return new mu(e) } function Ac(e) { return new pu(e) } function Tc(e) { return new hu(e) } function Ec(e) { return new cu(e) } function Nc(e) { return new wu(e) } function Ic(e) { return new xu(e) } function Mc(e) { return new uu(e) } function Fc(e) { return new gu(e) } function Dc(e) { return new pl(e) } function $c(e) { return new fl(e) } Cl.className = "RandomWidth", P.serialization.registerClass(Cl); const Rc = bc, Oc = vc, zc = xc, Pc = wc; function Bc(e) { return new ju(e) } function Lc(e) { return new Uu(e) } function jc(e) { return new Wu(e) } function Uc(e) { return new Iu(e) } function Wc(e) { return new ml(e) } function Vc(e) { return new bl(e) } function Gc(e) { return new wl(e) } function Hc(e) { return new vl(e) } function qc(e) { return new Cl(e) } function Yc(e, t) { return lo(e, t) } function Xc(e, t) { return mo(e, t) } function Kc(e, t) { return go(e, t) } function Zc(e, t) { return co(e, t) } function Jc(e, t) { return yo(e, t) } function Qc(e, t) { return fo(e, t) } function eh(e, t) { return po(e, t) } function th(e, t) { return oo(e, t) } function nh(e, t) { return Qa(e, t) } function rh(e, t) { return eo(e, t) } function ih(e, t) { return eo(e, t) } function ah(e, t) { return eo(e, t) } function oh(e, t) { return Ja(e, t) } function sh(e, t) { return Ja(e, t) } function uh(e, t) { return Ja(e, t) } function lh(e, t) { return function (e, t) { return (0, P.tidy)((() => { const n = e.sub(t).square().sum(), r = e.sub(e.mean()).square().sum(); return P.scalar(1).sub(n.div(r)) })) }(e, t) }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
function ch(e) { return new Ns(e) } function hh(e) { return Ts(t = e), new Ns({ l1: null != t ? t.l1 : null, l2: 0 }); var t } function dh(e) { return Ts(t = e), new Ns({ l2: null != t ? t.l2 : null, l1: 0 }); var t }
/**
* @license
* Copyright 2018 Google LLC
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
* =============================================================================
*/
class fh extends Ua { constructor() { super(...arguments), this.model = null } setModel(e) { if (!(e instanceof Jo)) throw new Error("model must be a LayersModel, not some other Container"); this.model = e } } function ph(e, t) { return e < t } function mh(e, t) { return e > t } class gh extends fh { constructor(e) { if (super(), null == e && (e = {}), e.restoreBestWeights) throw new sr("restoreBestWeights = True is not implemented in EarlyStopping yet."); this.monitor = e.monitor || "val_loss", this.minDelta = Math.abs(e.minDelta || 0), this.patience = e.patience || 0, this.verbose = e.verbose || 0, this.mode = e.mode || "auto", this.baseline = e.baseline, -1 === ["auto", "min", "max"].indexOf(this.mode) && (console.warn(`EarlyStopping mode '${this.mode}' is invalid. Falling back to mode 'auto'.`), this.mode = "auto"), "min" === this.mode ? this.monitorFunc = ph : "max" === this.mode || -1 !== this.monitor.indexOf("acc") ? this.monitorFunc = mh : this.monitorFunc = ph, this.monitorFunc === ph && (this.minDelta *= -1) } async onTrainBegin(e) { this.wait = 0, this.stoppedEpoch = 0, null != this.baseline ? this.best = this.baseline : this.best = this.monitorFunc === ph ? 1 / 0 : -1 / 0 } async onEpochEnd(e, t) { await Pa(t); const n = this.getMonitorValue(t); null != n && (this.monitorFunc(n - this.minDelta, this.best) ? (this.best = n, this.wait = 0) : (this.wait++, this.wait >= this.patience && (this.stoppedEpoch = e, this.model.stopTraining = !0))) } async onTrainEnd(e) { this.stoppedEpoch > 0 && this.verbose && console.log(`Epoch ${this.stoppedEpoch}: early stopping.`) } getMonitorValue(e) { null == e && (e = {}); const t = e[this.monitor]; return null == t && console.warn(`Metric for EarlyStopping ${this.monitor} is not available. Available metrics are: ${Object.keys(e)}`), t } } const yh = { earlyStopping: function (e) { return new gh(e) } };
/**
* @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 bh, vh, xh; (0, P.env)().registerFlag("KEEP_INTERMEDIATE_TENSORS", (() => !1), (e => { e && console.warn("Keep intermediate tensors is ON. This will print the values of all intermediate tensors during model inference. Not all models support this mode. For details, check e2e/benchmarks/ model_config.js. This significantly impacts performance.") })), (vh = bh || (bh = {}))[vh.DT_INVALID = 0] = "DT_INVALID", vh[vh.DT_FLOAT = 1] = "DT_FLOAT", vh[vh.DT_DOUBLE = 2] = "DT_DOUBLE", vh[vh.DT_INT32 = 3] = "DT_INT32", vh[vh.DT_UINT8 = 4] = "DT_UINT8", vh[vh.DT_INT16 = 5] = "DT_INT16", vh[vh.DT_INT8 = 6] = "DT_INT8", vh[vh.DT_STRING = 7] = "DT_STRING", vh[vh.DT_COMPLEX64 = 8] = "DT_COMPLEX64", vh[vh.DT_INT64 = 9] = "DT_INT64", vh[vh.DT_BOOL = 10] = "DT_BOOL", vh[vh.DT_QINT8 = 11] = "DT_QINT8", vh[vh.DT_QUINT8 = 12] = "DT_QUINT8", vh[vh.DT_QINT32 = 13] = "DT_QINT32", vh[vh.DT_BFLOAT16 = 14] = "DT_BFLOAT16", vh[vh.DT_QINT16 = 15] = "DT_QINT16", vh[vh.DT_QUINT16 = 16] = "DT_QUINT16", vh[vh.DT_UINT16 = 17] = "DT_UINT16", vh[vh.DT_COMPLEX128 = 18] = "DT_COMPLEX128", vh[vh.DT_HALF = 19] = "DT_HALF", vh[vh.DT_RESOURCE = 20] = "DT_RESOURCE", vh[vh.DT_VARIANT = 21] = "DT_VARIANT", vh[vh.DT_UINT32 = 22] = "DT_UINT32", vh[vh.DT_UINT64 = 23] = "DT_UINT64", vh[vh.DT_FLOAT_REF = 101] = "DT_FLOAT_REF", vh[vh.DT_DOUBLE_REF = 102] = "DT_DOUBLE_REF", vh[vh.DT_INT32_REF = 103] = "DT_INT32_REF", vh[vh.DT_UINT8_REF = 104] = "DT_UINT8_REF", vh[vh.DT_INT16_REF = 105] = "DT_INT16_REF", vh[vh.DT_INT8_REF = 106] = "DT_INT8_REF", vh[vh.DT_STRING_REF = 107] = "DT_STRING_REF", vh[vh.DT_COMPLEX64_REF = 108] = "DT_COMPLEX64_REF", vh[vh.DT_INT64_REF = 109] = "DT_INT64_REF", vh[vh.DT_BOOL_REF = 110] = "DT_BOOL_REF", vh[vh.DT_QINT8_REF = 111] = "DT_QINT8_REF", vh[vh.DT_QUINT8_REF = 112] = "DT_QUINT8_REF", vh[vh.DT_QINT32_REF = 113] = "DT_QINT32_REF", vh[vh.DT_BFLOAT16_REF = 114] = "DT_BFLOAT16_REF", vh[vh.DT_QINT16_REF = 115] = "DT_QINT16_REF", vh[vh.DT_QUINT16_REF = 116] = "DT_QUINT16_REF", vh[vh.DT_UINT16_REF = 117] = "DT_UINT16_REF", vh[vh.DT_COMPLEX128_REF = 118] = "DT_COMPLEX128_REF", vh[vh.DT_HALF_REF = 119] = "DT_HALF_REF", vh[vh.DT_RESOURCE_REF = 120] = "DT_RESOURCE_REF", vh[vh.DT_VARIANT_REF = 121] = "DT_VARIANT_REF", vh[vh.DT_UINT32_REF = 122] = "DT_UINT32_REF", vh[vh.DT_UINT64_REF = 123] = "DT_UINT64_REF", function (e) { let t; !function (e) { e[e.LEGACY = 0] = "LEGACY", e[e.V1 = 1] = "V1", e[e.V2 = 2] = "V2" }(t = e.CheckpointFormatVersion || (e.CheckpointFormatVersion = {})) }(xh || (xh = {}));
/**
* @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 wh = {}; function kh(e, t) { const n = { tfOpName: e, category: "custom", inputs: [], attrs: [], customExecutor: t }; wh[e] = n } function Sh(e) { return wh[e] } function _h(e) { delete wh[e] }
/**
* @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 Ch(e, t, n, r, i) { const a = t.inputParams[e]; if (a && void 0 !== a.inputIndexStart) { const e = a.inputIndexStart, o = 0 === a.inputIndexEnd ? void 0 : void 0 === a.inputIndexEnd ? e + 1 : a.inputIndexEnd, s = e < 0 ? t.inputNames.length + e : e; if ("tensor" === a.type) return Ah(t.inputNames[s], n, r, i); if ("tensors" === a.type) { const a = t.inputs.slice(e, o); return t.inputNames.slice(e, o).filter(((e, t) => { var n; return "NoOp" !== (null === (n = a[t]) || void 0 === n ? void 0 : n.op) })).map((e => Ah(e, n, r, i))) } const u = Ah(t.inputNames[s], n, r, i), l = u.dataSync(); return "number" === a.type ? l[0] : P.util.toNestedArray(u.shape, l) } const o = t.attrParams[e]; return o && o.value } function Ah(e, t, n, r) { const [i, a] = Ih(e, n); if (null != r) { const e = r.getHashTableHandleByName(i); if (null != e) return e } const o = n.currentContextIds.find((e => !!t[Nh(i, e)])); return void 0 !== o ? t[Nh(i, o)][a] : void 0 } function Th(e, t, n) { return t[Nh(e, n.currentContextId)] } function Eh(e, t) { const [n, r, i] = Ih(e, t); return [Nh(n, t && t.currentContextId), r, i] } function Nh(e, t) { return t ? `${e}-${t}` : e } function Ih(e, t) { if ("" === e) return ["", 0, void 0]; const n = null != t && null != t.parseNodeNameCache; if (n) { const n = t.parseNodeNameCache.get(e); if (null != n) return n } const r = e.split(":"); let i; if (1 === r.length) i = [e, 0, void 0]; else { const e = r[0], t = 3 === r.length ? r[1] : void 0; i = [e, Number(r[r.length - 1]), t] } return n && t.parseNodeNameCache.set(e, i), i } function Mh(e, t, n) { let r = Ch("pad", e, t, n); if ("explicit" === r) { r = Ch("explicitPaddings", e, t, n); const i = [[0, 0], [0, 0], [0, 0], [0, 0]]; for (let e = 0; e < 4; e++)i[e][0] = r[2 * e], i[e][1] = r[2 * e + 1]; return i } return r } function Fh(e) { return e.kept ? e : (0, P.clone)(e) }
/**
* @license
* Copyright 2023 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 Dh = [{ tfOpName: "Add", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AddV2", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AddN", category: "arithmetic", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "BiasAdd", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "Sub", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "RealDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Div", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "DivNoNan", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "FloorDiv", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Mul", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Maximum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Minimum", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Pow", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SquaredDifference", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Mod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "FloorMod", category: "arithmetic", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], $h = [{ tfOpName: "Abs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Acos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Asin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atan2", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Ceil", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ClipByValue", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "clipValueMin", type: "number" }, { start: 2, name: "clipValueMax", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Complex", category: "basic_math", inputs: [{ start: 0, name: "real", type: "tensor" }, { start: 1, name: "imag", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ComplexAbs", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cos", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Elu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Exp", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Floor", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Log", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Imag", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: !0 }] }, { tfOpName: "Neg", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Real", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "outputType", type: "dtype", notSupported: !0 }] }, { tfOpName: "Prelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "alpha", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Relu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Relu6", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Selu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sigmoid", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sin", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Rsqrt", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Square", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Tan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Tanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Sign", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Round", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Expm1", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Log1p", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Reciprocal", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Softplus", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Asinh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Acosh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Atanh", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Erf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LeakyRelu", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "alpha", name: "alpha", type: "number", defaultValue: .2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsNan", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsFinite", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "IsInf", category: "basic_math", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], Rh = [{ tfOpName: "EmptyTensorList", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "maxNumElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "LoopCond", category: "control", inputs: [{ start: 0, name: "pred", type: "tensor" }] }, { tfOpName: "Switch", category: "control", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "pred", type: "tensor" }] }, { tfOpName: "Merge", category: "control", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }] }, { tfOpName: "Enter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "frame_name", name: "frameName", type: "string" }, { tfName: "is_constant", name: "isConstant", type: "bool" }] }, { tfOpName: "Exit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "NextIteration", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayV3", category: "control", inputs: [{ start: 0, name: "size", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "dynamic_size", name: "dynamicSize", type: "bool" }, { tfName: "clear_after_read", name: "clearAfterRead", type: "bool" }, { tfName: "identical_element_shapes", name: "identicalElementShapes", type: "bool" }, { tfName: "tensor_array_name", name: "name", type: "string" }] }, { tfOpName: "TensorArrayWriteV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayReadV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "TensorArrayGatherV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape", name: "elementShape", type: "shape" }] }, { tfOpName: "TensorArrayScatterV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "tensor", type: "tensor" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArrayConcatV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "element_shape_except0", name: "elementShapeExcept0", type: "shape", notSupported: !0 }] }, { tfOpName: "TensorArraySplitV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }, { start: 2, name: "lengths", type: "number[]" }, { start: 3, name: "flowIn", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "TensorArraySizeV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }, { start: 1, name: "flowIn", type: "number" }] }, { tfOpName: "TensorArrayCloseV3", category: "control", inputs: [{ start: 0, name: "tensorArrayId", type: "tensor" }] }, { tfOpName: "StatelessIf", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "If", category: "control", inputs: [{ start: 0, name: "cond", type: "tensor" }, { start: 1, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "then_branch", name: "thenBranch", type: "func" }, { tfName: "else_branch", name: "elseBranch", type: "func" }] }, { tfOpName: "StatelessWhile", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "While", category: "control", inputs: [{ start: 0, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "cond", name: "cond", type: "func" }, { tfName: "body", name: "body", type: "func" }] }, { tfOpName: "TensorListScatter", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListScatterV2", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }, { start: 3, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGather", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "indices", type: "number[]" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListGetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListSetItem", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "index", type: "number" }, { start: 2, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListReserve", category: "control", inputs: [{ start: 0, name: "elementShape", type: "shape" }, { start: 1, name: "numElements", type: "number" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListFromTensor", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListStack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }, { tfName: "num_elements", name: "numElements", type: "dtype" }] }, { tfOpName: "TensorListSplit", category: "control", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }, { start: 2, name: "lengths", type: "number[]" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcat", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListConcatV2", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }], attrs: [{ tfName: "element_shape", name: "elementShape", type: "shape" }, { tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPopBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "elementShape", type: "shape" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListPushBack", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "tensor", type: "tensor" }], attrs: [{ tfName: "element_dtype", name: "elementDType", type: "dtype" }] }, { tfOpName: "TensorListLength", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }] }, { tfOpName: "TensorListResize", category: "control", inputs: [{ start: 0, name: "tensorListId", type: "tensor" }, { start: 1, name: "size", type: "number" }] }], Oh = [{ tfOpName: "AvgPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPool", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [], notSupported: !0 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPoolWithArgmax", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "include_batch_in_index", name: "includeBatchInIndex", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "AvgPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MaxPool3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "ksize", name: "kernelSize", type: "number[]" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Conv1D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "stride", name: "stride", type: "number" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NWC" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "dilation", name: "dilation", type: "number", defaultValue: 1 }] }, { tfOpName: "Conv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "useCudnnOnGpu", name: "useCudnnOnGpu", type: "bool" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "_FusedConv2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "use_cudnn_on_gpu", name: "useCudnnOnGpu", type: "bool", defaultValue: !0 }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: .2 }] }, { tfOpName: "Conv2DBackpropInput", category: "convolution", inputs: [{ start: 2, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 0, name: "outputShape", type: "number[]" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]", notSupported: !0 }] }, { tfOpName: "DepthwiseConv2d", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "DepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "FusedDepthwiseConv2dNative", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]", defaultValue: [1, 1, 1, 1] }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "explicit_paddings", name: "explicitPaddings", type: "number[]", defaultValue: [] }] }, { tfOpName: "Conv3D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }, { tfName: "data_format", name: "dataFormat", type: "string", defaultValue: "NHWC" }, { tfName: "dilations", name: "dilations", type: "number[]" }] }, { tfOpName: "Dilation2D", category: "convolution", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "filter", type: "tensor" }], attrs: [{ tfName: "strides", name: "strides", type: "number[]" }, { tfName: "rates", name: "dilations", type: "number[]" }, { tfName: "padding", name: "pad", type: "string" }] }], zh = [{ tfOpName: "Fill", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }, { start: 1, name: "value", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "LinSpace", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "num", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "OneHot", category: "creation", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "depth", type: "number" }, { start: 2, name: "onValue", type: "number", defaultValue: 1 }, { start: 3, name: "offValue", type: "number", defaultValue: 0 }], attrs: [{ tfName: "axis", name: "axis", type: "number", notSupported: !0 }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Ones", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "OnesLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "RandomStandardNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "RandomUniform", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number", defaultValue: 0 }, { tfName: "maxval", name: "maxval", type: "number", defaultValue: 1 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "RandomUniformInt", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "minval", name: "minval", type: "number" }, { tfName: "maxval", name: "maxval", type: "number" }, { tfName: "seed", name: "seed", type: "number", defaultValue: 0 }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }] }, { tfOpName: "Range", category: "creation", inputs: [{ start: 0, name: "start", type: "number" }, { start: 1, name: "stop", type: "number" }, { start: 2, name: "step", type: "number", defaultValue: 0 }], attrs: [{ tfName: "Tidx", name: "dtype", type: "dtype" }] }, { tfOpName: "TruncatedNormal", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "means", name: "mean", type: "number", defaultValue: 0 }, { tfName: "stddev", name: "stdDev", type: "number", defaultValue: 1 }, { tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number", defaultValue: 0, notSupported: !0 }, { tfName: "dtype", name: "dtype", type: "dtype" }, { tfName: "T", name: "T", type: "number", notSupported: !0 }] }, { tfOpName: "Zeros", category: "creation", inputs: [{ start: 0, name: "shape", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "ZerosLike", category: "creation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "Multinomial", category: "creation", inputs: [{ start: 0, name: "logits", type: "tensor" }, { start: 1, name: "numSamples", type: "number" }], attrs: [{ tfName: "seed", name: "seed", type: "number" }, { tfName: "seed2", name: "seed2", type: "number" }, { tfName: "T", name: "dtype", type: "dtype" }, { tfName: "output_dtype", name: "output_dtype", type: "dtype" }] }], Ph = [{ tfOpName: "NonMaxSuppressionV2", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV3", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }] }, { tfOpName: "NonMaxSuppressionV4", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }, { tfName: "T_threshold", name: "threshold", type: "dtype", notSupported: !0 }, { tfName: "pad_to_max_output_size", name: "padToMaxOutputSize", type: "bool" }] }, { tfOpName: "NonMaxSuppressionV5", category: "dynamic", inputs: [{ start: 0, name: "boxes", type: "tensor" }, { start: 1, name: "scores", type: "tensor" }, { start: 2, name: "maxOutputSize", type: "number" }, { start: 3, name: "iouThreshold", type: "number" }, { start: 4, name: "scoreThreshold", type: "number" }, { start: 5, name: "softNmsSigma", type: "number" }] }, { tfOpName: "Where", category: "dynamic", inputs: [{ start: 0, name: "condition", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ListDiff", category: "dynamic", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }], Bh = [{ tfOpName: "LowerBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "TopKV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "k", type: "number" }], attrs: [{ tfName: "sorted", name: "sorted", type: "bool" }] }, { tfOpName: "UpperBound", category: "evaluation", inputs: [{ start: 0, name: "sortedSequence", type: "tensor" }, { start: 1, name: "values", type: "tensor" }] }, { tfOpName: "Unique", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "UniqueV2", category: "evaluation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }], Lh = [{ tfOpName: "PlaceholderWithDefault", category: "graph", inputs: [{ start: 0, name: "default", type: "tensor" }], attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Placeholder", category: "graph", attrs: [{ tfName: "shape", name: "shape", type: "shape" }, { tfName: "dtype", name: "dtype", type: "dtype" }] }, { tfOpName: "Const", category: "graph" }, { tfOpName: "Identity", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IdentityN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Snapshot", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Rank", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Size", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "Shape", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "ShapeN", category: "graph", inputs: [{ start: 0, end: 0, name: "x", type: "tensors" }] }, { tfOpName: "Print", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "data", type: "tensors" }], attrs: [{ tfName: "message", name: "message", type: "string" }, { tfName: "first_n", name: "firstN", type: "number", notSupported: !0 }, { tfName: "summarize", name: "summarize", type: "number", defaultValue: 3 }] }, { tfOpName: "NoOp", category: "graph", inputs: [] }, { tfOpName: "StopGradient", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "FakeQuantWithMinMaxVars", category: "graph", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "min", name: "min", type: "number" }, { tfName: "max", name: "max", type: "number" }] }], jh = [{ tfOpName: "HashTable", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "HashTableV2", category: "hash_table", inputs: [], attrs: [{ tfName: "shared_name", name: "sharedName", type: "string" }, { tfName: "use_node_name_sharing", name: "useNodeNameSharing", type: "bool" }, { tfName: "key_dtype", name: "keyDType", type: "dtype" }, { tfName: "value_dtype", name: "valueDType", type: "dtype" }] }, { tfOpName: "LookupTableImport", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableImportV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableFind", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableFindV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "Tin", name: "tIn", type: "dtype", notSupported: !0 }, { tfName: "Tout", name: "tOut", type: "dtype", notSupported: !0 }] }, { tfOpName: "LookupTableSize", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "LookupTableSizeV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }] }, { tfOpName: "InitializeTable", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }, { tfOpName: "InitializeTableV2", category: "hash_table", inputs: [{ start: 0, name: "tableHandle", type: "tensor" }, { start: 1, name: "keys", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }], Uh = [{ tfOpName: "ResizeBilinear", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "ResizeNearestNeighbor", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "size", type: "number[]" }], attrs: [{ tfName: "align_corners", name: "alignCorners", type: "bool" }, { tfName: "half_pixel_centers", name: "halfPixelCenters", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "CropAndResize", category: "image", inputs: [{ start: 0, name: "image", type: "tensor" }, { start: 1, name: "boxes", type: "tensor" }, { start: 2, name: "boxInd", type: "tensor" }, { start: 3, name: "cropSize", type: "number[]" }], attrs: [{ tfName: "method", name: "method", type: "string" }, { tfName: "extrapolation_value", name: "extrapolationValue", type: "number" }] }, { tfOpName: "ImageProjectiveTransformV3", category: "image", inputs: [{ start: 0, name: "images", type: "tensor" }, { start: 1, name: "transforms", type: "tensor" }, { start: 2, name: "outputShape", type: "number[]" }, { start: 3, name: "fillValue", type: "number" }], attrs: [{ tfName: "interpolation", name: "interpolation", type: "string" }, { tfName: "fill_mode", name: "fillMode", type: "string" }] }], Wh = [{ tfOpName: "Equal", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "NotEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Greater", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "GreaterEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Less", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LessEqual", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalAnd", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalNot", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "LogicalOr", category: "logical", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Select", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SelectV2", category: "logical", inputs: [{ start: 0, name: "condition", type: "tensor" }, { start: 1, name: "a", type: "tensor" }, { start: 2, name: "b", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BitwiseAnd", category: "logical", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "y", type: "tensor" }] }], Vh = [{ tfOpName: "_FusedMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }, { start: 2, end: 0, name: "args", type: "tensors" }], attrs: [{ tfName: "num_args", name: "numArgs", type: "number" }, { tfName: "fused_ops", name: "fusedOps", type: "string[]", defaultValue: [] }, { tfName: "epsilon", name: "epsilon", type: "number", defaultValue: 1e-4 }, { tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "leakyrelu_alpha", name: "leakyreluAlpha", type: "number", defaultValue: .2 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "MatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "transpose_a", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "transpose_b", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BatchMatMul", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "BatchMatMulV2", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "b", type: "tensor" }], attrs: [{ tfName: "adj_x", name: "transposeA", type: "bool", defaultValue: !1 }, { tfName: "adj_y", name: "transposeB", type: "bool", defaultValue: !1 }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Transpose", category: "matrices", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "perm", type: "number[]" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Einsum", category: "matrices", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "equation", name: "equation", type: "string" }, { tfName: "N", name: "n", type: "number", defaultValue: 2 }, { tfName: "T", name: "dtype", type: "dtype" }] }, { tfOpName: "MatrixBandPart", category: "matrices", inputs: [{ start: 0, name: "a", type: "tensor" }, { start: 1, name: "numLower", type: "tensor" }, { start: 1, name: "numUpper", type: "tensor" }] }], Gh = [{ tfOpName: "EuclideanNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool", defaultValue: !1 }] }, { tfOpName: "FusedBatchNorm", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "FusedBatchNormV2", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "FusedBatchNormV3", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "scale", type: "tensor" }, { start: 2, name: "offset", type: "tensor" }, { start: 3, name: "mean", type: "tensor" }, { start: 4, name: "variance", type: "tensor" }], attrs: [{ tfName: "epsilon", name: "epsilon", type: "number", defaultValue: .001 }, { tfName: "data_format", name: "dataFormat", type: "string", notSupported: !0 }] }, { tfOpName: "LRN", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "depth_radius", name: "radius", type: "number", defaultValue: 5 }, { tfName: "bias", name: "bias", type: "number", defaultValue: 1 }, { tfName: "alpha", name: "alpha", type: "number", defaultValue: 1 }, { tfName: "beta", name: "beta", type: "number", defaultValue: .5 }] }, { tfOpName: "Softmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "LogSoftmax", category: "normalization", inputs: [{ start: 0, name: "x", type: "tensor" }] }], Hh = [{ tfOpName: "Bincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }] }, { tfOpName: "DenseBincount", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "size", type: "number" }, { start: 2, name: "weights", type: "tensor" }], attrs: [{ tfName: "binary_output", name: "binaryOutput", type: "bool" }] }, { tfOpName: "Max", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Mean", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Min", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Sum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "All", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "Any", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }] }, { tfOpName: "ArgMax", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "ArgMin", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "Prod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }], attrs: [{ tfName: "keep_dims", name: "keepDims", type: "bool" }, { tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "Cumprod", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }, { tfOpName: "Cumsum", category: "reduction", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }], attrs: [{ tfName: "exclusive", name: "exclusive", type: "bool" }, { tfName: "reverse", name: "reverse", type: "bool" }] }], qh = [{ tfOpName: "ConcatV2", category: "slice_join", inputs: [{ start: 0, end: -1, name: "tensors", type: "tensors" }, { start: -1, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "Concat", category: "slice_join", inputs: [{ start: 1, end: 0, name: "tensors", type: "tensors" }, { start: 0, name: "axis", type: "number" }], attrs: [{ tfName: "N", name: "n", type: "number", defaultValue: 2 }] }, { tfOpName: "GatherV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }], attrs: [{ tfName: "batch_dims", name: "batchDims", type: "number", defaultValue: 0 }] }, { tfOpName: "Gather", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", notSupported: !0 }] }, { tfOpName: "Reverse", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "dims", type: "bool[]" }] }, { tfOpName: "ReverseV2", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number[]" }] }, { tfOpName: "Slice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "size", type: "number[]" }] }, { tfOpName: "StridedSlice", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "begin", type: "number[]" }, { start: 2, name: "end", type: "number[]" }, { start: 3, name: "strides", type: "number[]" }], attrs: [{ tfName: "begin_mask", name: "beginMask", type: "number", defaultValue: 0 }, { tfName: "end_mask", name: "endMask", type: "number", defaultValue: 0 }, { tfName: "new_axis_mask", name: "newAxisMask", type: "number", defaultValue: 0 }, { tfName: "ellipsis_mask", name: "ellipsisMask", type: "number", defaultValue: 0 }, { tfName: "shrink_axis_mask", name: "shrinkAxisMask", type: "number", defaultValue: 0 }] }, { tfOpName: "Pack", category: "slice_join", inputs: [{ start: 0, end: 0, name: "tensors", type: "tensors" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "Unpack", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }], attrs: [{ tfName: "axis", name: "axis", type: "number", defaultValue: 0 }, { tfName: "num", name: "num", type: "number", defaultValue: 0, notSupported: !0 }] }, { tfOpName: "Tile", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "reps", type: "number[]" }] }, { tfOpName: "Split", category: "slice_join", inputs: [{ start: 0, name: "axis", type: "number", defaultValue: 0 }, { start: 1, name: "x", type: "tensor" }], attrs: [{ tfName: "num_split", name: "numOrSizeSplits", type: "number", defaultValue: 1 }] }, { tfOpName: "SplitV", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "numOrSizeSplits", type: "number[]" }, { start: 2, name: "axis", type: "number", defaultValue: 0 }] }, { tfOpName: "ScatterNd", category: "slice_join", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "shape", type: "number[]" }] }, { tfOpName: "GatherNd", category: "slice_join", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }] }, { tfOpName: "SparseToDense", category: "slice_join", inputs: [{ start: 0, name: "sparseIndices", type: "tensor" }, { start: 1, name: "outputShape", type: "number[]" }, { start: 2, name: "sparseValues", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }], attrs: [{ tfName: "validate_indices", name: "validateIndices", type: "bool", defaultValue: !1, notSupported: !0 }] }, { tfOpName: "TensorScatterUpdate", category: "slice_join", inputs: [{ start: 0, name: "tensor", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "values", type: "tensor" }] }], Yh = [{ tfOpName: "SparseFillEmptyRows", category: "sparse", inputs: [{ start: 0, name: "indices", type: "tensor" }, { start: 1, name: "values", type: "tensor" }, { start: 2, name: "denseShape", type: "tensor" }, { start: 3, name: "defaultValue", type: "tensor" }] }, { tfOpName: "SparseReshape", category: "sparse", inputs: [{ start: 0, name: "inputIndices", type: "tensor" }, { start: 1, name: "inputShape", type: "tensor" }, { start: 2, name: "newShape", type: "tensor" }], attrs: [{ tfName: "T", name: "dtype", type: "dtype", notSupported: !0 }] }, { tfOpName: "SparseSegmentMean", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }, { tfOpName: "SparseSegmentSum", category: "sparse", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "indices", type: "tensor" }, { start: 2, name: "segmentIds", type: "tensor" }] }], Xh = [{ tfOpName: "FFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "IFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }] }, { tfOpName: "RFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: !0 }] }, { tfOpName: "IRFFT", category: "spectral", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "fft_length", type: "number", notSupported: !0 }] }], Kh = [{ tfOpName: "StaticRegexReplace", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "pattern", name: "pattern", type: "string" }, { tfName: "rewrite", name: "rewrite", type: "string" }, { tfName: "replace_global", name: "replaceGlobal", type: "bool" }] }, { tfOpName: "StringNGrams", category: "string", inputs: [{ start: 0, name: "data", type: "tensor" }, { start: 1, name: "dataSplits", type: "tensor" }], attrs: [{ tfName: "separator", name: "separator", type: "string" }, { tfName: "ngram_widths", name: "nGramWidths", type: "number[]" }, { tfName: "left_pad", name: "leftPad", type: "string" }, { tfName: "right_pad", name: "rightPad", type: "string" }, { tfName: "pad_width", name: "padWidth", type: "number" }, { tfName: "preserve_short_sequences", name: "preserveShortSequences", type: "bool" }], outputs: ["ngrams", "ngrams_splits"] }, { tfOpName: "StringSplit", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }, { start: 1, name: "delimiter", type: "tensor" }], attrs: [{ tfName: "skip_empty", name: "skipEmpty", type: "bool" }], outputs: ["indices", "values", "shape"] }, { tfOpName: "StringToHashBucketFast", category: "string", inputs: [{ start: 0, name: "input", type: "tensor" }], attrs: [{ tfName: "num_buckets", name: "numBuckets", type: "number" }] }], Zh = [{ tfOpName: "Cast", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "SrcT", name: "sdtype", type: "dtype", notSupported: !0 }, { tfName: "DstT", name: "dtype", type: "dtype" }] }, { tfOpName: "ExpandDims", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "axis", type: "number" }] }, { tfOpName: "MirrorPad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "mode", name: "mode", type: "string" }] }, { tfOpName: "Pad", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }], attrs: [{ tfName: "constant_value", name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "PadV2", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "padding", type: "number[]" }, { start: 2, name: "constantValue", type: "number", defaultValue: 0 }] }, { tfOpName: "Reshape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "EnsureShape", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }] }, { tfOpName: "Squeeze", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "axis", tfDeprecatedName: "squeeze_dims", name: "axis", type: "number[]" }] }, { tfOpName: "SpaceToBatchND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "paddings", type: "number[]" }] }, { tfOpName: "BatchToSpaceND", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "blockShape", type: "number[]" }, { start: 2, name: "crops", type: "number[]" }] }, { tfOpName: "DepthToSpace", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }], attrs: [{ tfName: "block_size", name: "blockSize", type: "number" }, { tfName: "data_format", name: "dataFormat", type: "string" }] }, { tfOpName: "BroadcastTo", category: "transformation", inputs: [{ start: 0, name: "x", type: "tensor" }, { start: 1, name: "shape", type: "number[]" }], attrs: [] }, { tfOpName: "BroadcastArgs", category: "transformation", inputs: [{ start: 0, name: "s0", type: "tensor" }, { start: 1, name: "s1", type: "tensor" }], attrs: [] }];
/**
* @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 Jh { static get Instance() { return this._instance || (this._instance = new this) } constructor() { const e = [].concat(...[u, l, c, h, d, f, p, m, g, y, b, v, x, w, k, S, _, C, A].map((e => e.json))); this.opMappers = e.reduce(((e, t) => (e[t.tfOpName] = t, e)), {}) } transformGraph(e, t = {}) { const n = e.node, r = [], i = [], a = [], o = n.reduce(((e, t) => (e[t.name] = this.mapNode(t), t.op.startsWith("Placeholder") ? r.push(e[t.name]) : "Const" === t.op ? i.push(e[t.name]) : null != t.input && 0 !== t.input.length || a.push(e[t.name]), e)), {}); let s = []; const u = []; let l = {}, c = {}; null != t && (l = this.mapSignatureEntries(t.inputs), c = this.mapSignatureEntries(t.outputs)); const h = Object.keys(o); h.forEach((e => { const t = o[e]; t.inputNames.forEach(((e, n) => { const [r, , i] = Eh(e), a = o[r]; if (null != a.outputs) { const e = a.outputs.indexOf(i); if (-1 !== e) { const i = `${r}:${e}`; t.inputNames[n] = i } } t.inputs.push(a), a.children.push(t) })) })), 0 === Object.keys(c).length ? h.forEach((e => { const t = o[e]; 0 === t.children.length && u.push(t) })) : Object.keys(c).forEach((e => { const [t] = Eh(e), n = o[t]; null != n && (n.signatureKey = c[e], u.push(n)) })), Object.keys(l).length > 0 ? Object.keys(l).forEach((e => { const [t] = Eh(e), n = o[t]; n && (n.signatureKey = l[e], s.push(n)) })) : s = r; let d = {}; null != e.library && null != e.library.function && (d = e.library.function.reduce(((e, t) => (e[t.signature.name] = this.mapFunction(t), e)), {})); const f = { nodes: o, inputs: s, outputs: u, weights: i, placeholders: r, signature: t, functions: d }; return a.length > 0 && (f.initNodes = a), f } mapSignatureEntries(e) { return Object.keys(e || {}).reduce(((t, n) => (t[e[n].name] = n, t)), {}) } mapNode(e) { const t = Sh(e.op) || this.opMappers[e.op] || {}; null == e.attr && (e.attr = {}); const n = { name: e.name, op: e.op, category: t.category, inputNames: (e.input || []).map((e => e.startsWith("^") ? e.slice(1) : e)), inputs: [], children: [], inputParams: {}, attrParams: {}, rawAttrs: e.attr, outputs: t.outputs }; return null != t.inputs && (n.inputParams = t.inputs.reduce(((e, t) => (e[t.name] = { type: t.type, inputIndexStart: t.start, inputIndexEnd: t.end }, e)), {})), null != t.attrs && (n.attrParams = t.attrs.reduce(((t, n) => { const r = n.type; let i; switch (n.type) { case "string": i = ed(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ed(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "string[]": i = cd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = cd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "number": i = nd(e.attr, n.tfName, n.defaultValue || 0), void 0 === i && n.tfDeprecatedName && (i = nd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "number[]": i = ld(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ld(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "bool": i = td(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = td(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "bool[]": i = dd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = dd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "shape": i = ud(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ud(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "shape[]": i = hd(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = hd(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "dtype": i = ad(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = ad(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "dtype[]": i = od(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = od(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "func": i = id(e.attr, n.tfName, n.defaultValue), void 0 === i && n.tfDeprecatedName && (i = id(e.attr, n.tfDeprecatedName, n.defaultValue)); break; case "tensor": case "tensors": break; default: throw new Error(`Unsupported param type: ${n.type} for op: ${e.op}`) }return t[n.name] = { value: i, type: r }, t }), {})), n } mapFunction(e) { const t = e.nodeDef, n = []; let r = {}; null != t && (r = t.reduce(((e, t) => (e[t.name] = this.mapNode(t), "Const" === t.op && n.push(e[t.name]), e)), {})); const i = [], a = []; e.signature.inputArg.forEach((e => { const [t] = Eh(e.name), n = { name: t, op: "Placeholder", inputs: [], inputNames: [], category: "graph", inputParams: {}, attrParams: { dtype: { value: rd(e.type), type: "dtype" } }, children: [] }; n.signatureKey = e.name, i.push(n), r[t] = n })); Object.keys(r).forEach((e => { const t = r[e]; t.inputNames.forEach(((e, n) => { const [i, , a] = Eh(e), o = r[i]; if (null != o.outputs) { const e = o.outputs.indexOf(a); if (-1 !== e) { const r = `${i}:${e}`; t.inputNames[n] = r } } t.inputs.push(o), o.children.push(t) })) })); const o = e.ret; e.signature.outputArg.forEach((e => { const [t, n] = Eh(o[e.name]), i = r[t]; null != i && (i.defaultOutput = n, a.push(i)) })); const s = this.mapArgsToSignature(e); return { nodes: r, inputs: i, outputs: a, weights: n, placeholders: [], signature: s } } mapArgsToSignature(e) { return { methodName: e.signature.name, inputs: e.signature.inputArg.reduce(((e, t) => (e[t.name] = this.mapArgToTensorInfo(t), e)), {}), outputs: e.signature.outputArg.reduce(((t, n) => (t[n.name] = this.mapArgToTensorInfo(n, e.ret), t)), {}) } } mapArgToTensorInfo(e, t) { let n = e.name; return null != t && (n = t[n]), { name: n, dtype: e.type } } } function Qh(e, t) { const n = Array.isArray(e) ? String.fromCharCode.apply(null, e) : function (e) { const t = (0, P.env)().global; if (void 0 !== t.atob) return t.atob(e); if ("undefined" != typeof Buffer) return new Buffer(e, "base64").toString(); throw new Error("Unable to decode base64 in this environment. Missing built-in atob() or Buffer()") }(e); return t ? n : n.toLowerCase() } function ed(e, t, n, r = !1) { const i = e[t]; return null != i ? Qh(i.s, r) : n } function td(e, t, n) { const r = e[t]; return r ? r.b : n } function nd(e, t, n) { const r = e[t] || {}, i = null != r.i ? r.i : null != r.f ? r.f : n; return "number" == typeof i ? i : parseInt(i, 10) } function rd(e) { switch ("string" == typeof e && (e = bh[e]), e) { case bh.DT_FLOAT: case bh.DT_HALF: return "float32"; case bh.DT_INT32: case bh.DT_INT64: case bh.DT_INT8: case bh.DT_UINT8: return "int32"; case bh.DT_BOOL: return "bool"; case bh.DT_DOUBLE: return "float32"; case bh.DT_STRING: return "string"; case bh.DT_COMPLEX64: case bh.DT_COMPLEX128: return "complex64"; default: return null } } function id(e, t, n) { const r = e[t]; return r && r.func ? r.func.name : n } function ad(e, t, n) { const r = e[t]; return r && r.type ? rd(r.type) : n } function od(e, t, n) { const r = e[t]; return r && r.list && r.list.type ? r.list.type.map((e => rd(e))) : n } function sd(e) { if (!e.unknownRank) return null != e.dim ? e.dim.map((e => "number" == typeof e.size ? e.size : parseInt(e.size, 10))) : [] } function ud(e, t, n) { const r = e[t]; return r && r.shape ? sd(r.shape) : n } function ld(e, t, n) { const r = e[t]; return r ? ((r.list.f && r.list.f.length ? r.list.f : r.list.i) || []).map((e => "number" == typeof e ? e : parseInt(e, 10))) : n } function cd(e, t, n, r = !1) { const i = e[t]; return i && i.list && i.list.s ? i.list.s.map((e => Qh(e, r))) : n } function hd(e, t, n) { const r = e[t]; return r && r.list && r.list.shape ? r.list.shape.map((e => sd(e))) : n } function dd(e, t, n) { const r = e[t]; return r && r.list && r.list.b ? r.list.b : 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.
* =============================================================================
*/
class fd { constructor(e, t, n) { this.node = e, this.tensorMap = t, this.context = n, this.inputs = [], this.attrs = {}, this.inputs = e.inputNames.map((e => this.getInput(e))), null != e.rawAttrs && (this.attrs = Object.keys(e.rawAttrs).reduce(((e, t) => (e[t] = this.getAttr(t), e)), {})) } getInput(e) { return Ah(e, this.tensorMap, this.context) } getAttr(e, t) { const n = this.node.rawAttrs[e]; if (null != n.tensor) return Ah(e, this.tensorMap, this.context); if (null != n.i || null != n.f) return nd(this.node.rawAttrs, e, t); if (null != n.s) return ed(this.node.rawAttrs, e, t); if (null != n.b) return td(this.node.rawAttrs, e, t); if (null != n.shape) return ud(this.node.rawAttrs, e, t); if (null != n.type) return ad(this.node.rawAttrs, e, t); if (null != n.list) { if (null != n.list.i || null != n.list.f) return ld(this.node.rawAttrs, e, t); if (null != n.list.s) return cd(this.node.rawAttrs, e, t); if (null != n.list.shape) return hd(this.node.rawAttrs, e, t); if (null != n.list.b) return dd(this.node.rawAttrs, e, t); if (null != n.list.type) return od(this.node.rawAttrs, e, t) } return t } } var pd = n(7270);
/**
* @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(e, t, n = "") { if ("number" != typeof e && "number" != typeof t) { P.util.assert(e.length === t.length, (() => n + ` Shapes ${e} and ${t} must match`)); for (let r = 0; r < e.length; r++) { const i = e[r], a = t[r]; P.util.assert(i < 0 || a < 0 || i === a, (() => n + ` Shapes ${e} and ${t} must match`)) } } } function gd(e) { return "number" != typeof e && !e.some((e => e < 0)) } function yd(e, t, n) { let r = bd(e, n); const i = !gd(r); if (i && 0 === t.length) throw new Error(`Tried to calculate elements of an empty list with non-fully-defined elementShape: ${r}`); if (i && t.forEach((e => { r = bd(e.shape, r) })), !gd(r)) throw new Error(`Non-fully-defined elementShape: ${r}`); return r } function bd(e, t) { if ("number" == typeof e) return t; if ("number" == typeof t) return e; if (e.length !== t.length) throw new Error(`Incompatible ranks during merge: ${e} vs. ${t}`); const n = []; for (let r = 0; r < e.length; ++r) { const i = e[r], a = t[r]; if (i >= 0 && a >= 0 && i !== a) throw new Error(`Incompatible shape during merge: ${e} vs. ${t}`); n[r] = i >= 0 ? i : a } return n }
/**
* @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 vd { constructor(e, t, n, r, i, a, o) { this.name = e, this.dtype = t, this.maxSize = n, this.elementShape = r, this.identicalElementShapes = i, this.dynamicSize = a, this.clearAfterRead = o, this.tensors = [], this.closed_ = !1, this.idTensor = (0, P.scalar)(0), (0, P.keep)(this.idTensor) } get id() { return this.idTensor.id } get closed() { return this.closed_ } clearAndClose(e) { this.tensors.forEach((t => { null != e && e.has(t.tensor.id) || t.tensor.dispose() })), this.tensors = [], this.closed_ = !0, this.idTensor.dispose() } size() { return this.tensors.length } read(e) { if (this.closed_) throw new Error(`TensorArray ${this.name} has already been closed.`); if (e < 0 || e >= this.size()) throw new Error(`Tried to read from index ${e}, but array size is: ${this.size()}`); const t = this.tensors[e]; if (t.cleared) throw new Error(`TensorArray ${this.name}: Could not read index ${e} twice because it was cleared after a previous read (perhaps try setting clear_after_read = false?).`); return this.clearAfterRead && (t.cleared = !0), t.read = !0, t.tensor } readMany(e) { return e.map((e => this.read(e))) } write(e, t) { if (this.closed_) throw new Error(`TensorArray ${this.name} has already been closed.`); if (e < 0 || !this.dynamicSize && e >= this.maxSize) throw new Error(`Tried to write to index ${e}, but array is not resizeable and size is: ${this.maxSize}`); const n = this.tensors[e] || {}; if (t.dtype !== this.dtype) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e},\n because the value dtype is ${t.dtype}, but TensorArray dtype is ${this.dtype}.`); if (0 !== this.size() || null != this.elementShape && 0 !== this.elementShape.length || (this.elementShape = t.shape), md(this.elementShape, t.shape, `TensorArray ${this.name}: Could not write to TensorArray index ${e}.`), n.read) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been read.`); if (n.written) throw new Error(`TensorArray ${this.name}: Could not write to TensorArray index ${e}, because it has already been written.`); n.tensor = t, (0, P.keep)(t), n.written = !0, this.tensors[e] = n } writeMany(e, t) { if (e.length !== t.length) throw new Error(`TensorArray ${this.name}: could not write multiple tensors,because the index size: ${e.length} is not the same as tensors size: ${t.length}.`); e.forEach(((e, n) => this.write(e, t[n]))) } gather(e, t) { if (t && t !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but gather requested dtype ${t}`); if (e) e = e.slice(0, this.size()); else { e = []; for (let t = 0; t < this.size(); t++)e.push(t) } if (0 === e.length) return (0, P.tensor)([], [0].concat(this.elementShape)); const n = this.readMany(e); return md(this.elementShape, n[0].shape, "TensorArray shape mismatch: "), (0, P.stack)(n, 0) } concat(e) { if (e && e !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but concat requested dtype ${e}`); if (0 === this.size()) return (0, P.tensor)([], [0].concat(this.elementShape)); const t = []; for (let e = 0; e < this.size(); e++)t.push(e); const n = this.readMany(t); return md(this.elementShape, n[0].shape, `TensorArray shape mismatch: tensor array shape (${this.elementShape}) vs first tensor shape (${n[0].shape})`), (0, P.concat)(n, 0) } scatter(e, t) { if (t.dtype !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`); if (e.length !== t.shape[0]) throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${e.length} vs. ${t.shape[0]}`); const n = Math.max(...e); if (!this.dynamicSize && n >= this.maxSize) throw new Error(`Max index must be < array size (${n} vs. ${this.maxSize})`); this.writeMany(e, (0, P.unstack)(t, 0)) } split(e, t) { if (t.dtype !== this.dtype) throw new Error(`TensorArray dtype is ${this.dtype} but tensor has dtype ${t.dtype}`); let n = 0; const r = e.map((e => (n += e, n))); if (n !== t.shape[0]) throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${n}, and tensor's shape is: ${t.shape}`); if (!this.dynamicSize && e.length !== this.maxSize) throw new Error(`TensorArray's size is not equal to the size of lengths (${this.maxSize} vs. ${e.length}), and the TensorArray is not marked as dynamically resizeable`); const i = 0 === n ? 0 : t.size / n, a = []; (0, P.tidy)((() => { t = (0, P.reshape)(t, [1, n, i]); for (let n = 0; n < e.length; ++n) { const o = [0, 0 === n ? 0 : r[n - 1], 0], s = [1, e[n], i]; a[n] = (0, P.reshape)((0, P.slice)(t, o, s), this.elementShape) } return a })); const o = []; for (let t = 0; t < e.length; t++)o[t] = t; this.writeMany(o, a) } }
/**
* @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.
* =============================================================================
*/
class xd { get id() { return this.idTensor.id } constructor(e, t, n, r = -1) { this.tensors = e, this.elementShape = t, this.elementDtype = n, null != e && e.forEach((e => { if (n !== e.dtype) throw new Error(`Invalid data types; op elements ${n}, but list elements ${e.dtype}`); md(t, e.shape, "TensorList shape mismatch: "), (0, P.keep)(e) })), this.idTensor = (0, P.scalar)(0), this.maxNumElements = r, (0, P.keep)(this.idTensor) } copy() { return new xd([...this.tensors], this.elementShape, this.elementDtype) } clearAndClose(e) { this.tensors.forEach((t => { null != e && e.has(t.id) || t.dispose() })), this.tensors.length = 0, this.idTensor.dispose() } size() { return this.tensors.length } stack(e, t, n = -1) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); if (-1 !== n && this.tensors.length !== n) throw new Error(`Operation expected a list with ${n} elements but got a list with ${this.tensors.length} elements.`); md(e, this.elementShape, "TensorList shape mismatch: "); const r = yd(this.elementShape, this.tensors, e); return (0, P.tidy)((() => { const e = this.tensors.map((e => (0, P.reshape)(e, r))); return (0, P.stack)(e, 0) })) } popBack(e, t) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); if (0 === this.size()) throw new Error("Trying to pop from an empty list."); const n = yd(this.elementShape, this.tensors, e), r = this.tensors.pop(); return r.kept = !1, md(r.shape, e, "TensorList shape mismatch: "), (0, P.reshape)(r, n) } pushBack(e) { if (e.dtype !== this.elementDtype) throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${this.elementDtype}`); if (md(e.shape, this.elementShape, "TensorList shape mismatch: "), this.maxNumElements === this.size()) throw new Error("Trying to push element into a full list."); (0, P.keep)(e), this.tensors.push(e) } resize(e) { if (e < 0) throw new Error(`TensorListResize expects size to be non-negative. Got: ${e}`); if (-1 !== this.maxNumElements && e > this.maxNumElements) throw new Error(`TensorListResize input size ${e} is greater maxNumElement ${this.maxNumElements}.`); const t = new xd([], this.elementShape, this.elementDtype, this.maxNumElements); t.tensors.length = e; for (let n = 0; n < Math.min(this.tensors.length, e); ++n)t.tensors[n] = this.tensors[n]; return t } getItem(e, t, n) { if (n !== this.elementDtype) throw new Error(`Invalid data types; op elements ${n}, but list elements ${this.elementDtype}`); if (e < 0 || e > this.tensors.length) throw new Error(`Trying to access element ${e} in a list with ${this.tensors.length} elements.`); if (null == this.tensors[e]) throw new Error(`element at index ${e} is null.`); md(this.tensors[e].shape, t, "TensorList shape mismatch: "); const r = yd(this.elementShape, this.tensors, t); return (0, P.reshape)(this.tensors[e], r) } setItem(e, t) { if (t.dtype !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t.dtype}, but list elements ${this.elementDtype}`); if (e < 0 || -1 !== this.maxNumElements && e >= this.maxNumElements) throw new Error(`Trying to set element ${e} in a list with max ${this.maxNumElements} elements.`); md(this.elementShape, t.shape, "TensorList shape mismatch: "), (0, P.keep)(t), null != this.tensors[e] && (this.tensors[e].kept = !1), this.tensors[e] = t } gather(e, t, n) { if (t !== this.elementDtype) throw new Error(`Invalid data types; op elements ${t}, but list elements ${this.elementDtype}`); md(this.elementShape, n, "TensorList shape mismatch: "), e = e.slice(0, this.size()); const r = yd(this.elementShape, this.tensors, n); return 0 === e.length ? (0, P.tensor)([], [0].concat(r)) : (0, P.tidy)((() => { const t = e.map((e => (0, P.reshape)(this.tensors[e], r))); return (0, P.stack)(t, 0) })) } concat(e, t) { if (e && e !== this.elementDtype) throw new Error(`TensorList dtype is ${this.elementDtype} but concat requested dtype ${e}`); md(this.elementShape, t, "TensorList shape mismatch: "); const n = yd(this.elementShape, this.tensors, t); return 0 === this.size() ? (0, P.tensor)([], [0].concat(n)) : (0, P.tidy)((() => { const e = this.tensors.map((e => (0, P.reshape)(e, n))); return (0, P.concat)(e, 0) })) } }
/**
* @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 wd = async (e, t, n) => { switch (e.op) { case "If": case "StatelessIf": { const r = Ch("thenBranch", e, t, n), i = Ch("elseBranch", e, t, n), a = Ch("cond", e, t, n), o = Ch("args", e, t, n); return (await a.data())[0] ? n.functionMap[r].executeFunctionAsync(o, n.tensorArrayMap, n.tensorListMap) : n.functionMap[i].executeFunctionAsync(o, n.tensorArrayMap, n.tensorListMap) } case "While": case "StatelessWhile": { const r = Ch("body", e, t, n), i = Ch("cond", e, t, n), a = Ch("args", e, t, n), o = await n.functionMap[i].executeFunctionAsync(a, n.tensorArrayMap, n.tensorListMap), s = a.map((e => e.id)); let u = await o[0].data(); o.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || e.dispose() })); let l = a; for (; u[0];) { const e = l; l = await n.functionMap[r].executeFunctionAsync(l, n.tensorArrayMap, n.tensorListMap); const t = l.map((e => e.id)); e.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || -1 !== t.indexOf(e.id) || e.dispose() })); const a = await n.functionMap[i].executeFunctionAsync(l, n.tensorArrayMap, n.tensorListMap); u = await a[0].data(), a.forEach((e => { e.kept || -1 !== s.indexOf(e.id) || -1 !== t.indexOf(e.id) || e.dispose() })) } return l } case "LoopCond": return [Fh(Ch("pred", e, t, n))]; case "Switch": { const r = Ch("pred", e, t, n); let i = Ch("data", e, t, n); return i.kept || (i = Fh(i)), (await r.data())[0] ? [void 0, i] : [i, void 0] } case "Merge": { const r = e.inputNames.find((e => void 0 !== Ah(e, t, n))); if (r) { return [Fh(Ah(r, t, n))] } return } case "Enter": { const r = Ch("frameName", e, t, n), i = Ch("tensor", e, t, n); return n.enterFrame(r), [Fh(i)] } case "Exit": { const r = Ch("tensor", e, t, n); return n.exitFrame(), [Fh(r)] } case "NextIteration": { const r = Ch("tensor", e, t, n); return n.nextIteration(), [Fh(r)] } case "TensorArrayV3": { const r = Ch("size", e, t, n), i = Ch("dtype", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("dynamicSize", e, t, n), s = Ch("clearAfterRead", e, t, n), u = Ch("identicalElementShapes", e, t, n), l = Ch("name", e, t, n), c = new vd(l, i, r, a, u, o, s); return n.addTensorArray(c), [c.idTensor, (0, P.scalar)(1)] } case "TensorArrayWriteV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("index", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorArray(r.id); return o.write(i, a), [o.idTensor] } case "TensorArrayReadV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("index", e, t, n); return [n.getTensorArray(r.id).read(i)] } case "TensorArrayGatherV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("indices", e, t, n), a = Ch("dtype", e, t, n); return [n.getTensorArray(r.id).gather(i, a)] } case "TensorArrayScatterV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("indices", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorArray(r.id); return o.scatter(i, a), [o.idTensor] } case "TensorArrayConcatV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id), a = Ch("dtype", e, t, n); return [i.concat(a)] } case "TensorArraySplitV3": { const r = Ch("tensorArrayId", e, t, n), i = Ch("tensor", e, t, n), a = Ch("lengths", e, t, n), o = n.getTensorArray(r.id); return o.split(a, i), [o.idTensor] } case "TensorArraySizeV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id); return [(0, P.scalar)(i.size(), "int32")] } case "TensorArrayCloseV3": { const r = Ch("tensorArrayId", e, t, n), i = n.getTensorArray(r.id); return i.clearAndClose(), [i.idTensor] } case "TensorListSetItem": { const r = Ch("tensorListId", e, t, n), i = Ch("index", e, t, n), a = Ch("tensor", e, t, n), o = n.getTensorList(r.id); return o.setItem(i, a), [o.idTensor] } case "TensorListGetItem": { const r = Ch("tensorListId", e, t, n), i = Ch("index", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).getItem(i, a, o)] } case "TensorListScatterV2": case "TensorListScatter": { const r = Ch("indices", e, t, n), i = function (e, t, n, r) { if (t.length !== e.shape[0]) throw new Error(`Expected len(indices) == tensor.shape[0], but saw: ${t.length} vs. ${e.shape[0]}`); const i = Math.max(...t); if (null != r && -1 !== r && i >= r) throw new Error(`Max index must be < array size (${i} vs. ${r})`); const a = new xd([], n, e.dtype, r), o = (0, P.unstack)(e, 0); return t.forEach(((e, t) => { a.setItem(e, o[t]) })), a }(Ch("tensor", e, t, n), r, Ch("elementShape", e, t, n), Ch("numElements", e, t, n)); return n.addTensorList(i), [i.idTensor] } case "TensorListReserve": case "EmptyTensorList": { const r = Ch("elementShape", e, t, n), i = Ch("elementDType", e, t, n); let a; a = "TensorListReserve" === e.op ? "numElements" : "maxNumElements"; const o = Ch(a, e, t, n), s = function (e, t, n, r) { return new xd([], e, t, r) }(r, i, 0, "TensorListReserve" === e.op ? -1 : o); return n.addTensorList(s), [s.idTensor] } case "TensorListGather": { const r = Ch("tensorListId", e, t, n), i = Ch("indices", e, t, n), a = Ch("elementShape", e, t, n), o = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).gather(i, o, a)] } case "TensorListStack": { const r = Ch("tensorListId", e, t, n), i = Ch("elementShape", e, t, n), a = Ch("elementDType", e, t, n), o = Ch("numElements", e, t, n); return [n.getTensorList(r.id).stack(i, a, o)] } case "TensorListFromTensor": { const r = function (e, t, n) { const r = e.dtype; if (e.shape.length < 1) throw new Error(`Tensor must be at least a vector, but saw shape: ${e.shape}`); if (e.dtype !== n) throw new Error(`Invalid data types; op elements ${e.dtype}, but list elements ${n}`); md(e.shape.slice(1), t, "TensorList shape mismatch: "); const i = (0, P.unstack)(e); return new xd(i, t, r) }(Ch("tensor", e, t, n), Ch("elementShape", e, t, n), Ch("elementDType", e, t, n)); return n.addTensorList(r), [r.idTensor] } case "TensorListConcat": case "TensorListConcatV2": { const r = Ch("tensorListId", e, t, n), i = n.getTensorList(r.id), a = Ch("dtype", e, t, n), o = Ch("elementShape", e, t, n); return [i.concat(a, o)] } case "TensorListPushBack": { const r = Ch("tensorListId", e, t, n), i = Ch("tensor", e, t, n), a = n.getTensorList(r.id); return a.pushBack(i), [a.idTensor] } case "TensorListPopBack": { const r = Ch("tensorListId", e, t, n), i = Ch("elementShape", e, t, n), a = Ch("elementDType", e, t, n); return [n.getTensorList(r.id).popBack(i, a)] } case "TensorListSplit": { const r = Ch("tensor", e, t, n), i = Ch("elementShape", e, t, n), a = function (e, t, n) { let r = 0; const i = t.map((e => (r += e, r))); if (r !== e.shape[0]) throw new Error(`Expected sum of lengths to be equal to\n tensor.shape[0], but sum of lengths is\n ${r}, and tensor's shape is: ${e.shape}`); const a = bd(e.shape.slice(1), n), o = 0 === r ? 0 : e.size / r, s = (0, P.tidy)((() => { const n = []; e = (0, P.reshape)(e, [1, r, o]); for (let r = 0; r < t.length; ++r) { const s = [0, 0 === r ? 0 : i[r - 1], 0], u = [1, t[r], o]; n[r] = (0, P.reshape)((0, P.slice)(e, s, u), a) } return e.dispose(), n })), u = new xd([], n, e.dtype, t.length); for (let e = 0; e < s.length; e++)u.setItem(e, s[e]); return u }(r, Ch("lengths", e, t, n), i); return n.addTensorList(a), [a.idTensor] } case "TensorListLength": { const r = Ch("tensorListId", e, t, n), i = n.getTensorList(r.id); return [(0, P.scalar)(i.size(), "int32")] } case "TensorListResize": { const r = Ch("tensorListId", e, t, n), i = Ch("size", e, t, n), a = n.getTensorList(r.id).resize(i); return n.addTensorList(a), [a.idTensor] } default: throw TypeError(`Node type ${e.op} is not implemented`) } };
/**
* @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 kd(e, t, n) { const [r, i] = Ch("fusedOps", e, t, n), a = "biasadd" === r, o = !a, s = "prelu" === i, u = "fusedbatchnorm" === r, l = Ch("numArgs", e, t, n); if (a) { if (s && 2 !== l) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd and Prelu must have two extra arguments: bias and alpha."); if (!s && a && 1 !== l) throw new Error("FusedConv2d and DepthwiseConv2d with BiasAdd must have one extra argument: bias.") } if (u) throw new Error("FusedConv2d and DepthwiseConv2d with FusedBatchNorm is not supported"); const c = Ch("strides", e, t, n), h = Mh(e, t, n), d = Ch("dataFormat", e, t, n).toUpperCase(), f = Ch("dilations", e, t, n); let [p, m] = Ch("args", e, t, n); o && (m = p, p = void 0); return { stride: c, pad: h, dataFormat: d, dilations: f, biasArg: p, preluArg: m, activationFunc: i, leakyreluAlpha: Ch("leakyreluAlpha", e, t, n) } }
/**
* @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 Sd(e, t, n) { return { boxes: Ch("boxes", e, t, n), scores: Ch("scores", e, t, n), maxOutputSize: Ch("maxOutputSize", e, t, n), iouThreshold: Ch("iouThreshold", e, t, n), scoreThreshold: Ch("scoreThreshold", e, t, n), softNmsSigma: Ch("softNmsSigma", e, t, n) } }
/**
* @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.
* =============================================================================
*/
class _d { get id() { return this.handle.id } constructor(e, t) { this.keyDType = e, this.valueDType = t, this.handle = (0, P.scalar)(0), this.tensorMap = new Map, (0, P.keep)(this.handle) } clearAndClose() { this.tensorMap.forEach((e => e.dispose())), this.tensorMap.clear(), this.handle.dispose() } size() { return this.tensorMap.size } tensorSize() { return H.d(this.size(), "int32") } async import(e, t) { this.checkKeyAndValueTensor(e, t); const n = await e.data(); return this.tensorMap.forEach((e => e.dispose())), this.tensorMap.clear(), (0, P.tidy)((() => { const e = (0, P.unstack)(t), r = n.length, i = e.length; P.util.assert(r === i, (() => `The number of elements doesn't match, keys has ${r} elements, the values has ${i} elements.`)); for (let t = 0; t < r; t++) { const r = n[t], i = e[t]; (0, P.keep)(i), this.tensorMap.set(r, i) } return this.handle })) } async find(e, t) { this.checkKeyAndValueTensor(e, t); const n = await e.data(); return (0, P.tidy)((() => { const e = []; for (let r = 0; r < n.length; r++) { const i = n[r], a = this.findWithDefault(i, t); e.push(a) } return (0, P.stack)(e) })) } findWithDefault(e, t) { const n = this.tensorMap.get(e); return null != n ? n : t } checkKeyAndValueTensor(e, t) { if (e.dtype !== this.keyDType) throw new Error(`Expect key dtype ${this.keyDType}, but got ${e.dtype}`); if (t.dtype !== this.valueDType) throw new Error(`Expect value dtype ${this.valueDType}, but got ${t.dtype}`) } }
/**
* @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 Cd(e, t, n, r, i = P.tidy) { const a = ((e, t, n) => { switch (e.category) { case "arithmetic": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "BiasAdd": case "AddV2": case "Add": return [r.add(Ch("a", e, t, n), Ch("b", e, t, n))]; case "AddN": return [r.addN(Ch("tensors", e, t, n))]; case "FloorMod": case "Mod": return [r.mod(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Mul": return [r.mul(Ch("a", e, t, n), Ch("b", e, t, n))]; case "RealDiv": case "Div": return [r.div(Ch("a", e, t, n), Ch("b", e, t, n))]; case "DivNoNan": return [r.divNoNan(Ch("a", e, t, n), Ch("b", e, t, n))]; case "FloorDiv": return [r.floorDiv(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Sub": return [r.sub(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Minimum": return [r.minimum(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Maximum": return [r.maximum(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Pow": return [r.pow(Ch("a", e, t, n), Ch("b", e, t, n))]; case "SquaredDifference": return [r.squaredDifference(Ch("a", e, t, n), Ch("b", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "basic_math": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Abs": case "ComplexAbs": return [r.abs(Ch("x", e, t, n))]; case "Acos": return [r.acos(Ch("x", e, t, n))]; case "Acosh": return [r.acosh(Ch("x", e, t, n))]; case "Asin": return [r.asin(Ch("x", e, t, n))]; case "Asinh": return [r.asinh(Ch("x", e, t, n))]; case "Atan": return [r.atan(Ch("x", e, t, n))]; case "Atan2": return [r.atan2(Ch("x", e, t, n), Ch("y", e, t, n))]; case "Atanh": return [r.atanh(Ch("x", e, t, n))]; case "Ceil": return [r.ceil(Ch("x", e, t, n))]; case "Complex": return [r.complex(Ch("real", e, t, n), Ch("imag", e, t, n))]; case "Cos": return [r.cos(Ch("x", e, t, n))]; case "Cosh": return [r.cosh(Ch("x", e, t, n))]; case "Elu": return [r.elu(Ch("x", e, t, n))]; case "Erf": return [r.erf(Ch("x", e, t, n))]; case "Exp": return [r.exp(Ch("x", e, t, n))]; case "Expm1": return [r.expm1(Ch("x", e, t, n))]; case "Floor": return [r.floor(Ch("x", e, t, n))]; case "Log": return [r.log(Ch("x", e, t, n))]; case "Log1p": return [r.log1p(Ch("x", e, t, n))]; case "Imag": return [r.imag(Ch("x", e, t, n))]; case "Neg": return [r.neg(Ch("x", e, t, n))]; case "Reciprocal": return [r.reciprocal(Ch("x", e, t, n))]; case "Real": return [r.real(Ch("x", e, t, n))]; case "Relu": return [r.relu(Ch("x", e, t, n))]; case "Round": return [r.round(Ch("x", e, t, n))]; case "Selu": return [r.selu(Ch("x", e, t, n))]; case "Sigmoid": return [r.sigmoid(Ch("x", e, t, n))]; case "Sin": return [r.sin(Ch("x", e, t, n))]; case "Sign": return [r.sign(Ch("x", e, t, n))]; case "Sinh": return [r.sinh(Ch("x", e, t, n))]; case "Softplus": return [r.softplus(Ch("x", e, t, n))]; case "Sqrt": return [r.sqrt(Ch("x", e, t, n))]; case "Square": return [r.square(Ch("x", e, t, n))]; case "Tanh": return [r.tanh(Ch("x", e, t, n))]; case "Tan": return [r.tan(Ch("x", e, t, n))]; case "ClipByValue": return [r.clipByValue(Ch("x", e, t, n), Ch("clipValueMin", e, t, n), Ch("clipValueMax", e, t, n))]; case "Relu6": return [r.relu6(Ch("x", e, t, n))]; case "Rsqrt": return [r.rsqrt(Ah(e.inputNames[0], t, n))]; case "LeakyRelu": return [r.leakyRelu(Ch("x", e, t, n), Ch("alpha", e, t, n))]; case "Prelu": return [r.prelu(Ch("x", e, t, n), Ch("alpha", e, t, n))]; case "IsNan": return [r.isNaN(Ah(e.inputNames[0], t, n))]; case "IsInf": return [r.isInf(Ah(e.inputNames[0], t, n))]; case "IsFinite": return [r.isFinite(Ah(e.inputNames[0], t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "control": return wd(e, t, n); case "convolution": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Conv1D": { const i = Ch("stride", e, t, n), a = Ch("pad", e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilation", e, t, n); return [r.conv1d(Ch("x", e, t, n), Ch("filter", e, t, n), i, a, o, s)] } case "Conv2D": { const i = Ch("strides", e, t, n), a = Mh(e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilations", e, t, n); return [r.conv2d(Ch("x", e, t, n), Ch("filter", e, t, n), [i[1], i[2]], a, o, [s[1], s[2]])] } case "_FusedConv2D": { const { stride: i, pad: a, dataFormat: o, dilations: s, biasArg: u, preluArg: l, activationFunc: c, leakyreluAlpha: h } = kd(e, t, n); return [r.fused.conv2d({ x: Ch("x", e, t, n), filter: Ch("filter", e, t, n), strides: [i[1], i[2]], pad: a, dataFormat: o, dilations: [s[1], s[2]], bias: u, activation: c, preluActivationWeights: l, leakyreluAlpha: h })] } case "FusedDepthwiseConv2dNative": { const { stride: i, pad: a, dataFormat: o, dilations: s, biasArg: u, preluArg: l, activationFunc: c, leakyreluAlpha: h } = kd(e, t, n); return [r.fused.depthwiseConv2d({ x: Ch("x", e, t, n), filter: Ch("filter", e, t, n), strides: [i[1], i[2]], pad: a, dataFormat: o, dilations: [s[1], s[2]], bias: u, activation: c, preluActivationWeights: l, leakyreluAlpha: h })] } case "Conv2DBackpropInput": case "Conv2dTranspose": { const i = Ch("outputShape", e, t, n), a = Ch("strides", e, t, n), o = Mh(e, t, n); return [r.conv2dTranspose(Ch("x", e, t, n), Ch("filter", e, t, n), i, [a[1], a[2]], o)] } case "DepthwiseConv2dNative": case "DepthwiseConv2d": { const i = Ch("strides", e, t, n), a = Mh(e, t, n), o = Ch("dilations", e, t, n), s = Ch("dataFormat", e, t, n).toUpperCase(); return [r.depthwiseConv2d(Ch("input", e, t, n), Ch("filter", e, t, n), [i[1], i[2]], a, s, [o[1], o[2]])] } case "Conv3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("dataFormat", e, t, n).toUpperCase(), s = Ch("dilations", e, t, n); return [r.conv3d(Ch("x", e, t, n), Ch("filter", e, t, n), [i[1], i[2], i[3]], a, o, [s[1], s[2], s[3]])] } case "AvgPool": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.avgPool(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a)] } case "MaxPool": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.maxPool(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a)] } case "MaxPoolWithArgmax": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n), s = Ch("includeBatchInIndex", e, t, n), { result: u, indexes: l } = r.maxPoolWithArgmax(Ch("x", e, t, n), [o[1], o[2]], [i[1], i[2]], a, s); return [u, l] } case "AvgPool3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.avgPool3d(Ch("x", e, t, n), [o[1], o[2], o[3]], [i[1], i[2], i[3]], a)] } case "MaxPool3D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("kernelSize", e, t, n); return [r.maxPool3d(Ch("x", e, t, n), [o[1], o[2], o[3]], [i[1], i[2], i[3]], a)] } case "Dilation2D": { const i = Ch("strides", e, t, n), a = Ch("pad", e, t, n), o = Ch("dilations", e, t, n), s = i[1], u = i[2], l = o[1], c = o[2]; return [r.dilation2d(Ch("x", e, t, n), Ch("filter", e, t, n), [s, u], a, [l, c], "NHWC")] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "creation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Fill": { const i = Ch("shape", e, t, n), a = Ch("dtype", e, t, n), o = Ch("value", e, t, n); return [r.fill(i, o, a)] } case "LinSpace": { const i = Ch("start", e, t, n), a = Ch("stop", e, t, n), o = Ch("num", e, t, n); return [r.linspace(i, a, o)] } case "Multinomial": { const i = Ch("logits", e, t, n), a = Ch("numSamples", e, t, n), o = Ch("seed", e, t, n); return [r.multinomial(i, a, o)] } case "OneHot": { const i = Ch("indices", e, t, n), a = Ch("depth", e, t, n), o = Ch("onValue", e, t, n), s = Ch("offValue", e, t, n), u = Ch("dtype", e, t, n); return [r.oneHot(i, a, o, s, u)] } case "Ones": return [r.ones(Ch("shape", e, t, n), Ch("dtype", e, t, n))]; case "OnesLike": return [r.onesLike(Ch("x", e, t, n))]; case "RandomStandardNormal": return [r.randomStandardNormal(Ch("shape", e, t, n), Ch("dtype", e, t, n), Ch("seed", e, t, n))]; case "RandomUniform": return [r.randomUniform(Ch("shape", e, t, n), Ch("minval", e, t, n), Ch("maxval", e, t, n), Ch("dtype", e, t, n))]; case "RandomUniformInt": return [r.randomUniformInt(Ch("shape", e, t, n), Ch("minval", e, t, n), Ch("maxval", e, t, n), Ch("seed", e, t, n))]; case "Range": { const i = Ch("start", e, t, n), a = Ch("stop", e, t, n), o = Ch("step", e, t, n); return [r.range(i, a, o, Ch("dtype", e, t, n))] } case "TruncatedNormal": { const i = Ch("shape", e, t, n), a = Ch("mean", e, t, n), o = Ch("stdDev", e, t, n), s = Ch("seed", e, t, n); return [r.truncatedNormal(i, a, o, Ch("dtype", e, t, n), s)] } case "Zeros": return [r.zeros(Ch("shape", e, t, n), Ch("dtype", e, t, n))]; case "ZerosLike": return [r.zerosLike(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "dynamic": return (async (e, t, n, r, i = T) => { switch (e.op) { case "NonMaxSuppressionV5": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = Sd(e, t, n), c = await i.image.nonMaxSuppressionWithScoreAsync(r, a, o, s, u, l); return [c.selectedIndices, c.selectedScores] } case "NonMaxSuppressionV4": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = Sd(e, t, n), l = Ch("padToMaxOutputSize", e, t, n), c = await i.image.nonMaxSuppressionPaddedAsync(r, a, o, s, u, l); return [c.selectedIndices, c.validOutputs] } case "NonMaxSuppressionV3": case "NonMaxSuppressionV2": { const { boxes: r, scores: a, maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = Sd(e, t, n); return [await i.image.nonMaxSuppressionAsync(r, a, o, s, u)] } case "Where": { const r = i.cast(Ch("condition", e, t, n), "bool"), a = [await i.whereAsync(r)]; return r.dispose(), a } case "ListDiff": return i.setdiff1dAsync(Ch("x", e, t, n), Ch("y", e, t, n)); default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n); case "evaluation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "LowerBound": { const i = Ch("sortedSequence", e, t, n), a = Ch("values", e, t, n); return [r.lowerBound(i, a)] } case "TopKV2": { const i = Ch("x", e, t, n), a = Ch("k", e, t, n), o = Ch("sorted", e, t, n), s = r.topk(i, a, o); return [s.values, s.indices] } case "UpperBound": { const i = Ch("sortedSequence", e, t, n), a = Ch("values", e, t, n); return [r.upperBound(i, a)] } case "Unique": { const i = Ch("x", e, t, n), a = r.unique(i); return [a.values, a.indices] } case "UniqueV2": { const i = Ch("x", e, t, n), a = Ch("axis", e, t, n), o = r.unique(i, a); return [o.values, o.indices] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "image": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "ResizeBilinear": { const i = Ch("images", e, t, n), a = Ch("size", e, t, n), o = Ch("alignCorners", e, t, n), s = Ch("halfPixelCenters", e, t, n); return [r.image.resizeBilinear(i, [a[0], a[1]], o, s)] } case "ResizeNearestNeighbor": { const i = Ch("images", e, t, n), a = Ch("size", e, t, n), o = Ch("alignCorners", e, t, n), s = Ch("halfPixelCenters", e, t, n); return [r.image.resizeNearestNeighbor(i, [a[0], a[1]], o, s)] } case "CropAndResize": { const i = Ch("image", e, t, n), a = Ch("boxes", e, t, n), o = Ch("boxInd", e, t, n), s = Ch("cropSize", e, t, n), u = Ch("method", e, t, n), l = Ch("extrapolationValue", e, t, n); return [r.image.cropAndResize(i, a, o, s, u, l)] } case "ImageProjectiveTransformV3": { const i = Ch("images", e, t, n), a = Ch("transforms", e, t, n), o = Ch("outputShape", e, t, n), s = Ch("fillValue", e, t, n), u = Ch("interpolation", e, t, n), l = Ch("fillMode", e, t, n); return [r.image.transform(i, a, u.toLowerCase(), l.toLowerCase(), s, o)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "graph": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Const": return t[e.name]; case "PlaceholderWithDefault": const i = Ch("default", e, t, n); return [Ah(e.name, t, n) || i]; case "Placeholder": return [Ah(e.name, t, n)]; case "Identity": case "StopGradient": case "FakeQuantWithMinMaxVars": case "Snapshot": return [Fh(Ch("x", e, t, n))]; case "IdentityN": return Ch("x", e, t, n).map((e => Fh(e))); case "Shape": return [r.tensor1d(Ch("x", e, t, n).shape, "int32")]; case "ShapeN": return Ch("x", e, t, n).map((e => r.tensor1d(e.shape))); case "Size": return [r.scalar(Ch("x", e, t, n).size, "int32")]; case "Rank": return [r.scalar(Ch("x", e, t, n).rank, "int32")]; case "NoOp": return [r.scalar(1)]; case "Print": const a = Ch("x", e, t, n), o = Ch("data", e, t, n), s = Ch("message", e, t, n), u = Ch("summarize", e, t, n); console.warn("The graph has a tf.print() operation,usually used for debugging, which slows down performance."), console.log(s); for (let e = 0; e < o.length; e++)console.log(Array.prototype.slice.call(o[e].dataSync()).slice(0, u)); return [a]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "logical": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Equal": return [r.equal(Ch("a", e, t, n), Ch("b", e, t, n))]; case "NotEqual": return [r.notEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Greater": return [r.greater(Ch("a", e, t, n), Ch("b", e, t, n))]; case "GreaterEqual": return [r.greaterEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Less": return [r.less(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LessEqual": return [r.lessEqual(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LogicalAnd": return [r.logicalAnd(Ch("a", e, t, n), Ch("b", e, t, n))]; case "LogicalNot": return [r.logicalNot(Ch("a", e, t, n))]; case "LogicalOr": return [r.logicalOr(Ch("a", e, t, n), Ch("b", e, t, n))]; case "Select": case "SelectV2": return [r.where(Ch("condition", e, t, n), Ch("a", e, t, n), Ch("b", e, t, n))]; case "BitwiseAnd": return [r.bitwiseAnd(Ch("a", e, t, n), Ch("b", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "matrices": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "BatchMatMul": case "BatchMatMulV2": case "MatMul": return [r.matMul(Ch("a", e, t, n), Ch("b", e, t, n), Ch("transposeA", e, t, n), Ch("transposeB", e, t, n))]; case "Einsum": return [r.einsum(Ch("equation", e, t, n), ...Ch("tensors", e, t, n))]; case "Transpose": return [r.transpose(Ch("x", e, t, n), Ch("perm", e, t, n))]; case "_FusedMatMul": const [i, a] = Ch("fusedOps", e, t, n), o = "biasadd" === i, s = "prelu" === a, u = Ch("numArgs", e, t, n), l = Ch("leakyreluAlpha", e, t, n); if (o) { if (s && 2 !== u) throw new Error("Fused MatMul with BiasAdd and Prelu must have two extra arguments: bias and alpha."); if (!s && 1 !== u) throw new Error("Fused MatMul with BiasAdd must have one extra argument: bias.") } const [c, h] = Ch("args", e, t, n); return [r.fused.matMul({ a: Ch("a", e, t, n), b: Ch("b", e, t, n), transposeA: Ch("transposeA", e, t, n), transposeB: Ch("transposeB", e, t, n), bias: c, activation: a, preluActivationWeights: h, leakyreluAlpha: l })]; case "MatrixBandPart": return [r.linalg.bandPart(Ch("a", e, t, n), Ch("numLower", e, t, n), Ch("numUpper", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "normalization": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "EuclideanNorm": return [r.euclideanNorm(Ch("x", e, t, n), Ch("axis", e, t, n), Ch("keepDims", e, t, n))]; case "FusedBatchNorm": case "FusedBatchNormV2": case "FusedBatchNormV3": return [r.batchNorm(Ch("x", e, t, n), Ch("mean", e, t, n), Ch("variance", e, t, n), Ch("offset", e, t, n), Ch("scale", e, t, n), Ch("epsilon", e, t, n))]; case "LRN": return [r.localResponseNormalization(Ch("x", e, t, n), Ch("radius", e, t, n), Ch("bias", e, t, n), Ch("alpha", e, t, n), Ch("beta", e, t, n))]; case "Softmax": return [r.softmax(Ch("x", e, t, n))]; case "LogSoftmax": return [r.logSoftmax(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "ragged": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "RaggedGather": { const { outputNestedSplits: i, outputDenseValues: a } = r.raggedGather(Ch("paramsNestedSplits", e, t, n), Ch("paramsDenseValues", e, t, n), Ch("indices", e, t, n), Ch("outputRaggedRank", e, t, n)); return i.concat(a) } case "RaggedRange": { const { rtNestedSplits: i, rtDenseValues: a } = r.raggedRange(Ch("starts", e, t, n), Ch("limits", e, t, n), Ch("splits", e, t, n)); return [i, a] } case "RaggedTensorToTensor": return [r.raggedTensorToTensor(Ch("shape", e, t, n), Ch("values", e, t, n), Ch("defaultValue", e, t, n), Ch("rowPartitionTensors", e, t, n), Ch("rowPartitionTypes", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "reduction": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Max": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.max(Ch("x", e, t, n), i, a)] } case "Mean": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.mean(Ch("x", e, t, n), i, a)] } case "Min": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.min(Ch("x", e, t, n), i, a)] } case "Sum": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.sum(Ch("x", e, t, n), i, a)] } case "All": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.all(Ch("x", e, t, n), i, a)] } case "Any": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.any(Ch("x", e, t, n), i, a)] } case "ArgMax": { const i = Ch("axis", e, t, n); return [r.argMax(Ch("x", e, t, n), i)] } case "ArgMin": { const i = Ch("axis", e, t, n); return [r.argMin(Ch("x", e, t, n), i)] } case "Prod": { const i = Ch("axis", e, t, n), a = Ch("keepDims", e, t, n); return [r.prod(Ch("x", e, t, n), i, a)] } case "Cumprod": { const i = Ch("axis", e, t, n), a = Ch("exclusive", e, t, n), o = Ch("reverse", e, t, n); return [r.cumprod(Ch("x", e, t, n), i, a, o)] } case "Cumsum": { const i = Ch("axis", e, t, n), a = Ch("exclusive", e, t, n), o = Ch("reverse", e, t, n); return [r.cumsum(Ch("x", e, t, n), i, a, o)] } case "Bincount": const i = Ch("x", e, t, n), a = Ch("weights", e, t, n), o = Ch("size", e, t, n); return [r.bincount(i, a, o)]; case "DenseBincount": { const i = Ch("x", e, t, n), a = Ch("weights", e, t, n), o = Ch("size", e, t, n), s = Ch("binaryOutput", e, t, n); return [r.denseBincount(i, a, o, s)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "slice_join": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "ConcatV2": case "Concat": { const i = Ch("n", e, t, n), a = Ch("axis", e, t, n); let o = Ch("tensors", e, t, n); return o = o.slice(0, i), [r.concat(o, a)] } case "Gather": { const i = Ch("x", e, t, n), a = Ch("indices", e, t, n); return [r.gather(i, r.cast(a, "int32"), 0)] } case "GatherV2": { const i = Ch("axis", e, t, n), a = Ch("batchDims", e, t, n), o = Ch("x", e, t, n), s = Ch("indices", e, t, n); return [r.gather(o, r.cast(s, "int32"), i, a)] } case "Reverse": { const i = Ch("dims", e, t, n), a = []; for (let e = 0; e < i.length; e++)i[e] && a.push(e); const o = Ch("x", e, t, n); return [r.reverse(o, a)] } case "ReverseV2": { const i = Ch("axis", e, t, n), a = Ch("x", e, t, n); return [r.reverse(a, i)] } case "Slice": { const i = Ch("begin", e, t, n), a = Ch("size", e, t, n); return [r.slice(Ch("x", e, t, n), i, a)] } case "StridedSlice": { const i = Ch("begin", e, t, n), a = Ch("end", e, t, n), o = Ch("strides", e, t, n), s = Ch("beginMask", e, t, n), u = Ch("endMask", e, t, n), l = Ch("ellipsisMask", e, t, n), c = Ch("newAxisMask", e, t, n), h = Ch("shrinkAxisMask", e, t, n), d = Ch("x", e, t, n); return [r.stridedSlice(d, i, a, o, s, u, l, c, h)] } case "Pack": return (0, P.tidy)((() => { const i = Ch("axis", e, t, n), a = Ch("tensors", e, t, n), o = a[0].shape, s = r.squeeze(a[0]).shape, u = a.map((e => { const t = P.util.arraysEqual(e.shape, o); if (!t && !P.util.arraysEqual(r.squeeze(e).shape, s)) throw new Error("the input tensors shape does not match"); return t ? e : r.reshape(e, o) })); return [r.stack(u, i)] })); case "Unpack": { const i = Ch("axis", e, t, n), a = Ch("tensor", e, t, n); return r.unstack(a, i) } case "Tile": { const i = Ch("reps", e, t, n); return [r.tile(Ch("x", e, t, n), i)] } case "Split": case "SplitV": { const i = Ch("axis", e, t, n), a = Ch("numOrSizeSplits", e, t, n), o = Ch("x", e, t, n); return r.split(o, a, i) } case "ScatterNd": { const i = Ch("indices", e, t, n), a = Ch("values", e, t, n), o = Ch("shape", e, t, n); return [r.scatterND(i, a, o)] } case "GatherNd": { const i = Ch("x", e, t, n), a = Ch("indices", e, t, n); return [r.gatherND(i, a)] } case "SparseToDense": { const i = Ch("sparseIndices", e, t, n), a = Ch("outputShape", e, t, n), o = Ch("sparseValues", e, t, n), s = Ch("defaultValue", e, t, n); return [r.sparseToDense(i, o, a, o.dtype === s.dtype ? s : r.cast(s, o.dtype))] } case "TensorScatterUpdate": { const i = Ch("indices", e, t, n), a = Ch("values", e, t, n), o = Ch("tensor", e, t, n); return [r.tensorScatterUpdate(o, i, a)] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "sparse": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "SparseFillEmptyRows": { const { outputIndices: i, outputValues: a, emptyRowIndicator: o, reverseIndexMap: s } = r.sparse.sparseFillEmptyRows(Ch("indices", e, t, n), Ch("values", e, t, n), Ch("denseShape", e, t, n), Ch("defaultValue", e, t, n)); return [i, a, o, s] } case "SparseReshape": { const { outputIndices: i, outputShape: a } = r.sparse.sparseReshape(Ch("inputIndices", e, t, n), Ch("inputShape", e, t, n), Ch("newShape", e, t, n)); return [i, a] } case "SparseSegmentMean": return [r.sparse.sparseSegmentMean(Ch("data", e, t, n), Ch("indices", e, t, n), Ch("segmentIds", e, t, n))]; case "SparseSegmentSum": return [r.sparse.sparseSegmentSum(Ch("data", e, t, n), Ch("indices", e, t, n), Ch("segmentIds", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "spectral": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "FFT": return [r.fft(Ch("x", e, t, n))]; case "IFFT": return [r.ifft(Ch("x", e, t, n))]; case "RFFT": return [r.rfft(Ch("x", e, t, n))]; case "IRFFT": return [r.irfft(Ch("x", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "string": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "StaticRegexReplace": return [r.string.staticRegexReplace(Ch("input", e, t, n), Ch("pattern", e, t, n), Ch("rewrite", e, t, n), Ch("replaceGlobal", e, t, n))]; case "StringNGrams": { const { nGrams: i, nGramsSplits: a } = r.string.stringNGrams(Ch("data", e, t, n), Ch("dataSplits", e, t, n), Ch("separator", e, t, n), Ch("nGramWidths", e, t, n), Ch("leftPad", e, t, n), Ch("rightPad", e, t, n), Ch("padWidth", e, t, n), Ch("preserveShortSequences", e, t, n)); return [i, a] } case "StringSplit": { const { indices: i, values: a, shape: o } = r.string.stringSplit(Ch("input", e, t, n), Ch("delimiter", e, t, n), Ch("skipEmpty", e, t, n)); return [i, a, o] } case "StringToHashBucketFast": return [r.string.stringToHashBucketFast(Ch("input", e, t, n), Ch("numBuckets", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "transformation": return i((() => ((e, t, n, r = T) => { switch (e.op) { case "Cast": return [r.cast(Ch("x", e, t, n), Ch("dtype", e, t, n))]; case "ExpandDims": { const i = Ch("axis", e, t, n); return [r.expandDims(Ch("x", e, t, n), i)] } case "Squeeze": { const i = Ch("axis", e, t, n); return [r.squeeze(Ch("x", e, t, n), i)] } case "Reshape": return [r.reshape(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "EnsureShape": return [r.ensureShape(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "MirrorPad": return [r.mirrorPad(Ch("x", e, t, n), Ch("padding", e, t, n), Ch("mode", e, t, n))]; case "PadV2": case "Pad": return [r.pad(Ch("x", e, t, n), Ch("padding", e, t, n), Ch("constantValue", e, t, n))]; case "SpaceToBatchND": { const i = Ch("blockShape", e, t, n), a = Ch("paddings", e, t, n); return [r.spaceToBatchND(Ch("x", e, t, n), i, a)] } case "BatchToSpaceND": { const i = Ch("blockShape", e, t, n), a = Ch("crops", e, t, n); return [r.batchToSpaceND(Ch("x", e, t, n), i, a)] } case "DepthToSpace": { const i = Ch("blockSize", e, t, n), a = Ch("dataFormat", e, t, n).toUpperCase(); return [r.depthToSpace(Ch("x", e, t, n), i, a)] } case "BroadcastTo": return [r.broadcastTo(Ch("x", e, t, n), Ch("shape", e, t, n))]; case "BroadcastArgs": return [r.broadcastArgs(Ch("s0", e, t, n), Ch("s1", e, t, n))]; default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n))); case "hash_table": return (async (e, t, n, r) => { switch (e.op) { case "HashTable": case "HashTableV2": { const i = r.getHashTableHandleByName(e.name); if (null != i) return [i]; { const i = Ch("keyDType", e, t, n), a = Ch("valueDType", e, t, n), o = new _d(i, a); return r.addHashTable(e.name, o), [o.handle] } } case "InitializeTable": case "InitializeTableV2": case "LookupTableImport": case "LookupTableImportV2": { const i = Ch("tableHandle", e, t, n, r), a = Ch("keys", e, t, n), o = Ch("values", e, t, n), s = r.getHashTableById(i.id); return [await s.import(a, o)] } case "LookupTableFind": case "LookupTableFindV2": { const i = Ch("tableHandle", e, t, n, r), a = Ch("keys", e, t, n), o = Ch("defaultValue", e, t, n), s = r.getHashTableById(i.id); return [await s.find(a, o)] } case "LookupTableSize": case "LookupTableSizeV2": { const i = Ch("tableHandle", e, t, n, r); return [r.getHashTableById(i.id).tensorSize()] } default: throw TypeError(`Node type ${e.op} is not implemented`) } })(e, t, n, r); case "custom": const a = Sh(e.op); if (a && a.customExecutor) return a.customExecutor(new fd(e, t, n)); throw TypeError(`Custom op ${e.op} is not registered.`); default: throw TypeError(`Unknown op '${e.op}'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()`) } })(e, t, n); return P.util.isPromise(a) ? a.then((e => [].concat(e))) : [].concat(a) } class Ad { constructor(e = {}, t = {}, n = {}, r = {}, i) { this.weightMap = e, this.tensorArrayMap = t, this.tensorListMap = n, this.functionMap = r, this.parseNodeNameCache = i, this.rootContext = { id: 0, frameName: "", iterationId: 0 }, this.contexts = [this.rootContext], this.lastId = 0, this.generateCurrentContextIds() } newFrame(e, t) { return { id: e, frameName: t, iterationId: 0 } } set currentContext(e) { this.contexts !== e && (this.contexts = e, this.generateCurrentContextIds()) } get currentContext() { return this.contexts } get currentContextId() { return this._currentContextIds[0] } get currentContextIds() { return this._currentContextIds } generateCurrentContextIds() { const e = []; for (let t = 0; t < this.contexts.length - 1; t++) { const n = this.contexts.slice(0, this.contexts.length - t); e.push(this.contextIdforContexts(n)) } e.push(""), this._currentContextIds = e } contextIdforContexts(e) { return e ? e.map((e => 0 === e.id && 0 === e.iterationId ? "" : `${e.frameName}-${e.iterationId}`)).join("/") : "" } enterFrame(e) { this.contexts && (this.lastId++, this.contexts = this.contexts.slice(), this.contexts.push(this.newFrame(this.lastId, e)), this._currentContextIds.unshift(this.contextIdforContexts(this.contexts))) } exitFrame() { if (!(this.contexts && this.contexts.length > 1)) throw new Error("Cannot exit frame, the context is empty"); this.contexts = this.contexts.slice(), this.contexts.splice(-1), this.currentContextIds.shift() } nextIteration() { if (!(this.contexts && this.contexts.length > 0)) throw new Error("Cannot increase frame iteration, the context is empty"); { this.contexts = this.contexts.slice(), this.lastId++; const e = Object.assign({}, this.contexts[this.contexts.length - 1]); e.iterationId += 1, e.id = this.lastId, this.contexts.splice(-1, 1, e), this._currentContextIds.splice(0, 1, this.contextIdforContexts(this.contexts)) } } getWeight(e) { return this.weightMap[e] } addTensorArray(e) { this.tensorArrayMap[e.id] = e } getTensorArray(e) { return this.tensorArrayMap[e] } addTensorList(e) { this.tensorListMap[e.id] = e } getTensorList(e) { return this.tensorListMap[e] } dispose(e) { for (const t in this.tensorArrayMap) this.tensorArrayMap[t].clearAndClose(e); for (const t in this.tensorListMap) this.tensorListMap[t].clearAndClose(e) } }
/**
* @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 Td(e, t, n, r) { const i = new Set, a = []; let o = null, s = null; const u = new Set, l = new Set(Object.keys(e).map((e => Ih(e)[0]))); r = r || []; const c = new Set(r.map((e => Ih(e.name)[0]))), h = [...t]; for (; h.length > 0;) { const e = h.pop(); (Dd(e) || $d(e) || Rd(e)) && null == o && (o = e, s = o.children.map((e => e.name)).filter((e => i.has(e)))), i.add(e.name), null == n[e.name] && (l.has(e.name) || c.has(e.name) || (0 !== e.inputs.length ? e.inputs.forEach((e => { u.has(e.name) || (u.add(e.name), h.push(e)) })) : a.push(e.name))) } return { inputs: e, outputs: t, usedNodes: i, missingInputs: a, dynamicNode: o, syncInputs: s } } function Ed(e, t) { const { usedNodes: n, inputs: r } = t, i = Object.keys(r).map((e => Ih(e)[0])).map((t => e.nodes[t])), a = e.initNodes || [], o = e => n.has("string" == typeof e ? e : e.name); function s(e) { return [...new Map(e.map((e => [e.name, e]))).values()] } const u = s([...i, ...e.weights, ...a]).filter(o), l = s([...u, ...Object.values(e.nodes)]).filter(o), c = new Map(l.map((e => [e.name, e]))), h = {}; for (const e of l) { h[e.name] = h[e.name] || 0; for (const t of e.children) o(t) || (h[t.name] = Number.POSITIVE_INFINITY), h[t.name] = (h[t.name] || 0) + 1 } const d = Object.entries(h).filter((([, e]) => 0 === e)).map((([e]) => e)), f = [...d]; for (; d.length > 0;) { const e = d.pop(), t = c.get(e); for (const e of t.children.filter(o)) 0 == --h[e.name] && (f.push(e.name), d.push(e.name)) } const p = function (e, t) { const n = new Map(e.map((e => [e.name, e]))), r = t.map((e => e.name)), i = new Set(r); for (; r.length > 0;) { const e = r.pop(), t = n.get(e); for (const e of t.children) n.has(e.name) && !i.has(e.name) && (i.add(e.name), r.push(e.name)) } const a = e.filter((e => i.has(e.name))); return a }(f.map((e => c.get(e))), u); return function (e, t) { const n = new Map(e.map(((e, t) => [e.name, t]))), r = new Set(t.map((e => e.name))), i = e => r.has("string" == typeof e ? e : e.name), a = new Set(e.map((e => e.name))), o = e => a.has("string" == typeof e ? e : e.name); for (const t of e) { for (const e of t.children.filter(o)) { if (!n.has(e.name)) throw new Nd(`Child ${e.name} of node ${t.name} is unreachable.`); if (n.get(t.name) > n.get(e.name)) throw new Nd(`Node ${t.name} is scheduled to run after its child ${e.name}.`) } if (!i(t)) for (const e of t.inputs) { if (!n.has(e.name)) throw new Nd(`Input ${e.name} of node ${t.name} is unreachable.`); if (n.get(e.name) > n.get(t.name)) throw new Nd(`Node ${t.name} is scheduled to run before its input ${e.name}.`) } } }(p, u), p } class Nd extends Error { constructor(e) { super(`NodesExecutionOrderError: ${e}`) } } const Id = new Set(["Switch", "Merge", "Enter", "Exit", "NextIteration", "StatelessIf", "StatelessWhile", "if", "While"]), Md = new Set(["NonMaxSuppressionV2", "NonMaxSuppressionV3", "NonMaxSuppressionV5", "Where"]), Fd = new Set(["HashTable", "HashTableV2", "LookupTableImport", "LookupTableImportV2", "LookupTableFind", "LookupTableFindV2", "LookupTableSize", "LookupTableSizeV2"]); function Dd(e) { return Id.has(e.op) } function $d(e) { return Md.has(e.op) } function Rd(e) { return Fd.has(e.op) }
/**
* @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 Od { get weightIds() { return this.parent ? this.parent.weightIds : this._weightIds } get functionExecutorMap() { return this.parent ? this.parent.functionExecutorMap : this._functionExecutorMap } get weightMap() { return this.parent ? this.parent.weightMap : this._weightMap } set weightMap(e) { const t = Object.keys(e).map((t => e[t].map((e => e.id)))); this._weightIds = [].concat(...t), this._weightMap = e } set resourceManager(e) { this._resourceManager = e } get inputs() { return this._inputs.map((e => ({ name: e.name, shape: e.attrParams.shape ? e.attrParams.shape.value : void 0, dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0 }))) } get outputs() { return this._outputs.map((e => ({ name: e.name, shape: e.attrParams.shape ? e.attrParams.shape.value : void 0, dtype: e.attrParams.dtype ? e.attrParams.dtype.value : void 0 }))) } get inputNodes() { return this._inputs.map((e => e.signatureKey || e.name)) } get outputNodes() { return this._outputs.map((e => { const t = e.signatureKey || e.name; return e.defaultOutput ? `${t}:${e.defaultOutput}` : t })) } get functions() { return Object.keys(this._functions).reduce(((e, t) => (e[t] = this._functions[t].signature, e)), {}) } constructor(e, t) { this.graph = e, this.parent = t, this.compiledMap = new Map, this.parseNodeNameCache = new Map, this._weightMap = {}, this.SEPARATOR = ",", this._functions = {}, this._functionExecutorMap = {}, this.keepIntermediateTensors = !1, this._outputs = e.outputs, this._inputs = e.inputs, this._initNodes = e.initNodes, this._signature = e.signature, this._functions = e.functions, null != e.functions && Object.keys(e.functions).forEach((t => { this._functionExecutorMap[t] = new Od(e.functions[t], this) })) } getCompilationKey(e, t) { const n = e.map((e => e.name)).sort(), r = t.map((e => e.name)).sort(); return n.join(this.SEPARATOR) + "--" + r.join(this.SEPARATOR) } compile(e, t) { const n = Td(e, t, this.weightMap, this._initNodes), { missingInputs: r, dynamicNode: i, syncInputs: a } = n; if (null != i) throw new Error(`This execution contains the node '${i.name}', which has the dynamic op '${i.op}'. Please use model.executeAsync() instead. Alternatively, to avoid the dynamic ops, specify the inputs [${a}]`); if (r.length > 0) { const n = t.map((e => e.name)), i = Object.keys(e); throw new Error(`Cannot compute the outputs [${n}] from the provided inputs [${i}]. Missing the following inputs: [${r}]`) } const o = Ed(this.graph, n), s = function (e) { const t = new Map(e.map(((e, t) => [e.name, t]))), n = Number.MAX_SAFE_INTEGER, r = e.map(((e, t) => Dd(e) ? n : t)), i = e => { const n = r[t.get(e.name)]; return null == n ? -1 : n }, a = e.map(((e, t) => e.children.map(i).reduce(((e, t) => Math.max(e, t)), r[t]))), o = new Map; for (let t = 0; t < e.length; ++t) { const r = a[t]; if (r === n) continue; const i = e[t], s = e[r]; o.has(s.name) || o.set(s.name, []), o.get(s.name).push(i) } return o }(o); return { orderedNodes: o, nodeLiveUntilMap: s } } cloneAndKeepTensor(e) { if (null == e) return null; const t = e.clone(); return (0, P.keep)(t), t } cloneTensorList(e) { if (!e) return null; return e.map((e => this.cloneAndKeepTensor(e))) } cloneTensorMap(e) { return Object.fromEntries(Object.entries(e).map((([e, t]) => [e, this.cloneTensorList(t)]))) } execute(e, t) { this.disposeIntermediateTensors(), e = this.mapInputs(e); const n = Object.keys(e).sort(); this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t); const r = n.map((e => this.graph.nodes[Ih(e)[0]])), i = t.map((e => Ih(e)[0])), a = new Set(i); let o = i.map((e => this.graph.nodes[e])); 0 === o.length && (o = this._outputs); const s = this.getCompilationKey(r, o); let u = this.compiledMap.get(s); null == u && (u = this.compile(e, o), this.compiledMap.set(s, u)); try { this.keepIntermediateTensors = (0, P.env)().getBool("KEEP_INTERMEDIATE_TENSORS") } catch (e) { this.keepIntermediateTensors = !1, console.warn(e.message) } const l = {}, c = {}; return (0, P.tidy)((() => { const n = new Ad(this.weightMap, l, c, this.functionExecutorMap, this.parseNodeNameCache), r = Object.assign({}, this.weightMap); this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)), Object.keys(e).forEach((t => { const [i, a] = Ih(t, n), o = []; o[a] = e[t], r[i] = o, this.keepIntermediateTensors && (this.clonedTensorsMap[i] = this.cloneTensorList(o)) })); const i = this.getFrozenTensorIds(r), { orderedNodes: o, nodeLiveUntilMap: s } = u; for (const e of o) { if (r[e.name]) continue; const t = Cd(e, r, n, this._resourceManager); if (P.util.isPromise(t)) throw new Error(`The execution of the op '${e.op}' returned a promise. Please use model.executeAsync() instead.`); r[e.name] = t, this.keepIntermediateTensors && (this.clonedTensorsMap[e.name] = this.cloneTensorList(t)), this.checkTensorForDisposalWithNodeLiveUntilInfo(e, r, n, i, a, s.get(e.name)) } return null == this.parent && n.dispose(i), t.map((e => Ah(e, r, n))) })) } getFrozenTensorIds(e) { const t = [].concat.apply([], Object.keys(e).map((t => e[t])).map((e => e.map((e => e.id))))); return new Set(t) } checkTensorForDisposal(e, t, n, r, i, a, o) { if (!Dd(t) && !a.has(e)) { for (const r of n[e]) null != r && (o[r.id] = (o[r.id] || 0) + t.children.length); for (const e of t.inputs) { if (Dd(e)) continue; const t = Th(e.name, n, r); if (null != t) for (const e of t) { if (!e || e.kept || i.has(e.id)) continue; const t = o[e.id]; 1 === t ? (e.dispose(), delete o[e.id]) : null != t && o[e.id]-- } } } } checkTensorForDisposalWithNodeLiveUntilInfo(e, t, n, r, i, a) { function o(e) { return Dd(e) || i.has(e.name) } if (!Dd(e) && null != a) for (const e of a) { if (o(e)) continue; const i = Th(e.name, t, n); for (const e of i) !e || e.kept || r.has(e.id) || e.dispose() } } async executeAsync(e, t) { return this._executeAsync(e, t) } disposeIntermediateTensors() { this.clonedTensorsMap && (Object.values(this.clonedTensorsMap).forEach((e => { for (const t of e) t && !t.isDisposed && t.dispose() })), this.clonedTensorsMap = null) } getIntermediateTensors() { return this.clonedTensorsMap } async _executeAsync(e, t, n = !1, r = {}, i = {}) { this.disposeIntermediateTensors(), n || (e = this.mapInputs(e), this.checkInputs(e), this.checkInputShapeAndType(e), t = this.mapOutputs(t), this.checkOutputs(t)); try { this.keepIntermediateTensors = (0, P.env)().getBool("KEEP_INTERMEDIATE_TENSORS") } catch (e) { this.keepIntermediateTensors = !1, console.warn(e.message) } const a = new Ad(this.weightMap, r, i, this.functionExecutorMap, this.parseNodeNameCache); this.keepIntermediateTensors && (this.clonedTensorsMap = this.cloneTensorMap(this.weightMap)); const o = await this.executeWithControlFlow(e, a, t, n), s = t.map((e => Ah(e, o, a))), u = s.map((e => e.id)), l = Object.keys(e).map((t => e[t].id)), c = new Set([...u, ...l, ...this.weightIds]); return Object.values(o).forEach((e => { e.forEach((e => { !e || e.isDisposed || c.has(e.id) || e.dispose() })) })), null == this.parent && a.dispose(c), s } async executeFunctionAsync(e, t, n) { const r = e.reduce(((e, t, n) => (e[this.inputs[n].name] = t, e)), {}); return this._executeAsync(r, this.outputNodes, !0, t, n) } async executeWithControlFlow(e, t, n, r) { const i = Object.keys(e), a = i.map((e => this.graph.nodes[Ih(e)[0]])), o = n.map((e => Ih(e)[0])), s = new Set(o); let u = o.map((e => this.graph.nodes[e])); 0 === u.length && (u = this._outputs); const { usedNodes: l, missingInputs: c, dynamicNode: h, syncInputs: d } = Td(e, u, this.weightMap, this._initNodes), f = [...a, ...this.graph.weights, ...this._initNodes || []].map((e => ({ node: e, contexts: t.currentContext }))), p = Object.assign({}, this.weightMap); Object.keys(e).forEach((t => { const [n, r] = Ih(t), i = []; i[r] = e[t], p[n] = i })); const m = {}, g = this.getFrozenTensorIds(p), y = {}; for (; f.length > 0;) { const e = this.processStack(a, f, t, p, y, g, s, m, l); await Promise.all(e) } null != h || r || console.warn("This model execution did not contain any nodes with control flow or dynamic output shapes. You can use model.execute() instead."); const b = u.filter((e => !Dd(e) && !Ah(e.name, p, t))).map((e => e.name)); if (b.length > 0) { let e = ""; throw null != h && (e = `Alternatively, to avoid the dynamic ops, use model.execute() and specify the inputs [${d}]`), new Error(`Cannot compute the outputs [${b}] from the provided inputs [${i}]. Consider providing the following inputs: [${c}]. ${e}`) } return p } processStack(e, t, n, r, i, a, o, s, u) { const l = []; for (; t.length > 0;) { const e = t.pop(); n.currentContext = e.contexts; let c = ""; if ("Enter" === e.node.op && Ch("isConstant", e.node, r, n) && ([c] = Eh(e.node.name, n)), null == r[e.node.name]) { const h = Cd(e.node, r, n, this._resourceManager); c || ([c] = Eh(e.node.name, n)); const d = n.currentContext; P.util.isPromise(h) ? l.push(h.then((l => (r[c] = l, this.keepIntermediateTensors && (this.clonedTensorsMap[c] = this.cloneTensorList(l)), n.currentContext = d, this.checkTensorForDisposal(c, e.node, r, n, a, o, s), this.processChildNodes(e.node, t, n, r, i, u), l)))) : (r[c] = h, this.keepIntermediateTensors && (this.clonedTensorsMap[c] = this.cloneTensorList(h)), this.checkTensorForDisposal(c, e.node, r, n, a, o, s), this.processChildNodes(e.node, t, n, r, i, u)) } else this.processChildNodes(e.node, t, n, r, i, u) } return l } processChildNodes(e, t, n, r, i, a) { e.children.forEach((e => { const [o] = Eh(e.name, n); !i[o] && a.has(e.name) && ("Merge" === e.op ? e.inputNames.some((e => !!Ah(e, r, n))) && (i[o] = !0, t.push({ contexts: n.currentContext, node: e })) : e.inputNames.every((e => !!Ah(e, r, n))) && (i[o] = !0, t.push({ contexts: n.currentContext, node: e }))) })) } dispose() { Object.keys(this.weightMap).forEach((e => this.weightMap[e].forEach((e => e.dispose())))) } checkInputShapeAndType(e) { Object.keys(e).forEach((t => { const n = e[t], [r] = Ih(t), i = this.graph.nodes[r]; if (i.attrParams.shape && i.attrParams.shape.value) { const e = i.attrParams.shape.value, t = e.length === n.shape.length && n.shape.every(((t, n) => -1 === e[n] || e[n] === t)); P.util.assert(t, (() => `The shape of dict['${i.name}'] provided in model.execute(dict) must be [${e}], but was [${n.shape}]`)) } i.attrParams.dtype && i.attrParams.dtype.value && P.util.assert(n.dtype === i.attrParams.dtype.value, (() => `The dtype of dict['${i.name}'] provided in model.execute(dict) must be ${i.attrParams.dtype.value}, but was ${n.dtype}`)) })) } mapInputs(e) { var t, n; const r = {}; for (const i in e) { const a = null === (n = null === (t = this._signature) || void 0 === t ? void 0 : t.inputs) || void 0 === n ? void 0 : n[i]; null != a ? r[a.name] = e[i] : r[i] = e[i] } return r } checkInputs(e) { const t = Object.keys(e).filter((e => { const [t] = Ih(e); return null == this.graph.nodes[t] })); if (t.length > 0) throw new Error(`The dict provided in model.execute(dict) has keys: [${t}] that are not part of graph`) } mapOutputs(e) { return e.map((e => { var t, n; const r = null === (n = null === (t = this._signature) || void 0 === t ? void 0 : t.outputs) || void 0 === n ? void 0 : n[e]; return null != r ? r.name : e }), {}) } checkOutputs(e) { e.forEach((e => { const [t] = Ih(e); if (!this.graph.nodes[t]) throw new Error(`The output '${e}' is not found in the graph`) })) } } class zd { constructor(e = {}, t = {}) { this.hashTableNameToHandle = e, this.hashTableMap = t } addHashTable(e, t) { this.hashTableNameToHandle[e] = t.handle, this.hashTableMap[t.id] = t } getHashTableHandleByName(e) { return this.hashTableNameToHandle[e] } getHashTableById(e) { return this.hashTableMap[e] } dispose() { for (const e in this.hashTableMap) this.hashTableMap[e].clearAndClose(), delete this.hashTableMap[e]; for (const e in this.hashTableNameToHandle) this.hashTableNameToHandle[e].dispose(), delete this.hashTableNameToHandle[e] } } var Pd = n(7084);
/**
* @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 Bd = "?tfjs-format=file", Ld = "model.json"; class jd { get modelVersion() { return this.version } get inputNodes() { return this.executor.inputNodes } get outputNodes() { return this.executor.outputNodes } get inputs() { return this.executor.inputs } get outputs() { return this.executor.outputs } get weights() { return this.executor.weightMap } get metadata() { return this.artifacts.userDefinedMetadata } get modelSignature() { return this.signature } get modelStructuredOutputKeys() { return this.structuredOutputKeys } constructor(e, t = {}, n = P.io) { this.modelUrl = e, this.loadOptions = t, this.version = "n/a", this.io = n, null == t && (this.loadOptions = {}), this.resourceManager = new zd } findIOHandler() { const e = this.modelUrl; if (null != e.load) this.handler = e; else if (null != this.loadOptions.requestInit) this.handler = this.io.browserHTTPRequest(e, this.loadOptions); else { const t = this.io.getLoadHandlers(e, this.loadOptions); if (0 === t.length) t.push(this.io.browserHTTPRequest(e, this.loadOptions)); else if (t.length > 1) throw new Error(`Found more than one (${t.length}) load handlers for URL '${[e]}'`); this.handler = t[0] } } load() { if (this.findIOHandler(), null == this.handler.load) throw new Error("Cannot proceed with model loading because the IOHandler provided does not have the `load` method implemented."); const e = this.handler.load(); return P.util.isPromise(e) ? e.then((e => null == e.getWeightStream ? this.loadSync(e) : this.loadStreaming(e))) : this.loadSync(e) } loadSync(e) { const t = this.io.decodeWeights(e.weightData, e.weightSpecs); return this.loadWithWeightMap(e, t) } async loadStreaming(e) { if (null == e.getWeightStream) throw new Error("Model artifacts missing streamWeights function"); const t = await (0, Pd.s5)(e.getWeightStream(), e.weightSpecs); return this.loadWithWeightMap(e, t) } loadWithWeightMap(e, t) { this.artifacts = e; const n = this.artifacts.modelTopology; let r = this.artifacts.signature; if (null != this.artifacts.userDefinedMetadata) { const e = this.artifacts.userDefinedMetadata; null != e.signature && (r = e.signature), null != e.structuredOutputKeys && (this.structuredOutputKeys = e.structuredOutputKeys) } if (this.signature = r, this.version = `${n.versions.producer}.${n.versions.minConsumer}`, this.executor = new Od(Jh.Instance.transformGraph(n, this.signature)), this.executor.weightMap = this.convertTensorMapToTensorsMap(t), this.executor.resourceManager = this.resourceManager, null != e.modelInitializer && null != e.modelInitializer.node) { const t = Jh.Instance.transformGraph(e.modelInitializer); this.initializer = new Od(t), this.initializer.weightMap = this.executor.weightMap, this.initializer.resourceManager = this.resourceManager, this.initializerSignature = e.initializerSignature } return !0 } async save(e, t) { if ("string" == typeof e) { const t = this.io.getSaveHandlers(e); if (0 === t.length) throw new Error(`Cannot find any save handlers for URL '${e}'`); if (t.length > 1) throw new Error(`Found more than one (${t.length}) save handlers for URL '${e}'`); e = t[0] } if (null == e.save) throw new Error("GraphModel.save() cannot proceed because the IOHandler provided does not have the `save` attribute defined."); return e.save(this.artifacts) } addStructuredOutputNames(e) { if (this.structuredOutputKeys) { const t = e instanceof P.Tensor ? [e] : e, n = {}; return t.forEach(((e, t) => n[this.structuredOutputKeys[t]] = e)), n } return e } predict(e, t) { const n = this.execute(e, this.outputNodes); return this.addStructuredOutputNames(n) } async predictAsync(e, t) { const n = await this.executeAsync(e, this.outputNodes); return this.addStructuredOutputNames(n) } normalizeInputs(e) { var t; if (!(e instanceof P.Tensor || Array.isArray(e))) { const n = null === (t = this.signature) || void 0 === t ? void 0 : t.inputs; if (null != n) for (const t in n) { const r = n[t]; null != r.resourceId && (e[t] = this.resourceIdToCapturedInput[r.resourceId]) } return e } e = Array.isArray(e) ? e : [e]; const n = Object.keys(this.resourceIdToCapturedInput).length; if (e.length + n !== this.inputNodes.length) throw new Error(`Input tensor count mismatch, the graph model has ${this.inputNodes.length - n} non-resource placeholders, while there are ${e.length} input tensors provided.`); let r = 0; return this.inputNodes.reduce(((t, n) => { var i, a, o; const s = null === (o = null === (a = null === (i = this.signature) || void 0 === i ? void 0 : i.inputs) || void 0 === a ? void 0 : a[n]) || void 0 === o ? void 0 : o.resourceId; return t[n] = null != s ? this.resourceIdToCapturedInput[s] : e[r++], t }), {}) } normalizeOutputs(e) { return e = e || this.outputNodes, Array.isArray(e) ? e : [e] } executeInitializerGraph() { return null == this.initializer ? [] : null == this.initializerSignature ? this.initializer.execute({}, []) : this.initializer.execute({}, Object.keys(this.initializerSignature.outputs)) } async executeInitializerGraphAsync() { return null == this.initializer ? [] : null == this.initializerSignature ? this.initializer.executeAsync({}, []) : this.initializer.executeAsync({}, Object.keys(this.initializerSignature.outputs)) } setResourceIdToCapturedInput(e) { if (this.resourceIdToCapturedInput = {}, this.initializerSignature) { const t = this.initializerSignature.outputs, n = Object.keys(t); for (let r = 0; r < n.length; r++) { const i = t[n[r]]; this.resourceIdToCapturedInput[i.resourceId] = e[r] } } } execute(e, t) { null == this.resourceIdToCapturedInput && this.setResourceIdToCapturedInput(this.executeInitializerGraph()), e = this.normalizeInputs(e), t = this.normalizeOutputs(t); const n = this.executor.execute(e, t); return n.length > 1 ? n : n[0] } async executeAsync(e, t) { null == this.resourceIdToCapturedInput && this.setResourceIdToCapturedInput(await this.executeInitializerGraphAsync()), e = this.normalizeInputs(e), t = this.normalizeOutputs(t); const n = await this.executor.executeAsync(e, t); return n.length > 1 ? n : n[0] } getIntermediateTensors() { return this.executor.getIntermediateTensors() } disposeIntermediateTensors() { this.executor.disposeIntermediateTensors() } convertTensorMapToTensorsMap(e) { return Object.keys(e).reduce(((t, n) => (t[n] = [e[n]], t)), {}) } dispose() { this.executor.dispose(), this.initializer && (this.initializer.dispose(), this.resourceIdToCapturedInput && (0, P.dispose)(this.resourceIdToCapturedInput)), this.resourceManager.dispose() } } async function Ud(e, t = {}, n = P.io) { if (null == e) throw new Error("modelUrl in loadGraphModel() cannot be null. Please provide a url or an IOHandler that loads the model"); null == t && (t = {}), t.fromTFHub && "string" == typeof e && (e = function (e) { e.endsWith("/") || (e += "/"); return `${e}${Ld}${Bd}` }(e)); const r = new jd(e, t, n); return await r.load(), r } function Wd(e) { if (null == e) throw new Error("modelUrl in loadGraphModelSync() cannot be null. Please provide model artifacts or an IOHandler that loads the model"); let t; if (e instanceof Array) { const [n, r] = e; if (!n) throw new Error("modelJSON must be the first element of the array"); if (!(r && r instanceof ArrayBuffer)) throw new Error("An ArrayBuffer of weights must be the second element of the array"); if (!("modelTopology" in n)) throw new Error("Model JSON is missing 'modelTopology'"); if (!("weightsManifest" in n)) throw new Error("Model JSON is missing 'weightsManifest'"); const i = P.io.getWeightSpecs(n.weightsManifest), a = P.io.getModelArtifactsForJSONSync(n, i, r); t = P.io.fromMemorySync(a) } else if ("load" in e) t = e; else { if (!("modelTopology" in e && "weightSpecs" in e && "weightData" in e)) throw new Error("Unknown model format"); t = P.io.fromMemorySync(e) } const n = new jd(t); return n.load(), n }
/** @license See the LICENSE file. */
const Vd = "4.22.0";
/**
* @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.
* =============================================================================
*/
var Gd, Hd, qd = n(7391); function Yd(e, t, n = new Map, r = new Set) { if (null == e) return null; if ("function" == typeof Blob && e instanceof Blob) return e.slice(); if (r.has(e)) throw new Error("Circular references are not supported."); if (n.has(e)) return n.get(e); const i = t(e); if (i.recurse && null !== i.value) throw new Error("A deep map function may not return both a value and recurse=true."); if (i.recurse) { if (Qd(e)) { const i = Array.isArray(e) ? [] : {}; r.add(e); for (const a in e) { const o = Yd(e[a], t, n, r); i[a] = o } return r.delete(e), e.__proto__ && (i.__proto__ = e.__proto__), i } throw new Error(`Can't recurse into non-iterable type: ${e}`) } return n.set(e, i.value), i.value } function Xd(e, t = Zd) { return Kd(e, t) } function Kd(e, t, n = new Set) { const r = e[0]; if (n.has(r)) throw new Error("Circular references are not supported."); const i = t(e); if (i.recurse && null !== i.value) throw new Error("A deep zip function may not return both a value and recurse=true."); if (i.recurse) { if (Qd(r)) { const i = Array.isArray(r) ? [] : {}; n.add(r); for (const a in r) { const r = Kd(e.map((e => e[a])), t, n); i[a] = r } return n.delete(r), i } throw new Error(`Can't recurse into non-iterable type: ${r}`) } return i.value } function Zd(e) { return null === e ? null : Qd(e[0]) ? { value: null, recurse: !0 } : { value: e, recurse: !1 } } async function Jd(e, t) { const n = new Map; Yd(e, t, n); for (const e of Array.from(n.keys())) { const t = n.get(e); if (P.util.isPromise(t)) { const r = await t; n.set(e, r) } } return Yd(e, t, n) } function Qd(e) { let t = !1; if (P.env().get("IS_BROWSER")) t = e instanceof TextDecoder; else { const { StringDecoder: r } = n(551); t = e instanceof r } return null != e && !ArrayBuffer.isView(e) && (Array.isArray(e) || "object" == typeof e && !(e instanceof P.Tensor) && !(e instanceof Promise) && !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 ef(e) { return Yd(e, tf) } function tf(e) { return e instanceof P.Tensor ? { value: e.clone(), recurse: !1 } : Qd(e) ? { value: null, recurse: !0 } : { value: e, recurse: !1 } }
/**
* @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 nf { constructor(e) { if (this.capacity = e, this.begin = 0, this.end = 0, null == e) throw new RangeError("Can't create a ring buffer of unknown capacity."); if (e < 1) throw new RangeError("Can't create ring buffer of capacity < 1."); this.data = new Array(e), this.doubledCapacity = 2 * e } wrap(e) { for (; e < 0;)e += this.doubledCapacity; return e % this.doubledCapacity } get(e) { if (e < 0) throw new RangeError("Can't get item at a negative index."); return this.data[e % this.capacity] } set(e, t) { if (e < 0) throw new RangeError("Can't set item at a negative index."); this.data[e % this.capacity] = t } length() { let e = this.end - this.begin; return e < 0 && (e = this.doubledCapacity + e), e } isFull() { return this.length() === this.capacity } isEmpty() { return 0 === this.length() } push(e) { if (this.isFull()) throw new RangeError("Ring buffer is full."); this.set(this.end, e), this.end = this.wrap(this.end + 1) } pushAll(e) { for (const t of e) this.push(t) } pop() { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); this.end = this.wrap(this.end - 1); const e = this.get(this.end); return this.set(this.end, void 0), e } unshift(e) { if (this.isFull()) throw new RangeError("Ring buffer is full."); this.begin = this.wrap(this.begin - 1), this.set(this.begin, e) } shift() { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); const e = this.get(this.begin); return this.set(this.begin, void 0), this.begin = this.wrap(this.begin + 1), e } shuffleExcise(e) { if (this.isEmpty()) throw new RangeError("Ring buffer is empty."); const t = this.wrap(this.begin + e), n = this.get(t); return this.set(t, this.pop()), n } }
/**
* @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 rf extends nf { constructor() { super(rf.INITIAL_CAPACITY) } isFull() { return !1 } push(e) { super.isFull() && this.expand(), super.push(e) } unshift(e) { super.isFull() && this.expand(), super.unshift(e) } expand() { const e = 2 * this.capacity, t = new Array(e), n = this.length(); for (let e = 0; e < n; e++)t[e] = this.get(this.wrap(this.begin + e)); this.data = t, this.capacity = e, this.doubledCapacity = 2 * this.capacity, this.begin = 0, this.end = n } }
/**
* @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 af(e) { return new lf(e) } function of(e) { return new cf(e) } function sf(e, t) { return new wf(e, t) } rf.INITIAL_CAPACITY = 32; class uf { async toArray() { const e = []; let t = await this.next(); for (; !t.done;)e.push(t.value), t = await this.next(); return e } async toArrayForTest() { const e = this.prefetch(100), t = []; let n = await e.next(); for (; !n.done;)t.push(n.value), n = await e.next(); return t } async resolveFully() { let e = await this.next(); for (; !e.done;)e = await this.next() } async resolveWhile(e) { let t = await this.next(), n = e(t.value); for (; !t.done && n;)t = await this.next(), n = e(t.value) } handleErrors(e) { return new yf(this, e) } filter(e) { return new mf(this, e) } map(e) { return new gf(this, e) } mapAsync(e) { return new bf(this, e) } serialMapAsync(e) { return new bf(this, e).serial() } flatmap(e) { return new xf(this, e) } async forEachAsync(e) { return this.map(e).resolveFully() } async serialForEach(e) { return this.serialMapAsync(e).resolveWhile((e => !0 === e)) } rowMajorBatch(e, t = !0) { return new pf(this, e, t) } columnMajorBatch(e, t = !0, n = Zd) { return this.rowMajorBatch(e, t).map((e => Xd(e, n))) } concatenate(e, t) { return new wf(af([this, e]), t) } take(e) { return e < 0 || null == e ? this : new ff(this, e) } skip(e) { return e < 0 || null == e ? this : new df(this, e) } prefetch(e) { return new Sf(this, e) } shuffle(e, t) { return new _f(this, e, t) } serial() { return new hf(this) } } class lf extends uf { constructor(e) { super(), this.items = e, this.trav = 0 } summary() { return `Array of ${this.items.length} items` } async next() { if (this.trav >= this.items.length) return { value: null, done: !0 }; const e = this.items[this.trav]; return this.trav++, { value: ef(e), done: !1 } } } class cf extends uf { constructor(e) { super(), this.nextFn = e } summary() { return "Function call" } async next() { try { return this.nextFn() } catch (e) { throw e.message = `Error thrown while iterating through a dataset: ${e.message}`, e } } } class hf extends uf { constructor(e) { super(), this.upstream = e, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Serial` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { return this.upstream.next() } } class df extends uf { constructor(e, t) { super(), this.upstream = e, this.maxCount = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Skip` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; this.count++ < this.maxCount;) { const e = await this.upstream.next(); if (e.done) return e; P.dispose(e.value) } return this.upstream.next() } } class ff extends uf { constructor(e, t) { super(), this.upstream = e, this.maxCount = t, this.count = 0 } summary() { return `${this.upstream.summary()} -> Take` } async next() { return this.count++ >= this.maxCount ? { value: null, done: !0 } : this.upstream.next() } } class pf extends uf { constructor(e, t, n = !0) { super(), this.upstream = e, this.batchSize = t, this.enableSmallLastBatch = n, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> RowMajorBatch` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { const e = []; for (; e.length < this.batchSize;) { const t = await this.upstream.next(); if (t.done) return this.enableSmallLastBatch && e.length > 0 ? { value: e, done: !1 } : { value: null, done: !0 }; e.push(t.value) } return { value: e, done: !1 } } } class mf extends uf { constructor(e, t) { super(), this.upstream = e, this.predicate = t, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> Filter` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; ;) { const e = await this.upstream.next(); if (e.done || this.predicate(e.value)) return e; P.dispose(e.value) } } } class gf extends uf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> Map` } async next() { const e = await this.upstream.next(); if (e.done) return { value: null, done: !0 }; const t = P.tensor_util.getTensorsInContainer(e.value), n = this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return { value: n, done: !1 } } } class yf extends uf { constructor(e, t) { super(), this.upstream = e, this.handler = t, this.count = 0, this.lastRead = Promise.resolve({ value: null, done: !1 }) } summary() { return `${this.upstream.summary()} -> handleErrors` } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; ;)try { return await this.upstream.next() } catch (e) { if (!this.handler(e)) return { value: null, done: !0 } } } } class bf extends uf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> AsyncMap` } async next() { const e = await this.upstream.next(); if (e.done) return { value: null, done: !0 }; const t = P.tensor_util.getTensorsInContainer(e.value), n = await this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return { value: n, done: !1 } } } class vf extends uf { constructor() { super(), this.outputQueue = new rf, this.lastRead = Promise.resolve({ value: null, done: !1 }) } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } async serialNext() { for (; 0 === this.outputQueue.length();)if (!await this.pump()) return { value: null, done: !0 }; return { value: this.outputQueue.shift(), done: !1 } } } class xf extends vf { constructor(e, t) { super(), this.upstream = e, this.transform = t } summary() { return `${this.upstream.summary()} -> Flatmap` } async pump() { const e = await this.upstream.next(); if (e.done) return !1; const t = P.tensor_util.getTensorsInContainer(e.value), n = this.transform(e.value), r = P.tensor_util.getTensorsInContainer(n); this.outputQueue.pushAll(n); for (const e of t) P.tensor_util.isTensorInList(e, r) || e.dispose(); return !0 } } class wf extends uf { constructor(e, t) { super(), this.baseErrorHandler = t, this.lastRead = null, this.iterator = null, this.moreIterators = e } summary() { return "TODO: fill in upstream of chained summaries -> Chained" } async next() { return this.lastRead = this.readFromChain(this.lastRead), this.lastRead } async readFromChain(e) { if (await e, null == this.iterator) { const e = await this.moreIterators.next(); if (e.done) return { value: null, done: !0 }; this.iterator = e.value, null != this.baseErrorHandler && (this.iterator = this.iterator.handleErrors(this.baseErrorHandler)) } const t = await this.iterator.next(); return t.done ? (this.iterator = null, this.readFromChain(e)) : t } } (Hd = Gd || (Gd = {}))[Hd.FAIL = 0] = "FAIL", Hd[Hd.SHORTEST = 1] = "SHORTEST", Hd[Hd.LONGEST = 2] = "LONGEST"; class kf extends uf { constructor(e, t = Gd.FAIL) { super(), this.iterators = e, this.mismatchMode = t, this.count = 0, this.currentPromise = null } summary() { return "{TODO: fill in upstream of zip summaries} -> Zip" } async nextState(e) { await e; let t = 0, n = 0; const r = await Jd(this.iterators, (function (e) { if (e instanceof uf) { return { value: e.next().then((e => (t++, e.done && n++, e.value))), recurse: !1 } } return { value: null, recurse: !0 } })); if (t === n) return { value: null, done: !0 }; if (n > 0) switch (this.mismatchMode) { case Gd.FAIL: throw new Error(`Zipped streams should have the same length. Mismatched at element ${this.count}.`); case Gd.SHORTEST: return { value: null, done: !0 }; case Gd.LONGEST: }return this.count++, { value: r, done: !1 } } async next() { return this.currentPromise = this.nextState(this.currentPromise), this.currentPromise } } class Sf extends uf { constructor(e, t) { super(), this.upstream = e, this.bufferSize = t, this.buffer = new nf(t) } summary() { return `${this.upstream.summary()} -> Prefetch` } refill() { for (; !this.buffer.isFull();) { const e = this.upstream.next(); this.buffer.push(e) } } next() { return this.refill(), this.buffer.shift() } } class _f extends Sf { constructor(e, t, n) { super(e, t), this.upstream = e, this.windowSize = t, this.upstreamExhausted = !1, this.random = qd.alea(n || P.util.now().toString()), this.lastRead = Promise.resolve({ value: null, done: !1 }) } async next() { return this.lastRead = this.lastRead.then((() => this.serialNext())), this.lastRead } randomInt(e) { return Math.floor(this.random() * e) } chooseIndex() { return this.randomInt(this.buffer.length()) } async serialNext() { for (this.upstreamExhausted || this.refill(); !this.buffer.isEmpty();) { const e = this.chooseIndex(), t = await this.buffer.shuffleExcise(e); if (!t.done) return this.refill(), t; this.upstreamExhausted = !0 } return { value: null, done: !0 } } }
/**
* @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 Cf { constructor() { this.size = null } batch(e, t = !0) { const n = this; let r; return P.util.assert(e > 0, (() => `batchSize needs to be positive, but it is\n ${e}`)), r = this.size === 1 / 0 || null == this.size ? this.size : t ? Math.ceil(this.size / e) : Math.floor(this.size / e), Af((async () => (await n.iterator()).columnMajorBatch(e, t, Nf)), r) } concatenate(e) { const t = this; let n; return n = this.size === 1 / 0 || e.size === 1 / 0 ? 1 / 0 : null != this.size && null != e.size ? this.size + e.size : null, Af((async () => (await t.iterator()).concatenate(await e.iterator())), n) } filter(e) { const t = this; let n; return n = this.size === 1 / 0 ? 1 / 0 : null, Af((async () => (await t.iterator()).filter((t => P.tidy((() => e(t)))))), n) } async forEachAsync(e) { return (await this.iterator()).forEachAsync(e) } map(e) { const t = this; return Af((async () => (await t.iterator()).map((t => P.tidy((() => e(t)))))), this.size) } mapAsync(e) { const t = this; return Af((async () => (await t.iterator()).mapAsync(e)), this.size) } prefetch(e) { if (null == e) throw new RangeError("`Dataset.prefetch()` requires bufferSize to be specified."); const t = this; return Af((async () => (await t.iterator()).prefetch(e)), this.size) } repeat(e) { const t = this; let n; return n = null != this.size && e > 0 ? this.size * e : 0 === e ? 0 : null != this.size && (void 0 === e || e < 0) ? 1 / 0 : null, Af((async () => sf(of((async () => ({ value: await t.iterator(), done: !1 }))).take(e))), n) } skip(e) { const t = this; let n; return n = null != this.size && e >= 0 && this.size >= e ? this.size - e : null != this.size && (this.size < e || void 0 === e || e < 0) ? 0 : null, Af((async () => (await t.iterator()).skip(e)), n) } shuffle(e, t, n = !0) { if (null == e || e < 0) throw null == this.size ? new RangeError("`Dataset.shuffle()` requires bufferSize to be specified.") : new RangeError(`\`Dataset.shuffle()\` requires bufferSize to be specified. If your data fits in main memory (for regular JS objects), and/or GPU memory (for \`tf.Tensor\`s), consider setting bufferSize to the dataset size (${this.size} elements)`); const r = this, i = qd.alea(t || P.util.now().toString()); return Af((async () => { let t = i.int32(); return n && (t += i.int32()), (await r.iterator()).shuffle(e, t.toString()) }), this.size) } take(e) { const t = this; let n; return n = null != this.size && this.size > e ? e : null != this.size && this.size <= e ? this.size : null, Af((async () => (await t.iterator()).take(e)), n) } async toArray() { if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array."); return (await this.iterator()).toArray() } async toArrayForTest() { if (this.size === 1 / 0) throw new Error("Can not convert infinite data stream to array."); return (await this.iterator()).toArrayForTest() } } function Af(e, t = null) { return new class extends Cf { constructor() { super(...arguments), this.size = t } async iterator() { return e() } } } function Tf(e) { return Af((async () => af(e)), e.length) } function Ef(e) { if (!Qd(e)) throw new Error("The argument to zip() must be an object or array."); let t; if (Array.isArray(e)) for (let n = 0; n < e.length; n++)t = null == t ? e[n].size : Math.min(t, e[n].size); else if (e instanceof Object) for (const n in e) t = null == t ? e[n].size : Math.min(t, e[n].size); return Af((async () => function (e, t = Gd.FAIL) { return new kf(e, t) }(await Jd(e, (e => { if (e instanceof Cf) return { value: e.iterator(), recurse: !1 }; if (Qd(e)) return { value: null, recurse: !0 }; throw new Error("Leaves of the structure passed to zip() must be Datasets, not primitives.") })), Gd.SHORTEST)), t) } function Nf(e) { if (null === e) return null; const t = e[0]; if (null == (n = t) || null === (r = n) || "object" != typeof r && "function" != typeof r || Array.isArray(n) || "object" == typeof n && n instanceof P.Tensor || P.util.isTypedArray(n)) { return { value: function (e) { if (0 === e.length) throw new Error("Can't make a batch of zero elements."); return e[0] instanceof P.Tensor ? P.stack(e) : P.tensor(e) }(e), recurse: !1 } } var n, r; return { value: null, recurse: !0 } } Cf.MAX_BUFFER_SIZE = 1e4;
/**
* @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 If extends Cf { constructor(e) { super(), this.input = e } async iterator() { return (await this.input.iterator()).decodeUTF8().split("\n").map((e => (e.endsWith("\r") && (e = e.slice(0, -1)), e))) } }
/**
* @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 Mf = '"', Ff = Symbol("out"), Df = Symbol("field"), $f = Symbol("quote"), Rf = Symbol("quoteafterquote"), Of = Symbol("quoteinquote"); class zf extends Cf { async columnNames() { return this.columnNamesValidated || await this.setColumnNames(), this.configuredColumnsOnly ? Object.keys(this.columnConfigs) : this.fullColumnNames } async setColumnNames() { const e = await this.maybeReadHeaderLine(); if (!this.fullColumnNames && !e) throw new Error("Column names must be provided if there is no header line."); this.fullColumnNames && e && P.util.assert(e.length === this.fullColumnNames.length, (() => "The length of provided columnNames (" + this.fullColumnNames.length.toString() + ") does not match the length of the header line read from file (" + e.length.toString() + ").")), this.fullColumnNames || (this.fullColumnNames = e); const t = this.fullColumnNames.reduce(((e, t) => (e[t] = e[t] + 1 || 1, e)), {}), n = Object.keys(t).filter((e => t[e] > 1)); if (P.util.assert(0 === n.length, (() => "Duplicate column names found: " + n.toString())), this.columnConfigs) for (const e of Object.keys(this.columnConfigs)) { if (-1 === this.fullColumnNames.indexOf(e)) throw new Error('The key "' + e + '" provided in columnConfigs does not match any of the column names (' + this.fullColumnNames.toString() + ").") } this.columnNamesValidated = !0 } async maybeReadHeaderLine() { if (this.hasHeader) { const e = await this.base.iterator(), t = await e.next(); if (t.done) throw new Error("No data was found for CSV parsing."); const n = t.value; return this.parseRow(n, !1) } return null } constructor(e, t) { super(), this.input = e, this.hasHeader = !0, this.fullColumnNames = null, this.columnNamesValidated = !1, this.columnConfigs = null, this.configuredColumnsOnly = !1, this.delimiter = ",", this.delimWhitespace = !1, this.base = new If(e), t || (t = {}), this.hasHeader = !1 !== t.hasHeader, this.fullColumnNames = t.columnNames, this.columnConfigs = t.columnConfigs, this.configuredColumnsOnly = t.configuredColumnsOnly, t.delimWhitespace ? (P.util.assert(null == t.delimiter, (() => "Delimiter should not be provided when delimWhitespace is true.")), this.delimWhitespace = !0, this.delimiter = " ") : this.delimiter = t.delimiter ? t.delimiter : "," } async iterator() { this.columnNamesValidated || await this.setColumnNames(); let e = await this.base.iterator(); return this.hasHeader && (e = e.skip(1)), e.map((e => this.makeDataElement(e))) } makeDataElement(e) { const t = this.parseRow(e), n = {}, r = {}; for (let i = 0; i < this.fullColumnNames.length; i++) { const a = this.fullColumnNames[i], o = this.columnConfigs ? this.columnConfigs[a] : null; if (!this.configuredColumnsOnly || o) { const s = t[i]; let u = null; if ("" === s) if (o && void 0 !== o.default) u = o.default; else { if (o && (o.required || o.isLabel)) throw new Error(`Required column ${a} is empty in this line: ${e}`); u = void 0 } else { const e = Number(s); if (isNaN(e)) u = o && "bool" === o.dtype ? this.getBoolean(s) : s; else if (o && o.dtype) switch (o.dtype) { case "float32": default: u = e; break; case "int32": u = Math.floor(e); break; case "bool": u = this.getBoolean(s) } else u = e } o && o.isLabel ? r[a] = u : n[a] = u } } return 0 === Object.keys(r).length ? n : { xs: n, ys: r } } getBoolean(e) { return "1" === e || "true" === e.toLowerCase() ? 1 : 0 } parseRow(e, t = !0) { const n = []; let r = 0; const i = e.length; let a = Ff; for (let t = 0; t < i; t++)switch (a) { case Ff: switch (e.charAt(t)) { case Mf: r = t + 1, a = $f; break; case this.delimiter: if (r = t + 1, " " === this.delimiter && this.delimWhitespace) break; n.push(""), a = Ff; break; default: a = Df, r = t }break; case Df: if (e.charAt(t) === this.delimiter) n.push(e.substring(r, t)), a = Ff, r = t + 1; break; case $f: if (e.charAt(t) === Mf) a = Rf; break; case Rf: switch (e.charAt(t)) { case this.delimiter: n.push(e.substring(r, t - 1)), a = Ff, r = t + 1; break; case Mf: a = $f; break; default: a = Of }break; case Of: if (e.charAt(t) === Mf) a = $f }if (a === Rf ? n.push(e.substring(r, i - 1)) : n.push(e.substring(r)), t && n.length !== this.fullColumnNames.length) throw new Error(`Invalid row in csv file. Should have ${this.fullColumnNames.length} elements in a row, but got ${n}`); return 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.
*
* =============================================================================
*/
class Pf extends uf { constructor(e) { super(), this.microphoneConfig = e, this.isClosed = !1, this.fftSize = e.fftSize || 1024; const t = Math.log2(this.fftSize); if (this.fftSize < 0 || t < 4 || t > 14 || !Number.isInteger(t)) throw new Error(`Invalid fftSize: it must be a power of 2 between 2 to 4 and 2 to 14, but got ${this.fftSize}`); if (this.numFrames = e.numFramesPerSpectrogram || 43, this.sampleRateHz = e.sampleRateHz, this.columnTruncateLength = e.columnTruncateLength || this.fftSize, this.audioTrackConstraints = e.audioTrackConstraints, this.smoothingTimeConstant = e.smoothingTimeConstant || 0, this.includeSpectrogram = !1 !== e.includeSpectrogram, this.includeWaveform = !0 === e.includeWaveform, !this.includeSpectrogram && !this.includeWaveform) throw new Error("Both includeSpectrogram and includeWaveform are false. At least one type of data should be returned.") } summary() { return "microphone" } static async create(e = {}) { if (!(0, P.env)().get("IS_BROWSER")) throw new Error("microphone API is only supported in browser environment."); const t = new Pf(e); return await t.start(), t } async start() { try { this.stream = await navigator.mediaDevices.getUserMedia({ audio: null == this.audioTrackConstraints || this.audioTrackConstraints, video: !1 }) } catch (e) { throw new Error(`Error thrown while initializing video stream: ${e.message}`) } if (!this.stream) throw new Error("Could not obtain audio from microphone."); const e = window.AudioContext || window.webkitAudioContext; if (this.audioContext = new e, this.sampleRateHz) { if (this.audioContext.sampleRate !== this.sampleRateHz) throw new Error(`Mismatch in sampling rate: Expected: ${this.sampleRateHz}; Actual: ${this.audioContext.sampleRate}`) } else this.sampleRateHz = this.audioContext.sampleRate; const t = this.audioContext.createMediaStreamSource(this.stream); this.analyser = this.audioContext.createAnalyser(), this.analyser.fftSize = 2 * this.fftSize, this.analyser.smoothingTimeConstant = this.smoothingTimeConstant, t.connect(this.analyser), this.freqData = new Float32Array(this.fftSize), this.timeData = new Float32Array(this.fftSize) } async next() { if (this.isClosed) return { value: null, done: !0 }; let e, t; const n = await this.getAudioData(); if (this.includeSpectrogram) { const t = this.flattenQueue(n.freqDataQueue); e = this.getTensorFromAudioDataArray(t, [this.numFrames, this.columnTruncateLength, 1]) } if (this.includeWaveform) { const e = this.flattenQueue(n.timeDataQueue); t = this.getTensorFromAudioDataArray(e, [this.numFrames * this.fftSize, 1]) } return { value: { spectrogram: e, waveform: t }, done: !1 } } async capture() { return (await this.next()).value } async getAudioData() { const e = [], t = []; let n = 0; return new Promise((r => { const i = setInterval((() => { this.includeSpectrogram && (this.analyser.getFloatFrequencyData(this.freqData), this.freqData[0] === -1 / 0 && r({ freqDataQueue: e, timeDataQueue: t }), e.push(this.freqData.slice(0, this.columnTruncateLength))), this.includeWaveform && (this.analyser.getFloatTimeDomainData(this.timeData), t.push(this.timeData.slice())), ++n === this.numFrames && (clearInterval(i), r({ freqDataQueue: e, timeDataQueue: t })) }), this.fftSize / this.sampleRateHz * 1e3) })) } stop() { this.isClosed || (this.isClosed = !0, this.analyser.disconnect(), this.audioContext.close(), null != this.stream && this.stream.getTracks().length > 0 && this.stream.getTracks()[0].stop()) } toArray() { throw new Error("Can not convert infinite audio stream to array.") } getSampleRate() { return this.sampleRateHz } flattenQueue(e) { const t = e[0].length, n = new Float32Array(e.length * t); return e.forEach(((e, r) => n.set(e, r * t))), n } getTensorFromAudioDataArray(e, t) { const n = new Float32Array(P.util.sizeFromShape(t)); return n.set(e, n.length - e.length), (0, P.tensor)(n, 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.
*
* =============================================================================
*/
class Bf extends uf { constructor(e, t) { if (super(), this.webcamVideoElement = e, this.webcamConfig = t, this.isClosed = !0, this.resize = !1, this.needToResize()) if (this.resize = !0, this.cropSize = [this.webcamConfig.resizeHeight, this.webcamConfig.resizeWidth], this.cropBoxInd = (0, P.tensor1d)([0], "int32"), this.webcamConfig.centerCrop) { const e = 1 * this.webcamConfig.resizeWidth / this.webcamVideoElement.width, t = 1 * this.webcamConfig.resizeHeight / this.webcamVideoElement.height, n = (1 - e) / 2, r = (1 - t) / 2, i = n + e, a = t + r; this.cropBox = (0, P.tensor2d)([r, n, a, i], [1, 4]) } else this.cropBox = (0, P.tensor2d)([0, 0, 1, 1], [1, 4]) } summary() { return "webcam" } static async create(e, t = {}) { if (!(0, P.env)().get("IS_BROWSER")) throw new Error("tf.data.webcam is only supported in browser environment."); if (!e) { if (e = document.createElement("video"), !t.resizeWidth || !t.resizeHeight) throw new Error("Please provide webcam video element, or resizeWidth and resizeHeight to create a hidden video element."); e.width = t.resizeWidth, e.height = t.resizeHeight } const n = new Bf(e, t); return await n.start(), n } async start() { this.webcamConfig.facingMode && P.util.assert("user" === this.webcamConfig.facingMode || "environment" === this.webcamConfig.facingMode, (() => `Invalid webcam facing mode: ${this.webcamConfig.facingMode}. Please provide 'user' or 'environment'`)); try { this.stream = await navigator.mediaDevices.getUserMedia({ video: { deviceId: this.webcamConfig.deviceId, facingMode: this.webcamConfig.facingMode ? this.webcamConfig.facingMode : "user", width: this.webcamVideoElement.width, height: this.webcamVideoElement.height } }) } catch (e) { throw e.message = `Error thrown while initializing video stream: ${e.message}`, e } if (!this.stream) throw new Error("Could not obtain video from webcam."); try { this.webcamVideoElement.srcObject = this.stream } catch (e) { console.log(e), this.webcamVideoElement.src = window.URL.createObjectURL(this.stream) } return this.webcamVideoElement.play(), this.isClosed = !1, new Promise((e => { this.webcamVideoElement.onloadedmetadata = () => { e() } })) } async next() { if (this.isClosed) return { value: null, done: !0 }; let e; try { e = P.browser.fromPixels(this.webcamVideoElement) } catch (e) { throw new Error(`Error thrown converting video to pixels: ${JSON.stringify(e)}`) } if (!this.resize) return { value: e, done: !1 }; try { return { value: this.cropAndResizeFrame(e), done: !1 } } catch (e) { throw new Error(`Error thrown cropping the video: ${e.message}`) } finally { e.dispose() } } needToResize() { return !(!this.webcamConfig.resizeWidth || !this.webcamConfig.resizeHeight || this.webcamVideoElement.width === this.webcamConfig.resizeWidth && this.webcamVideoElement.height === this.webcamConfig.resizeHeight) } cropAndResizeFrame(e) { return (0, P.tidy)((() => { const t = (0, P.expandDims)((0, P.cast)(e, "float32"), 0); let n; n = P.image.cropAndResize(t, this.cropBox, this.cropBoxInd, this.cropSize, "bilinear"); const r = n.shape; return (0, P.reshape)(n, r.slice(1)) })) } async capture() { return (await this.next()).value } stop() { this.stream.getTracks().forEach((e => e.stop())); try { this.webcamVideoElement.srcObject = null } catch (e) { console.log(e), this.webcamVideoElement.src = null } this.isClosed = !0 } toArray() { throw new Error("Can not convert infinite video stream to array.") } }
/**
* @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 Lf { }
/**
* @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 jf extends uf { split(e) { return new Uf(this, e) } } class Uf extends jf { constructor(e, t) { super(), this.upstream = e, this.impl = new Wf(e, t) } summary() { return this.impl.summary() } async next() { return this.impl.next() } } class Wf extends vf { constructor(e, t) { super(), this.upstream = e, this.separator = t, this.carryover = "" } summary() { return `${this.upstream.summary()} -> Split('${this.separator}')` } async pump() { const e = await this.upstream.next(); if (e.done) return "" !== this.carryover && (this.outputQueue.push(this.carryover), this.carryover = "", !0); const t = e.value.split(this.separator); t[0] = this.carryover + t[0]; for (const e of t.slice(0, -1)) this.outputQueue.push(e); return this.carryover = t[t.length - 1], !0 } }
/**
* @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 Vf extends uf { decodeUTF8() { return new Gf(this) } } class Gf extends jf { constructor(e) { super(), this.upstream = e, this.impl = new Hf(e) } summary() { return this.impl.summary() } async next() { return this.impl.next() } } class Hf extends vf { constructor(e) { if (super(), this.upstream = e, (0, P.env)().get("IS_BROWSER")) this.decoder = new TextDecoder("utf-8"); else { const { StringDecoder: e } = n(4530); this.decoder = new e("utf8") } } summary() { return `${this.upstream.summary()} -> Utf8` } async pump() { const e = await this.upstream.next(); let t, n; return !e.done && (t = e.value, n = (0, P.env)().get("IS_BROWSER") ? this.decoder.decode(t, { stream: !0 }) : this.decoder.write(Buffer.from(t.buffer)), this.outputQueue.push(n), !0) } }
/**
* @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 qf extends Vf { constructor(e, t = {}) { super(), this.file = e, this.options = t, P.util.assert(e instanceof Uint8Array || !!(0, P.env)().get("IS_BROWSER") && (e instanceof File || e instanceof Blob), (() => "FileChunkIterator only supports File, Blob and Uint8Array right now.")), this.offset = t.offset || 0, this.chunkSize = t.chunkSize || 1048576 } summary() { return `FileChunks ${this.file}` } async next() { if (this.offset >= (this.file instanceof Uint8Array ? this.file.byteLength : this.file.size)) return { value: null, done: !0 }; const e = new Promise(((e, t) => { const n = this.offset + this.chunkSize; if (this.file instanceof Uint8Array) e(new Uint8Array(this.file.slice(this.offset, n))); else { const r = new FileReader; r.onload = n => { let i = r.result; if (i instanceof ArrayBuffer && (i = new Uint8Array(i)), !(i instanceof Uint8Array)) return t(new TypeError("FileReader returned unknown type.")); e(i) }, r.onabort = e => t(new Error("Aborted")), r.onerror = e => t(new Error(e.type)); const i = this.file.slice(this.offset, n); r.readAsArrayBuffer(i) } this.offset = n })); return { value: await e, done: !1 } } } const Yf = e => ({ method: e.method, headers: e.headers, body: e.body, mode: e.mode, credentials: e.credentials, cache: e.cache, redirect: e.redirect, referrer: e.referrer, integrity: e.integrity });
/**
* @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 Xf(e) { return "string" == typeof e && "file://" === e.slice(0, 7) }
/**
* @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 Kf extends Lf { constructor(e, t = {}) { super(), this.input = e, this.options = t } async iterator() { if (Xf(this.input) && (0, P.env)().get("IS_NODE")) { const e = n(8108); this.input = e.readFileSync(this.input.slice(7)) } return new qf(this.input, this.options) } }
/**
* @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 Zf extends Lf {
constructor(e, t = {}) { super(), this.url = e, this.fileOptions = t } async iterator() {
return Xf(this.url) ? new Kf(this.url, this.fileOptions).iterator() :
/**
* @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.
*
* =============================================================================
*/
async function (e, t = {}, n) { let r, i; "string" == typeof e ? r = e : (r = e.url, i = Yf(e)); const a = await (n || P.util.fetch)(r, i); if (a.ok) { const e = new Uint8Array(await a.arrayBuffer()); return new qf(e, t) } throw new Error(a.statusText) }(this.url, this.fileOptions)
}
}
/**
* @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 Jf(e, t = {}) { return new zf(new Zf(e), t) } function Qf(e) { const t = of(e); return Af((async () => t)) } function ep(e) { return Af((async () => { const t = await e(); return of((() => t.next())) })) } async function tp(e, t) { return Bf.create(e, t) } async function np(e) { return Pf.create(e) }
/** @license See the LICENSE file. */
const rp = "4.22.0";
/**
* @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 ip(e, t) { Array.isArray(e) || (e = [e]), e.forEach((e => { null != e && P.util.assert("complex64" !== e.dtype, (() => `${t} does not support complex64 tensors in the CPU backend.`)) })) }
/**
* @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 ap = P.kernel_impls.whereImpl; class op extends P.KernelBackend { nextDataId() { return op.nextDataId++ } constructor() { super(), this.blockSize = 48, this.firstUse = !0, this.data = new P.DataStorage(this, (0, P.engine)()) } write(e, t, n) { this.firstUse && (this.firstUse = !1, (0, P.env)().get("IS_NODE") && P.backend_util.warn("\n============================\nHi, looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, visit https://github.com/tensorflow/tfjs-node for more details. \n============================")); const r = { id: this.nextDataId() }; return this.data.set(r, { values: e, dtype: n, refCount: 1 }), r } makeTensorInfo(e, t, n) { let r; if ("string" === t && null != n && n.length > 0 && P.util.isString(n[0])) { const i = n.map((e => P.util.encodeString(e))); r = this.write(i, e, t) } else r = this.write(n, e, t); return { dataId: r, shape: e, dtype: t } } refCount(e) { if (this.data.has(e)) { return this.data.get(e).refCount } return 0 } incRef(e) { this.data.get(e).refCount++ } decRef(e) { if (this.data.has(e)) { this.data.get(e).refCount-- } } move(e, t, n, r, i) { this.data.set(e, { values: t, dtype: r, refCount: i }) } numDataIds() { return this.data.numDataIds() } async read(e) { return this.readSync(e) } readSync(e) { const { dtype: t, complexTensorInfos: n } = this.data.get(e); if ("complex64" === t) { const e = this.readSync(n.real.dataId), t = this.readSync(n.imag.dataId); return P.backend_util.mergeRealAndImagArrays(e, t) } return P.util.convertBackendValuesAndArrayBuffer(this.data.get(e).values, t) } bufferSync(e) { const t = this.readSync(e.dataId); if ("string" === e.dtype) try { const n = t.map((e => P.util.decodeString(e))); return (0, P.buffer)(e.shape, e.dtype, n) } catch (e) { throw new Error("Failed to decode encoded string bytes into utf-8") } return (0, P.buffer)(e.shape, e.dtype, t) } makeOutput(e, t, n) { return (0, P.engine)().makeTensorFromTensorInfo(this.makeTensorInfo(t, n, e), this) } disposeData(e, t = !1) { if (this.data.has(e)) { if (this.data.get(e).refCount--, !t && this.data.get(e).refCount > 0) return !1; const { complexTensorInfos: n } = this.data.get(e); null != n && (this.disposeData(n.real.dataId, !0), this.disposeData(n.imag.dataId, !0)), this.data.delete(e) } return !0 } disposeIntermediateTensorInfo(e) { this.disposeData(e.dataId) } async time(e) { const t = P.util.now(); e(); return { kernelMs: P.util.now() - t } } memory() { return { unreliable: !0, reasons: ["The reported memory is an upper bound. Due to automatic garbage collection, the true allocated memory may be less."] } } where(e) { ip([e], "where"); const t = this.readSync(e.dataId); return ap(e.shape, t) } dispose() { } floatPrecision() { return 32 } epsilon() { return super.epsilon() } }
/**
* @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 sp(e) { const t = new Float32Array(e.length); for (let n = 0; n < e.length; ++n)t[n] = Math.abs(e[n]); return t } op.nextDataId = 0; const up = { kernelName: P.Abs, backendName: "cpu", kernelFunc: e => { const { x: t } = e.inputs, n = e.backend; ip(t, "abs"); let r = new Float32Array(P.util.sizeFromShape(t.shape)); return r = sp(n.data.get(t.dataId).values), n.makeOutput(r, t.shape, t.dtype) } };
/**
* @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 lp(e) { return (t, n, r, i, a) => { const o = P.backend_util.assertAndGetBroadcastShape(t, n), s = o.length, u = P.util.computeStrides(o), l = P.util.sizeFromShape(o), c = P.util.getTypedArrayFromDType(a, l), h = t.length, d = n.length, f = P.util.computeStrides(t), p = P.util.computeStrides(n), m = P.backend_util.getBroadcastDims(t, o), g = P.backend_util.getBroadcastDims(n, o); if (m.length + g.length === 0) for (let t = 0; t < c.length; ++t)c[t] = e(r[t % r.length], i[t % i.length]); else for (let t = 0; t < c.length; ++t) { const n = P.util.indexToLoc(t, s, u), a = n.slice(-h); m.forEach((e => a[e] = 0)); const o = P.util.locToIndex(a, h, f), l = n.slice(-d); g.forEach((e => l[e] = 0)); const y = P.util.locToIndex(l, d, p); c[t] = e(r[o], i[y]) } return [c, o] } }
/**
* @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 cp(e) { const { inputs: t, backend: n } = e, { real: r, imag: i } = t, a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, s = n.makeTensorInfo(r.shape, "complex64"); return n.data.get(s.dataId).complexTensorInfos = { real: n.makeTensorInfo(r.shape, "float32", a), imag: n.makeTensorInfo(i.shape, "float32", o) }, s } const hp = { kernelName: P.Complex, backendName: "cpu", kernelFunc: cp };
/**
* @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 dp(e, t, n = "float32") { if ("complex64" === n) { return cp({ inputs: { real: dp(e, t, "float32"), imag: dp(e, t, "float32") }, backend: e }) } const r = P.util.makeZerosTypedArray(P.util.sizeFromShape(t), n); return e.makeTensorInfo(t, n, r) }
/**
* @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 fp(e) { const { inputs: t, backend: n } = e, { x: r } = t; return n.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype } } const pp = { kernelName: P.Identity, backendName: "cpu", kernelFunc: fp };
/**
* @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 mp(e) { const { inputs: t, backend: n } = e, { input: r } = t, i = n.data.get(r.dataId).complexTensorInfos.real, a = n.data.get(i.dataId).values; return n.makeTensorInfo(i.shape, i.dtype, a) } const gp = { kernelName: P.Real, backendName: "cpu", kernelFunc: mp };
/**
* @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 yp(e, t, n, r) { if ("int32" === r) { return [t, "int32", Int32Array.from(e)] } if ("bool" === r) { const r = P.util.toTypedArray([0], n), [i, a] = lp(((e, t) => e !== t ? 1 : 0))(t, [], e, r, "bool"); return [a, "bool", i] } throw new Error(`Error in Cast: failed to cast ${n} to ${r}`) } function bp(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dtype: a } = r; if ("complex64" === a) { if ("complex64" === i.dtype) return fp({ inputs: { x: i }, backend: n }); const e = dp(n, i.shape, i.dtype), t = bp({ inputs: { x: i }, backend: n, attrs: { dtype: "float32" } }), r = cp({ inputs: { real: t, imag: e }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), r } if ("complex64" === i.dtype) { const e = mp({ inputs: { input: i }, backend: n }), t = bp({ inputs: { x: e }, backend: n, attrs: { dtype: a } }); return n.disposeIntermediateTensorInfo(e), t } if (!P.util.hasEncodingLoss(i.dtype, a)) { const e = fp({ inputs: { x: i }, backend: n }); return { dataId: e.dataId, shape: e.shape, dtype: a } } const o = n.data.get(i.dataId).values, [s, u, l] = yp(o, i.shape, i.dtype, a); return n.makeTensorInfo(s, u, l) } const vp = { kernelName: P.Cast, backendName: "cpu", kernelFunc: bp };
/**
* @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 xp(e, t, n, r) { return null == n ? ({ inputs: n, backend: i }) => { const { a, b: o } = n, s = i; ip([a, o], e); const u = s.data.get(a.dataId).values, l = s.data.get(o.dataId).values, c = "string" === a.dtype ? P.backend_util.fromUint8ToStringArray(u) : u, h = "string" === a.dtype ? P.backend_util.fromUint8ToStringArray(l) : l, d = r || a.dtype, [f, p] = t(a.shape, o.shape, c, h, d); return s.makeTensorInfo(p, d, f) } : ({ inputs: e, backend: i }) => { const { a, b: o } = e, s = i; if ("complex64" === a.dtype || "complex64" === o.dtype) { const e = bp({ inputs: { x: a }, backend: s, attrs: { dtype: "complex64" } }), t = s.data.get(e.dataId), r = t.complexTensorInfos.real, i = t.complexTensorInfos.imag, u = s.data.get(r.dataId).values, l = s.data.get(i.dataId).values, c = bp({ inputs: { x: o }, backend: s, attrs: { dtype: "complex64" } }), h = s.data.get(c.dataId), d = h.complexTensorInfos.real, f = h.complexTensorInfos.imag, p = s.data.get(d.dataId).values, m = s.data.get(f.dataId).values, [g, y, b] = n(a.shape, o.shape, u, l, p, m), v = s.makeTensorInfo(b, "float32", g), x = s.makeTensorInfo(b, "float32", y), w = cp({ inputs: { real: v, imag: x }, backend: s }); return s.disposeIntermediateTensorInfo(e), s.disposeIntermediateTensorInfo(c), s.disposeIntermediateTensorInfo(v), s.disposeIntermediateTensorInfo(x), w } { const e = s.data.get(a.dataId).values, n = s.data.get(o.dataId).values, i = r || a.dtype, [u, l] = t(a.shape, o.shape, e, n, i); return s.makeTensorInfo(l, i, u) } } } function wp(e) { return (t, n, r, i, a, o) => { const s = P.backend_util.assertAndGetBroadcastShape(t, n), u = P.util.sizeFromShape(s), l = s.length, c = P.util.computeStrides(s), h = P.util.getTypedArrayFromDType("float32", u), d = P.util.getTypedArrayFromDType("float32", u), f = P.backend_util.getBroadcastDims(t, s), p = P.backend_util.getBroadcastDims(n, s), m = P.backend_util.mergeRealAndImagArrays(r, i), g = P.backend_util.mergeRealAndImagArrays(a, o), y = t.length, b = P.util.computeStrides(t), v = n.length, x = P.util.computeStrides(n); if (f.length + p.length === 0) for (let t = 0; t < h.length; t++) { const n = t % m.length, r = t % g.length, i = e(m[2 * n], m[2 * n + 1], g[2 * r], g[2 * r + 1]); h[t] = i.real, d[t] = i.imag } else for (let t = 0; t < h.length; t++) { const n = P.util.indexToLoc(t, l, c), r = n.slice(-y); f.forEach((e => r[e] = 0)); const i = P.util.locToIndex(r, y, b), a = n.slice(-v); p.forEach((e => a[e] = 0)); const o = P.util.locToIndex(a, v, x), s = e(m[2 * i], m[2 * i + 1], g[2 * o], g[2 * o + 1]); h[t] = s.real, d[t] = s.imag } return [h, d, s] } }
/**
* @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.
* =============================================================================
*/
const kp = lp(((e, t) => e + t)), Sp = wp(((e, t, n, r) => ({ real: e + n, imag: t + r }))), _p = xp(P.Add, kp, Sp), Cp = { kernelName: P.Add, backendName: "cpu", kernelFunc: _p };
/**
* @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 Ap(e, t, n, r, i) { const a = P.util.sizeFromShape(r), o = P.util.makeZerosTypedArray(i, n); for (let n = 0; n < e.length; n++) { const r = e[n]; if (r < 0) throw new Error("Input x must be non-negative!"); r >= i || (o[r] += a > 0 ? t[n] : 1) } return o } function Tp(e, t, n, r = !1) { const i = e.shape[0], a = e.shape[1], o = (0, P.buffer)([i, n], t.dtype); for (let s = 0; s < i; s++)for (let i = 0; i < a; i++) { const a = e.get(s, i); if (a < 0) throw new Error("Input x must be non-negative!"); a >= n || (r ? o.set(1, s, a) : t.size > 0 ? o.set(o.get(s, a) + t.get(s, i), s, a) : o.set(o.get(s, a) + 1, s, a)) } return o }
/**
* @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 Ep = lp(((e, t) => e & t)), Np = xp(P.BitwiseAnd, Ep), Ip = { kernelName: P.BitwiseAnd, backendName: "cpu", kernelFunc: Np };
/**
* @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 Mp(e) { return (t, n, r) => { const i = P.util.getArrayFromDType(n, t.length); for (let n = 0; n < t.length; ++n)i[n] = e(t[n], r); return i } }
/**
* @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 Fp(e, t, n) { return Dp(e, Mp(t), n) } function Dp(e, t, n) { return ({ inputs: r, attrs: i, backend: a }) => { const { x: o } = r; ip(o, e); const s = a, u = s.data.get(o.dataId).values; let l; if ("string" === o.dtype) { if (!Array.isArray(u)) throw new Error("String tensor's value was not an instance of Array"); l = P.backend_util.fromUint8ToStringArray(u) } else l = u; const c = n || o.dtype, h = t(l, c, i); return s.makeTensorInfo(o.shape, c, h) } }
/**
* @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.
* =============================================================================
*/
const $p = Mp((e => Math.ceil(e))), Rp = Dp(P.Ceil, $p), Op = { kernelName: P.Ceil, backendName: "cpu", kernelFunc: Rp };
/**
* @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 zp(e, t, n, r) { const i = P.util.getArrayFromDType(n, P.util.sizeFromShape(t)); if (r && "string" !== n) { let t = 0; e.forEach((e => { const n = P.util.sizeFromShape(e.shape); i.set(e.vals, t), t += n })) } else { let r = 0; e.forEach((e => { const a = "string" === n ? P.backend_util.fromUint8ToStringArray(e.vals) : e.vals; let o = 0; for (let n = 0; n < e.shape[0]; ++n) { const s = n * t[1] + r; for (let t = 0; t < e.shape[1]; ++t)i[s + t] = a[o++] } r += e.shape[1] })) } return i }
/**
* @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.
* =============================================================================
*/
const Pp = lp(((e, t) => e === t ? 1 : 0)), Bp = xp(P.Equal, Pp, null, "bool"), Lp = { kernelName: P.Equal, backendName: "cpu", kernelFunc: Bp }, jp = Mp((e => Math.exp(e))), Up = Dp(P.Exp, jp, "float32"), Wp = { kernelName: P.Exp, backendName: "cpu", kernelFunc: Up }, Vp = Mp((e => Math.expm1(e))), Gp = Dp(P.Expm1, Vp), Hp = { kernelName: P.Expm1, backendName: "cpu", kernelFunc: Gp }, qp = Mp((e => Math.floor(e))), Yp = Dp(P.Floor, qp), Xp = { kernelName: P.Floor, backendName: "cpu", kernelFunc: Yp }, Kp = lp(((e, t) => Math.floor(e / t))), Zp = xp(P.FloorDiv, Kp, null, "int32"), Jp = { kernelName: P.FloorDiv, backendName: "cpu", kernelFunc: Zp };
/**
* @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 Qp(e, t, n, r, i, a, o, s, u) { const l = (0, P.buffer)([r, a], n); for (let n = 0; n < r; n++) { const r = []; let c = 0; for (let t = 0; t < i; t++) { const a = e[n * i + t]; c += a * o[t], r.push(a) } if (c < 0 || c >= u / a) throw new Error(`Invalid indices: ${r} does not index into ${s}`); for (let e = 0; e < a; e++)l.values[n * a + e] = t.get(...t.indexToLoc(c * a + e)) } return l }
/**
* @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 em(e, t, n) { const r = (0, P.buffer)(n, e.dtype); for (let n = 0; n < r.size; ++n) { const i = r.indexToLoc(n).slice(), a = i[0], o = i[2], s = t.locToIndex([a, o]); i[2] = t.values[s]; const u = e.locToIndex(i); 0 <= u && u < e.values.length && (r.values[n] = e.values[u]) } return r }
/**
* @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.
* =============================================================================
*/
const tm = lp(((e, t) => e > t ? 1 : 0)), nm = xp(P.Greater, tm, null, "bool"), rm = { kernelName: P.Greater, backendName: "cpu", kernelFunc: nm }, im = lp(((e, t) => e >= t ? 1 : 0)), am = xp(P.GreaterEqual, im, null, "bool"), om = { kernelName: P.GreaterEqual, backendName: "cpu", kernelFunc: am }, sm = lp(((e, t) => e < t ? 1 : 0)), um = xp(P.Less, sm, null, "bool"), lm = { kernelName: P.Less, backendName: "cpu", kernelFunc: um }, cm = lp(((e, t) => e <= t ? 1 : 0)), hm = xp(P.LessEqual, cm, null, "bool"), dm = { kernelName: P.LessEqual, backendName: "cpu", kernelFunc: hm };
/**
* @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 fm(e, t, n) { const r = (t - e) / (n - 1), i = P.util.makeZerosTypedArray(n, "float32"); i[0] = e; for (let e = 1; e < i.length; e++)i[e] = i[e - 1] + r; return i }
/**
* @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.
* =============================================================================
*/
const pm = Mp((e => Math.log(e))), mm = Dp(P.Log, pm), gm = { kernelName: P.Log, backendName: "cpu", kernelFunc: mm };
/**
* @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 ym(e, t, n, r) { const i = P.util.getTypedArrayFromDType(r, P.util.sizeFromShape(n)); for (let n = 0; n < i.length; ++n) { const r = n * t; let a = e[r]; for (let n = 0; n < t; ++n) { const t = e[r + n]; (Number.isNaN(t) || t > a) && (a = t) } i[n] = a } return i }
/**
* @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.
* =============================================================================
*/
const bm = lp(((e, t) => Math.max(e, t))), vm = xp(P.Maximum, bm), xm = { kernelName: P.Maximum, backendName: "cpu", kernelFunc: vm }, wm = lp(((e, t) => Math.min(e, t))), km = xp(P.Minimum, wm), Sm = { kernelName: P.Minimum, backendName: "cpu", kernelFunc: km }, _m = lp(((e, t) => e * t)), Cm = wp(((e, t, n, r) => ({ real: e * n - t * r, imag: e * r + t * n }))), Am = xp(P.Multiply, _m, Cm), Tm = { kernelName: P.Multiply, backendName: "cpu", kernelFunc: Am };
/**
* @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 Em(e, t, n) { const r = P.util.createScalarValue(-1, n); return _m([], t, r, e, n) } const Nm = { kernelName: P.Neg, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; ip(r, "neg"); const i = n.data.get(r.dataId).values, [a, o] = Em(i, r.shape, r.dtype); return n.makeTensorInfo(o, r.dtype, a) } }, Im = lp(((e, t) => e !== t ? 1 : 0)), Mm = xp(P.NotEqual, Im, null, "bool"), Fm = { kernelName: P.NotEqual, backendName: "cpu", kernelFunc: Mm };
/**
* @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 Dm(e, t, n, r, i) { const a = t.length, o = P.util.sizeFromShape(t), s = P.util.computeStrides(t), u = P.util.computeStrides(i), l = P.util.getTypedArrayFromDType(n, P.util.sizeFromShape(i)); for (let t = 0; t < o; ++t) { const n = P.util.indexToLoc(t, a, s), i = new Array(n.length); for (let e = 0; e < i.length; e++)i[e] = n[r[e]]; l[P.util.locToIndex(i, a, u)] = e[t] } return l }
/**
* @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 $m(e) { const { inputs: t, attrs: n, backend: r } = e, { x: i } = t, { perm: a } = n; ip(i, "transpose"); const o = i.shape.length, s = new Array(o); for (let e = 0; e < s.length; e++)s[e] = i.shape[a[e]]; const u = Dm(r.data.get(i.dataId).values, i.shape, i.dtype, a, s); return { dataId: r.write(u, s, i.dtype), shape: s, dtype: i.dtype } } const Rm = { kernelName: P.Transpose, backendName: "cpu", kernelFunc: $m };
/**
* @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 Om(e, t, n, r) { const [i, a] = P.backend_util.computeOutAndReduceShapes(e, r), o = (0, P.upcastType)(t, "int32"), s = P.util.makeZerosTypedArray(P.util.sizeFromShape(i), o), u = P.util.sizeFromShape(a); for (let e = 0; e < s.length; ++e) { const t = e * u; let r = 1; for (let e = 0; e < u; ++e)r *= n[t + e]; s[e] = r } return { outVals: s, outShape: i, outDtype: o } } const zm = { kernelName: P.Prod, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "prod"); const s = i.shape.length, u = P.util.parseAxisParam(a, i.shape), l = P.backend_util.getAxesPermutation(u, s); let c = u, h = i; const d = []; null != l && (h = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), d.push(h), c = P.backend_util.getInnerMostAxes(c.length, s)); const f = n.data.get(h.dataId).values, { outVals: p, outShape: m, outDtype: g } = Om(h.shape, h.dtype, f, c); let y = m; return o && (y = P.backend_util.expandShapeToKeepDim(m, u)), d.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(y, g, p) } }; function Pm(e, t, n, r) { const i = []; let a = 0; const o = t.length - 1 + n.length, s = new Array(o).fill(null).map((() => [0])); !function (e, t) { for (let n = 0; n < e.length; ++n) { const r = e[n], i = n === e.length - 1 ? t : e[n + 1].length; if (0 === r.length) throw new Error("Ragged splits may not be empty"); if (r[0] < 0) throw new Error("Ragged splits must be non-negative"); if (r[r.length - 1] > i) throw new Error("Ragged splits must not point past values"); for (let e = 1; e < r.length; ++e)if (r[e - 1] > r[e]) throw new Error("Ragged splits must be sorted in ascending order") } }(n, r); let u = 1; for (let e = 0; e < t.length - 1; ++e) { u *= t[e]; const n = t[e + 1]; for (let t = 1; t < u + 1; ++t)s[e].push(t * n) } for (let r = 0; r < e.length; ++r) { let o = e[r], u = e[r] + 1; for (let e = 0; e < n.length; ++e) { const r = n[e], i = e + t.length - 1; if (i >= 0) { const e = s[i], t = e[e.length - 1] - r[o]; for (let e = o; e < u; ++e)s[i].push(r[e + 1] + t) } o = r[o], u = r[u] } u !== o && (i.push([o, u]), a += u - o) } return { outSplits: s, valueSlices: i, numValues: a } } function Bm(e, t) { const n = e.slice(0, t); for (; n.length < t;)n.push(1); for (let r = t; r < e.length; r++)n[t - 1] *= e[r]; return n } function Lm(e, t, n, r, i) { const a = t.slice(); a[0] = i; const o = P.util.getArrayFromDType(n, P.util.sizeFromShape(a)), s = e.length; return function (e, t, n, r, i, a) { const o = Bm(t, 2)[1], s = Bm(a, 2)[1]; let u = 0; for (const t of n) for (let n = t[0]; n < t[1]; ++n) { for (let t = 0; t < r; ++t)i[u * s + t] = e[n * o + t]; ++u } }(e, t, r, 0 === s ? 0 : s / t[0], o, a), [o, a] } function jm(e, t, n, r, i, a, o, s) {
if (0 === e.length) throw new Error("paramsNestedSplits must be non empty"); if (0 === t[0].length) throw new Error("Split tensors must not be scalars"); if (
/**
* @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 (e, t, n) { e.forEach(((e, r) => { if (e < 0 || e >= n) { const i = P.util.indexToLoc(r, t.length, P.util.computeStrides(t)).join(","); throw new Error(`indices[${i}] = ${e} is not in [0, ${n})`) } })) }(a, o, t[0][0] - 1), 0 === r.length) throw new Error("params.rank must be nonzero"); const u = r[0], { outSplits: l, valueSlices: c, numValues: h } = Pm(a, o, e, u), d = function (e) { const t = []; for (let n = 0; n < e.length; ++n) { const r = e[n].length, i = P.util.getArrayFromDType("int32", r); t.push(i), e[n].forEach(((e, t) => i[t] = e)) } return t }(l), f = Lm(n, r, i, c, h); return [d, f[0], f[1]]
}
/**
* @license
* Copyright 2022 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 Um = 2147483647; function Wm(e, t, n, r, i, a, o) { if (t.length > 1) throw new Error("starts must be a scalar or vector"); if (i.length > 1) throw new Error("limits must be a scalar or vector"); if (o.length > 1) throw new Error("deltas must be a scalar or vector"); const s = 0 === t.length, u = 0 === i.length, l = 0 === o.length, c = []; s || c.push(t[0]), u || c.push(i[0]), l || c.push(o[0]); for (let e = 1; e < c.length; ++e)if (c[e] !== c[e - 1]) throw new Error("starts, limits, and deltas must have the same shape"); const h = 0 === c.length ? 1 : c[0], d = P.util.getArrayFromDType("int32", h + 1); d[0] = 0; for (let t = 0; t < h; ++t) { const n = s ? e[0] : e[t], i = u ? r[0] : r[t], o = l ? a[0] : a[t]; if (0 === o) throw new Error("Requires delta != 0"); let c; if (o > 0 && i < n || o < 0 && i > n) c = 0; else if (c = Math.ceil(Math.abs((i - n) / o)), c > Um) throw new Error(`Requires ((limit - start) / delta) <= ${Um}`); d[t + 1] = d[t] + c } const f = d[h], p = P.util.getArrayFromDType(n, f); let m = 0; for (let t = 0; t < h; ++t) { const n = d[t + 1] - d[t]; let r = s ? e[0] : e[t]; const i = l ? a[0] : a[t]; for (let e = 0; e < n; ++e)p[m++] = r, r += i } return [d, p] }
/**
* @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.
* =============================================================================
*/
var Vm = P.backend_util.RowPartitionType; class Gm { constructor(e, t, n, r, i, a, o, s, u, l) { this.shape = e, this.shapeShape = t, this.values = n, this.valuesShape = r, this.valuesDType = i, this.defaultValue = a, this.defaultValueShape = o, this.rowPartitionValues = s, this.rowPartitionValuesShapes = u, this.rowPartitionTypes = P.backend_util.getRowPartitionTypesHelper(l), this.raggedRank = P.backend_util.getRaggedRank(this.rowPartitionTypes) } getRowPartitionTypeByDimension(e) { return this.rowPartitionTypes[0] === Vm.FIRST_DIM_SIZE ? this.rowPartitionTypes[e + 1] : this.rowPartitionTypes[e] } getRowPartitionTensor(e) { return this.rowPartitionTypes[0] === Vm.FIRST_DIM_SIZE ? this.rowPartitionValues[e + 1] : this.rowPartitionValues[e] } getMaxWidth(e) { const t = this.getRowPartitionTensor(e - 1); switch (this.getRowPartitionTypeByDimension(e - 1)) { case Vm.VALUE_ROWIDS: return Gm.getMaxWidthValueRowID(t); case Vm.ROW_SPLITS: return Gm.getMaxWidthRowSplit(t); default: throw new Error(`Cannot handle partition type ${Vm[this.getRowPartitionTypeByDimension(e - 1)]}`) } } static getMaxWidthRowSplit(e) { const t = e.length; if (0 === t || 1 === t) return 0; let n = 0; for (let r = 0; r < t - 1; ++r) { const t = e[r + 1] - e[r]; t > n && (n = t) } return n } static getMaxWidthValueRowID(e) { const t = e.length; if (0 === t) return 0; let n = 0, r = e[0], i = 0; for (let a = 1; a < t; ++a) { const t = e[a]; t !== r && (r = t, i = Math.max(a - n, i), n = a) } return Math.max(t - n, i) } tensorShapeFromTensor(e, t, n = !0) { if (0 === t.length) { if (-1 === e[0]) return []; throw new Error("The only valid scalar shape tensor is the fully unknown shape specified as -1.") } return qm(e, n) } calculateOutputSize(e) { const t = this.valuesShape, n = this.defaultValueShape; P.backend_util.validateDefaultValueShape(n, t); const r = this.tensorShapeFromTensor(this.shape, this.shapeShape), i = P.backend_util.combineRaggedTensorToTensorShapes(this.raggedRank, r, t); i[0] < 0 && (i[0] = e); for (let e = 1; e <= this.raggedRank; ++e)i[e] < 0 && (i[e] = this.getMaxWidth(e)); return i } calculateFirstParentOutputIndex(e, t, n) { const r = Math.min(e, n), i = []; let a = 0; for (let e = 0; e < r; ++e, a += t)i.push(a); for (let t = r; t < e; ++t)i.push(-1); return P.util.assert(i.length === e, (() => "Final length of result must be equal to firstDimension.")), i } calculateOutputIndexRowSplit(e, t, n, r) { const i = e.length, a = []; for (let o = 0; o < i - 1; ++o) { const i = e[o + 1] - e[o]; let s = Math.min(r, i), u = t[o]; -1 === u && (s = 0); for (let e = 0; e < s; ++e)a.push(u), u += n; for (let e = 0; e < i - s; ++e)a.push(-1) } if (i > 0 && a.length !== e[i - 1]) throw new Error("Invalid row split size."); return a } calculateOutputIndexValueRowID(e, t, n, r) { const i = e.length, a = []; if (0 === i) return []; let o = 0, s = e[0]; if (s >= t.length) throw new Error(`Got currentValueRowId=${s}, which is not less than ${t.length}`); let u = t[s]; a.push(u); for (let l = 1; l < i; ++l) { const i = e[l]; if (i === s) u >= 0 && (++o, o < r ? u += n : u = -1); else { if (o = 0, s = i, i >= t.length) throw new Error(`Got nextValueRowId=${i} which is not less than ${t.length}`); u = t[i] } a.push(u) } if (a.length !== e.length) throw new Error("Invalid row ids."); return a } calculateOutputIndex(e, t, n, r) { const i = this.getRowPartitionTensor(e), a = this.getRowPartitionTypeByDimension(e); switch (a) { case Vm.VALUE_ROWIDS: return this.calculateOutputIndexValueRowID(i, t, n, r); case Vm.ROW_SPLITS: if (i.length - 1 > t.length) throw new Error(`Row partition size is greater than output size: ${i.length - 1} > ${t.length}`); return this.calculateOutputIndexRowSplit(i, t, n, r); default: throw new Error(`Unsupported partition type: ${Vm[a]}`) } } getFirstDimensionSize() { const e = this.rowPartitionValues[0]; if (0 === this.rowPartitionTypes.length) throw new Error("No row_partition_types given."); const t = this.rowPartitionTypes[0]; switch (t) { case Vm.FIRST_DIM_SIZE: return e[0]; case Vm.VALUE_ROWIDS: throw new Error("Cannot handle VALUE_ROWIDS in first dimension."); case Vm.ROW_SPLITS: return this.rowPartitionValuesShapes[0][0] - 1; default: throw new Error(`Cannot handle type ${Vm[t]}`) } } compute() { if (this.rowPartitionValues[0].length <= 0) throw new Error("Invalid first partition input. Tensor requires at least one element."); const e = this.getFirstDimensionSize(), t = this.calculateOutputSize(e), n = new Array(this.raggedRank + 1); n[n.length - 1] = 1; for (let e = n.length - 2; e >= 0; --e)n[e] = n[e + 1] * t[e + 1]; const r = qm(t, !1), i = P.util.getArrayFromDType(this.valuesDType, P.util.sizeFromShape(r)); if (n[0] * t[0] > 0) { let a = this.calculateFirstParentOutputIndex(e, n[0], t[0]); for (let e = 1; e <= this.raggedRank; ++e) { a = this.calculateOutputIndex(e - 1, a, n[e], t[e]) } this.setOutput(this.raggedRank, a, i, r) } return [r, i] } setOutput(e, t, n, r) { if (0 === n.length) return; const i = this.values, a = n; let o = r.slice(); o = o.slice(e + 1); const s = P.util.sizeFromShape(o), u = t.length; let l = this.defaultValue; if (l.length !== s && 1 !== l.length) { const e = this.defaultValueShape; (0, P.tidy)((() => { const t = (0, P.reshape)(l, e), n = (0, P.broadcastTo)(t, o); l = n.dataSync() })) } let c = 0, h = 0, d = 0; for (let e = 0; e <= u; ++e) { let r = e < u ? t[e] : -1; if (r !== d) { if (h < d) { const e = i.subarray(c * s); Hm(a.subarray(h * s), e, (d - h) * s) } if (e >= u) { const e = n.length; r = Math.floor(e / s) } if (r > d) if (1 === this.defaultValue.length) a.subarray(d * s, r * s).fill(this.defaultValue[0]), d = r; else for (; r > d;) { Hm(a.slice(d * s), l, s), ++d } r < 0 ? (c = e + 1, h = d) : (c = e, h = d, d = h + 1) } else ++d } } } function Hm(e, t, n) { for (let r = 0; r < n; r++)e[r] = t[r] } function qm(e, t) { const n = []; for (let r of e) { if (r < 0) { if (!t) throw new Error(`Dimension ${r} must be >= 0`); if (r < -1) throw new Error(`Dimension ${r} must be >= -1`); r = -1 } n.push(r) } return n } function Ym(e, t, n, r, i, a, o, s, u, l) { return new Gm(e, t, n, r, i, a, o, s, u, l).compute() }
/**
* @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 Xm(e, t, n, r) { if (e === t || e < t && n < 0 || t < e && n > 1) return P.util.makeZerosTypedArray(0, r); const i = Math.abs(Math.ceil((t - e) / n)), a = P.util.makeZerosTypedArray(i, r); t < e && 1 === n && (n = -1), a[0] = e; for (let e = 1; e < a.length; e++)a[e] = a[e - 1] + n; return a }
/**
* @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.
* =============================================================================
*/
const Km = Mp((e => 1 / Math.sqrt(e))), Zm = Dp(P.Rsqrt, Km), Jm = { kernelName: P.Rsqrt, backendName: "cpu", kernelFunc: Zm };
/**
* @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 Qm(e, t, n, r, i, a, o, s, u, l) { const c = [r / i, i], h = e.values, d = t.values; if (0 === r) return (0, P.buffer)(n, t.dtype); const f = u instanceof P.TensorBuffer ? u : (0, P.buffer)(c, t.dtype); "string" == typeof u || "number" == typeof u ? f.values.fill(u) : "boolean" == typeof u && f.values.fill(+u); for (let e = 0; e < a; e++) { const a = []; let u = 0; for (let t = 0; t < o; t++) { const n = h[e * o + t]; a.push(n), u += n * s[t] } if (u < 0 || u >= r / i) throw new Error(`Invalid indices: ${a} does not index into ${n}`); for (let n = 0; n < i; n++)l ? f.values[u * i + n] += d[e * i + n] : f.values[u * i + n] = 0 === t.rank ? d[0] : d[e * i + n] } return f }
/**
* @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.
* =============================================================================
*/
const eg = Mp((e => 1 / (1 + Math.exp(-e)))), tg = Fp(P.Sigmoid, (e => 1 / (1 + Math.exp(-e)))), ng = { kernelName: P.Sigmoid, backendName: "cpu", kernelFunc: tg };
/**
* @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 rg(e, t, n, r, i) { const a = P.slice_util.isSliceContinous(r, t, n), o = P.util.sizeFromShape(n), s = P.util.computeStrides(r); if (a) { const n = P.slice_util.computeFlatOffset(t, s); return "string" === i ? e.slice(n, n + o) : e.subarray(n, n + o) } const u = "string" === i ? P.backend_util.fromUint8ToStringArray(e) : e, l = (0, P.buffer)(r, i, u), c = (0, P.buffer)(n, i); for (let e = 0; e < c.size; ++e) { const n = c.indexToLoc(e), r = n.map(((e, n) => e + t[n])); c.set(l.get(...r), ...n) } return "string" === i ? P.backend_util.fromStringArrayToUint8(c.values) : c.values } function ig(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, size: o } = r; ip(i, "slice"); const [s, u] = P.slice_util.parseSliceParams(i, a, o); P.slice_util.assertParamsValid(i, s, u); const l = rg(n.data.get(i.dataId).values, s, u, i.shape, i.dtype); return n.makeTensorInfo(u, i.dtype, l) } const ag = { kernelName: P.Slice, backendName: "cpu", kernelFunc: ig };
/**
* @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 og(e, t, n, r, i, a, o) { const s = t[0], u = a[0], l = new Array(u), c = new Array(s), h = t[1]; if (0 === u) { if (0 !== s) throw new Error(P.backend_util.getSparseFillEmptyRowsIndicesDenseShapeMismatch(s)); return [P.util.getArrayFromDType(n, 0), [0, h], P.util.getArrayFromDType(i, 0), l, c] } let d = !0, f = 0; const p = new Array(u).fill(0); for (let t = 0; t < s; ++t) { const n = e[t * h]; if (n < 0) throw new Error(P.backend_util.getSparseFillEmptyRowsNegativeIndexErrorMessage(t, n)); if (n >= u) throw new Error(P.backend_util.getSparseFillEmptyRowsOutOfRangeIndexErrorMessage(t, n, u)); ++p[n], d = d && n >= f, f = n } let m = !0; for (let e = 0; e < u; ++e) { const t = 0 === p[e]; l[e] = t, m = m && !t, p[e] = Math.max(p[e], 1), e > 0 && (p[e] += p[e - 1]) } if (m && d) { const t = e, n = r; for (let e = 0; e < s; ++e)c[e] = e; return [t, [s, h], n, l, c] } { const t = p[u - 1], a = P.util.getArrayFromDType(n, t * h), d = P.util.getArrayFromDType(i, t), f = new Array(u).fill(0); for (let t = 0; t < s; ++t) { const n = e[t * h], i = f[n], o = (0 === n ? 0 : p[n - 1]) + i; f[n]++; for (let n = 0; n < h; ++n)a[o * h + n] = e[t * h + n]; d[o] = r[t], c[t] = o } for (let e = 0; e < u; ++e) { if (0 === f[e]) { const t = 0 === e ? 0 : p[e - 1]; a[t * h + 0] = e; for (let e = 1; e < h; ++e)a[t * h + e] = 0; d[t] = o } } return [a, [t, h], d, l, c] } }
/**
* @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 sg(e, t, n, r, i) { const a = P.util.sizeFromShape(r), o = t[0], s = i.length, u = []; let l = 1, c = -1; for (let e = 0; e < s; ++e) { const t = i[e]; if (-1 === t) { if (-1 !== c) throw new Error(P.backend_util.getSparseReshapeMultipleNegativeOneOutputDimErrorMessage(c, e)); c = e, u.push(1) } else { if (t < 0) throw new Error(P.backend_util.getSparseReshapeNegativeOutputDimErrorMessage(e, t)); l *= t, u.push(t) } } if (-1 !== c) { if (l <= 0) throw new Error(P.backend_util.getSparseReshapeEmptyTensorZeroOutputDimErrorMessage()); const e = Math.trunc(a / l); if (l * e !== a) throw new Error(P.backend_util.getSparseReshapeInputOutputMultipleErrorMessage(r, u)); u[c] = e } if (P.util.sizeFromShape(u) !== a) throw new Error(P.backend_util.getSparseReshapeInputOutputMismatchErrorMessage(r, u)); const h = r.length, d = []; if (h > 0) { d[h - 1] = 1; for (let e = h - 2; e >= 0; --e)d[e] = d[e + 1] * r[e + 1] } const f = []; if (s > 0) { f[s - 1] = 1; for (let e = s - 2; e >= 0; --e)f[e] = f[e + 1] * u[e + 1] } const p = P.util.getArrayFromDType(n, o * s); for (let t = 0; t < o; ++t) { let n = 0; for (let r = 0; r < h; ++r)n += e[t * h + r] * d[r]; for (let e = 0; e < s; ++e)p[t * s + e] = Math.trunc(n / f[e]), n %= f[e] } return [p, [o, s], 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.
* =============================================================================
*/
function ug(e, t, n, r, i, a = !1, o = 0) { const s = r.length, u = [t[0], e.length / t[0]], l = u[1], c = s > 0 ? i[s - 1] + 1 : 0; if (c < 0) throw new Error(P.backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); const h = t.slice(); h[0] = c; const d = h.reduce(((e, t) => e * t), 1), f = P.util.getArrayFromDType(n, d); if (0 === s) return c > 0 && f.fill(o), [f, h]; if (c <= 0) throw new Error(P.backend_util.getSparseSegmentReductionNegativeSegmentIdsErrorMessage()); let p = 0, m = 1, g = 0, y = i[p]; for (; ;) { let t = 0; if (m < s) { if (t = i[m], y === t) { ++m; continue } if (y >= t) throw new Error(P.backend_util.getSparseSegmentReductionNonIncreasingSegmentIdsErrorMessage()) } if (y < 0 || y >= c) throw new Error(P.backend_util.getSparseSegmentReductionSegmentIdOutOfRangeErrorMessage(y, c)); y > g && f.fill(o, g * l, y * l); for (let t = p; t < m; ++t) { const n = r[t]; if (n < 0 || n >= u[0]) throw new Error(P.backend_util.getSparseSegmentReductionIndicesOutOfRangeErrorMessage(t, r[t], u[0])); for (let t = 0; t < l; t++)f[y * l + t] += e[n * l + t] } if (a) for (let e = 0; e < l; e++)f[y * l + e] /= m - p; if (p = m, ++m, g = y + 1, y = t, m > s) break } return g < c && f.fill(o, g * l, c * l), [f, h] }
/**
* @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.
* =============================================================================
*/
const lg = Mp((e => Math.sqrt(e))), cg = Fp(P.Sqrt, (e => Math.sqrt(e))), hg = { kernelName: P.Sqrt, backendName: "cpu", kernelFunc: cg }, dg = lp(((e, t) => { const n = e - t; return n * n })), fg = xp(P.SquaredDifference, dg), pg = { kernelName: P.SquaredDifference, backendName: "cpu", kernelFunc: fg }, mg = Mp(((e, t) => { const { pattern: n, replaceGlobal: r, rewrite: i } = t; return e.replace(new RegExp(n, r ? "g" : ""), i) })), gg = Dp(P.StaticRegexReplace, mg), yg = { kernelName: P.StaticRegexReplace, backendName: "cpu", kernelFunc: gg };
/**
* @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 bg(e, t, n, r) { const i = (0, P.buffer)(e, t.dtype); for (let e = 0; e < i.size; e++) { const a = i.indexToLoc(e), o = new Array(a.length); for (let e = 0; e < o.length; e++)o[e] = a[e] * n[e] + r[e]; i.set(t.get(...o), ...a) } return i }
/**
* @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.
* =============================================================================
*/
class vg { constructor(e, t, n, r, i, a) { this.separator = P.util.encodeString(e), this.nGramWidths = t, this.leftPad = P.util.encodeString(n), this.rightPad = P.util.encodeString(r), this.padWidth = i, this.preserveShort = a } getPadWidth(e) { return Math.min(this.padWidth < 0 ? e - 1 : this.padWidth, e - 1) } getNumNGrams(e, t) { const n = this.getPadWidth(t); return Math.max(0, e + 2 * n - t + 1) } createNGrams(e, t, n, r, i, a) { for (let o = 0; o < i; ++o) { const s = this.getPadWidth(a), u = Math.max(0, s - o), l = Math.max(0, s - (i - (o + 1))), c = a - (u + l), h = t + (u > 0 ? 0 : o - s); let d = 0; d += u * this.leftPad.length; for (let t = 0; t < c; ++t)d += e[h + t].length; d += l * this.rightPad.length; d += (u + l + c - 1) * this.separator.length, n[r + o] = new Uint8Array(d); const f = n[r + o]; let p = 0; const m = e => e.forEach((e => f[p++] = e)); for (let e = 0; e < u; ++e)m(this.leftPad), m(this.separator); for (let t = 0; t < c - 1; ++t)m(e[h + t]), m(this.separator); if (c > 0) { m(e[h + c - 1]); for (let e = 0; e < l; ++e)m(this.separator), m(this.rightPad) } else { for (let e = 0; e < l - 1; ++e)m(this.rightPad), m(this.separator); m(this.rightPad) } } } compute(e, t) { const n = e.length, r = t.length; if (r > 0) { let e = t[0]; if (0 !== e) throw new Error(`First split value must be 0, got ${e}`); for (let i = 1; i < r; ++i) { let r = t[i] >= e; if (r = r && t[i] <= n, !r) throw new Error(`Invalid split value ${t[i]}, must be in [${e}, ${n}]`); e = t[i] } if (e !== n) throw new Error(`Last split value must be data size. Expected ${n}, got ${e}`) } const i = r - 1, a = P.util.getArrayFromDType("int32", r); if (0 === n || 0 === r) { const e = new Array(n); for (let e = 0; e <= i; ++e)a[e] = 0; return [e, a] } a[0] = 0; for (let e = 1; e <= i; ++e) { const n = t[e] - t[e - 1]; let r = 0; this.nGramWidths.forEach((e => { r += this.getNumNGrams(n, e) })), this.preserveShort && n > 0 && 0 === r && (r = 1), a[e] = a[e - 1] + r } const o = new Array(a[i]); for (let n = 0; n < i; ++n) { const r = t[n]; let i = a[n]; if (this.nGramWidths.forEach((a => { const s = t[n + 1] - t[n], u = this.getNumNGrams(s, a); this.createNGrams(e, r, o, i, u, a), i += u })), this.preserveShort && i === a[n]) { const a = t[n + 1] - t[n]; if (0 === a) continue; const s = a + 2 * this.padWidth, u = 1; this.createNGrams(e, r, o, i, u, s) } } return [o, a] } } function xg(e, t, n, r, i, a, o, s) { return new vg(n, r, i, a, o, s).compute(e, t) }
/**
* @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 wg(e, t, n, r) { if (!e.length) return; if (0 === t.length) { for (let t = 0; t < e.length; ++t)r.push(e.subarray(t, t + 1)); return } if (1 === t.length) { const i = t[0]; let a = e.indexOf(i); for (; -1 !== a;) { const t = e.subarray(0, a); n && 0 === t.length || r.push(t), a = (e = e.subarray(a + 1)).indexOf(i) } return void (n && 0 === e.length || r.push(e)) } let i = 0; for (let a = 0; a < e.length + 1; a++)if (a === e.length || -1 !== t.indexOf(e[a])) { const t = e.subarray(i, a); n && 0 === t.length || r.push(t), i = a + 1 } } function kg(e, t, n) { const r = e.length, i = []; let a = 0, o = 0; const s = new Array(r); for (let u = 0; u < r; ++u) { const r = i.length; wg(e[u], t, n, i); const l = i.length - r; s[u] = l, a += l, o = Math.max(o, l) } const u = P.util.getArrayFromDType("int32", 2 * a), l = new Array(a), c = [r, o]; let h = 0; for (let e = 0; e < r; ++e)for (let t = 0; t < s[e]; ++t)u[2 * h] = e, u[2 * h + 1] = t, l[h] = i[h], ++h; return [u, l, c] }
/**
* @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 Sg(e, t) { const n = P.util.getArrayFromDType("int32", e.length); for (let r = 0; r < e.length; ++r)n[r] = P.util.fingerPrint64(e[r]).modulo(t).getLowBitsUnsigned(); return n }
/**
* @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.
* =============================================================================
*/
const _g = lp(((e, t) => e - t)), Cg = wp(((e, t, n, r) => ({ real: e - n, imag: t - r }))), Ag = xp(P.Sub, _g, Cg), Tg = { kernelName: P.Sub, backendName: "cpu", kernelFunc: Ag };
/**
* @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 Eg(e, t) { const n = new Array(e.rank); for (let r = 0; r < n.length; r++)n[r] = e.shape[r] * t[r]; const r = (0, P.buffer)(n, e.dtype); for (let t = 0; t < r.values.length; ++t) { const n = r.indexToLoc(t), i = new Array(e.rank); for (let t = 0; t < i.length; t++)i[t] = n[t] % e.shape[t]; const a = e.locToIndex(i); r.values[t] = e.values[a] } return r }
/**
* @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.
* =============================================================================
*/
const Ng = (e, t) => { const n = t.value - e.value; return 0 === n ? e.index - t.index : n }; function Ig(e, t, n = 0, r = e.length - 1) { for (; r > n;) { if (r - n > 600) { const i = r - n + 1, a = t - n + 1, o = Math.log(i), s = .5 * Math.exp(2 * o / 3), u = .5 * Math.sqrt(o * s * (i - s) / i) * Math.sign(a - i / 2); Ig(e, t, Math.max(n, Math.floor(t - a * s / i + u)), Math.min(r, Math.floor(t + (i - a) * s / i + u))) } const i = e[t]; let a = n, o = r; for (P.util.swap(e, n, t), Ng(e[r], i) > 0 && P.util.swap(e, n, r); a < o;) { for (P.util.swap(e, a, o), a++, o--; Ng(e[a], i) < 0;)a += 1; for (; Ng(e[o], i) > 0;)o -= 1 } 0 === Ng(e[n], i) ? P.util.swap(e, n, o) : (o += 1, P.util.swap(e, o, r)), o <= t && (n = o + 1), t <= o && (r = o - 1) } } function Mg(e, t, n, r, i) { const a = t[t.length - 1], [o, s] = [e.length / a, a], u = P.util.getTypedArrayFromDType(n, o * r), l = P.util.getTypedArrayFromDType("int32", o * r); for (let t = 0; t < o; t++) { const n = t * s, a = e.subarray(n, n + s); let o = new Array(a.length); a.forEach(((e, t) => o[t] = { value: e, index: t })), r < o.length && (Ig(o, r), o = o.slice(0, r)), i && o.sort(Ng); const c = t * r, h = u.subarray(c, c + r), d = l.subarray(c, c + r); for (let e = 0; e < r; e++)h[e] = o[e].value, d[e] = o[e].index } const c = t.slice(); return c[c.length - 1] = r, [(0, P.buffer)(c, n, u), (0, P.buffer)(c, "int32", l)] }
/**
* @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 Fg(e, t, n, r) { const i = P.util.parseAxisParam(t, n)[0], a = [1, n[0], 1]; for (let e = 0; e < i; e++)a[0] *= n[e]; a[1] = n[i]; for (let e = i + 1; e < n.length; e++)a[2] *= n[e]; const o = new Map, s = new Int32Array(n[i]), u = new P.TensorBuffer(a, r, e), l = [], c = 1 === a[0] && 1 === a[2]; for (let t = 0; t < n[i]; t++) { let n; if (c) n = e[t].toString(); else { const e = []; for (let n = 0; n < a[0]; n++)for (let r = 0; r < a[2]; r++)e.push(u.get(n, t, r)); n = e.join(",") } const r = o.get(n); if (null != r) s[t] = r; else { const e = o.size; o.set(n, e), s[t] = e, l.push(t) } } const h = a.slice(); h[1] = o.size; const d = new P.TensorBuffer(h, r); l.forEach(((e, t) => { for (let n = 0; n < a[0]; n++)for (let r = 0; r < a[2]; r++)d.set(u.get(n, e, r), n, t, r) })); const f = n.slice(); return f[i] = h[1], { outputValues: d.values, outputShape: f, indices: s } }
/** @license See the LICENSE file. */
const Dg = "4.22.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.
* =============================================================================
*/
/**
* @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.
* =============================================================================
*/
(0, P.registerBackend)("cpu", (() => new op), 1);
/**
* @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.
* =============================================================================
*/
const $g = Fp(P.Elu, (e => e >= 0 ? e : Math.exp(e) - 1)), Rg = { kernelName: P.Elu, backendName: "cpu", kernelFunc: $g };
/**
* @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 Og(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { alpha: a } = r; ip([i], "leakyRelu"); const o = P.util.sizeFromShape(i.shape), s = n.data.get(i.dataId).values, u = P.util.getTypedArrayFromDType("float32", o); for (let e = 0; e < s.length; e++)u[e] = s[e] < 0 ? a * s[e] : s[e]; return n.makeTensorInfo(i.shape, "float32", u) } const zg = { kernelName: P.LeakyRelu, backendName: "cpu", kernelFunc: Og }, Pg = lp(((e, t) => e < 0 ? t * e : e)); function Bg(e) { const { inputs: t, backend: n } = e, { x: r, alpha: i } = t; ip([r, i], "prelu"); const a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, [s, u] = Pg(r.shape, i.shape, a, o, "float32"); return n.makeTensorInfo(u, "float32", s) } const Lg = { kernelName: P.Prelu, backendName: "cpu", kernelFunc: Bg }, jg = Fp(P.Relu, (e => Math.max(0, e))), Ug = { kernelName: P.Relu, backendName: "cpu", kernelFunc: jg }, Wg = Fp(P.Relu6, (e => Math.min(Math.max(0, e), 6))), Vg = { kernelName: P.Relu6, backendName: "cpu", kernelFunc: Wg };
/**
* @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 Gg(e, t, n, r, i) { if ("linear" === n) return fp({ inputs: { x: t }, backend: e }); if ("relu" === n) return jg({ inputs: { x: t }, backend: e }); if ("elu" === n) return $g({ inputs: { x: t }, backend: e }); if ("relu6" === n) return Wg({ inputs: { x: t }, backend: e }); if ("prelu" === n) return Bg({ inputs: { x: t, alpha: r }, backend: e }); if ("leakyrelu" === n) return Og({ inputs: { x: t }, backend: e, attrs: { alpha: i } }); if ("sigmoid" === n) return tg({ inputs: { x: t }, backend: e }); throw new Error(`Activation ${n} has not been implemented for the CPU backend.`) }
/**
* @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 Hg(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { shape: a } = r, o = P.util.sizeFromShape(i.shape), s = P.util.inferFromImplicitShape(a, o), u = P.util.sizeFromShape(s); P.util.assert(o === u, (() => `The new shape (${s}) has ${u} elements and the old shape (${i.shape}) has ${o} elements. The new shape and old shape must have the same number of elements.`)), n.incRef(i.dataId); const l = n.data.get(i.dataId); if (null != l.complexTensorInfos) { const e = l.complexTensorInfos.real, t = l.complexTensorInfos.imag; e.shape = s, t.shape = s } return { dataId: i.dataId, shape: s, dtype: i.dtype } } const qg = { kernelName: P.Reshape, backendName: "cpu", kernelFunc: Hg };
/**
* @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 Yg(e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a } = t, { transposeA: o, transposeB: s } = r; ip([i, a], "matMul"); const u = i.shape.length, l = a.shape.length, c = o ? i.shape[u - 2] : i.shape[u - 1], h = s ? a.shape[l - 1] : a.shape[l - 2], d = o ? i.shape[u - 1] : i.shape[u - 2], f = s ? a.shape[l - 2] : a.shape[l - 1], p = i.shape.slice(0, -2), m = a.shape.slice(0, -2), g = P.util.sizeFromShape(p), y = P.util.sizeFromShape(m), b = P.broadcast_util.assertAndGetBroadcastShape(i.shape.slice(0, -2), a.shape.slice(0, -2)).concat([d, f]); P.util.assert(c === h, (() => `Error in matMul: inner shapes (${c}) and (${h}) of Tensors with shapes ${i.shape} and ${a.shape} and transposeA=${o} and transposeB=${s} must match.`)); const v = s ? [y, f, h] : [y, h, f], x = Hg({ inputs: { x: i }, backend: n, attrs: { shape: o ? [g, c, d] : [g, d, c] } }), w = Hg({ inputs: { x: a }, backend: n, attrs: { shape: v } }), k = o ? x.shape[1] : x.shape[2], S = o ? x.shape[2] : x.shape[1], _ = s ? w.shape[1] : w.shape[2], C = Math.max(g, y), A = n.data.get(x.dataId).values, T = n.data.get(w.dataId).values, E = P.util.computeStrides(x.shape), N = P.util.computeStrides(w.shape), [I, M, F] = o ? [E[0], 1, E[1]] : [E[0], E[1], 1], [D, $, R] = s ? [1, N[1], N[0]] : [N[1], 1, N[0]], O = S * _, z = (0, P.buffer)([C, S, _], x.dtype), B = z.values, L = n.blockSize; for (let e = 0; e < C; e++) { const t = e % g, n = e % y; for (let r = 0; r < S; r += L) { const i = Math.min(r + L, S); for (let a = 0; a < _; a += L) { const o = Math.min(a + L, _); for (let s = 0; s < k; s += L) { const u = Math.min(s + L, k); for (let l = r; l < i; l++)for (let r = a; r < o; r++) { let i = 0; for (let e = s; e < u; e++) { i += A[t * I + l * M + e * F] * T[e * D + r * $ + n * R] } B[e * O + (l * _ + r)] += i } } } } } return n.disposeIntermediateTensorInfo(x), n.disposeIntermediateTensorInfo(w), n.makeTensorInfo(b, z.dtype, z.values) } const Xg = { kernelName: P.BatchMatMul, backendName: "cpu", kernelFunc: Yg }; const Kg = {
kernelName: P._FusedMatMul, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a, bias: o, preluActivationWeights: s } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: h } = r; let d, f, p; const m = []; d = Yg({ inputs: { a: i, b: a }, attrs: { transposeA: u, transposeB: l }, backend: n }), o && (f = _p({ inputs: { a: d, b: o }, backend: n }), m.push(d), d = f), c && (p = Gg(n, d, c, s, h), m.push(d), d = p); for (const e of m) n.disposeIntermediateTensorInfo(e); return d }
}, Zg = Fp(P.Acos, (e => Math.acos(e))), Jg = { kernelName: P.Acos, backendName: "cpu", kernelFunc: Zg }, Qg = Fp(P.Acosh, (e => Math.acosh(e))), ey = { kernelName: P.Acosh, backendName: "cpu", kernelFunc: Qg }; const ty = {
kernelName: P.AddN, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, r = t; ip(t, "addN"); const i = r.map((e => n.data.get(e.dataId).values)), a = (0, P.buffer)(r[0].shape, r[0].dtype), o = a.values; for (let e = 0; e < r.length; e++) { const t = i[e]; for (let e = 0; e < o.length; e++)o[e] += t[e] } return n.makeTensorInfo(a.shape, a.dtype, a.values) }
}; const ny = {
kernelName: P.All, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "all"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("all", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; n = n && r } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g }
}; const ry = {
kernelName: P.Any, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "any"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("any", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; n = n || r } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g }
}; const iy = {
kernelName: P.ArgMax, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; ip(i, "argMax"); let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = $m({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), o = [o[0]], P.backend_util.assertAxesAreInnerMostDims("argMax", o, u.shape.length); const [c, h] = P.backend_util.computeOutAndReduceShapes(u.shape, o), d = P.util.sizeFromShape(c), f = P.util.makeZerosTypedArray(d, "int32"), p = P.util.sizeFromShape(h), m = n.data.get(u.dataId).values; for (let e = 0; e < f.length; ++e) { const t = e * p; let n = m[t], r = 0; for (let e = 0; e < p; ++e) { const i = m[t + e]; i > n && (n = i, r = e) } f[e] = r } return l.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(c, "int32", f) }
}; const ay = {
kernelName: P.ArgMin, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; ip(i, "argMin"); let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = $m({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), o = [o[0]], P.backend_util.assertAxesAreInnerMostDims("argMin", o, u.shape.length); const [c, h] = P.backend_util.computeOutAndReduceShapes(u.shape, o), d = P.util.sizeFromShape(c), f = P.util.makeZerosTypedArray(d, "int32"), p = P.util.sizeFromShape(h), m = n.data.get(u.dataId).values; for (let e = 0; e < f.length; ++e) { const t = e * p; let n = m[t], r = 0; for (let e = 0; e < p; ++e) { const i = m[t + e]; i < n && (n = i, r = e) } f[e] = r } return l.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(c, "int32", f) }
}, oy = Fp(P.Asin, (e => Math.asin(e))), sy = { kernelName: P.Asin, backendName: "cpu", kernelFunc: oy }, uy = Fp(P.Asinh, (e => Math.asinh(e))), ly = { kernelName: P.Asinh, backendName: "cpu", kernelFunc: uy }, cy = Fp(P.Atan, (e => Math.atan(e))), hy = { kernelName: P.Atan, backendName: "cpu", kernelFunc: cy }, dy = lp(((e, t) => Math.atan2(e, t))), fy = xp(P.Atan2, dy), py = { kernelName: P.Atan2, backendName: "cpu", kernelFunc: fy }, my = Fp(P.Atanh, (e => Math.atanh(e))), gy = { kernelName: P.Atanh, backendName: "cpu", kernelFunc: my };
/**
* @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 yy(e, t, n, r, i, a) { const o = i.strideHeight, s = i.strideWidth, u = i.dilationHeight, l = i.dilationWidth, c = i.effectiveFilterHeight, h = i.effectiveFilterWidth, d = i.padInfo.top, f = i.padInfo.left, p = "max" === a ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, m = (0, P.buffer)(i.outShape, n), g = m.values, y = i.outShape[1] * i.outShape[2] * i.outShape[3], b = i.outShape[2] * i.outShape[3], v = i.outShape[3]; for (let t = 0; t < i.batchSize; ++t) { const n = t * y, m = t * r[0]; for (let t = 0; t < i.inChannels; ++t)for (let y = 0; y < i.outHeight; ++y) { const x = y * o - d, w = Math.max(0, x), k = Math.min(i.inHeight, c + x), S = n + y * b; for (let n = 0; n < i.outWidth; ++n) { const o = n * s - f, c = Math.max(0, o), d = Math.min(i.inWidth, h + o); let y = p, b = 0, x = 0; for (let n = w; n < k; n += u) { const i = m + n * r[1]; for (let n = c; n < d; n += l) { const o = e[i + n * r[2] + t]; "max" === a && o > y ? y = o : "avg" === a && (b += o, x++) } if (isNaN(y)) break } g[S + n * v + t] = "avg" === a ? b / x : y } } } return m } function by(e, t, n, r, i = !1, a = !1) { const o = (0, P.buffer)(r.outShape, "int32"), s = r.strideHeight, u = r.strideWidth, l = r.dilationHeight, c = r.dilationWidth, h = r.effectiveFilterHeight, d = r.effectiveFilterWidth, f = r.padInfo.top, p = r.padInfo.left, m = (0, P.buffer)(t, n, e); for (let e = 0; e < r.batchSize; ++e)for (let t = 0; t < r.inChannels; ++t)for (let n = 0; n < r.outHeight; ++n) { const g = n * s - f; let y = g; for (; y < 0;)y += l; const b = Math.min(r.inHeight, h + g); for (let s = 0; s < r.outWidth; ++s) { const h = s * u - p; let f = h; for (; f < 0;)f += c; const v = Math.min(r.inWidth, d + h); let x = Number.NEGATIVE_INFINITY, w = -1; for (let n = y; n < b; n += l) { const o = n - g; for (let s = f; s < v; s += c) { const u = s - h, l = m.get(e, n, s, t); l > x && (x = l, w = i ? a ? ((e * r.inHeight + n) * r.inWidth + s) * r.inChannels + t : (n * r.inWidth + s) * r.inChannels + t : o * d + u) } } o.set(w, e, n, s, t) } } return o } function vy(e, t, n, r, i, a) { const o = i.strideDepth, s = i.strideHeight, u = i.strideWidth, l = i.dilationDepth, c = i.dilationHeight, h = i.dilationWidth, d = i.effectiveFilterDepth, f = i.effectiveFilterHeight, p = i.effectiveFilterWidth, m = i.padInfo.front, g = i.padInfo.top, y = i.padInfo.left, b = "max" === a ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY, v = (0, P.buffer)(i.outShape, n), x = v.values, w = i.outShape[1] * i.outShape[2] * i.outShape[3] * i.outShape[4], k = i.outShape[2] * i.outShape[3] * i.outShape[4], S = i.outShape[3] * i.outShape[4], _ = i.outShape[4]; for (let t = 0; t < i.batchSize; ++t) { const n = t * w, v = t * r[0]; for (let t = 0; t < i.inChannels; ++t)for (let w = 0; w < i.outDepth; ++w) { const C = w * o - m; let A = C; for (; A < 0;)A += l; const T = Math.min(i.inDepth, d + C), E = n + w * k; for (let n = 0; n < i.outHeight; ++n) { const o = n * s - g; let d = o; for (; d < 0;)d += c; const m = Math.min(i.inHeight, f + o), w = E + n * S; for (let n = 0; n < i.outWidth; ++n) { const o = n * u - y; let s = o; for (; s < 0;)s += h; const f = Math.min(i.inWidth, p + o), g = w + n * _; let k = b, S = 0, C = 0; for (let n = A; n < T; n += l) { const i = v + n * r[1]; for (let n = d; n < m; n += c) { const o = i + n * r[2]; for (let n = s; n < f; n += h) { const i = e[o + n * r[3] + t]; if ("max" === a && i > k ? k = i : "avg" === a && (S += i, C++), isNaN(k)) break } if (isNaN(k)) break } if (isNaN(k)) break } x[g + t] = "avg" === a ? S / Math.max(C, 1) : k } } } } return v } const xy = {
kernelName: P.AvgPool, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; ip(i, "avgPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); let c; if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) c = fp({ inputs: { x: i }, backend: n }); else { const e = n.data.get(i.dataId).values, t = P.util.computeStrides(i.shape), r = yy(e, i.shape, i.dtype, t, l, "avg"); c = n.makeTensorInfo(l.outShape, i.dtype, r.values) } return c }
}; const wy = {
kernelName: P.AvgPool3D, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r; ip(i, "avgPool3d"); const c = P.backend_util.computePool3DInfo(i.shape, a, o, 1, s, u, l), h = vy(n.data.get(i.dataId).values, i.shape, i.dtype, P.util.computeStrides(i.shape), c, "avg"); return n.makeTensorInfo(h.shape, "float32", h.values) }
}; const ky = {
kernelName: P.AvgPool3DGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, { filterSize: o, strides: s, pad: u, dimRoundingMode: l } = r; ip([i, a], "avgPool3DGrad"); const c = P.backend_util.computePool3DInfo(a.shape, o, s, 1, u, l), h = c.strideDepth, d = c.strideHeight, f = c.strideWidth, p = c.filterDepth, m = c.filterHeight, g = c.filterWidth, y = c.dilationDepth, b = c.dilationHeight, v = c.dilationWidth, x = c.effectiveFilterDepth, w = c.effectiveFilterHeight, k = c.effectiveFilterWidth, S = x - 1 - c.padInfo.front, _ = k - 1 - c.padInfo.left, C = w - 1 - c.padInfo.top, A = (0, P.buffer)(a.shape, "float32"), T = 1 / (p * m * g), E = n.bufferSync(i); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inDepth; ++n)for (let r = 0; r < c.inHeight; ++r)for (let i = 0; i < c.inWidth; ++i) { const a = n - S, o = r - C, s = i - _; let u = 0; for (let n = 0; n < x; n += y) { const r = (a + n) / h; if (!(r < 0 || r >= c.outDepth || Math.floor(r) !== r)) for (let n = 0; n < w; n += b) { const i = (o + n) / d; if (!(i < 0 || i >= c.outHeight || Math.floor(i) !== i)) for (let n = 0; n < k; n += v) { const a = (s + n) / f; if (a < 0 || a >= c.outWidth || Math.floor(a) !== a) continue; u += E.get(e, r, i, a, t) } } } A.set(u * T, e, n, r, i, t) } return n.makeTensorInfo(A.shape, A.dtype, A.values) }
}; const Sy = {
kernelName: P.AvgPoolGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a; ip([i, a], "avgPoolGrad"); const { filterSize: s, strides: u, pad: l } = r, c = P.backend_util.computePool2DInfo(o.shape, s, u, 1, l), h = c.strideHeight, d = c.strideWidth, f = c.filterHeight, p = c.filterWidth, m = c.dilationHeight, g = c.dilationWidth, y = c.effectiveFilterHeight, b = c.effectiveFilterWidth, v = b - 1 - c.padInfo.left, x = y - 1 - c.padInfo.top, w = (0, P.buffer)(o.shape, "float32"), k = 1 / (f * p), S = n.data.get(i.dataId).values, _ = (0, P.buffer)(i.shape, "float32", S); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inHeight; ++n)for (let r = 0; r < c.inWidth; ++r) { const i = n - x, a = r - v; let o = 0; for (let n = 0; n < y; n += m) { const r = (i + n) / h; if (!(r < 0 || r >= c.outHeight || Math.floor(r) !== r)) for (let n = 0; n < b; n += g) { const i = (a + n) / d; if (i < 0 || i >= c.outWidth || Math.floor(i) !== i) continue; o += _.get(e, r, i, t) } } w.set(o * k, e, n, r, t) } return n.makeTensorInfo(w.shape, w.dtype, w.values) }
}; const _y = {
kernelName: P.FusedBatchNorm, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, scale: a, offset: o, mean: s, variance: u } = t; P.util.assert(s.shape.length === u.shape.length, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), P.util.assert(null == o || s.shape.length === o.shape.length, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), P.util.assert(null == a || s.shape.length === a.shape.length, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")), ip([i, s, u, a, o], "batchNorm"); let { varianceEpsilon: l } = r; null == l && (l = .001); const c = n.data.get(i.dataId).values, h = n.data.get(s.dataId).values, d = n.data.get(u.dataId).values, f = a ? n.data.get(a.dataId).values : new Float32Array([1]), p = o ? n.data.get(o.dataId).values : new Float32Array([0]), m = new Float32Array(c.length), g = p.length, y = f.length, b = d.length, v = h.length; let x = 0, w = 0, k = 0, S = 0; for (let e = 0; e < c.length; ++e)m[e] = p[x++] + (c[e] - h[w++]) * f[k++] / Math.sqrt(d[S++] + l), x >= g && (x = 0), w >= v && (w = 0), k >= y && (k = 0), S >= b && (S = 0); return n.makeTensorInfo(i.shape, i.dtype, m) }
}; const Cy = {
kernelName: P.BatchToSpaceND, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, crops: o } = r; ip([i], "batchToSpaceND"); const s = a.reduce(((e, t) => e * t)), u = P.backend_util.getReshaped(i.shape, a, s), l = P.backend_util.getPermuted(u.length, a.length), c = P.backend_util.getReshapedPermuted(i.shape, a, s), h = P.backend_util.getSliceBeginCoords(o, a.length), d = P.backend_util.getSliceSize(c, o, a.length), f = Hg({ inputs: { x: i }, backend: n, attrs: { shape: u } }), p = $m({ inputs: { x: f }, backend: n, attrs: { perm: l } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: c } }), g = ig({ inputs: { x: m }, backend: n, attrs: { begin: h, size: d } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), g }
}; const Ay = {
kernelName: P.Bincount, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o } = r, s = Ap(n.data.get(i.dataId).values, n.data.get(a.dataId).values, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, s) }
}; const Ty = {
kernelName: P.BroadcastArgs, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { s0: r, s1: i } = t, a = n.data.get(r.dataId).values, o = n.data.get(i.dataId).values, s = P.backend_util.assertAndGetBroadcastShape(Array.from(a), Array.from(o)); return n.makeTensorInfo([s.length], "int32", Int32Array.from(s)) }
}, Ey = Fp(P.ClipByValue, ((e, t) => { const n = t; return e > n.clipValueMax ? n.clipValueMax : e < n.clipValueMin ? n.clipValueMin : e })), Ny = { kernelName: P.ClipByValue, backendName: "cpu", kernelFunc: Ey }, Iy = { kernelName: P.ComplexAbs, backendName: "cpu", kernelFunc: e => { const { x: t } = e.inputs, n = e.backend, r = new Float32Array(P.util.sizeFromShape(t.shape)), i = n.data.get(t.dataId), a = i.complexTensorInfos.real, o = i.complexTensorInfos.imag, s = n.data.get(a.dataId).values, u = n.data.get(o.dataId).values; for (let e = 0; e < s.length; e++) { const t = s[e], n = u[e]; r[e] = Math.hypot(t, n) } return n.makeOutput(r, t.shape, "float32") } };
/**
* @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 My(e) { const { inputs: t, backend: n } = e, { input: r } = t, i = n.data.get(r.dataId).complexTensorInfos.imag, a = n.data.get(i.dataId).values; return n.makeTensorInfo(i.shape, i.dtype, a) } const Fy = { kernelName: P.Imag, backendName: "cpu", kernelFunc: My };
/**
* @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 Dy(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r, a = P.util.parseAxisParam(i, t[0].shape)[0], o = t.map((e => e.shape)); P.backend_util.assertParamsConsistent(o, a); let s = P.backend_util.computeOutShape(t.map((e => e.shape)), a); if (0 === P.util.sizeFromShape(s)) return n.makeTensorInfo(s, t[0].dtype, []); const u = t.filter((e => P.util.sizeFromShape(e.shape) > 0)); if (1 === u.length) return fp({ inputs: { x: u[0] }, backend: n }); if ("complex64" === u[0].dtype) { const e = u.map((e => mp({ inputs: { input: e }, backend: n }))), t = u.map((e => My({ inputs: { input: e }, backend: n }))), r = Dy({ inputs: e, backend: n, attrs: { axis: a } }), i = Dy({ inputs: t, backend: n, attrs: { axis: a } }), o = cp({ inputs: { real: r, imag: i }, backend: n }); return e.forEach((e => n.disposeIntermediateTensorInfo(e))), t.forEach((e => n.disposeIntermediateTensorInfo(e))), n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(i), o } const l = u.map((e => { const t = P.util.sizeFromShape(e.shape.slice(a)); return Hg({ inputs: { x: e }, backend: n, attrs: { shape: [-1, t] } }) })), c = l.map((e => ({ vals: n.data.get(e.dataId).values, shape: e.shape }))); s = P.backend_util.computeOutShape(l.map((e => e.shape)), 1); const h = 1 === l[0].shape[0], d = zp(c, s, t[0].dtype, h), f = P.backend_util.computeOutShape(u.map((e => e.shape)), a), p = n.makeTensorInfo(f, t[0].dtype, d); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), p } const $y = { kernelName: P.Concat, backendName: "cpu", kernelFunc: Dy };
/**
* @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 Ry(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = r; ip([i, a], "conv2d"); const h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, l, s, c, !1, h), f = d.filterHeight, p = d.filterWidth, m = d.dilationHeight, g = d.dilationWidth, y = d.padInfo.left, b = d.padInfo.top, v = "channelsLast" === d.dataFormat, x = new P.TensorBuffer(d.outShape, i.dtype), w = P.util.computeStrides(i.shape), k = P.util.computeStrides(a.shape), S = w[0], _ = v ? w[1] : w[2], C = v ? w[2] : 1, A = v ? 1 : w[1], T = x.strides[0], E = v ? x.strides[1] : x.strides[2], N = v ? x.strides[2] : 1, I = v ? 1 : x.strides[1], M = n.data.get(i.dataId).values, F = n.data.get(a.dataId).values, D = x.values; for (let e = 0; e < d.batchSize; ++e) { const t = e * S, n = e * T; for (let e = 0; e < d.outHeight; ++e) { const r = n + e * E, i = e * d.strideHeight - b; for (let e = 0; e < f; ++e) { const n = i + e * m; if (n < 0 || n >= d.inHeight) continue; const a = e * k[0], o = t + n * _; for (let e = 0; e < d.outWidth; ++e) { const t = r + e * N, n = e * d.strideWidth - y; for (let e = 0; e < p; ++e) { const r = n + e * g; if (r < 0 || r >= d.inWidth) continue; const i = o + r * C; let s = a + e * k[1]; for (let e = 0; e < d.inChannels; ++e) { const n = M[i + e * A]; for (let e = 0; e < d.outChannels; ++e)D[t + e * I] += n * F[s + e]; s += d.outChannels } } } } } } return n.makeTensorInfo(x.shape, x.dtype, D) } const Oy = { kernelName: P.Conv2D, backendName: "cpu", kernelFunc: Ry }; const zy = {
kernelName: P.Conv2DBackpropFilter, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, dataFormat: u, dimRoundingMode: l, filterShape: c } = r; ip([i, a], "conv2dBackpropFilter"); const h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, c, o, 1, s, l, !1, h), { strideHeight: f, strideWidth: p, filterHeight: m, filterWidth: g } = d, y = "channelsLast" === d.dataFormat, b = new P.TensorBuffer(d.filterShape, "float32"), v = d.padInfo.left, x = d.padInfo.top, w = n.data.get(i.dataId).values, k = n.data.get(a.dataId).values, S = new P.TensorBuffer(i.shape, i.dtype, w), _ = new P.TensorBuffer(a.shape, a.dtype, k); for (let e = 0; e < m; ++e) { const t = Math.max(0, Math.ceil((x - e) / f)), n = Math.min(d.outHeight, (d.inHeight + x - e) / f); for (let r = 0; r < g; ++r) { const i = Math.max(0, Math.ceil((v - r) / p)), a = Math.min(d.outWidth, (d.inWidth + v - r) / p); for (let o = 0; o < d.inChannels; ++o)for (let s = 0; s < d.outChannels; ++s) { let u = 0; for (let l = 0; l < d.batchSize; ++l)for (let c = t; c < n; ++c) { const t = e + c * f - x; for (let e = i; e < a; ++e) { const n = r + e * p - v; u += y ? S.get(l, t, n, o) * _.get(l, c, e, s) : S.get(l, o, t, n) * _.get(l, s, c, e) } } b.set(u, e, r, o, s) } } } return n.makeTensorInfo(b.shape, b.dtype, b.values) }
}; const Py = {
kernelName: P.Conv2DBackpropInput, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { inputShape: o, strides: s, pad: u, dataFormat: l, dimRoundingMode: c } = r; ip([i, a], "conv2dBackpropInput"); const h = P.util.computeStrides(a.shape), d = P.util.computeStrides(i.shape); let f = P.backend_util.convertConv2DDataFormat(l); const p = P.backend_util.computeConv2DInfo(o, a.shape, s, 1, u, c, !1, f), m = new P.TensorBuffer(p.inShape, "float32"), g = m.values, y = n.data.get(i.dataId).values, b = n.data.get(a.dataId).values, [v, x, w] = h, { batchSize: k, filterHeight: S, filterWidth: _, inChannels: C, inHeight: A, inWidth: T, outChannels: E, outHeight: N, outWidth: I, strideHeight: M, strideWidth: F } = p; f = p.dataFormat; const D = S - 1 - p.padInfo.top, $ = _ - 1 - p.padInfo.left, R = "channelsLast" === f, O = m.strides[0], z = R ? m.strides[1] : m.strides[2], B = R ? m.strides[2] : 1, L = R ? 1 : m.strides[1], j = d[0], U = R ? d[1] : d[2], W = R ? d[2] : 1, V = R ? 1 : d[1]; for (let e = 0; e < k; ++e)for (let t = 0; t < C; ++t)for (let n = 0; n < A; ++n) { const r = n - D, i = Math.max(0, Math.ceil(r / M)), a = Math.min(N, (S + r) / M); for (let o = 0; o < T; ++o) { const s = o - $, u = Math.max(0, Math.ceil(s / F)), l = Math.min(I, (_ + s) / F); let c = 0; for (let n = i; n < a; ++n) { const i = n * M - r; for (let r = u; r < l; ++r) { const a = j * e + U * n + W * r, o = v * (S - 1 - i) + x * (_ - 1 - (r * F - s)) + w * t; for (let e = 0; e < E; ++e) { c += y[a + V * e] * b[o + e] } } } g[O * e + z * n + B * o + L * t] = c } } return n.makeTensorInfo(m.shape, m.dtype, m.values) }
}; const By = {
kernelName: P.Conv3D, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r; ip([i, a], "conv3d"); const l = P.backend_util.computeConv3DInfo(i.shape, a.shape, o, u, s), { filterDepth: c, filterHeight: h, filterWidth: d, dilationDepth: f, dilationHeight: p, dilationWidth: m, padInfo: g } = l, y = g.front, b = g.left, v = g.top, x = new P.TensorBuffer(l.outShape, i.dtype), w = n.data.get(i.dataId).values, k = n.data.get(a.dataId).values, S = x.values, _ = P.util.computeStrides(i.shape), C = P.util.computeStrides(a.shape); for (let e = 0; e < l.batchSize; ++e) { const t = e * _[0], n = e * x.strides[0]; for (let e = 0; e < l.outDepth; ++e) { const r = n + e * x.strides[1], i = e * l.strideDepth - y; for (let e = 0; e < c; ++e) { const n = i + e * f; if (n < 0 || n >= l.inDepth) continue; const a = e * C[0], o = t + n * _[1]; for (let e = 0; e < l.outHeight; ++e) { const t = r + e * x.strides[2], n = e * l.strideHeight - v; for (let e = 0; e < h; ++e) { const r = n + e * p; if (r < 0 || r >= l.inHeight) continue; const i = a + e * C[1], s = o + r * _[2]; for (let e = 0; e < l.outWidth; ++e) { const n = t + e * l.outChannels, r = e * l.strideWidth - b; for (let e = 0; e < d; ++e) { const t = r + e * m; if (t < 0 || t >= l.inWidth) continue; const a = i + e * C[2], o = s + t * l.inChannels; let u = a; for (let e = 0; e < l.inChannels; ++e) { const t = w[o + e]; for (let e = 0; e < l.outChannels; ++e)S[n + e] += t * k[u + e]; u += l.outChannels } } } } } } } } return n.makeTensorInfo(x.shape, x.dtype, x.values) }
}; const Ly = {
kernelName: P.Conv3DBackpropFilterV2, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, filterShape: u } = r; ip([i, a], "conv3dBackpropFilterV2"); const l = P.util.computeStrides(i.shape), c = P.util.computeStrides(a.shape), h = P.backend_util.computeConv3DInfo(i.shape, u, o, 1, s), d = h.strideDepth, f = h.strideHeight, p = h.strideWidth, m = h.filterDepth, g = h.filterHeight, y = h.filterWidth, b = new P.TensorBuffer(h.filterShape, "float32"), v = b.values, [x, w, k, S] = b.strides, _ = n.data.get(a.dataId).values, [C, A, T, E] = c, N = n.data.get(i.dataId).values, [I, M, F, D] = l, $ = h.padInfo.front, R = h.padInfo.left, O = h.padInfo.top; for (let e = 0; e < m; ++e) { const t = Math.max(0, Math.ceil(($ - e) / d)), n = Math.min(h.outDepth, (h.inDepth + $ - e) / d), r = e * x; for (let i = 0; i < g; ++i) { const a = Math.max(0, Math.ceil((O - i) / f)), o = Math.min(h.outHeight, (h.inHeight + O - i) / f), s = i * w + r; for (let r = 0; r < y; ++r) { const u = Math.max(0, Math.ceil((R - r) / p)), l = Math.min(h.outWidth, (h.inWidth + R - r) / p), c = r * k + s; for (let s = 0; s < h.inChannels; ++s) { const m = s * S + c; for (let c = 0; c < h.outChannels; ++c) { let g = 0; for (let m = 0; m < h.batchSize; ++m) { const h = m * I, y = m * C; for (let m = t; m < n; ++m) { const t = (e + m * d - $) * M + h, n = m * A + y; for (let e = a; e < o; ++e) { const a = (i + e * f - O) * F + t, o = e * T + n; for (let e = u; e < l; ++e) { const t = e * E + o; g += N[(r + e * p - R) * D + a + s] * _[t + c] } } } } v[m + c] = g } } } } } return n.makeTensorInfo(b.shape, b.dtype, b.values) }
}; const jy = {
kernelName: P.Conv3DBackpropInputV2, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { pad: o, strides: s, inputShape: u } = r; ip([i], "conv3dBackpropInputV2"); const l = P.util.computeStrides(i.shape), c = P.util.computeStrides(a.shape), h = P.backend_util.computeConv3DInfo(u, a.shape, s, 1, o), d = new P.TensorBuffer(h.inShape, "float32"), f = d.values, [p, m, g, y] = d.strides, b = n.data.get(i.dataId).values, [v, x, w, k] = l, S = n.data.get(a.dataId).values, [_, C, A, T] = c, { batchSize: E, filterDepth: N, filterHeight: I, filterWidth: M, inChannels: F, inDepth: D, inHeight: $, inWidth: R, outChannels: O, outDepth: z, outHeight: B, outWidth: L, strideDepth: j, strideHeight: U, strideWidth: W } = h, V = N - 1 - h.padInfo.front, G = I - 1 - h.padInfo.top, H = M - 1 - h.padInfo.left; for (let e = 0; e < E; ++e)for (let t = 0; t < F; ++t)for (let n = 0; n < D; ++n) { const r = n - V, i = Math.max(0, Math.ceil(r / j)), a = Math.min(z, (N + r) / j); for (let o = 0; o < $; ++o) { const s = o - G, u = Math.max(0, Math.ceil(s / U)), l = Math.min(B, (I + s) / U); for (let c = 0; c < R; ++c) { const h = c - H, d = Math.max(0, Math.ceil(h / W)), E = Math.min(L, (M + h) / W); let F = 0; for (let n = i; n < a; ++n) { const i = n * j - r; for (let r = u; r < l; ++r) { const a = r * U - s; for (let o = d; o < E; ++o) { const s = v * e + x * n + w * r + k * o, u = _ * (N - 1 - i) + C * (I - 1 - a) + A * (M - 1 - (o * W - h)) + T * t; for (let e = 0; e < O; ++e) { F += b[s + e] * S[u + e] } } } } f[p * e + m * n + g * o + y * c + t] = F } } } return n.makeTensorInfo(d.shape, d.dtype, d.values) }
}, Uy = Fp(P.Cos, (e => Math.cos(e))), Wy = { kernelName: P.Cos, backendName: "cpu", kernelFunc: Uy }, Vy = Fp(P.Cosh, (e => Math.cosh(e))), Gy = { kernelName: P.Cosh, backendName: "cpu", kernelFunc: Vy }; const Hy = {
kernelName: P.CropAndResize, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i, boxes: a, boxInd: o } = t, { cropSize: s, method: u, extrapolationValue: l } = r, [c, h, d, f] = i.shape, p = a.shape[0], [m, g] = s, y = (0, P.buffer)([p, m, g, f], "float32"), b = n.data.get(a.dataId).values, v = n.data.get(o.dataId).values, x = n.data.get(i.dataId).values, w = P.util.computeStrides(i.shape), k = P.util.computeStrides(y.shape); for (let e = 0; e < p; e++) { const t = 4 * e, n = b[t], r = b[t + 1], i = b[t + 2], a = b[t + 3], o = v[e]; if (o >= c) continue; const s = m > 1 ? (i - n) * (h - 1) / (m - 1) : 0, p = g > 1 ? (a - r) * (d - 1) / (g - 1) : 0; for (let t = 0; t < m; t++) { const c = m > 1 ? n * (h - 1) + t * s : .5 * (n + i) * (h - 1); if (c < 0 || c > h - 1) for (let n = 0; n < g; n++)for (let r = 0; r < f; r++) { const i = r + n * k[2] + t * k[1] + e * k[0]; y.values[i] = l } else if ("bilinear" === u) { const n = Math.floor(c), i = Math.ceil(c), s = c - n; for (let u = 0; u < g; u++) { const c = g > 1 ? r * (d - 1) + u * p : .5 * (r + a) * (d - 1); if (c < 0 || c > d - 1) { for (let n = 0; n < f; n++) { const r = n + u * k[2] + t * k[1] + e * k[0]; y.values[r] = l } continue } const h = Math.floor(c), m = Math.ceil(c), b = c - h; for (let r = 0; r < f; r++) { let a = r + h * w[2] + n * w[1] + o * w[0]; const l = x[a]; a = r + m * w[2] + n * w[1] + o * w[0]; const c = x[a]; a = r + h * w[2] + i * w[1] + o * w[0]; const d = x[a]; a = r + m * w[2] + i * w[1] + o * w[0]; const f = l + (c - l) * b, p = d + (x[a] - d) * b; a = r + u * k[2] + t * k[1] + e * k[0], y.values[a] = f + (p - f) * s } } } else for (let n = 0; n < g; ++n) { const i = g > 1 ? r * (d - 1) + n * p : .5 * (r + a) * (d - 1); if (i < 0 || i > d - 1) { for (let r = 0; r < f; r++) { const i = r + n * k[2] + t * k[1] + e * k[0]; y.values[i] = l } continue } const s = Math.round(i), u = Math.round(c); for (let r = 0; r < f; r++) { const i = r + s * w[2] + u * w[1] + o * w[0], a = r + n * k[2] + t * k[1] + e * k[0]; y.values[a] = x[i] } } } } return n.makeTensorInfo(y.shape, y.dtype, y.values) }
}; const qy = {
kernelName: P.Cumprod, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; ip(i, "cumprod"); const u = P.backend_util.getAxesPermutation([a], i.shape.length); let l = i; null != u && (l = $m({ inputs: { x: i }, backend: n, attrs: { perm: u } })); const c = P.backend_util.getInnerMostAxes(1, i.shape.length)[0]; if (c !== l.shape.length - 1) throw new Error(`backend.cumprod in CPU expects an inner-most axis=${l.shape.length - 1} but got axis=${c}`); const h = (0, P.upcastType)(l.dtype, "int32"), d = P.util.makeOnesTypedArray(P.util.sizeFromShape(l.shape), h), f = n.data.get(l.dataId).values, p = l.shape[l.shape.length - 1], m = s ? (e, t) => e + p - t - 1 : (e, t) => e + t; for (let e = 0; e < f.length; e += p)for (let t = 0; t < p; t++) { const n = m(e, t); if (0 === t) d[n] = o ? 1 : f[n]; else { const r = m(e, t - 1); d[n] = o ? f[r] * d[r] : f[n] * d[r] } } const g = n.makeTensorInfo(l.shape, h, d); if (null != u) { const e = $m({ inputs: { x: g }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(u) } }); return n.disposeIntermediateTensorInfo(g), n.disposeIntermediateTensorInfo(l), e } return g }
}; const Yy = {
kernelName: P.Cumsum, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; ip(i, "cumsum"); const u = P.backend_util.getAxesPermutation([a], i.shape.length); let l = i; null != u && (l = $m({ inputs: { x: i }, backend: n, attrs: { perm: u } })); const c = P.backend_util.getInnerMostAxes(1, i.shape.length)[0]; if (c !== l.shape.length - 1) throw new Error(`backend.cumsum in CPU expects an inner-most axis=${l.shape.length - 1} but got axis=${c}`); const h = (0, P.upcastType)(l.dtype, "int32"), d = P.util.makeZerosTypedArray(P.util.sizeFromShape(l.shape), h), f = n.data.get(l.dataId).values, p = l.shape[l.shape.length - 1], m = s ? (e, t) => e + p - t - 1 : (e, t) => e + t; for (let e = 0; e < f.length; e += p)for (let t = 0; t < p; t++) { const n = m(e, t); if (0 === t) d[n] = o ? 0 : f[n]; else { const r = m(e, t - 1); d[n] = o ? f[r] + d[r] : f[n] + d[r] } } const g = n.makeTensorInfo(l.shape, h, d); if (null != u) { const e = $m({ inputs: { x: g }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(u) } }); return n.disposeIntermediateTensorInfo(g), n.disposeIntermediateTensorInfo(l), e } return g }
}; const Xy = {
kernelName: P.DenseBincount, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o, binaryOutput: s } = r; if (1 === i.shape.length) { const e = Ap(n.data.get(i.dataId).values, n.data.get(a.dataId).values, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, e) } if (2 === i.shape.length) { const e = Tp(n.bufferSync(i), n.bufferSync(a), o, s); return n.makeTensorInfo(e.shape, a.dtype, e.values) } throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`) }
}; const Ky = {
kernelName: P.DepthToSpace, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockSize: a, dataFormat: o } = r; P.util.assert("NHWC" === o, (() => `Only NHWC dataFormat supported on CPU for depthToSpace. Got ${o}`)); const s = i.shape[0], u = i.shape[1], l = i.shape[2], c = i.shape[3], h = u * a, d = l * a, f = c / (a * a), p = n.data.get(i.dataId).values, m = new Float32Array(s * h * d * f); let g = 0; for (let e = 0; e < s; ++e)for (let t = 0; t < h; ++t) { const n = Math.floor(t / a), r = t % a; for (let t = 0; t < d; ++t) { const i = Math.floor(t / a), o = (r * a + t % a) * f; for (let t = 0; t < f; ++t) { const r = t + o + c * (i + l * (n + u * e)); m[g++] = p[r] } } } return n.makeTensorInfo([s, h, d, f], i.dtype, m) }
};
/**
* @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 Zy(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u, dimRoundingMode: l } = r; ip([i, a], "depthwiseConv2DNative"); const c = P.util.computeStrides(i.shape), h = P.util.computeStrides(a.shape); let d = u; null == d && (d = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, d), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${d}'`)); const f = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, d, s, l, !0), { filterHeight: p, filterWidth: m, dilationHeight: g, dilationWidth: y, padInfo: b } = f, v = b.left, x = b.top, w = f.outChannels / f.inChannels, k = new P.TensorBuffer(f.outShape, i.dtype), S = n.data.get(i.dataId).values, _ = n.data.get(a.dataId).values, C = k.values; for (let e = 0; e < f.batchSize; ++e) { const t = e * c[0], n = e * k.strides[0]; for (let e = 0; e < f.outHeight; ++e) { const r = n + e * k.strides[1], i = e * f.strideHeight - x; for (let e = 0; e < p; ++e) { const n = i + e * g; if (n < 0 || n >= f.inHeight) continue; const a = e * h[0], o = t + n * c[1]; for (let e = 0; e < f.outWidth; ++e) { const t = r + e * k.strides[2], n = e * f.strideWidth - v; for (let e = 0; e < m; ++e) { const r = n + e * y; if (r < 0 || r >= f.inWidth) continue; const i = a + e * h[1], s = o + r * f.inChannels; let u = t, l = i; for (let e = 0; e < f.inChannels; ++e) { const t = S[s + e]; for (let e = 0; e < w; ++e)C[u + e] += t * _[l + e]; u += w, l += w } } } } } } return n.makeTensorInfo(k.shape, k.dtype, k.values) } const Jy = { kernelName: P.DepthwiseConv2dNative, backendName: "cpu", kernelFunc: Zy }; const Qy = {
kernelName: P.DepthwiseConv2dNativeBackpropFilter, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, filterShape: c } = r; ip([i, a], "depthwiseConv2dNativeBackpropFilter"); const h = P.backend_util.computeConv2DInfo(i.shape, c, o, s, u, l, !0), { strideHeight: d, strideWidth: f, filterHeight: p, filterWidth: m } = h, g = new P.TensorBuffer(h.filterShape, "float32"), y = h.padInfo.left, b = h.padInfo.top, v = h.outChannels / h.inChannels, x = n.data.get(i.dataId).values, w = new P.TensorBuffer(i.shape, i.dtype, x), k = n.data.get(a.dataId).values, S = new P.TensorBuffer(a.shape, a.dtype, k); for (let e = 0; e < p; ++e) { const t = Math.max(0, Math.ceil((b - e) / d)), n = Math.min(h.outHeight, (h.inHeight + b - e) / d); for (let r = 0; r < m; ++r) { const i = Math.max(0, Math.ceil((y - r) / f)), a = Math.min(h.outWidth, (h.inWidth + y - r) / f); for (let o = 0; o < h.outChannels; ++o) { const s = Math.trunc(o / v), u = o % v; let l = 0; for (let u = 0; u < h.batchSize; ++u)for (let c = t; c < n; ++c) { const t = e + c * d - b; for (let e = i; e < a; ++e) { const n = r + e * f - y; l += w.get(u, t, n, s) * S.get(u, c, e, o) } } g.set(l, e, r, s, u) } } } return n.makeTensorInfo(g.shape, g.dtype, g.values) }
}; const eb = {
kernelName: P.DepthwiseConv2dNativeBackpropInput, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, inputShape: c } = r; ip([i, a], "depthwiseConv2DNativeBackpropInput"); const h = P.util.computeStrides(i.shape), d = P.util.computeStrides(a.shape), f = P.backend_util.computeConv2DInfo(c, a.shape, o, s, u, l, !0), p = new P.TensorBuffer(f.inShape, "float32"), m = p.values, [g, y, b] = p.strides, v = n.data.get(i.dataId).values, [x, w, k] = h, S = n.data.get(a.dataId).values, [_, C, A] = d, { batchSize: T, filterHeight: E, filterWidth: N, inChannels: I, inHeight: M, inWidth: F, outChannels: D, outHeight: $, outWidth: R, strideHeight: O, strideWidth: z } = f, B = E - 1 - f.padInfo.top, L = N - 1 - f.padInfo.left, j = D / I; for (let e = 0; e < T; ++e)for (let t = 0; t < I; ++t)for (let n = 0; n < M; ++n) { const r = n - B, i = Math.max(0, Math.ceil(r / O)), a = Math.min($, (E + r) / O); for (let o = 0; o < F; ++o) { const s = o - L, u = Math.max(0, Math.ceil(s / z)), l = Math.min(R, (N + s) / z); let c = 0; for (let n = i; n < a; ++n) { const i = n * O - r; for (let r = u; r < l; ++r) { const a = x * e + w * n + k * r, o = _ * (E - 1 - i) + C * (N - 1 - (r * z - s)) + A * t; for (let e = 0; e < j; ++e) { c += v[a + (t * j + e)] * S[o + e] } } } m[g * e + y * n + b * o + t] = c } } return n.makeTensorInfo(p.shape, p.dtype, p.values) }
}; const tb = {
kernelName: P.Diag, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = P.util.sizeFromShape(r.shape), a = n.data.get(r.dataId).values, o = (0, P.buffer)([i, i], r.dtype), s = o.values; for (let e = 0; e < a.length; e++)s[e * i + e] = a[e]; const u = [...r.shape, ...r.shape]; return n.makeTensorInfo(u, o.dtype, o.values) }
}, nb = { kernelName: P.Dilation2D, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i } = e, { strides: a, pad: o, dilations: s } = n, u = t, l = u.data.get(r.dataId).values, c = r.shape.length, h = u.data.get(i.dataId).values, d = i.shape.length, { batchSize: f, inHeight: p, inWidth: m, inChannels: g, outHeight: y, outWidth: b, padInfo: v, strideHeight: x, strideWidth: w, filterHeight: k, filterWidth: S, dilationHeight: _, dilationWidth: C, outShape: A } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, a, o, "NHWC", s), T = P.util.sizeFromShape(A), E = A.length, N = P.util.getArrayFromDType(r.dtype, T); for (let e = 0; e < f; ++e)for (let t = 0; t < y; ++t) { const n = t * x - v.top; for (let a = 0; a < b; ++a) { const o = a * w - v.left; for (let s = 0; s < g; ++s) { let u = Number.MIN_SAFE_INTEGER; for (let t = 0; t < k; ++t) { const a = n + t * _; if (a >= 0 && a < p) for (let n = 0; n < S; ++n) { const f = o + n * C; if (f >= 0 && f < m) { const o = P.util.locToIndex([e, a, f, s], c, P.util.computeStrides(r.shape)), p = P.util.locToIndex([t, n, s], d, P.util.computeStrides(i.shape)), m = l[o] + h[p]; m > u && (u = m) } } } N[P.util.locToIndex([e, t, a, s], E, P.util.computeStrides(A))] = u } } } return { dataId: u.write(P.util.toTypedArray(N, r.dtype), A, r.dtype), shape: A, dtype: r.dtype } } }, rb = { kernelName: P.Dilation2DBackpropFilter, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i, dy: a } = e, { strides: o, pad: s, dilations: u } = n, l = t, c = P.util.toNestedArray(r.shape, l.data.get(r.dataId).values), h = P.util.toNestedArray(i.shape, l.data.get(i.dataId).values), { batchSize: d, inHeight: f, inWidth: p, inChannels: m, outHeight: g, outWidth: y, padInfo: b, strideHeight: v, strideWidth: x, filterHeight: w, filterWidth: k, dilationHeight: S, dilationWidth: _, outShape: C } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, o, s, "NHWC", u); P.util.assert(a.rank === C.length, (() => `Error in ${P.Dilation2DBackpropFilter}, dy must have the same rank as output ${C.length}, but got ${a.rank}`)); const A = P.util.toNestedArray(C, l.data.get(a.dataId).values), T = P.util.makeZerosNestedTypedArray(i.shape, i.dtype); for (let e = 0; e < d; ++e)for (let t = 0; t < g; ++t) { const n = t * v - b.top; for (let r = 0; r < y; ++r) { const i = r * x - b.left; for (let a = 0; a < m; ++a) { let o = Number.MIN_SAFE_INTEGER, s = 0, u = 0; for (let t = 0; t < w; ++t) { const r = n + t * S; if (r >= 0 && r < f) for (let n = 0; n < k; ++n) { const l = i + n * _; if (l >= 0 && l < p) { const i = c[e][r][l][a] + h[t][n][a]; i > o && (o = i, s = t, u = n) } } } T[s][u][a] += A[e][t][r][a] } } } return { dataId: l.write(P.util.toTypedArray(T, r.dtype), i.shape, i.dtype), shape: i.shape, dtype: i.dtype } } }, ib = { kernelName: P.Dilation2DBackpropInput, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, filter: i, dy: a } = e, { strides: o, pad: s, dilations: u } = n, l = t, c = P.util.toNestedArray(r.shape, l.data.get(r.dataId).values), h = P.util.toNestedArray(i.shape, l.data.get(i.dataId).values), { batchSize: d, inHeight: f, inWidth: p, inChannels: m, outHeight: g, outWidth: y, padInfo: b, strideHeight: v, strideWidth: x, filterHeight: w, filterWidth: k, dilationHeight: S, dilationWidth: _, outShape: C } = P.backend_util.computeDilation2DInfo(r.shape, i.shape, o, s, "NHWC", u); P.util.assert(a.rank === C.length, (() => `Error in ${P.Dilation2DBackpropInput}, dy must have the same rank as output ${C.length}, but got ${a.rank}`)); const A = P.util.toNestedArray(C, l.data.get(a.dataId).values), T = P.util.makeZerosNestedTypedArray(r.shape, r.dtype); for (let e = 0; e < d; ++e)for (let t = 0; t < g; ++t) { const n = t * v - b.top; for (let r = 0; r < y; ++r) { const i = r * x - b.left; for (let a = 0; a < m; ++a) { let o = Number.MIN_SAFE_INTEGER, s = n < 0 ? 0 : n, u = i < 0 ? 0 : i; for (let t = 0; t < w; ++t) { const r = n + t * S; if (r >= 0 && r < f) for (let n = 0; n < k; ++n) { const l = i + n * _; if (l >= 0 && l < p) { const i = c[e][r][l][a] + h[t][n][a]; i > o && (o = i, s = r, u = l) } } } T[e][s][u][a] += A[e][t][r][a] } } } return { dataId: l.write(P.util.toTypedArray(T, r.dtype), r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }; const ab = {
kernelName: P.Draw, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i } = t, { canvas: a, options: o } = r, { contextOptions: s, imageOptions: u } = o || {}, l = (null == u ? void 0 : u.alpha) || 1, c = (null == s ? void 0 : s.contextType) || "2d"; if ("2d" !== c) throw new Error(`Context type ${s.contextType} is not supported by the CPU backend.`); const h = a.getContext(c, (null == s ? void 0 : s.contextAttributes) || {}); if (null == h) throw new Error(`Could not get the context with ${c} type.`); const [d, f] = i.shape.slice(0, 2), p = 2 === i.shape.length ? 1 : i.shape[2], m = n.data.get(i.dataId).values, g = "float32" === i.dtype ? 255 : 1, y = new Uint8ClampedArray(f * d * 4); for (let e = 0; e < d * f; ++e) { const t = [0, 0, 0, 255 * l]; for (let n = 0; n < p; n++) { const r = m[e * p + n]; if ("float32" === i.dtype) { if (r < 0 || r > 1) throw new Error(`Tensor values for a float32 Tensor must be in the range [0 - 1] but encountered ${r}.`) } else if ("int32" === i.dtype && (r < 0 || r > 255)) throw new Error(`Tensor values for a int32 Tensor must be in the range [0 - 255] but encountered ${r}.`); 1 === p ? (t[0] = r * g, t[1] = r * g, t[2] = r * g) : t[n] = r * g } const n = 4 * e; y[n + 0] = Math.round(t[0]), y[n + 1] = Math.round(t[1]), y[n + 2] = Math.round(t[2]), y[n + 3] = Math.round(t[3]) } a.width = f, a.height = d; const b = new ImageData(y, f, d); return h.putImageData(b, 0, 0), i }
};
/**
* @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 ob(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; let s; ip(i, "sum"), s = "bool" === i.dtype ? bp({ inputs: { x: i }, backend: n, attrs: { dtype: "int32" } }) : fp({ inputs: { x: i }, backend: n }); const u = s.shape.length, l = P.util.parseAxisParam(a, s.shape), c = P.backend_util.getAxesPermutation(l, u); let h = l, d = s; null != c && (d = $m({ inputs: { x: s }, backend: n, attrs: { perm: c } }), h = P.backend_util.getInnerMostAxes(h.length, u)), P.backend_util.assertAxesAreInnerMostDims("sum", h, d.shape.length); const [f, p] = P.backend_util.computeOutAndReduceShapes(d.shape, h); let m = dp(n, f, P.backend_util.upcastType(d.dtype, "int32")); const g = P.util.sizeFromShape(p), y = n.data.get(m.dataId).values, b = n.data.get(d.dataId).values; for (let e = 0; e < y.length; ++e) { const t = e * g; let n = 0; for (let e = 0; e < g; ++e)n += b[t + e]; y[e] = n } if (o) { const e = m; m = Hg({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(m.shape, l) } }), n.disposeIntermediateTensorInfo(e) } return n.disposeIntermediateTensorInfo(s), null != c && n.disposeIntermediateTensorInfo(d), m } const sb = { kernelName: P.Sum, backendName: "cpu", kernelFunc: ob }; const ub = {
kernelName: P.Einsum, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { equation: i } = r, a = t, { allDims: o, summedDims: s, idDims: u } = P.backend_util.decodeEinsumEquation(i, a.length); P.backend_util.checkEinsumDimSizes(o.length, u, a); const { path: l, steps: c } = P.backend_util.getEinsumComputePath(s, u), h = c.length; let d = null, f = o.length; const p = []; for (let e = 0; e < h; ++e) { for (const t of c[e]) { const { permutationIndices: e, expandDims: r } = P.backend_util.getEinsumPermutation(f, u[t]); let i; P.backend_util.isIdentityPermutation(e) ? i = a[t] : (i = $m({ inputs: { x: a[t] }, backend: n, attrs: { perm: e } }), p.push(i)); const o = i.shape.slice(); for (let e = 0; e < r.length; ++e)o.splice(r[e], 0, 1); P.util.arraysEqual(i.shape, o) || (i = Hg({ inputs: { x: i }, backend: n, attrs: { shape: o } }), p.push(i)), null === d ? d = i : (d = Am({ inputs: { a: i, b: d }, backend: n }), p.push(d)) } e < h - 1 && (l[e] >= 0 && (d = ob({ inputs: { x: d }, backend: n, attrs: { axis: l[e] - (o.length - f), keepDims: !1 } }), p.push(d)), f--) } for (const e of p) e !== d && n.disposeIntermediateTensorInfo(e); return d }
}; const lb = {
kernelName: P.EluGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { dy: r, y: i } = t; ip([r, i], "eluGrad"); const a = new Float32Array(P.util.sizeFromShape(i.shape)), o = n.data.get(i.dataId).values, s = n.data.get(r.dataId).values; for (let e = 0; e < o.length; ++e) { const t = o[e]; a[e] = t >= 0 ? s[e] : s[e] * (t + 1) } return n.makeTensorInfo(i.shape, "float32", a) }
}, cb = P.backend_util.ERF_P, hb = P.backend_util.ERF_A1, db = P.backend_util.ERF_A2, fb = P.backend_util.ERF_A3, pb = P.backend_util.ERF_A4, mb = P.backend_util.ERF_A5, gb = Fp(P.Erf, (e => { const t = Math.sign(e), n = Math.abs(e), r = 1 / (1 + cb * n); return t * (1 - ((((mb * r + pb) * r + fb) * r + db) * r + hb) * r * Math.exp(-n * n)) })), yb = { kernelName: P.Erf, backendName: "cpu", kernelFunc: gb };
/**
* @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 bb(e) { const { inputs: t, backend: n, attrs: r } = e, { input: i } = t, { dim: a } = r, o = i.shape.length, s = i.shape.slice(); let u = a; return a < 0 && (P.util.assert(-(o + 1) <= a, (() => `Axis must be in the interval [${-(o + 1)}, ${o}]`)), u = o + a + 1), s.splice(u, 0, 1), Hg({ inputs: { x: i }, backend: n, attrs: { shape: s } }) } const vb = { kernelName: P.ExpandDims, backendName: "cpu", kernelFunc: bb }, xb = lp(((e, t) => e / t)), wb = xp(P.RealDiv, xb), kb = { kernelName: P.RealDiv, backendName: "cpu", kernelFunc: wb };
/**
* @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 Sb(e, t, n) { const r = e.shape, i = r[0], a = r[1], o = n.data.get(e.dataId), s = o.complexTensorInfos.real, u = o.complexTensorInfos.imag, l = [i, a], c = P.util.sizeFromShape(l), h = P.util.getTypedArrayFromDType("float32", c), d = P.util.getTypedArrayFromDType("float32", c); for (let e = 0; e < i; e++) { const r = ig({ inputs: { x: s }, backend: n, attrs: { begin: [e, 0], size: [1, a] } }), i = ig({ inputs: { x: u }, backend: n, attrs: { begin: [e, 0], size: [1, a] } }), o = cp({ inputs: { real: r, imag: i }, backend: n }), { real: l, imag: c } = _b(o, t, n), f = P.backend_util.mergeRealAndImagArrays(l, c); for (let t = 0; t < a; t++) { const n = P.backend_util.getComplexWithIndex(f, t); h[e * a + t] = n.real, d[e * a + t] = n.imag } n.disposeIntermediateTensorInfo(r), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(o) } const f = n.makeTensorInfo(l, "float32", h), p = n.makeTensorInfo(l, "float32", d), m = cp({ inputs: { real: f, imag: p }, backend: n }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), m } function _b(e, t, n) { const r = P.util.sizeFromShape(e.shape), i = n.data.get(e.dataId), a = n.data.get(i.complexTensorInfos.real.dataId).values, o = n.data.get(i.complexTensorInfos.imag.dataId).values; if ((s = r) & s - 1) { const e = function (e, t, n) { const r = new Float32Array(2 * t); for (let i = 0; i < t; i++) { let a = 0, o = 0; for (let r = 0; r < t; r++) { const s = P.backend_util.exponent(i * r, t, n), u = P.backend_util.getComplexWithIndex(e, r); a += u.real * s.real - u.imag * s.imag, o += u.real * s.imag + u.imag * s.real } n && (a /= t, o /= t), P.backend_util.assignToTypedArray(r, a, o, i) } return r }(P.backend_util.mergeRealAndImagArrays(a, o), r, t); return P.backend_util.splitRealAndImagArrays(e) } { const i = Cb(a, o, r, t, n), s = [e.shape[0], e.shape[1]]; if (t) { const e = n.makeTensorInfo(s, "float32", i.real), t = n.makeTensorInfo(s, "float32", i.imag), a = n.makeTensorInfo([], "float32", P.util.createScalarValue(r, "float32")), o = fp({ inputs: { x: a }, backend: n }), u = kb.kernelFunc({ inputs: { a: e, b: a }, backend: n }), l = kb.kernelFunc({ inputs: { a: t, b: o }, backend: n }), c = n.data.get(u.dataId).values, h = n.data.get(l.dataId).values; return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(u), n.disposeIntermediateTensorInfo(l), { real: c, imag: h } } return i } var s } function Cb(e, t, n, r, i) { if (1 === n) return { real: e, imag: t }; const a = P.backend_util.mergeRealAndImagArrays(e, t), o = n / 2, s = P.backend_util.complexWithEvenIndex(a), u = s.real, l = s.imag, c = [u.length], h = i.makeTensorInfo(c, "float32", u), d = i.makeTensorInfo(c, "float32", l), f = cp({ inputs: { real: h, imag: d }, backend: i }), p = P.backend_util.complexWithOddIndex(a), m = p.real, g = p.imag, y = [m.length], b = i.makeTensorInfo(y, "float32", m), v = i.makeTensorInfo(y, "float32", g), x = cp({ inputs: { real: b, imag: v }, backend: i }), w = Cb(u, l, o, r, i), k = w.real, S = w.imag, _ = [k.length], C = i.makeTensorInfo(_, "float32", k), A = i.makeTensorInfo(_, "float32", S), T = cp({ inputs: { real: C, imag: A }, backend: i }), E = Cb(m, g, o, r, i), N = E.real, I = E.imag, M = [N.length], F = i.makeTensorInfo(M, "float32", N), D = i.makeTensorInfo(M, "float32", I), $ = cp({ inputs: { real: F, imag: D }, backend: i }), R = P.backend_util.exponents(n, r), O = [R.real.length], z = i.makeTensorInfo(O, "float32", R.real), B = i.makeTensorInfo(O, "float32", R.imag), L = cp({ inputs: { real: z, imag: B }, backend: i }), j = Am({ inputs: { a: L, b: $ }, backend: i }), U = _p({ inputs: { a: T, b: j }, backend: i }), W = Ag({ inputs: { a: T, b: j }, backend: i }), V = mp({ inputs: { input: U }, backend: i }), G = mp({ inputs: { input: W }, backend: i }), H = My({ inputs: { input: U }, backend: i }), q = My({ inputs: { input: W }, backend: i }), Y = Dy({ inputs: [V, G], backend: i, attrs: { axis: 0 } }), X = Dy({ inputs: [H, q], backend: i, attrs: { axis: 0 } }), K = i.data.get(Y.dataId).values, Z = i.data.get(X.dataId).values; return i.disposeIntermediateTensorInfo(h), i.disposeIntermediateTensorInfo(d), i.disposeIntermediateTensorInfo(f), i.disposeIntermediateTensorInfo(b), i.disposeIntermediateTensorInfo(v), i.disposeIntermediateTensorInfo(x), i.disposeIntermediateTensorInfo(C), i.disposeIntermediateTensorInfo(A), i.disposeIntermediateTensorInfo(T), i.disposeIntermediateTensorInfo(F), i.disposeIntermediateTensorInfo(D), i.disposeIntermediateTensorInfo($), i.disposeIntermediateTensorInfo(z), i.disposeIntermediateTensorInfo(B), i.disposeIntermediateTensorInfo(L), i.disposeIntermediateTensorInfo(j), i.disposeIntermediateTensorInfo(U), i.disposeIntermediateTensorInfo(W), i.disposeIntermediateTensorInfo(V), i.disposeIntermediateTensorInfo(H), i.disposeIntermediateTensorInfo(G), i.disposeIntermediateTensorInfo(q), i.disposeIntermediateTensorInfo(Y), i.disposeIntermediateTensorInfo(X), { real: K, imag: Z } } const Ab = {
kernelName: P.FFT, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { input: r } = t, i = P.util.sizeFromShape(r.shape), a = r.shape[r.shape.length - 1], o = Hg({ inputs: { x: r }, backend: n, attrs: { shape: [i / a, a] } }), s = Sb(o, !1, n), u = Hg({ inputs: { x: s }, backend: n, attrs: { shape: r.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(s), u }
};
/**
* @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 Tb(e) { const { backend: t, attrs: n } = e, { shape: r, value: i, dtype: a } = n, o = a || P.util.inferDtype(i), s = P.util.getArrayFromDType(o, P.util.sizeFromShape(r)); return function (e, t) { e.fill(t) }(s, i), t.makeTensorInfo(r, o, s) } const Eb = { kernelName: P.Fill, backendName: "cpu", kernelFunc: Tb };
/**
* @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.
* =============================================================================
*/
const Nb = { kernelName: P.FlipLeftRight, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, i = n, a = P.util.getTypedArrayFromDType(r.dtype, P.util.sizeFromShape(r.shape)), [o, s, u, l] = r.shape, c = i.data.get(r.dataId).values; for (let e = 0; e < o; e++) { const t = e * u * s * l; for (let e = 0; e < s; e++) { const n = e * (u * l); for (let e = 0; e < u; e++) { const r = e * l; for (let i = 0; i < l; i++) { const o = Math.round(u - e - 1), s = t + n + r + i; let h = c[s]; if (o >= 0 && o < u) { h = c[t + n + o * l + i] } a[s] = h } } } } return { dataId: i.write(a, r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }; const Ib = {
kernelName: P.FusedConv2D, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r; let m = Ry({ inputs: { x: i, filter: a }, backend: n, attrs: { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d } }); if (o) { const e = m; if ("NCHW" === c && 1 === o.shape.length && 1 !== o.shape[0]) { const e = Hg({ inputs: { x: o }, backend: n, attrs: { shape: [o.shape[0], 1, 1] } }); m = _p({ inputs: { a: m, b: e }, backend: n }), n.disposeIntermediateTensorInfo(e) } else m = _p({ inputs: { a: m, b: o }, backend: n }); n.disposeIntermediateTensorInfo(e) } if (f) { const e = m; if ("NCHW" === c && "prelu" === f && 1 === s.shape.length && 1 !== s.shape[0]) { const e = Hg({ inputs: { x: s }, backend: n, attrs: { shape: [s.shape[0], 1, 1] } }); m = Gg(n, m, f, e, p), n.disposeIntermediateTensorInfo(e) } else m = Gg(n, m, f, s, p); n.disposeIntermediateTensorInfo(e) } return m }
}; const Mb = {
kernelName: P.FusedDepthwiseConv2D, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r; let m = Zy({ inputs: { x: i, filter: a }, backend: n, attrs: { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d } }); if (o) { const e = m; m = _p({ inputs: { a: m, b: o }, backend: n }), n.disposeIntermediateTensorInfo(e) } if (f) { const e = m; m = Gg(n, m, f, s, p), n.disposeIntermediateTensorInfo(e) } return m }
}; const Fb = {
kernelName: P.GatherNd, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { params: r, indices: i } = t, a = P.util.sizeFromShape(r.shape), o = i.shape, s = o[o.length - 1], [u, l, c, h] = P.backend_util.prepareAndValidate(r, i); if (0 === l) return n.makeTensorInfo(u, r.dtype, []); const d = Qp(n.data.get(i.dataId).values, n.bufferSync(r), r.dtype, l, s, c, h, r.shape, a); return n.makeTensorInfo(u, r.dtype, d.values) }
}; const Db = {
kernelName: P.GatherV2, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, indices: a } = t, { axis: o, batchDims: s } = r; ip([i, a], "gatherV2"); const u = P.util.parseAxisParam(o, i.shape)[0], l = n.data.get(a.dataId).values, c = i.shape[u]; for (let e = 0; e < l.length; ++e) { const t = l[e]; P.util.assert(t <= c - 1 && t >= 0, (() => `GatherV2: the index value ${t} is not in [0, ${c - 1}]`)) } let h = s; null == s && (h = 0); const d = P.util.sizeFromShape(a.shape), f = P.backend_util.segment_util.collectGatherOpShapeInfo(i, a, u, h), p = Hg({ inputs: { x: i }, backend: n, attrs: { shape: [f.batchSize, f.outerSize, f.dimSize, f.sliceSize] } }), m = Hg({ inputs: { x: a }, backend: n, attrs: { shape: [f.batchSize, d / f.batchSize] } }), g = [f.batchSize, f.outerSize, d / f.batchSize, f.sliceSize], y = n.bufferSync(m), b = em(n.bufferSync(p), y, g); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), n.makeTensorInfo(f.outputShape, b.dtype, b.values) }
}; const $b = {
kernelName: P.IFFT, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { input: r } = t, i = P.util.sizeFromShape(r.shape), a = r.shape[r.shape.length - 1], o = Hg({ inputs: { x: r }, backend: n, attrs: { shape: [i / a, a] } }), s = Sb(o, !0, n), u = Hg({ inputs: { x: s }, backend: n, attrs: { shape: r.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(s), u }
}, Rb = Fp(P.IsFinite, (e => Number.isFinite(e) ? 1 : 0), "bool"), Ob = { kernelName: P.IsFinite, backendName: "cpu", kernelFunc: Rb }, zb = Fp(P.IsInf, (e => Math.abs(e) === 1 / 0 ? 1 : 0), "bool"), Pb = { kernelName: P.IsInf, backendName: "cpu", kernelFunc: zb }, Bb = Fp(P.IsNan, (e => Number.isNaN(e) ? 1 : 0), "bool"), Lb = { kernelName: P.IsNan, backendName: "cpu", kernelFunc: Bb }; const jb = {
kernelName: P.LinSpace, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, num: a } = n, o = fm(r, i, a); return t.makeTensorInfo([o.length], "float32", o) }
}, Ub = Fp(P.Log1p, (e => Math.log1p(e))), Wb = { kernelName: P.Log1p, backendName: "cpu", kernelFunc: Ub }, Vb = lp(((e, t) => e && t)), Gb = xp(P.LogicalAnd, Vb, null, "bool"), Hb = { kernelName: P.LogicalAnd, backendName: "cpu", kernelFunc: Gb }, qb = Fp(P.LogicalNot, (e => e ? 0 : 1), "bool"), Yb = { kernelName: P.LogicalNot, backendName: "cpu", kernelFunc: qb }, Xb = lp(((e, t) => e || t)), Kb = xp(P.LogicalOr, Xb, null, "bool"), Zb = { kernelName: P.LogicalOr, backendName: "cpu", kernelFunc: Kb }; const Jb = {
kernelName: P.LRN, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { depthRadius: a, bias: o, alpha: s, beta: u } = r; ip(i, "LRN"); const l = i.shape[3], c = l - 1, h = n.data.get(i.dataId).values, d = P.util.sizeFromShape(i.shape), f = new Float32Array(d); function p(e) { const t = e % l; let n = e - t + Math.max(0, t - a); const r = e - t + Math.min(t + a, c); let i = 0; for (; n <= r; n++) { const e = h[n]; i += e * e } return i } for (let e = 0; e < d; e++) { const t = p(e), n = h[e] * Math.pow(o + s * t, -u); f[e] = n } return n.makeTensorInfo(i.shape, i.dtype, f) }
}; const Qb = {
kernelName: P.LRNGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, y: a, dy: o } = t, { depthRadius: s, bias: u, alpha: l, beta: c } = r; ip(o, "LRNGrad"); const h = P.util.sizeFromShape(o.shape), d = o.shape[3], f = n.data.get(o.dataId).values, p = n.data.get(i.dataId).values, m = n.data.get(a.dataId).values, g = new Float32Array(h), y = h; for (let e = 0; e < y; e++) { const t = e % d, n = e - t + Math.max(0, t - s), r = e - t + Math.min(d, t + s + 1); let i = 0; for (let e = n; e < r; e++)i += Math.pow(p[e], 2); i = l * i + u; for (let t = n; t < r; t++) { let n = -2 * l * c * p[t] * m[e] / i; e === t && (n += Math.pow(i, -c)), n *= f[e], g[t] += n } } return n.makeTensorInfo(o.shape, i.dtype, g) }
};
/**
* @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 ev(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reductionIndices: a, keepDims: o } = r, s = n; let u = i.shape; const l = u.length, c = P.util.parseAxisParam(a, u); let h = c; const d = P.backend_util.getAxesPermutation(h, l); let f = s.data.get(i.dataId).values; if (null != d) { const e = new Array(l); for (let t = 0; t < e.length; t++)e[t] = u[d[t]]; f = Dm(f, u, i.dtype, d, e), h = P.backend_util.getInnerMostAxes(h.length, l), u = e } ip(i, "max"), P.backend_util.assertAxesAreInnerMostDims("max", h, l); const [p, m] = P.backend_util.computeOutAndReduceShapes(u, h), g = ym(f, P.util.sizeFromShape(m), p, i.dtype), y = s.write(g, p, i.dtype); let b = p; if (o) { b = P.backend_util.expandShapeToKeepDim(p, c) } return { dataId: y, shape: b, dtype: i.dtype } } const tv = { kernelName: P.Max, backendName: "cpu", kernelFunc: ev }; const nv = {
kernelName: P.MaxPool, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; ip(i, "maxPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); let c; if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) c = fp({ inputs: { x: i }, backend: n }); else { const e = n.data.get(i.dataId).values, t = P.util.computeStrides(i.shape), r = yy(e, i.shape, i.dtype, t, l, "max"); c = n.makeTensorInfo(l.outShape, i.dtype, r.values) } return c }
}; const rv = {
kernelName: P.MaxPool3D, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r; ip(i, "maxPool3d"); const c = P.backend_util.computePool3DInfo(i.shape, a, o, 1, s, u, l), h = vy(n.data.get(i.dataId).values, i.shape, i.dtype, P.util.computeStrides(i.shape), c, "max"); return n.makeTensorInfo(h.shape, "float32", h.values) }
}; const iv = {
kernelName: P.MaxPool3DGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, { filterSize: o, strides: s, pad: u, dimRoundingMode: l } = r; ip([i, a], "maxPool3DGrad"); const c = P.backend_util.computePool3DInfo(a.shape, o, s, 1, u, l), h = function (e, t) { const n = (0, P.buffer)(t.outShape, "int32"), r = t.strideDepth, i = t.strideHeight, a = t.strideWidth, o = t.dilationDepth, s = t.dilationHeight, u = t.dilationWidth, l = t.effectiveFilterDepth, c = t.effectiveFilterHeight, h = t.effectiveFilterWidth, d = t.padInfo.front, f = t.padInfo.top, p = t.padInfo.left; for (let m = 0; m < t.batchSize; ++m)for (let g = 0; g < t.inChannels; ++g)for (let y = 0; y < t.outDepth; ++y) { const b = y * r - d; let v = b; for (; v < 0;)v += o; const x = Math.min(t.inDepth, l + b); for (let r = 0; r < t.outHeight; ++r) { const l = r * i - f; let d = l; for (; d < 0;)d += s; const w = Math.min(t.inHeight, c + l); for (let i = 0; i < t.outWidth; ++i) { const f = i * a - p; let k = f; for (; k < 0;)k += u; const S = Math.min(t.inWidth, h + f); let _ = Number.NEGATIVE_INFINITY, C = -1; for (let t = v; t < x; t += o) { const n = t - b; for (let r = d; r < w; r += s) { const i = r - l; for (let a = k; a < S; a += u) { const o = a - f, s = e.get(m, t, r, a, g); s >= _ && (_ = s, C = n * c * h + i * c + o) } } } n.set(C, m, y, r, i, g) } } } return n }(n.bufferSync(a), c), d = c.strideDepth, f = c.strideHeight, p = c.strideWidth, m = c.dilationDepth, g = c.dilationHeight, y = c.dilationWidth, b = c.effectiveFilterDepth, v = c.effectiveFilterHeight, x = c.effectiveFilterWidth, w = b - 1 - c.padInfo.front, k = x - 1 - c.padInfo.left, S = v - 1 - c.padInfo.top, _ = (0, P.buffer)(a.shape, "float32"), C = n.bufferSync(i); for (let e = 0; e < c.batchSize; ++e)for (let t = 0; t < c.inChannels; ++t)for (let n = 0; n < c.inDepth; ++n)for (let r = 0; r < c.inHeight; ++r)for (let i = 0; i < c.inWidth; ++i) { const a = n - w, o = r - S, s = i - k; let u = 0; for (let n = 0; n < b; n += m) { const r = (a + n) / d; if (!(r < 0 || r >= c.outDepth || Math.floor(r) !== r)) for (let i = 0; i < v; i += g) { const a = (o + i) / f; if (!(a < 0 || a >= c.outHeight || Math.floor(a) !== a)) for (let o = 0; o < x; o += y) { const l = (s + o) / p; if (l < 0 || l >= c.outWidth || Math.floor(l) !== l) continue; const d = b * v * x - 1 - h.get(e, r, a, l, t) === n * v * x + i * x + o ? 1 : 0; if (0 === d) continue; u += C.get(e, r, a, l, t) * d } } } _.set(u, e, n, r, i, t) } return n.makeTensorInfo(_.shape, _.dtype, _.values) }
}; const av = {
kernelName: P.MaxPoolGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a, output: o } = t, s = a; ip([a, o], "maxPoolGrad"); const { filterSize: u, strides: l, pad: c, dimRoundingMode: h } = r, d = P.backend_util.computePool2DInfo(s.shape, u, l, 1, c, h), f = n.data.get(s.dataId).values, p = (0, P.buffer)(d.outShape, s.dtype, by(f, s.shape, s.dtype, d).values), m = d.strideHeight, g = d.strideWidth, y = d.dilationHeight, b = d.dilationWidth, v = d.effectiveFilterHeight, x = d.effectiveFilterWidth, w = x - 1 - d.padInfo.left, k = v - 1 - d.padInfo.top, S = (0, P.buffer)(s.shape, "float32"), _ = n.data.get(i.dataId).values, C = (0, P.buffer)(i.shape, "float32", _); for (let e = 0; e < d.batchSize; ++e)for (let t = 0; t < d.inChannels; ++t)for (let n = 0; n < d.inHeight; ++n)for (let r = 0; r < d.inWidth; ++r) { const i = n - k, a = r - w; let o = 0; for (let n = 0; n < v; n += y) { const r = (i + n) / m; if (!(r < 0 || r >= d.outHeight || Math.floor(r) !== r)) for (let i = 0; i < x; i += b) { const s = (a + i) / g; if (s < 0 || s >= d.outWidth || Math.floor(s) !== s) continue; const u = v * x - 1 - p.get(e, r, s, t) === n * x + i ? 1 : 0; if (0 === u) continue; o += C.get(e, r, s, t) * u } } S.set(o, e, n, r, t) } return n.makeTensorInfo(S.shape, S.dtype, S.values) }
};
/**
* @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.
* =============================================================================
*/
const ov = {
kernelName: P.MaxPoolWithArgmax, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => {
const { x: r } = e, { filterSize: i, strides: a, pad: o, includeBatchInIndex: s } = t, u = n; ip(r, "MaxPoolWithArgmax"); const l = u.data.get(r.dataId).values, c = P.backend_util.computePool2DInfo(r.shape, i, a, [1, 1], o), [h, d] =
/**
* @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 (e, t, n, r, i) { const a = yy(e, 0, n, P.util.computeStrides(t), i, "max"), o = by(e, t, n, i, !0, r); return [a.values, o.values] }(l, r.shape, r.dtype, s, c), f = u.write(h, c.outShape, r.dtype), p = u.write(d, c.outShape, r.dtype); return [{ dataId: f, shape: c.outShape, dtype: r.dtype }, { dataId: p, shape: c.outShape, dtype: "int32" }]
}
}; const sv = {
kernelName: P.Mean, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = P.util.parseAxisParam(a, i.shape), u = P.backend_util.computeOutAndReduceShapes(i.shape, s)[1], l = P.util.sizeFromShape(u), c = [], h = n.makeTensorInfo([], "float32", new Float32Array([l])); c.push(h); const d = bp({ inputs: { x: i }, backend: n, attrs: { dtype: "float32" } }); c.push(d); const f = wb({ inputs: { a: d, b: h }, backend: n }); c.push(f); const p = ob({ inputs: { x: f }, backend: n, attrs: { axis: a, keepDims: o } }); return c.forEach((e => n.disposeIntermediateTensorInfo(e))), p }
}; const uv = {
kernelName: P.Min, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r; ip(i, "min"); const s = P.util.parseAxisParam(a, i.shape); let u = s; const l = P.backend_util.getAxesPermutation(u, i.shape.length); let c = i; null != l && (c = $m({ inputs: { x: i }, backend: n, attrs: { perm: l } }), u = P.backend_util.getInnerMostAxes(u.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("min", u, c.shape.length); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, u), f = P.util.sizeFromShape(d), p = P.util.makeZerosTypedArray(P.util.sizeFromShape(h), c.dtype), m = n.data.get(c.dataId).values; for (let e = 0; e < p.length; ++e) { const t = e * f; let n = m[t]; for (let e = 0; e < f; ++e) { const r = m[t + e]; (Number.isNaN(r) || r < n) && (n = r) } p[e] = n } null != l && n.disposeIntermediateTensorInfo(c); const g = n.makeTensorInfo(h, c.dtype, p); if (o) { const e = Hg({ inputs: { x: g }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(h, s) } }); return n.disposeIntermediateTensorInfo(g), e } return g }
}; const lv = {
kernelName: P.MirrorPad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, mode: o } = r; ip(i, "mirrorPad"); const s = a.map(((e, t) => e[0] + i.shape[t] + e[1])), u = a.map((e => e[0])), l = a.map(((e, t) => e[0] + i.shape[t])), c = "reflect" === o ? 0 : 1, h = n.data.get(i.dataId).values, d = i.shape.length, f = P.util.computeStrides(i.shape), p = P.util.sizeFromShape(s), m = s.length, g = P.util.computeStrides(s), y = P.util.getTypedArrayFromDType(i.dtype, p); for (let e = 0; e < p; e++) { let t = P.util.indexToLoc(e, m, g); for (let e = 0; e < m; e++)t[e] < u[e] ? t[e] = 2 * u[e] - t[e] - c : t[e] >= l[e] && (t[e] = 2 * (l[e] - 1) - t[e] + c); t = t.map(((e, t) => e - u[t])); const n = P.util.locToIndex(t, d, f); y[e] = h[n] } return { dataId: n.write(y, s, i.dtype), shape: s, dtype: i.dtype } }
}, cv = lp(((e, t) => { const n = e % t; return e < 0 && t < 0 || e >= 0 && t >= 0 ? n : (n + t) % t })), hv = xp(P.Mod, cv), dv = { kernelName: P.Mod, backendName: "cpu", kernelFunc: hv };
/**
* @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 fv(e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { dim: a } = r, o = i.shape.length; let s = a; if (-1 === s && (s = o - 1), s !== o - 1) throw Error(`Softmax along a non-last dimension is not yet supported. Logits was rank ${o} and dim was ${s}`); const u = P.util.parseAxisParam([s], i.shape), l = ev({ inputs: { x: i }, backend: n, attrs: { reductionIndices: u, keepDims: !1 } }), c = P.backend_util.expandShapeToKeepDim(l.shape, u), h = Hg({ inputs: { x: l }, backend: n, attrs: { shape: c } }), d = Ag({ inputs: { a: i, b: h }, backend: n }), f = Up({ inputs: { x: d }, backend: n }), p = ob({ inputs: { x: f }, backend: n, attrs: { axis: u, keepDims: !1 } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: c } }), g = wb({ inputs: { a: f, b: m }, backend: n }); return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), g } const pv = { kernelName: P.Softmax, backendName: "cpu", kernelFunc: fv }; const mv = {
kernelName: P.Multinomial, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { numSamples: a, seed: o, normalized: s } = r; ip(i, "multinomial"); const u = s ? i : fv({ inputs: { logits: i }, backend: n, attrs: { dim: -1 } }), l = u.shape[0], c = u.shape[1], h = n.data.get(u.dataId).values, d = [l, a], f = P.util.makeZerosTypedArray(P.util.sizeFromShape(d), "int32"); for (let e = 0; e < l; ++e) { const t = e * c, n = new Float32Array(c - 1); n[0] = h[t]; for (let e = 1; e < n.length; ++e)n[e] = n[e - 1] + h[t + e]; const r = qd.alea(o.toString()), i = e * a; for (let e = 0; e < a; ++e) { const t = r(); f[i + e] = n.length; for (let r = 0; r < n.length; r++)if (t < n[r]) { f[i + e] = r; break } } } return s || n.disposeIntermediateTensorInfo(u), n.makeTensorInfo(d, "int32", f) }
}, gv = P.kernel_impls.nonMaxSuppressionV3Impl; const yv = { kernelName: P.NonMaxSuppressionV3, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = r; ip(i, "NonMaxSuppression"); const l = n.data.get(i.dataId).values, c = n.data.get(a.dataId).values, { selectedIndices: h } = gv(l, c, o, s, u); return n.makeTensorInfo([h.length], "int32", new Int32Array(h)) } }, bv = P.kernel_impls.nonMaxSuppressionV4Impl; const vv = { kernelName: P.NonMaxSuppressionV4, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, padToMaxOutputSize: l } = r; ip(i, "NonMaxSuppressionPadded"); const c = n.data.get(i.dataId).values, h = n.data.get(a.dataId).values, { selectedIndices: d, validOutputs: f } = bv(c, h, o, s, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([f]))] } }, xv = P.kernel_impls.nonMaxSuppressionV5Impl; const wv = { kernelName: P.NonMaxSuppressionV5, backendName: "cpu", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = r; ip(i, "NonMaxSuppressionWithScore"); const c = n.data.get(i.dataId).values, h = n.data.get(a.dataId).values, d = o, f = s, p = u, m = l, { selectedIndices: g, selectedScores: y } = xv(c, h, d, f, p, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([y.length], "float32", new Float32Array(y))] } }; const kv = {
kernelName: P.OneHot, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i } = t, { dtype: a, depth: o, onValue: s, offValue: u } = r; ip(i, "oneHot"); const l = P.util.sizeFromShape(i.shape), c = new Float32Array(l * o); c.fill(u); const h = n.data.get(i.dataId).values; for (let e = 0; e < l; ++e)h[e] >= 0 && h[e] < o && (c[e * o + h[e]] = s); return n.makeTensorInfo([...i.shape, o], a, c) }
};
/**
* @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 Sv(e) { const { inputs: t, backend: n } = e, { x: r } = t; if ("string" === r.dtype) throw new Error("zerosLike is not supported for string tensors"); if ("complex64" === r.dtype) { const e = mp({ inputs: { input: r }, backend: n }), t = Sv({ inputs: { x: e }, backend: n }), i = My({ inputs: { input: r }, backend: n }), a = Sv({ inputs: { x: i }, backend: n }), o = cp({ inputs: { real: t, imag: a }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(a), o } return Tb({ backend: n, attrs: { shape: r.shape, value: 0, dtype: r.dtype } }) } const _v = { kernelName: P.ZerosLike, backendName: "cpu", kernelFunc: Sv }; const Cv = {
kernelName: P.OnesLike, backendName: "cpu", kernelFunc:
/**
* @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 e(t) { const { inputs: n, backend: r } = t, { x: i } = n; if ("string" === i.dtype) throw new Error("onesLike is not supported for string tensors"); if ("complex64" === i.dtype) { const t = mp({ inputs: { input: i }, backend: r }), n = e({ inputs: { x: t }, backend: r }), a = My({ inputs: { input: i }, backend: r }), o = Sv({ inputs: { x: a }, backend: r }), s = cp({ inputs: { real: n, imag: o }, backend: r }); return r.disposeIntermediateTensorInfo(t), r.disposeIntermediateTensorInfo(n), r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s } return Tb({ backend: r, attrs: { shape: i.shape, value: 1, dtype: i.dtype } }) }
};
/**
* @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 Av(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r; if (1 === t.length) return bb({ inputs: { input: t[0] }, backend: n, attrs: { dim: i } }); const a = t[0].shape, o = t[0].dtype; t.forEach((e => { P.util.assertShapesMatch(a, e.shape, "All tensors passed to stack must have matching shapes"), P.util.assert(o === e.dtype, (() => "All tensors passed to stack must have matching dtypes")) })); const s = [], u = Dy({ inputs: t.map((e => { const t = bb({ inputs: { input: e }, backend: n, attrs: { dim: i } }); return s.push(t), t })), backend: n, attrs: { axis: i } }); return s.forEach((e => n.disposeIntermediateTensorInfo(e))), u } const Tv = { kernelName: P.Pack, backendName: "cpu", kernelFunc: Av }; const Ev = {
kernelName: P.PadV2, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, constantValue: o } = r; ip(i, "pad"); const s = a.map(((e, t) => e[0] + i.shape[t] + e[1])), u = a.map((e => e[0])), l = n.data.get(i.dataId).values, c = P.util.sizeFromShape(i.shape), h = i.shape.length, d = P.util.computeStrides(i.shape), f = P.util.sizeFromShape(s), p = s.length, m = P.util.computeStrides(s), g = P.util.getTypedArrayFromDType(i.dtype, f); 0 !== o && g.fill(o); for (let e = 0; e < c; e++) { const t = P.util.indexToLoc(e, h, d).map(((e, t) => e + u[t])); g[P.util.locToIndex(t, p, m)] = l[e] } return { dataId: n.write(g, s, i.dtype), shape: s, dtype: i.dtype } }
}, Nv = lp(((e, t) => Math.pow(e, t))), Iv = xp(P.Pow, Nv), Mv = { kernelName: P.Pow, backendName: "cpu", kernelFunc: Iv }; const Fv = {
kernelName: P.RaggedGather, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { paramsNestedSplits: i, paramsDenseValues: a, indices: o } = t, { outputRaggedRank: s } = r, u = i.map((e => n.data.get(e.dataId).values)), l = i.map((e => e.shape)), c = n.data.get(a.dataId).values, h = n.data.get(o.dataId).values, [d, f, p] = jm(u, l, c, a.shape, a.dtype, h, o.shape), m = d.map((e => n.makeTensorInfo([e.length], "int32", e))), g = n.makeTensorInfo(p, a.dtype, f); return m.concat([g]) }
}; const Dv = {
kernelName: P.RaggedRange, backendName: "cpu", kernelFunc:
/**
* @license
* Copyright 2022 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 (e) { const { inputs: t, backend: n } = e, { starts: r, limits: i, deltas: a } = t, o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = Wm(o, r.shape, r.dtype, s, i.shape, u, a.shape); return [n.makeTensorInfo([l.length], "int32", l), n.makeTensorInfo([c.length], r.dtype, c)] }
}; const $v = {
kernelName: P.RaggedTensorToTensor, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { shape: i, values: a, defaultValue: o, rowPartitionTensors: s } = t, { rowPartitionTypes: u } = r, l = n.data.get(i.dataId).values, c = n.data.get(a.dataId).values, h = n.data.get(o.dataId).values, d = s.map((e => n.data.get(e.dataId).values)), f = s.map((e => e.shape)), [p, m] = Ym(l, i.shape, c, a.shape, a.dtype, h, o.shape, d, f, u); return n.makeTensorInfo(p, a.dtype, m) }
}; const Rv = {
kernelName: P.Range, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, dtype: a, step: o } = n, s = Xm(r, i, o, a); return t.makeTensorInfo([s.length], a, s) }
}, Ov = Fp(P.Reciprocal, (e => 1 / e)), zv = { kernelName: P.Reciprocal, backendName: "cpu", kernelFunc: Ov }; const Pv = {
kernelName: P.ResizeBilinear, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r; ip(i, "resizeBilinear"); const u = P.util.computeStrides(i.shape), [l, c] = s, [h, d, f, p] = i.shape, m = n.data.get(i.dataId).values, g = new Float32Array(P.util.sizeFromShape([h, l, c, p])), y = [a && l > 1 ? d - 1 : d, a && c > 1 ? f - 1 : f], b = [a && l > 1 ? l - 1 : l, a && c > 1 ? c - 1 : c]; let v = 0; const x = y[0] / b[0], w = y[1] / b[1]; for (let e = 0; e < h; e++)for (let t = 0; t < l; t++) { let n; n = o ? x * (t + .5) - .5 : x * t; const r = Math.max(0, Math.floor(n)), i = n - r, a = Math.min(d - 1, Math.ceil(n)), s = e * u[0] + r * u[1], l = e * u[0] + a * u[1]; for (let e = 0; e < c; e++) { let t; t = o ? w * (e + .5) - .5 : w * e; const n = Math.max(0, Math.floor(t)), r = t - n, a = Math.min(f - 1, Math.ceil(t)), c = s + n * u[2], h = l + n * u[2], d = s + a * u[2], y = l + a * u[2]; for (let e = 0; e < p; e++) { const t = m[c + e], n = m[h + e], a = t + (m[d + e] - t) * r, o = a + (n + (m[y + e] - n) * r - a) * i; g[v++] = o } } } return n.makeTensorInfo([h, l, c, p], "float32", g) }
}; const Bv = {
kernelName: P.ResizeBilinearGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r; ip([a, i], "resizeBilinearGrad"); const s = P.util.computeStrides(i.shape), [u, l, c, h] = i.shape, [, d, f] = a.shape, p = new Float32Array(u * l * c * h), m = [o && d > 1 ? l - 1 : l, o && f > 1 ? c - 1 : c], g = [o && d > 1 ? d - 1 : d, o && f > 1 ? f - 1 : f], y = m[0] / g[0], b = m[1] / g[1], v = n.data.get(a.dataId).values; let x = 0; for (let e = 0; e < u; e++) { const t = e * s[0]; for (let e = 0; e < d; e++) { const n = e * y, r = Math.floor(n), i = Math.min(Math.ceil(n), l - 1), a = t + r * s[1], o = t + i * s[1], u = n - r, d = 1 - u; for (let e = 0; e < f; e++) { const t = e * b, n = Math.floor(t), r = Math.min(Math.ceil(t), c - 1), i = t - n, l = 1 - i, f = a + n * s[2], m = a + r * s[2], g = o + n * s[2], y = o + r * s[2], w = d * l, k = d * i, S = u * l, _ = u * i; for (let e = 0; e < h; e++) { const t = v[x++]; p[f + e] += t * w, p[m + e] += t * k, p[g + e] += t * S, p[y + e] += t * _ } } } } return n.makeTensorInfo([u, c, l, h], "float32", p) }
}; const Lv = {
kernelName: P.ResizeNearestNeighbor, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r; ip(i, "resizeNearestNeighbor"); const u = P.util.computeStrides(i.shape), [l, c] = s, [h, d, f, p] = i.shape, m = n.data.get(i.dataId).values, g = new Float32Array(h * l * c * p), y = [a && l > 1 ? d - 1 : d, a && c > 1 ? f - 1 : f], b = [a && l > 1 ? l - 1 : l, a && c > 1 ? c - 1 : c], v = y[0] / b[0], x = y[1] / b[1]; let w = 0; for (let e = 0; e < h; e++) { const t = e * u[0]; for (let e = 0; e < l; e++) { const n = o ? v * (e + .5) : v * e; let r = Math.min(d - 1, a ? Math.round(n) : Math.floor(n)); o && (r = Math.max(0, r)); const i = t + r * u[1]; for (let e = 0; e < c; e++) { const t = o ? x * (e + .5) : x * e; let n = Math.min(f - 1, a ? Math.round(t) : Math.floor(t)); o && (n = Math.max(0, n)); const r = i + n * u[2]; for (let e = 0; e < p; e++) { const t = m[r + e]; g[w++] = t } } } } return n.makeTensorInfo([h, l, c, p], i.dtype, g) }
}; const jv = {
kernelName: P.ResizeNearestNeighborGrad, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r; ip([a, i], "resizeNearestNeighborGrad"); const s = P.util.computeStrides(i.shape), u = P.util.computeStrides(a.shape), [l, c, h, d] = i.shape, [, f, p] = a.shape, m = new Float32Array(l * c * h * d), g = n.data.get(a.dataId).values, y = [o && f > 1 ? c - 1 : c, o && p > 1 ? h - 1 : h], b = [o && f > 1 ? f - 1 : f, o && p > 1 ? p - 1 : p], v = y[0] / b[0], x = y[1] / b[1], w = 1 / v, k = 1 / x, S = 2 * Math.ceil(w) + 2, _ = 2 * Math.ceil(k) + 2; for (let e = 0; e < l; e++) { const t = e * s[0]; for (let e = 0; e < c; e++) { const n = t + e * s[1], r = Math.floor(e * w), i = Math.floor(r - S / 2); for (let r = 0; r < h; r++) { const a = n + r * s[2], l = Math.floor(r * k), y = Math.floor(l - _ / 2); for (let n = 0; n < d; n++) { let s = 0; for (let a = 0; a < S; a++) { const l = a + i; if (l < 0 || l >= f) continue; const d = t + l * u[1], m = l * v; if (e === Math.min(c - 1, o ? Math.round(m) : Math.floor(m))) for (let e = 0; e < _; e++) { const t = e + y; if (t < 0 || t >= p) continue; const i = d + t * u[2], a = t * x; r === Math.min(h - 1, o ? Math.round(a) : Math.floor(a)) && (s += g[i + n]) } } m[a + n] = s } } } } return n.makeTensorInfo(i.shape, i.dtype, m) }
}; const Uv = {
kernelName: P.Reverse, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dims: a } = r; ip(i, "reverse"); const o = i.shape.length, s = P.util.parseAxisParam(a, i.shape); if (0 === o) return fp({ inputs: { x: i }, backend: n }); const u = new P.TensorBuffer(i.shape, i.dtype), l = n.bufferSync(i); for (let e = 0; e < u.size; e++) { const t = u.indexToLoc(e), n = t.slice(); s.forEach((e => n[e] = i.shape[e] - 1 - n[e])), u.set(l.get(...n), ...t) } return n.makeTensorInfo(u.shape, u.dtype, u.values) }
}, Wv = { kernelName: P.RotateWithOffset, backendName: "cpu", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, { radians: i, fillValue: a, center: o } = t, s = n, u = P.util.getTypedArrayFromDType(r.dtype, P.util.sizeFromShape(r.shape)), [l, c, h, d] = r.shape, [f, p] = P.backend_util.getImageCenter(o, c, h), m = Math.sin(i), g = Math.cos(i), y = s.data.get(r.dataId).values; for (let e = 0; e < l; e++) { const t = e * h * c * d; for (let e = 0; e < c; e++) { const n = e * (h * d); for (let r = 0; r < h; r++) { const i = r * d; for (let o = 0; o < d; o++) { const s = [l, e, r, o], b = s[2], v = s[1]; let x = (b - f) * g - (v - p) * m, w = (b - f) * m + (v - p) * g; x = Math.round(x + f), w = Math.round(w + p); let k = a; if ("number" != typeof a && (k = 3 === o ? 255 : a[o]), x >= 0 && x < h && w >= 0 && w < c) { k = y[t + w * (h * d) + x * d + o] } u[t + n + i + o] = k } } } } return { dataId: s.write(u, r.shape, r.dtype), shape: r.shape, dtype: r.dtype } } }, Vv = Fp(P.Round, (e => { const t = Math.floor(e); return e - t < .5 ? Math.floor(e) : e - t > .5 ? Math.ceil(e) : t % 2 == 0 ? t : t + 1 })), Gv = { kernelName: P.Round, backendName: "cpu", kernelFunc: Vv }; const Hv = {
kernelName: P.ScatterNd, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i, updates: a } = t, { shape: o } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(a, i, o), d = Qm(n.bufferSync(i), n.bufferSync(a), o, h, l, u, s, c, 0, !0); return n.makeTensorInfo(o, d.dtype, d.values) }
};
/**
* @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 qv(e, t) { let n = 0, r = e.length, i = 0; for (; n < r;)i = Math.floor((n + r) / 2), e[i] < t ? n = i + 1 : r = i; return r } function Yv(e, t) { let n = 0, r = e.length, i = 0; for (; n < r;)i = Math.floor((n + r) / 2), e[i] <= t ? n = i + 1 : r = i; return r } const Xv = {
kernelName: P.SearchSorted, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { sortedSequence: i, values: a } = t, { side: o } = r, s = function (e, t, n, r, i, a) { const o = P.util.getArrayFromDType("int32", n * i); for (let s = 0; s < n; ++s) { const n = e.slice(s * r, (s + 1) * r), u = s * i; for (let e = 0; e < i; ++e)o[u + e] = "left" === a ? qv(n, t[e + u]) : Yv(n, t[e + u]) } return o }(n.data.get(i.dataId).values, n.data.get(a.dataId).values, i.shape[0], i.shape[1], a.shape[1], o); return n.makeTensorInfo(a.shape, "int32", s) }
}; const Kv = {
kernelName: P.Select, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { condition: r, t: i, e: a } = t; ip([r, i, a], "select"); const o = r.shape.length, s = n.data.get(r.dataId).values, u = n.data.get(i.dataId).values, l = n.data.get(a.dataId).values, c = (0, P.upcastType)(i.dtype, a.dtype), h = P.util.makeZerosTypedArray(P.util.sizeFromShape(i.shape), c); let d = 0; const f = 0 === o || o > 1 || 1 === i.shape.length ? 1 : P.util.sizeFromShape(i.shape.slice(1)); for (let e = 0; e < s.length; e++)for (let t = 0; t < f; t++)1 === s[e] ? h[d++] = u[e] : h[d++] = l[e]; return n.makeTensorInfo(i.shape, c, h) }
}, Zv = P.backend_util.SELU_SCALEALPHA, Jv = P.backend_util.SELU_SCALE, Qv = Fp(P.Selu, (e => e >= 0 ? Jv * e : Zv * (Math.exp(e) - 1))), ex = { kernelName: P.Selu, backendName: "cpu", kernelFunc: Qv }, tx = Fp(P.Sign, (e => e < 0 ? -1 : e > 0 ? 1 : 0)), nx = { kernelName: P.Sign, backendName: "cpu", kernelFunc: tx }, rx = Fp(P.Sin, (e => Math.sin(e))), ix = { kernelName: P.Sin, backendName: "cpu", kernelFunc: rx }, ax = Fp(P.Sinh, (e => Math.sinh(e))), ox = { kernelName: P.Sinh, backendName: "cpu", kernelFunc: ax }, sx = Math.log(1.1920928955078125e-7) + 2, ux = Fp(P.Softplus, (e => { const t = e > -sx, n = e < sx, r = Math.exp(e); let i; return i = n ? r : t ? e : Math.log(1 + r), i })), lx = { kernelName: P.Softplus, backendName: "cpu", kernelFunc: ux }; const cx = {
kernelName: P.SpaceToBatchND, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, paddings: o } = r; ip([i], "spaceToBatchND"); const s = P.util.sizeFromShape(a), u = [[0, 0]]; u.push(...o); for (let e = 1 + a.length; e < i.shape.length; ++e)u.push([0, 0]); const l = Ev.kernelFunc({ inputs: { x: i }, backend: n, attrs: { paddings: u, constantValue: 0 } }), c = P.backend_util.getReshaped(l.shape, a, s, !1), h = P.backend_util.getPermuted(c.length, a.length, !1), d = P.backend_util.getReshapedPermuted(l.shape, a, s, !1), f = Hg({ inputs: { x: l }, backend: n, attrs: { shape: c } }), p = $m({ inputs: { x: f }, backend: n, attrs: { perm: h } }), m = Hg({ inputs: { x: p }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), m }
}; const hx = {
kernelName: P.SparseFillEmptyRows, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { indices: r, values: i, denseShape: a, defaultValue: o } = t; if (1 !== a.shape.length) throw new Error(`Dense shape must be a vector, saw:\n ${a.shape}`); if (2 !== r.shape.length) throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Values must be a vector, saw:\n ${i.shape}`); if (0 !== o.shape.length) throw new Error(`Default value must be a scalar, saw:\n ${o.shape}`); const s = n.data.get(r.dataId).values, u = n.data.get(i.dataId).values, l = n.data.get(a.dataId).values, c = n.data.get(o.dataId).values[0], [h, d, f, p, m] = og(s, r.shape, r.dtype, u, i.dtype, l, c); return [n.makeTensorInfo(d, r.dtype, h), n.makeTensorInfo([d[0]], i.dtype, f), n.makeTensorInfo([p.length], "bool", new Uint8Array(p.map((e => Number(e))))), n.makeTensorInfo([m.length], r.dtype, new Int32Array(m))] }
}; const dx = {
kernelName: P.SparseReshape, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { inputIndices: r, inputShape: i, newShape: a } = t; if (2 !== r.shape.length) throw new Error(`Input indices should be a matrix but received shape\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Input shape should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Target shape should be a vector but received shape ${a.shape}`); const o = Array.from(n.data.get(i.dataId).values), s = n.data.get(r.dataId).values, u = Array.from(n.data.get(a.dataId).values), [l, c, h] = sg(s, r.shape, r.dtype, o, u); return [n.makeTensorInfo(c, r.dtype, l), n.makeTensorInfo([h.length], a.dtype, new Int32Array(h))] }
}; const fx = {
kernelName: P.SparseSegmentMean, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); if (i.shape[0] !== a.shape[0]) throw new Error("segmentIds and indices should have same size."); const o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = ug(o, r.shape, r.dtype, s, u, !0); return n.makeTensorInfo(c, r.dtype, l) }
}; const px = {
kernelName: P.SparseSegmentSum, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); if (i.shape[0] !== a.shape[0]) throw new Error("segmentIds and indices should have same size."); const o = n.data.get(r.dataId).values, s = n.data.get(i.dataId).values, u = n.data.get(a.dataId).values, [l, c] = ug(o, r.shape, r.dtype, s, u); return n.makeTensorInfo(c, r.dtype, l) }
}; const mx = {
kernelName: P.SparseToDense, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { sparseIndices: i, sparseValues: a, defaultValue: o } = t, { outputShape: s } = r, { sliceRank: u, numUpdates: l, sliceSize: c, strides: h, outputSize: d } = P.backend_util.calculateShapes(a, i, s), f = !1, p = n.bufferSync(i); let m; switch (a.dtype) { case "bool": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, Boolean(n.data.get(o.dataId).values[0]), f); break; case "float32": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, n.data.get(o.dataId).values[0], f); break; case "int32": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, n.data.get(o.dataId).values[0], f); break; case "string": m = Qm(p, n.bufferSync(a), s, d, c, l, u, h, P.util.decodeString(n.data.get(o.dataId).values[0]), f); break; default: throw new Error(`Unsupported type ${a.dtype}`) }return n.makeTensorInfo(s, m.dtype, m.values) }
}; const gx = {
kernelName: P.SplitV, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { numOrSizeSplits: a, axis: o } = r, s = P.util.parseAxisParam(o, i.shape)[0], u = P.backend_util.prepareSplitSize(i, a, s), l = new Array(i.shape.length).fill(0), c = i.shape.slice(); return u.map((e => { const t = [...c]; t[s] = e; const r = ig({ inputs: { x: i }, backend: n, attrs: { begin: l, size: t } }); return l[s] += e, r })) }
}, yx = { kernelName: P.Square, backendName: "cpu", kernelFunc: ({ inputs: e, backend: t }) => { const { x: n } = e, r = t; ip(n, "square"); const i = r.data.get(n.dataId).values, a = new Float32Array(i.length); for (let e = 0; e < i.length; ++e) { const t = i[e]; a[e] = t * t } return { dataId: r.write(a, n.shape, n.dtype), shape: n.shape, dtype: n.dtype } } }, bx = Fp(P.Step, ((e, t) => { const n = t; return isNaN(e) ? NaN : e > 0 ? 1 : n.alpha })), vx = { kernelName: P.Step, backendName: "cpu", kernelFunc: bx }; const xx = {
kernelName: P.StridedSlice, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, end: o, strides: s, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: h, shrinkAxisMask: d } = r; ip(i, "stridedSlice"); const { finalShapeSparse: f, finalShape: p, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: b, end: v, strides: x } = P.slice_util.sliceInfo(i.shape, a, o, s, u, l, c, h, d); let w; if (m) w = Hg({ inputs: { x: i }, backend: n, attrs: { shape: p } }); else if (g || y) { P.util.assert(i.shape.length >= 1, (() => `Input must have rank at least 1, got: ${i.shape.length}`)); const e = P.slice_util.computeOutShape(b, v, x), t = ig({ inputs: { x: i }, backend: n, attrs: { begin: b, size: e } }); w = Hg({ inputs: { x: t }, backend: n, attrs: { shape: p } }), n.disposeIntermediateTensorInfo(t) } else { const e = bg(f, n.bufferSync(i), x, b); w = n.makeTensorInfo(p, e.dtype, e.values) } return w }
}; const wx = {
kernelName: P.StringNGrams, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { separator: i, nGramWidths: a, leftPad: o, rightPad: s, padWidth: u, preserveShortSequences: l } = r, { data: c, dataSplits: h } = t, d = n.data.get(c.dataId).values, f = n.data.get(h.dataId).values, [p, m] = xg(d, f, i, a, o, s, u, l); return [n.makeTensorInfo([p.length], "string", p), n.makeTensorInfo(h.shape, "int32", m)] }
}; const kx = {
kernelName: P.StringSplit, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { skipEmpty: i } = r, { input: a, delimiter: o } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (1 !== a.shape.length) throw new Error(`Input must be a vector, got shape: ${a.shape}`); if (0 !== o.shape.length) throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`); const s = n.data.get(a.dataId).values, u = n.data.get(o.dataId).values[0], [l, c, h] = kg(s, u, i), d = c.length; return [n.makeTensorInfo([d, 2], "int32", l), n.makeTensorInfo([d], "string", c), n.makeTensorInfo([2], "int32", new Int32Array(h))] }
}; const Sx = {
kernelName: P.StringToHashBucketFast, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { numBuckets: i } = r, { input: a } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (i <= 0) throw new Error("Number of buckets must be at least 1"); const o = Sg(n.data.get(a.dataId).values, i); return n.makeTensorInfo(a.shape, "int32", o) }
}, _x = Fp(P.Tan, (e => Math.tan(e))), Cx = { kernelName: P.Tan, backendName: "cpu", kernelFunc: _x }, Ax = Fp(P.Tanh, (e => Math.tanh(e))), Tx = { kernelName: P.Tanh, backendName: "cpu", kernelFunc: Ax }; const Ex = {
kernelName: P.TensorScatterUpdate, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { tensor: r, indices: i, updates: a } = t, { sliceRank: o, numUpdates: s, sliceSize: u, strides: l, outputSize: c } = P.backend_util.calculateShapes(a, i, r.shape), h = n.bufferSync(i), d = n.bufferSync(a), f = n.bufferSync(r), p = Qm(h, d, r.shape, c, u, s, o, l, f, !1); return n.makeTensorInfo(r.shape, p.dtype, p.values) }
}; const Nx = {
kernelName: P.Tile, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reps: a } = r; ip(i, "tile"); const o = Eg(n.bufferSync(i), a); return n.makeTensorInfo(o.shape, o.dtype, o.values) }
}; const Ix = {
kernelName: P.TopK, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { k: a, sorted: o } = r; ip(i, "topk"); const s = n.data.get(i.dataId).values, [u, l] = Mg(s, i.shape, i.dtype, a, o); return [n.makeTensorInfo(u.shape, u.dtype, u.values), n.makeTensorInfo(l.shape, l.dtype, l.values)] }
}; const Mx = {
kernelName: P.Transform, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, attrs: n, backend: r } = e, { image: i, transforms: a } = t, { interpolation: o, fillMode: s, fillValue: u, outputShape: l } = n, [c, h, d, f] = i.shape, [p, m] = null != l ? l : [h, d], g = [c, p, m, f], y = P.util.computeStrides(i.shape), b = y[0], v = y[1], x = y[2], w = P.util.computeStrides(g), k = w[0], S = w[1], _ = w[2], C = P.util.getTypedArrayFromDType(i.dtype, P.util.sizeFromShape(g)); C.fill(u); const A = r.data.get(i.dataId).values, T = r.data.get(a.dataId).values; for (let e = 0; e < c; ++e) { const t = 1 === a.shape[0] ? T : T.subarray(8 * e, 8 * e + 8); for (let n = 0; n < p; ++n)for (let r = 0; r < m; ++r)for (let i = 0; i < f; ++i) { let a; const l = t[6] * r + t[7] * n + 1; if (0 === l) continue; const c = (t[0] * r + t[1] * n + t[2]) / l, f = (t[3] * r + t[4] * n + t[5]) / l, p = Fx(c, d, s), m = Fx(f, h, s); switch (o) { case "nearest": a = $x(A, h, d, b, v, x, e, m, p, i, u); break; case "bilinear": a = Rx(A, h, d, b, v, x, e, m, p, i, u); break; default: throw new Error(`Error in Transform: Expect 'nearest' or 'bilinear', but got ${o}`) }C[e * k + n * S + r * _ + i] = a } return r.makeTensorInfo(g, i.dtype, C) } return { dataId: r.write(C, g, i.dtype), shape: i.shape, dtype: i.dtype } }
}; function Fx(e, t, n) { switch (n) { case "reflect": return function (e, t) { let n = e; if (n < 0) if (t <= 1) n = 0; else { const e = 2 * t; n < e && (n = e * Math.trunc(-n / e) + n), n = n < -t ? n + e : -n - 1 } else if (n > t - 1) if (t <= 1) n = 0; else { const e = 2 * t; n -= e * Math.trunc(n / e), n >= t && (n = e - n - 1) } return P.util.clamp(0, n, t - 1) }(e, t); case "wrap": return function (e, t) { let n = e; if (n < 0) if (t <= 1) n = 0; else { const e = t - 1; n += t * (Math.trunc(-n / e) + 1) } else if (n > t - 1) if (t <= 1) n = 0; else { const e = t - 1; n -= t * Math.trunc(n / e) } return P.util.clamp(0, n, t - 1) }(e, t); case "nearest": return function (e, t) { return P.util.clamp(0, e, t - 1) }(e, t); default: return function (e) { return e }(e) } } function Dx(e, t, n, r, i, a, o, s, u, l, c) { return 0 <= s && s < t && 0 <= u && u < n ? e[o * r + s * i + u * a + l] : c } function $x(e, t, n, r, i, a, o, s, u, l, c) { return Dx(e, t, n, r, i, a, o, Math.round(s), Math.round(u), l, c) } function Rx(e, t, n, r, i, a, o, s, u, l, c) { const h = Math.floor(s), d = Math.floor(u), f = h + 1, p = d + 1; return (f - s) * ((p - u) * Dx(e, t, n, r, i, a, o, h, d, l, c) + (u - d) * Dx(e, t, n, r, i, a, o, h, p, l, c)) + (s - h) * ((p - u) * Dx(e, t, n, r, i, a, o, f, d, l, c) + (u - d) * Dx(e, t, n, r, i, a, o, f, p, l, c)) } const Ox = {
kernelName: P.Unique, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, attrs: n, backend: r } = e, { axis: i } = n, { x: a } = t; ip(a, "unique"); const o = r.data.get(a.dataId).values, { outputValues: s, outputShape: u, indices: l } = Fg(o, i, a.shape, a.dtype); return [r.makeTensorInfo(u, a.dtype, s), r.makeTensorInfo([l.length], "int32", l)] }
}; const zx = {
kernelName: P.Unpack, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { value: i } = t; let { axis: a } = r; a < 0 && (a += i.shape.length); const o = i.shape.length, s = i.shape[a], u = new Array(o - 1); let l = 0; for (let e = 0; e < o; e++)e !== a && (u[l++] = i.shape[e]); const c = new Array(o).fill(0), h = i.shape.slice(); h[a] = 1; const d = new Array(s); for (let e = 0; e < d.length; e++) { c[a] = e; const t = ig({ inputs: { x: i }, backend: n, attrs: { begin: c, size: h } }); d[e] = Hg({ inputs: { x: t }, backend: n, attrs: { shape: u } }), n.disposeIntermediateTensorInfo(t) } return d }
}; const Px = {
kernelName: P.UnsortedSegmentSum, backendName: "cpu", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, segmentIds: a } = t, { numSegments: o } = r; ip(i, "unsortedSegmentSum"); const s = [], u = [], l = i.shape.length - a.shape.length; let c = a; for (let e = 0; e < l; ++e) { const t = bb({ inputs: { input: c }, backend: n, attrs: { dim: e + 1 } }); c = t, u.push(t) } for (let e = 0; e < o; ++e) { const t = P.util.createScalarValue(e, "int32"), r = n.makeTensorInfo([], "int32", t), a = Bp({ inputs: { a: r, b: c }, backend: n }), o = bp({ inputs: { x: a }, backend: n, attrs: { dtype: "float32" } }), l = Am({ inputs: { a: o, b: i }, backend: n }), h = ob({ inputs: { x: l }, backend: n, attrs: { axis: 0, keepDims: !1 } }); s.push(h), u.push(r), u.push(a), u.push(o), u.push(l), u.push(h) } const h = Av({ inputs: s, backend: n, attrs: { axis: 0 } }); return u.forEach((e => n.disposeIntermediateTensorInfo(e))), h }
}, Bx = [Kg, up, Jg, ey, Cp, ty, ny, ry, iy, ay, sy, ly, hy, py, gy, xy, wy, ky, Sy, Xg, _y, Cy, Ay, Ip, Ty, vp, Op, Ny, hp, Iy, $y, Oy, zy, Py, By, Ly, jy, Wy, Gy, Hy, qy, Yy, Xy, Ky, Jy, Qy, eb, tb, nb, rb, ib, ab, ub, Rg, lb, Lp, yb, Wp, vb, Hp, Ab, Eb, Nb, Xp, Jp, Ib, Mb, Fb, Db, rm, om, pp, $b, Fy, Ob, Pb, Lb, zg, lm, dm, jb, gm, Wb, Hb, Yb, Zb, Jb, Qb, tv, xm, nv, rv, iv, av, ov, sv, uv, Sm, lv, dv, mv, Tm, Nm, yv, vv, wv, Fm, kv, Cv, Tv, Ev, Mv, Lg, zm, Fv, Dv, $v, Rv, gp, kb, zv, Ug, Vg, qg, Pv, Bv, Lv, jv, Uv, Wv, Gv, Jm, Hv, Xv, Kv, ex, ng, nx, ix, ox, ag, pv, lx, cx, hx, dx, fx, px, mx, gx, hg, yx, pg, yg, vx, xx, wx, kx, Sx, Tg, sb, Cx, Tx, Ex, Nx, Ix, Mx, Rm, Ox, zx, Px, _v]; for (const e of Bx) (0, P.registerKernel)(e);
/**
* @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 Lx = {}, jx = { alpha: !1, antialias: !1, premultipliedAlpha: !1, preserveDrawingBuffer: !1, depth: !1, stencil: !1, failIfMajorPerformanceCaveat: !0 }; function Ux(e, t) { Lx[e] = t } function Wx(e, t) { if (!(e in Lx) || null != t) { const n = function (e, t) { if (1 !== e && 2 !== e) throw new Error("Cannot get WebGL rendering context, WebGL is disabled."); const n = null == t ? function (e) { if ((0, P.env)().getBool("IS_SAFARI") || "undefined" == typeof OffscreenCanvas || 2 !== e) { if ("undefined" != typeof document) return document.createElement("canvas"); throw new Error("Cannot create a canvas in this context") } return new OffscreenCanvas(300, 150) }(e) : t; n.addEventListener("webglcontextlost", (t => { t.preventDefault(), delete Lx[e] }), !1), (0, P.env)().getBool("SOFTWARE_WEBGL_ENABLED") && (jx.failIfMajorPerformanceCaveat = !1); if (1 === e) return n.getContext("webgl", jx) || n.getContext("experimental-webgl", jx); return n.getContext("webgl2", jx) }(e, t); if (null === n) return console.log("Could not get context for WebGL version", e), null; Lx[e] = n } const n = Lx[e]; return null == n || n.isContextLost() ? (delete Lx[e], Wx(e)) : (n.disable(n.DEPTH_TEST), n.disable(n.STENCIL_TEST), n.disable(n.BLEND), n.disable(n.DITHER), n.disable(n.POLYGON_OFFSET_FILL), n.disable(n.SAMPLE_COVERAGE), n.enable(n.SCISSOR_TEST), n.enable(n.CULL_FACE), n.cullFace(n.BACK), Lx[e]) }
/**
* @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.
* =============================================================================
*/
var Vx, Gx, Hx, qx, Yx, Xx; function Kx(e, t) { return [t, e] } function Zx(e) { const t = P.util.sizeFromShape(e), n = Math.ceil(t / 4); return P.util.sizeToSquarishShape(n) } function Jx(e, t) { return [Math.max(1, Math.ceil(t / 2)), Math.max(1, Math.ceil(e / 2))] } function Qx(e, t) { const n = e; let r, i, a, o, s, u, l, c, h, d; return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? (r = n.R32F, i = n.R16F, a = n.RGBA16F, o = n.RGBA32F, s = n.RED, l = 4, c = 1, h = n.HALF_FLOAT, d = n.FLOAT, u = n.RGBA8) : (r = e.RGBA, i = e.RGBA, a = e.RGBA, o = n.RGBA, s = e.RGBA, l = 4, c = 4, h = null != t ? t.HALF_FLOAT_OES : null, d = e.FLOAT, u = e.RGBA), { internalFormatFloat: r, internalFormatHalfFloat: i, internalFormatPackedHalfFloat: a, internalFormatPackedFloat: o, textureFormatFloat: s, downloadTextureFormat: u, downloadUnpackNumChannels: l, defaultNumChannels: c, textureTypeHalfFloat: h, textureTypeFloat: d } }
/**
* @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.
* =============================================================================
*/
function ew(e, t) { const n = t(); return (0, P.env)().getBool("DEBUG") && function (e) { const t = e.getError(); if (t !== e.NO_ERROR) throw new Error("WebGL Error: " + iw(e, t)) }(e), n } (Gx = Vx || (Vx = {}))[Gx.DENSE = 0] = "DENSE", Gx[Gx.SHARED_BATCH = 1] = "SHARED_BATCH", (qx = Hx || (Hx = {}))[qx.RENDER = 0] = "RENDER", qx[qx.UPLOAD = 1] = "UPLOAD", qx[qx.PIXELS = 2] = "PIXELS", qx[qx.DOWNLOAD = 3] = "DOWNLOAD", (Xx = Yx || (Yx = {}))[Xx.UNPACKED_FLOAT16 = 0] = "UNPACKED_FLOAT16", Xx[Xx.UNPACKED_FLOAT32 = 1] = "UNPACKED_FLOAT32", Xx[Xx.PACKED_4X1_UNSIGNED_BYTE = 2] = "PACKED_4X1_UNSIGNED_BYTE", Xx[Xx.PACKED_2X2_FLOAT32 = 3] = "PACKED_2X2_FLOAT32", Xx[Xx.PACKED_2X2_FLOAT16 = 4] = "PACKED_2X2_FLOAT16"; const tw = 5.96e-8, nw = 65504; function rw(e) { return !!((0, P.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED") || 0 === e || tw < Math.abs(e) && Math.abs(e) < nw) } function iw(e, t) { switch (t) { case e.NO_ERROR: return "NO_ERROR"; case e.INVALID_ENUM: return "INVALID_ENUM"; case e.INVALID_VALUE: return "INVALID_VALUE"; case e.INVALID_OPERATION: return "INVALID_OPERATION"; case e.INVALID_FRAMEBUFFER_OPERATION: return "INVALID_FRAMEBUFFER_OPERATION"; case e.OUT_OF_MEMORY: return "OUT_OF_MEMORY"; case e.CONTEXT_LOST_WEBGL: return "CONTEXT_LOST_WEBGL"; default: return `Unknown error code ${t}` } } function aw(e, t) { return Iw(e, (() => e.getExtension(t)), 'Extension "' + t + '" not supported on this browser.') } function ow(e, t) { const n = Iw(e, (() => e.createShader(e.VERTEX_SHADER)), "Unable to create vertex WebGLShader."); if (ew(e, (() => e.shaderSource(n, t))), ew(e, (() => e.compileShader(n))), !1 === e.getShaderParameter(n, e.COMPILE_STATUS)) throw console.log(e.getShaderInfoLog(n)), new Error("Failed to compile vertex shader."); return n } function sw(e, t) { const n = Iw(e, (() => e.createShader(e.FRAGMENT_SHADER)), "Unable to create fragment WebGLShader."); if (ew(e, (() => e.shaderSource(n, t))), ew(e, (() => e.compileShader(n))), (0, P.env)().get("ENGINE_COMPILE_ONLY")) return n; if (!1 === e.getShaderParameter(n, e.COMPILE_STATUS)) throw lw(t, e.getShaderInfoLog(n)), new Error("Failed to compile fragment shader."); return n } const uw = /ERROR: [0-9]+:([0-9]+):/g; function lw(e, t) { const n = uw.exec(t); if (null == n) return console.log(`Couldn't parse line number in error: ${t}`), void console.log(e); const r = +n[1], i = e.split("\n"), a = i.length.toString().length + 2, o = i.map(((e, t) => P.util.rightPad((t + 1).toString(), a) + e)); let s = 0; for (let e = 0; e < o.length; e++)s = Math.max(o[e].length, s); const u = o.slice(0, r - 1), l = o.slice(r - 1, r), c = o.slice(r); console.log(u.join("\n")), console.log(t.split("\n")[0]), console.log(`%c ${P.util.rightPad(l[0], s)}`, "border:1px solid red; background-color:#e3d2d2; color:#a61717"), console.log(c.join("\n")) } function cw(e) { return Iw(e, (() => e.createProgram()), "Unable to create WebGLProgram.") } function hw(e, t) { if (ew(e, (() => e.linkProgram(t))), !(0, P.env)().get("ENGINE_COMPILE_ONLY") && !1 === e.getProgramParameter(t, e.LINK_STATUS)) throw console.log(e.getProgramInfoLog(t)), new Error("Failed to link vertex and fragment shaders.") } function dw(e, t) { if (ew(e, (() => e.validateProgram(t))), !1 === e.getProgramParameter(t, e.VALIDATE_STATUS)) throw console.log(e.getProgramInfoLog(t)), new Error("Shader program validation failed.") } function fw(e, t) { const n = Iw(e, (() => e.createBuffer()), "Unable to create WebGLBuffer"); return ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, n))), ew(e, (() => e.bufferData(e.ARRAY_BUFFER, t, e.STATIC_DRAW))), n } function pw(e, t) { const n = Iw(e, (() => e.createBuffer()), "Unable to create WebGLBuffer"); return ew(e, (() => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, n))), ew(e, (() => e.bufferData(e.ELEMENT_ARRAY_BUFFER, t, e.STATIC_DRAW))), n } function mw() { return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? 1 : 4 } function gw(e) { return Iw(e, (() => e.createTexture()), "Unable to create WebGLTexture.") } function yw(e, t) { const n = (0, P.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE"); if (e <= 0 || t <= 0) { throw new Error("Requested texture size " + `[${e}x${t}]` + " is invalid.") } if (e > n || t > n) { throw new Error("Requested texture size " + `[${e}x${t}]` + " greater than WebGL maximum on this browser / GPU " + `[${n}x${n}]` + ".") } } function bw(e) { return Iw(e, (() => e.createFramebuffer()), "Unable to create WebGLFramebuffer.") } function vw(e, t, n, r, i, a, o) { const s = e.getAttribLocation(t, n); return -1 !== s && (ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, r))), ew(e, (() => e.vertexAttribPointer(s, i, e.FLOAT, !1, a, o))), ew(e, (() => e.enableVertexAttribArray(s))), !0) } function xw(e, t, n) { Mw(e, n), ew(e, (() => e.activeTexture(e.TEXTURE0 + n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))) } function ww(e, t) { Mw(e, t), ew(e, (() => e.activeTexture(e.TEXTURE0 + t))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function kw(e, t, n) { return Iw(e, (() => e.getUniformLocation(t, n)), 'uniform "' + n + '" not present in program.') } function Sw(e, t, n) { return e.getUniformLocation(t, n) } function _w(e, t, n, r) { ew(e, (() => xw(e, t, r))), ew(e, (() => e.uniform1i(n, r))) } function Cw(e) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, null))), ew(e, (() => e.viewport(0, 0, e.canvas.width, e.canvas.height))), ew(e, (() => e.scissor(0, 0, e.canvas.width, e.canvas.height))) } function Aw(e, t, n) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, n))), ew(e, (() => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, t, 0))) } function Tw(e, t) { ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, t))), ew(e, (() => e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, null, 0))) } function Ew(e) { const t = e.checkFramebufferStatus(e.FRAMEBUFFER); if (t !== e.FRAMEBUFFER_COMPLETE) throw new Error("Error binding framebuffer: " + Nw(e, t)) } function Nw(e, t) { switch (t) { case e.FRAMEBUFFER_INCOMPLETE_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_ATTACHMENT"; case e.FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: return "FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT"; case e.FRAMEBUFFER_INCOMPLETE_DIMENSIONS: return "FRAMEBUFFER_INCOMPLETE_DIMENSIONS"; case e.FRAMEBUFFER_UNSUPPORTED: return "FRAMEBUFFER_UNSUPPORTED"; default: return `unknown error ${t}` } } function Iw(e, t, n) { const r = ew(e, (() => t())); if (null == r) throw new Error(n); return r } function Mw(e, t) { const n = e.MAX_COMBINED_TEXTURE_IMAGE_UNITS - 1, r = t + e.TEXTURE0; if (r < e.TEXTURE0 || r > n) { throw new Error(`textureUnit must be in ${`[gl.TEXTURE0, gl.TEXTURE${n}]`}.`) } } function Fw(e, t = 2) { return P.util.sizeFromShape(e.slice(0, e.length - t)) } function Dw(e) { if (0 === e.length) throw Error("Cannot get rows and columns of an empty shape array."); return [e.length > 1 ? e[e.length - 2] : 1, e[e.length - 1]] } function $w(e) { let t = [1, 1, 1]; return 0 === e.length || 1 === e.length && 1 === e[0] || (t = [Fw(e), ...Dw(e)]), t } function Rw(e, t = !1) { let n = (0, P.env)().getNumber("WEBGL_MAX_TEXTURE_SIZE"), r = (0, P.env)().getNumber("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE"); if (r === 1 / 0 && (0, P.env)().getBool("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE") && (r = n / 2), t && (n *= 2, r *= 2, 1 === (e = e.map(((t, n) => n >= e.length - 2 ? P.util.nearestLargerEven(e[n]) : e[n]))).length && (e = [2, e[0]])), 2 !== e.length) { const t = P.util.squeezeShape(e); e = t.newShape } let i = P.util.sizeFromShape(e), a = null; e.length <= 1 && i <= n ? a = [1, i] : 2 === e.length && e[0] <= n && e[1] <= n ? a = e : 3 === e.length && e[0] * e[1] <= n && e[2] <= n ? a = [e[0] * e[1], e[2]] : 3 === e.length && e[0] <= n && e[1] * e[2] <= n ? a = [e[0], e[1] * e[2]] : 4 === e.length && e[0] * e[1] * e[2] <= n && e[3] <= n ? a = [e[0] * e[1] * e[2], e[3]] : 4 === e.length && e[0] <= n && e[1] * e[2] * e[3] <= n && (a = [e[0], e[1] * e[2] * e[3]]); const o = null != a && Math.max(...a) > r && Math.min(...a) <= (t ? 2 : 1) && Math.min(...a) > 0; if (null == a || o) if (t) { const t = Fw(e); let n = 2, r = 2; e.length && ([n, r] = Dw(e)), i = t * (n / 2) * (r / 2), a = P.util.sizeToSquarishShape(i).map((e => 2 * e)) } else a = P.util.sizeToSquarishShape(i); return a } function Ow(e) { return e % 2 == 0 } function zw(e, t) { if (e = e.slice(-2), t = t.slice(-2), P.util.arraysEqual(e, t)) return !0; if (!e.length || !t.length) return !0; if (0 === e[0] || 0 === e[1] || 0 === t[0] || 0 === t[1]) return !0; if (e.length !== t.length) { const n = e[e.length - 1], r = t[t.length - 1]; if (n === r) return !0; if (Ow(n) && Ow(r) && (1 === e[0] || 1 === t[0])) return !0 } return e[1] === t[1] && Ow(e[0]) && Ow(t[0]) } let Pw, Bw; function Lw(e) { if (null == Pw) { const t = Wx(e); Pw = t.getParameter(t.MAX_TEXTURE_SIZE) } return Pw } function jw() { Pw = null } function Uw() { Bw = null } function Ww(e) { if (null == Bw) { const t = Wx(e); Bw = t.getParameter(t.MAX_TEXTURE_IMAGE_UNITS) } return Math.min(16, Bw) } function Vw(e) { if (0 === e) return 0; let t; const n = Wx(e); return t = Gw(n, "EXT_disjoint_timer_query_webgl2") && 2 === e ? 2 : Gw(n, "EXT_disjoint_timer_query") ? 1 : 0, t } function Gw(e, t) { return null != e.getExtension(t) } function Hw(e) { try { if (null != Wx(e)) return !0 } catch (e) { return console.log("Error when getting WebGL context: ", e), !1 } return !1 } function qw(e) { if (0 === e) return !1; const t = Wx(e); if (1 === e) { if (!Gw(t, "OES_texture_float")) return !1 } else if (!Gw(t, "EXT_color_buffer_float")) return !1; return Xw(t) } function Yw(e) { if (0 === e) return !1; const t = Wx(e); if (1 !== e) { if (Gw(t, "EXT_color_buffer_float")) return Xw(t); const e = "EXT_color_buffer_half_float"; if (Gw(t, e)) { const n = t.getExtension(e); return function (e, t) { const n = Qx(e, t), r = e.createTexture(); e.bindTexture(e.TEXTURE_2D, r); const i = 1, a = 1; e.texImage2D(e.TEXTURE_2D, 0, n.internalFormatHalfFloat, i, a, 0, n.textureFormatFloat, n.textureTypeHalfFloat, null); const o = e.createFramebuffer(); e.bindFramebuffer(e.FRAMEBUFFER, o), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, r, 0); const s = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE; return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(r), e.deleteFramebuffer(o), s }(t, n) } return !1 } if (!Gw(t, "OES_texture_float")) return !1; if (!Gw(t, "WEBGL_color_buffer_float")) return !1; return Xw(t) } function Xw(e) { const t = Qx(e), n = e.createTexture(); e.bindTexture(e.TEXTURE_2D, n); e.texImage2D(e.TEXTURE_2D, 0, t.internalFormatFloat, 1, 1, 0, t.textureFormatFloat, t.textureTypeFloat, null); const r = e.createFramebuffer(); e.bindFramebuffer(e.FRAMEBUFFER, r), e.framebufferTexture2D(e.FRAMEBUFFER, e.COLOR_ATTACHMENT0, e.TEXTURE_2D, n, 0); const i = e.checkFramebufferStatus(e.FRAMEBUFFER) === e.FRAMEBUFFER_COMPLETE; return e.bindTexture(e.TEXTURE_2D, null), e.bindFramebuffer(e.FRAMEBUFFER, null), e.deleteTexture(n), e.deleteFramebuffer(r), i } function Kw(e) { if (2 !== e) return !1; return null != Wx(e).fenceSync } function Zw(e, t) { Array.isArray(e) || (e = [e]), e.forEach((e => { null != e && P.util.assert("complex64" !== e.dtype, (() => `${t} does not support complex64 tensors in the WebGL backend.`)) })) }
/**
* @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 Jw = (0, P.env)();
/**
* @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 Qw() { let e, t, n, r, i, a, o, s, u, l; return 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? (e = "#version 300 es", t = "in", n = "out", r = "in", i = "texture", a = "outputColor", o = "out vec4 outputColor;", s = (0, P.env)().getBool("WEBGL2_ISNAN_CUSTOM") ? "\n bool isnan_custom(float val) {\n uint floatToUint = floatBitsToUint(val);\n return (floatToUint & 0x7fffffffu) > 0x7f800000u;\n }\n\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan_custom(val.x),\n isnan_custom(val.y), isnan_custom(val.z), isnan_custom(val.w));\n }\n\n #define isnan(value) isnan_custom(value)\n " : "", u = "", l = "\n #define round(value) newRound(value)\n int newRound(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 newRound(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n ") : (e = "", t = "attribute", n = "varying", r = "varying", i = "texture2D", a = "gl_FragColor", o = "", s = "\n #define isnan(value) isnan_custom(value)\n bool isnan_custom(float val) {\n return (val > 0. || val < 1. || val == 0.) ? false : true;\n }\n bvec4 isnan_custom(vec4 val) {\n return bvec4(isnan(val.x), isnan(val.y), isnan(val.z), isnan(val.w));\n }\n ", u = "\n uniform float INFINITY;\n\n bool isinf(float val) {\n return abs(val) == INFINITY;\n }\n bvec4 isinf(vec4 val) {\n return equal(abs(val), vec4(INFINITY));\n }\n ", l = "\n int round(float value) {\n return int(floor(value + 0.5));\n }\n\n ivec4 round(vec4 value) {\n return ivec4(floor(value + vec4(0.5)));\n }\n "), { version: e, attribute: t, varyingVs: n, varyingFs: r, texture2D: i, output: a, defineOutput: o, defineSpecialNaN: s, defineSpecialInf: u, defineRound: l } }
/**
* @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 ek(e, t, n = "index") { const r = P.util.computeStrides(t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / ${t}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${t}` : `index -= ${e[i]} * ${t}`};`)).join("") } function tk(e, t, n = "index") { const r = P.util.computeStrides(t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / outShapeStrides[${i}]`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * outShapeStrides[${i}]` : `index -= ${e[i]} * outShapeStrides[${i}]`};`)).join("") } function nk(e, t, n = "index") { const r = function (e, t) { const n = e.length, r = e.map((e => `${t}[${e}]`)), i = new Array(n - 1); i[n - 2] = r[n - 1]; for (let e = n - 3; e >= 0; --e)i[e] = `(${i[e + 1]} * ${r[e + 1]})`; return i }(e.map(((e, t) => t)), t); return r.map(((t, i) => `${`int ${e[i]} = ${n} / ${r[i]}`}; ${i === r.length - 1 ? `int ${e[i + 1]} = ${n} - ${e[i]} * ${r[i]}` : `index -= ${e[i]} * ${r[i]}`};`)).join("") } function rk(e) { const t = P.util.computeStrides(e).map((e => e.toString())); return `\n int getFlatIndex(ivec3 coords) {\n return coords.x * ${t[0]} + coords.y * ${t[1]} + coords.z;\n }\n` } Jw.registerFlag("HAS_WEBGL", (() => Jw.getNumber("WEBGL_VERSION") > 0)), Jw.registerFlag("WEBGL_VERSION", (() => Hw(2) ? 2 : Hw(1) ? 1 : 0)), Jw.registerFlag("WEBGL_CHECK_NUMERICAL_PROBLEMS", (() => !1)), Jw.registerFlag("WEBGL_BUFFER_SUPPORTED", (() => 2 === Jw.get("WEBGL_VERSION"))), Jw.registerFlag("WEBGL_CPU_FORWARD", (() => !0)), Jw.registerFlag("WEBGL_FORCE_F16_TEXTURES", (() => !1)), Jw.registerFlag("WEBGL_PACK", (() => Jw.getBool("HAS_WEBGL"))), Jw.registerFlag("WEBGL_PACK_NORMALIZATION", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_CLIP", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_DEPTHWISECONV", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_BINARY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_UNARY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_ARRAY_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_IMAGE_OPERATIONS", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_REDUCE", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_LAZILY_UNPACK", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_CONV_IM2COL", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_PACK_CONV2DTRANSPOSE", (() => Jw.getBool("WEBGL_PACK"))), Jw.registerFlag("WEBGL_MAX_TEXTURE_SIZE", (() => Lw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_MAX_TEXTURES_IN_SHADER", (() => Ww(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION", (() => { const e = Jw.getNumber("WEBGL_VERSION"); return 0 === e ? 0 : Vw(e) })), Jw.registerFlag("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE", (() => Jw.getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 && !P.device_util.isMobile())), Jw.registerFlag("WEBGL_RENDER_FLOAT32_CAPABLE", (() => qw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_RENDER_FLOAT32_ENABLED", (() => !Jw.getBool("WEBGL_FORCE_F16_TEXTURES") && Jw.getBool("WEBGL_RENDER_FLOAT32_CAPABLE"))), Jw.registerFlag("WEBGL_DOWNLOAD_FLOAT_ENABLED", (() => Yw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_FENCE_API_ENABLED", (() => Kw(Jw.getNumber("WEBGL_VERSION")))), Jw.registerFlag("WEBGL_SIZE_UPLOAD_UNIFORM", (() => Jw.getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? 4 : 0)), Jw.registerFlag("WEBGL_DELETE_TEXTURE_THRESHOLD", (() => -1), (e => { if ("number" != typeof e) throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be a number but got ${e}.`); if (e < 0 && -1 !== e) throw new Error(`WEBGL_DELETE_TEXTURE_THRESHOLD must be -1 (indicating never delete) or at least 0, but got ${e}.`) })), Jw.registerFlag("WEBGL_FLUSH_THRESHOLD", (() => P.device_util.isMobile() ? 1 : -1), (e => { if ("number" != typeof e) throw new Error(`WEBGL_FLUSH_THRESHOLD must be a number but got ${e}.`); if (e < 0 && -1 !== e) throw new Error(`WEBGL_FLUSH_THRESHOLD must be -1 (indicating never manual flush) or at least 0, but got ${e}.`) })), Jw.registerFlag("CPU_HANDOFF_SIZE_THRESHOLD", (() => 128)), Jw.registerFlag("WEBGL_USE_SHAPES_UNIFORMS", (() => !1)), Jw.registerFlag("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD", (() => 1e5)), Jw.registerFlag("TOPK_K_CPU_HANDOFF_THRESHOLD", (() => 128)), Jw.registerFlag("WEBGL_EXP_CONV", (() => !1)), Jw.registerFlag("SOFTWARE_WEBGL_ENABLED", (() => Jw.getBool("IS_TEST"))), Jw.registerFlag("WEBGL_MAX_SIZE_FOR_NARROW_TEXTURE", (() => 1 / 0)), Jw.registerFlag("WEBGL_AUTO_SQUARIFY_NARROW_TEXTURE_SHAPE", (() => !1)), Jw.registerFlag("WEBGL2_ISNAN_CUSTOM", (() => !1)), Jw.registerFlag("ENGINE_COMPILE_ONLY", (() => !1)); const ik = "\n const float FLOAT_MAX = 1.70141184e38;\n const float FLOAT_MIN = 1.17549435e-38;\n\n lowp vec4 encode_float(highp float v) {\n if (isnan(v)) {\n return vec4(255, 255, 255, 255);\n }\n\n highp float av = abs(v);\n\n if(av < FLOAT_MIN) {\n return vec4(0.0, 0.0, 0.0, 0.0);\n } else if(v > FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 127.0) / 255.0;\n } else if(v < -FLOAT_MAX) {\n return vec4(0.0, 0.0, 128.0, 255.0) / 255.0;\n }\n\n highp vec4 c = vec4(0,0,0,0);\n\n highp float e = floor(log2(av));\n highp float m = exp2(fract(log2(av))) - 1.0;\n\n c[2] = floor(128.0 * m);\n m -= c[2] / 128.0;\n c[1] = floor(32768.0 * m);\n m -= c[1] / 32768.0;\n c[0] = floor(8388608.0 * m);\n\n highp float ebias = e + 127.0;\n c[3] = floor(ebias / 2.0);\n ebias -= c[3] * 2.0;\n c[2] += floor(ebias) * 128.0;\n\n c[3] += 128.0 * step(0.0, -v);\n\n return c / 255.0;\n }\n", { getBroadcastDims: ak } = P.backend_util; function ok(e, t, n) { const r = []; if (e.forEach((e => { const t = P.util.sizeFromShape(e.shapeInfo.logicalShape); if (e.shapeInfo.isUniform ? r.push(`uniform float ${e.name}${t > 1 ? `[${t}]` : ""};`) : (r.push(`uniform sampler2D ${e.name};`), r.push(`uniform int offset${e.name};`)), n.enableShapeUniforms) { const { uniformShape: t } = yk(n.packedInputs, e.shapeInfo.logicalShape, e.shapeInfo.texShape); switch (t.length) { case 1: r.push(`uniform int ${e.name}Shape;`); break; case 2: r.push(`uniform ivec2 ${e.name}Shape;`); break; case 3: r.push(`uniform ivec3 ${e.name}Shape;`); break; case 4: r.push(`uniform ivec4 ${e.name}Shape;`) }r.push(`uniform ivec2 ${e.name}TexShape;`) } })), n.enableShapeUniforms) { switch (t.logicalShape.length) { case 1: r.push("uniform int outShape;"); break; case 2: r.push("uniform ivec2 outShape;"), r.push("uniform int outShapeStrides;"); break; case 3: r.push("uniform ivec3 outShape;"), r.push("uniform ivec2 outShapeStrides;"); break; case 4: r.push("uniform ivec4 outShape;"), r.push("uniform ivec3 outShapeStrides;") }r.push("uniform ivec2 outTexShape;") } n.customUniforms && n.customUniforms.forEach((e => { r.push(`uniform ${e.type} ${e.name}${e.arrayIndex ? `[${e.arrayIndex}]` : ""};`) })); const i = r.join("\n"), a = e.map((e => function (e, t, n = !1, r) { let i = ""; i += n ? uk(e, r) : sk(e, r); const a = e.shapeInfo.logicalShape, o = t.logicalShape; a.length <= o.length && (i += n ? function (e, t) { const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = e.shapeInfo.logicalShape.length, o = t.logicalShape.length, s = ak(e.shapeInfo.logicalShape, t.logicalShape), u = gk(o), l = o - a; let c; const h = ["x", "y", "z", "w", "u", "v"]; c = 0 === a ? "" : o < 2 && s.length >= 1 ? "coords = 0;" : s.map((e => `coords.${h[e + l]} = 0;`)).join("\n"); let d = ""; d = o < 2 && a > 0 ? "coords" : e.shapeInfo.logicalShape.map(((e, t) => `coords.${h[t + l]}`)).join(", "); let f = "return outputValue;"; const p = 1 === P.util.sizeFromShape(e.shapeInfo.logicalShape), m = P.util.sizeFromShape(t.logicalShape), g = 1 === m; if (1 !== a || p || g) { if (p && !g) f = 1 === o ? "\n return vec4(outputValue.x, outputValue.x, 0., 0.);\n " : "\n return vec4(outputValue.x);\n "; else if (s.length) { const e = a - 2, t = a - 1; s.indexOf(e) > -1 && s.indexOf(t) > -1 ? f = "return vec4(outputValue.x);" : s.indexOf(e) > -1 ? f = "return vec4(outputValue.x, outputValue.y, outputValue.x, outputValue.y);" : s.indexOf(t) > -1 && (f = "return vec4(outputValue.xx, outputValue.zz);") } } else f = "\n return vec4(outputValue.xy, outputValue.xy);\n "; return `\n vec4 ${i}() {\n ${u} coords = getOutputCoords();\n ${c}\n vec4 outputValue = get${r}(${d});\n ${f}\n }\n ` }(e, t) : function (e, t) { const n = e.name, r = n.charAt(0).toUpperCase() + n.slice(1), i = "get" + r + "AtOutCoords", a = t.texShape, o = e.shapeInfo.texShape, s = e.shapeInfo.logicalShape.length, u = t.logicalShape.length; if (!e.shapeInfo.isUniform && s === u && null == e.shapeInfo.flatOffset && P.util.arraysEqual(o, a)) return `\n float ${i}() {\n return sampleTexture(${n}, resultUV);\n }\n `; const l = gk(u), c = ak(e.shapeInfo.logicalShape, t.logicalShape), h = u - s; let d; const f = ["x", "y", "z", "w", "u", "v"]; d = 0 === s ? "" : u < 2 && c.length >= 1 ? "coords = 0;" : c.map((e => `coords.${f[e + h]} = 0;`)).join("\n"); let p = ""; p = u < 2 && s > 0 ? "coords" : e.shapeInfo.logicalShape.map(((e, t) => `coords.${f[t + h]}`)).join(", "); return `\n float ${i}() {\n ${l} coords = getOutputCoords();\n ${d}\n return get${r}(${p});\n }\n ` }(e, t)); return i }(e, t, n.packedInputs, n.enableShapeUniforms))).join("\n"), o = t.texShape, s = Qw(), u = function (e) { return `\n float sampleTexture(sampler2D textureSampler, vec2 uv) {\n return ${e.texture2D}(textureSampler, uv).r;\n }\n ` }(s); let l, c, h = function (e) { const t = `${e.version}\n precision highp float;\n precision highp int;\n precision highp sampler2D;\n ${e.varyingFs} vec2 resultUV;\n ${e.defineOutput}\n const vec2 halfCR = vec2(0.5, 0.5);\n\n struct ivec5\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n };\n\n struct ivec6\n {\n int x;\n int y;\n int z;\n int w;\n int u;\n int v;\n };\n\n uniform float NAN;\n ${e.defineSpecialNaN}\n ${e.defineSpecialInf}\n ${e.defineRound}\n\n int imod(int x, int y) {\n return x - y * (x / y);\n }\n\n int idiv(int a, int b, float sign) {\n int res = a / b;\n int mod = imod(a, b);\n if (sign < 0. && mod != 0) {\n res -= 1;\n }\n return res;\n }\n\n //Based on the work of Dave Hoskins\n //https://www.shadertoy.com/view/4djSRW\n #define HASHSCALE1 443.8975\n float random(float seed){\n vec2 p = resultUV * seed;\n vec3 p3 = fract(vec3(p.xyx) * HASHSCALE1);\n p3 += dot(p3, p3.yzx + 19.19);\n return fract((p3.x + p3.y) * p3.z);\n }\n\n ${lk}\n ${ck}\n ${hk}\n `; return t }(s); t.isPacked ? (l = function (e, t, n) { switch (e.length) { case 0: return fk(); case 1: return function (e, t, n) { const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)]; if (1 === r[0]) return n ? "\n int getOutputCoords() {\n return 2 * int(resultUV.x * ceil(float(outTexShape[1]) / 2.0));\n }\n " : `\n int getOutputCoords() {\n return 2 * int(resultUV.x * ${r[1]}.0);\n }\n `; if (1 === r[1]) return n ? "\n int getOutputCoords() {\n return 2 * int(resultUV.y * ceil(float(outTexShape[0]) / 2.0));\n }\n " : `\n int getOutputCoords() {\n return 2 * int(resultUV.y * ${r[0]}.0);\n }\n `; if (n) return "\n int getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n return 2 * (resTexRC.x * packedTexShape[1] + resTexRC.y);\n }\n "; return `\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n return 2 * (resTexRC.x * ${r[1]} + resTexRC.y);\n }\n ` }(0, t, n); case 2: return function (e, t, n) { const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)]; if (P.util.arraysEqual(e, t)) return n ? "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n return 2 * ivec2(resultUV.yx * vec2(packedTexShape[0], packedTexShape[1]));\n }\n " : `\n ivec2 getOutputCoords() {\n return 2 * ivec2(resultUV.yx * vec2(${r[0]}, ${r[1]}));\n }\n `; const i = Math.ceil(e[1] / 2); if (n) return "\n ivec2 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec2(r, c);\n }\n "; return `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec2(r, c);\n }\n ` }(e, t, n); case 3: return function (e, t, n) { if (n) return "\n ivec3 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n int texelsInLogicalRow = int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec3(b, r, c);\n }\n "; const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[2] / 2), a = i * Math.ceil(e[1] / 2); return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n int b = index / ${a};\n index -= b * ${a};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec3(b, r, c);\n }\n ` }(e, t, n); default: return function (e, t, n) { if (n) return "\n ivec4 getOutputCoords() {\n ivec2 packedTexShape = ivec2(ceil(float(outTexShape[0]) / 2.0), ceil(float(outTexShape[1]) / 2.0));\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(packedTexShape[0], packedTexShape[1]));\n int index = resTexRC.x * packedTexShape[1] + resTexRC.y;\n\n int texelsInLogicalRow = int(ceil(float(outShape[3]) / 2.0));\n int texelsInBatch = texelsInLogicalRow * int(ceil(float(outShape[2]) / 2.0));\n int texelsInBatchN = texelsInBatch * outShape[1];\n\n int b2 = index / texelsInBatchN;\n index -= b2 * texelsInBatchN;\n\n int b = index / texelsInBatch;\n index -= b * texelsInBatch;\n\n int r = 2 * (index / texelsInLogicalRow);\n int c = imod(index, texelsInLogicalRow) * 2;\n\n return ivec4(b2, b, r, c);\n }\n "; const r = [Math.ceil(t[0] / 2), Math.ceil(t[1] / 2)], i = Math.ceil(e[e.length - 1] / 2), a = i * Math.ceil(e[e.length - 2] / 2); let o = a, s = "", u = "b, r, c"; for (let t = 2; t < e.length - 1; t++)o *= e[e.length - t - 1], s = `\n int b${t} = index / ${o};\n index -= b${t} * ${o};\n ` + s, u = `b${t}, ` + u; return `\n ivec${e.length} getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${r[0]}, ${r[1]}));\n int index = resTexRC.x * ${r[1]} + resTexRC.y;\n\n ${s}\n\n int b = index / ${a};\n index -= b * ${a};\n\n int r = 2 * (index / ${i});\n int c = imod(index, ${i}) * 2;\n\n return ivec${e.length}(${u});\n }\n ` }(e, t, n) } }(t.logicalShape, o, n.enableShapeUniforms), c = function (e) { return `\n void setOutput(vec4 val) {\n ${e.output} = val;\n }\n ` }(s)) : (l = function (e, t, n) { switch (e.length) { case 0: return fk(); case 1: return function (e, t, n) { if (1 === t[0]) return n ? "\n int getOutputCoords() {\n return int(resultUV.x * float(outTexShape[1]));\n }\n " : `\n int getOutputCoords() {\n return int(resultUV.x * ${t[1]}.0);\n }\n `; if (1 === t[1]) return n ? "\n int getOutputCoords() {\n return int(resultUV.y * float(outTexShape[0]));\n }\n " : `\n int getOutputCoords() {\n return int(resultUV.y * ${t[0]}.0);\n }\n `; if (n) return "\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n return resTexRC.x * outTexShape[1] + resTexRC.y;\n }\n "; return `\n int getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n return resTexRC.x * ${t[1]} + resTexRC.y;\n }\n ` }(0, t, n); case 2: return function (e, t, n) { if (P.util.arraysEqual(e, t)) return n ? "\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(outTexShape[0], outTexShape[1]));\n }\n " : `\n ivec2 getOutputCoords() {\n return ivec2(resultUV.yx * vec2(${t[0]}, ${t[1]}));\n }\n `; if (1 === e[1]) return n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(index, 0);\n }\n " : `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(index, 0);\n }\n `; if (1 === e[0]) return n ? "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n return ivec2(0, index);\n }\n " : `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n return ivec2(0, index);\n }\n `; if (n) return "\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n int r = index / outShape[1];\n int c = index - r * outShape[1];\n return ivec2(r, c);\n }\n "; return `\n ivec2 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n int r = index / ${e[1]};\n int c = index - r * ${e[1]};\n return ivec2(r, c);\n }\n ` }(e, t, n); case 3: return function (e, t, n) { if (n) { return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${tk(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n` } const r = ek(["r", "c", "d"], e); return `\n ivec3 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec3(r, c, d);\n }\n ` }(e, t, n); case 4: return function (e, t, n) { if (n) { return `\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(outTexShape[0], outTexShape[1]));\n int index = resTexRC.x * outTexShape[1] + resTexRC.y;\n ${tk(["r", "c", "d", "d2"], e)}\n return ivec4(r, c, d, d2);\n }\n ` } const r = ek(["r", "c", "d", "d2"], e); return `\n ivec4 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n ${r}\n return ivec4(r, c, d, d2);\n }\n ` }(e, t, n); case 5: return function (e, t) { const n = ek(["r", "c", "d", "d2", "d3"], e); return `\n ivec5 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(${t[0]},\n ${t[1]}));\n\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec5 outShape = ivec5(r, c, d, d2, d3);\n return outShape;\n }\n ` }(e, t); case 6: return function (e, t) { const n = ek(["r", "c", "d", "d2", "d3", "d4"], e); return `\n ivec6 getOutputCoords() {\n ivec2 resTexRC = ivec2(resultUV.yx *\n vec2(${t[0]}, ${t[1]}));\n int index = resTexRC.x * ${t[1]} + resTexRC.y;\n\n ${n}\n\n ivec6 result = ivec6(r, c, d, d2, d3, d4);\n return result;\n }\n ` }(e, t); default: throw new Error(`${e.length}-D output sampling is not yet supported`) } }(t.logicalShape, o, n.enableShapeUniforms), c = function (e) { return `\n void setOutput(float val) {\n ${e.output} = vec4(val, 0, 0, 0);\n }\n ` }(s)), n.packedInputs && (h += dk); return [h, u, c, i, l, a, n.userCode].join("\n") } function sk(e, t = !1) { const n = e.shapeInfo.logicalShape; switch (n.length) { case 0: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1); if (e.shapeInfo.isUniform) return `float ${r}() {return ${n};}`; const [i, a] = e.shapeInfo.texShape; if (1 === i && 1 === a) return `\n float ${r}() {\n return sampleTexture(${n}, halfCR);\n }\n `; const o = pk(n); if (t) return `\n float ${r}() {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], ${o});\n return sampleTexture(${n}, uv);\n }\n `; const [s, u] = e.shapeInfo.texShape; return `\n float ${r}() {\n vec2 uv = uvFromFlat(${s}, ${u}, ${o});\n return sampleTexture(${n}, uv);\n }\n ` }(e, t); case 1: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1); if (e.shapeInfo.isUniform) return `\n float ${r}(int index) {\n ${mk(e)}\n }\n `; const i = e.shapeInfo.texShape, a = i[0], o = i[1]; if (1 === o && 1 === a) return `\n float ${r}(int index) {\n return sampleTexture(${n}, halfCR);\n }\n `; const s = pk(n); if (1 === o) return t ? `\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${s}) + 0.5) / float(${n}TexShape[0]));\n return sampleTexture(${n}, uv);\n }\n ` : `\n float ${r}(int index) {\n vec2 uv = vec2(0.5, (float(index + ${s}) + 0.5) / ${a}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (1 === a) return t ? `\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${s}) + 0.5) / float(${n}TexShape[1]), 0.5);\n return sampleTexture(${n}, uv);\n }\n ` : `\n float ${r}(int index) {\n vec2 uv = vec2((float(index + ${s}) + 0.5) / ${o}.0, 0.5);\n return sampleTexture(${n}, uv);\n }\n `; if (t) return `\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${n}TexShape[0], ${n}TexShape[1], index + ${s});\n return sampleTexture(${n}, uv);\n }\n `; return `\n float ${r}(int index) {\n vec2 uv = uvFromFlat(${a}, ${o}, index + ${s});\n return sampleTexture(${n}, uv);\n }\n ` }(e, t); case 2: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape; if (null != a && P.util.arraysEqual(n, a)) { if (t) return `\n float ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n `; const e = a[0]; return `\n float ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${a[1]}.0, ${e}.0);\n return sampleTexture(${r}, uv);\n }\n ` } const { newShape: o, keptDims: s } = P.util.squeezeShape(n), u = o; if (u.length < n.length) { const n = ["row", "col"]; return `\n ${sk(bk(e, u), t)}\n float ${i}(int row, int col) {\n return ${i}(${vk(n, s)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col) {\n int index = round(dot(vec2(row, col), vec2(${n[1]}, 1)));\n ${mk(e)}\n }\n `; const l = a[0], c = a[1], h = pk(r); if (1 === c) return t ? `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / float(${r}TexShape[0]));\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2(0.5, (index + 0.5) / ${l}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (1 === l) return t ? `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${r}Shape[1], 1, 1));\n vec2 uv = vec2((index + 0.5) / float(${r}TexShape[1]), 0.5);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col) {\n float index = dot(vec3(row, col, ${h}), vec3(${n[1]}, 1, 1));\n vec2 uv = vec2((index + 0.5) / ${c}.0, 0.5);\n return sampleTexture(${r}, uv);\n }\n `; if (t) return `\n float ${i}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${r}Shape[1] + col + ${h};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${n[1]} + col + ${h};\n vec2 uv = uvFromFlat(${l}, ${c}, index);\n return sampleTexture(${r}, uv);\n }\n` }(e, t); case 3: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[1] * n[2], o = n[2], { newShape: s, keptDims: u } = P.util.squeezeShape(n), l = s; if (l.length < n.length) { const n = ["row", "col", "depth"]; return `\n ${sk(bk(e, l), t)}\n float ${i}(int row, int col, int depth) {\n return ${i}(${vk(n, u)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col, int depth) {\n int index = round(dot(vec3(row, col, depth),\n vec3(${a}, ${o}, 1)));\n ${mk(e)}\n }\n `; const c = e.shapeInfo.texShape, h = c[0], d = c[1], f = e.shapeInfo.flatOffset; if (d === a && null == f) return t ? `\n float ${i}(int row, int col, int depth) {\n int stride1 = ${r}Shape[2];\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(stride1, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth) {\n float texR = float(row);\n float texC = dot(vec2(col, depth), vec2(${o}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (d === o && null == f) return t ? `\n float ${i}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${r}Shape[1], 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth) {\n float texR = dot(vec2(row, col), vec2(${n[1]}, 1));\n float texC = float(depth);\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${d}.0, ${h}.0);\n return sampleTexture(${r}, uv);\n }\n `; const p = pk(r); if (t) return `\n float ${i}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int stride0 = ${r}Shape[1] * ${r}Shape[2];\n int stride1 = ${r}Shape[2];\n int index = row * stride0 + col * stride1 + depth + ${p};\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index);\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col, int depth) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${a} + col * ${o} + depth + ${p};\n vec2 uv = uvFromFlat(${h}, ${d}, index);\n return sampleTexture(${r}, uv);\n }\n ` }(e, t); case 4: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = n[3], o = n[2] * a, s = n[1] * o, { newShape: u, keptDims: l } = P.util.squeezeShape(n); if (u.length < n.length) { const n = ["row", "col", "depth", "depth2"]; return `\n ${sk(bk(e, u), t)}\n float ${i}(int row, int col, int depth, int depth2) {\n return ${i}(${vk(n, l)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${i}(int row, int col, int depth, int depth2) {\n int index = round(dot(vec4(row, col, depth, depth2),\n vec4(${s}, ${o}, ${a}, 1)));\n ${mk(e)}\n }\n `; const c = e.shapeInfo.flatOffset, h = e.shapeInfo.texShape, d = h[0], f = h[1], p = `int stride2 = ${r}Shape[3];`, m = `int stride1 = ${r}Shape[2] * stride2;`, g = `int stride0 = ${r}Shape[1] * stride1;`; if (f === s && null == c) return t ? `\n float ${i}(int row, int col, int depth, int depth2) {\n ${p}\n ${m}\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(stride1, stride2, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = float(row);\n float texC =\n dot(vec3(col, depth, depth2),\n vec3(${o}, ${a}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `; if (f === a && null == c) return t ? `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${r}Shape[1] * ${r}Shape[2], ${r}Shape[2], 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}TexShape[1], ${r}TexShape[0]);\n return sampleTexture(${r}, uv);\n }\n ` : `\n float ${i}(int row, int col, int depth, int depth2) {\n float texR = dot(vec3(row, col, depth),\n vec3(${n[1] * n[2]}, ${n[2]}, 1));\n float texC = float(depth2);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${r}, uv);\n }\n `; const y = pk(r); if (t) return `\n float ${i}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n ${p}\n ${m}\n ${g}\n int index = row * stride0 + col * stride1 +\n depth * stride2 + depth2;\n vec2 uv = uvFromFlat(${r}TexShape[0], ${r}TexShape[1], index + ${y});\n return sampleTexture(${r}, uv);\n }\n `; return `\n float ${i}(int row, int col, int depth, int depth2) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${s} + col * ${o} +\n depth * ${a} + depth2;\n vec2 uv = uvFromFlat(${d}, ${f}, index + ${y});\n return sampleTexture(${r}, uv);\n }\n ` }(e, t); case 5: return function (e) { const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = t[4], a = t[3] * i, o = t[2] * a, s = t[1] * o, { newShape: u, keptDims: l } = P.util.squeezeShape(t); if (u.length < t.length) { const t = ["row", "col", "depth", "depth2", "depth3"]; return `\n ${sk(bk(e, u))}\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n return ${r}(${vk(t, l)});\n }\n ` } if (e.shapeInfo.isUniform) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float index = dot(\n vec4(row, col, depth, depth2),\n vec4(${s}, ${o}, ${a}, ${i})) +\n depth3;\n ${mk(e)}\n }\n `; const c = e.shapeInfo.flatOffset, h = e.shapeInfo.texShape, d = h[0], f = h[1]; if (f === s && null == c) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${o}, ${a}, ${i}, 1));\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (f === i && null == c) return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n float texR = dot(\n vec4(row, col, depth, depth2),\n vec4(${t[1] * t[2] * t[3]},\n ${t[2] * t[3]}, ${t[3]}, 1));\n int texC = depth3;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${f}.0, ${d}.0);\n return sampleTexture(${n}, uv);\n }\n `; const p = pk(n); return `\n float ${r}(int row, int col, int depth, int depth2, int depth3) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${s} + col * ${o} + depth * ${a} +\n depth2 * ${i} + depth3 + ${p};\n vec2 uv = uvFromFlat(${d}, ${f}, index);\n return sampleTexture(${n}, uv);\n }\n ` }(e); case 6: return function (e) { const t = e.shapeInfo.logicalShape, n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), { newShape: i, keptDims: a } = P.util.squeezeShape(t); if (i.length < t.length) { const t = ["row", "col", "depth", "depth2", "depth3", "depth4"]; return `\n ${sk(bk(e, i))}\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n return ${r}(${vk(t, a)});\n }\n ` } const o = t[5], s = t[4] * o, u = t[3] * s, l = t[2] * u, c = t[1] * l; if (e.shapeInfo.isUniform) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int index = round(dot(\n vec4(row, col, depth, depth2),\n vec4(${c}, ${l}, ${u}, ${s})) +\n dot(\n vec2(depth3, depth4),\n vec2(${o}, 1)));\n ${mk(e)}\n }\n `; const h = e.shapeInfo.flatOffset, d = e.shapeInfo.texShape, f = d[0], p = d[1]; if (p === c && null == h) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n int texR = row;\n float texC = dot(vec4(col, depth, depth2, depth3),\n vec4(${l}, ${u}, ${s}, ${o})) +\n float(depth4);\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `; if (p === o && null == h) return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n float texR = dot(vec4(row, col, depth, depth2),\n vec4(${t[1] * t[2] * t[3] * t[4]},\n ${t[2] * t[3] * t[4]},\n ${t[3] * t[4]},\n ${t[4]})) + float(depth3);\n int texC = depth4;\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${p}.0, ${f}.0);\n return sampleTexture(${n}, uv);\n }\n `; const m = pk(n); return `\n float ${r}(int row, int col, int depth,\n int depth2, int depth3, int depth4) {\n // Explicitly use integer operations as dot() only works on floats.\n int index = row * ${c} + col * ${l} + depth * ${u} +\n depth2 * ${s} + depth3 * ${o} + depth4 + ${m};\n vec2 uv = uvFromFlat(${f}, ${p}, index);\n return sampleTexture(${n}, uv);\n }\n ` }(e); default: throw new Error(`${n.length}-D input sampling is not yet supported`) } } function uk(e, t) { switch (e.shapeInfo.logicalShape.length) { case 0: return function (e) { const t = e.name, n = "get" + t.charAt(0).toUpperCase() + t.slice(1), r = Qw(); return `\n vec4 ${n}() {\n return ${r.texture2D}(${t}, halfCR);\n }\n ` }(e); case 1: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = e.shapeInfo.texShape, a = Qw(); if (t) return `\n vec4 ${r}(int index) {\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n vec2 uv = packedUVfrom1D(\n packedTexShape[0], packedTexShape[1], index);\n return ${a.texture2D}(${n}, uv);\n }\n `; const o = [Math.ceil(i[0] / 2), Math.ceil(i[1] / 2)]; return `\n vec4 ${r}(int index) {\n vec2 uv = packedUVfrom1D(\n ${o[0]}, ${o[1]}, index);\n return ${a.texture2D}(${n}, uv);\n }\n ` }(e, t); case 2: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = a[0], s = a[1], u = Qw(); if (null != a && P.util.arraysEqual(n, a)) return t ? `\n vec4 ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${r}TexShape[1], ${r}TexShape[0]);\n\n return ${u.texture2D}(${r}, uv);\n }\n ` : `\n vec4 ${i}(int row, int col) {\n vec2 uv = (vec2(col, row) + halfCR) / vec2(${s}.0, ${o}.0);\n\n return ${u.texture2D}(${r}, uv);\n }\n `; if (t) return `\n vec4 ${i}(int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom2D(valuesPerRow, packedTexShape[0], packedTexShape[1], row, col);\n return ${u.texture2D}(${r}, uv);\n }\n `; const l = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)], c = Math.ceil(n[1] / 2); return `\n vec4 ${i}(int row, int col) {\n vec2 uv = packedUVfrom2D(${c}, ${l[0]}, ${l[1]}, row, col);\n return ${u.texture2D}(${r}, uv);\n }\n ` }(e, t); case 3: return function (e, t) { const n = e.shapeInfo.logicalShape, r = e.name, i = "get" + r.charAt(0).toUpperCase() + r.slice(1), a = e.shapeInfo.texShape, o = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)]; if (1 === n[0]) { const r = [1, 2], a = ["b", "row", "col"]; return `\n ${uk(bk(e, n.slice(1)), t)}\n vec4 ${i}(int b, int row, int col) {\n return ${i}(${vk(a, r)});\n }\n ` } const s = Qw(); if (t) return `\n vec4 ${i}(int b, int row, int col) {\n ivec2 packedTexShape = ivec2(ceil(float(${r}TexShape[0]) / 2.0), ceil(float(${r}TexShape[1]) / 2.0));\n int valuesPerRow = int(ceil(float(${r}Shape[2]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${r}Shape[1]) / 2.0));\n vec2 uv = packedUVfrom3D(\n packedTexShape[0], packedTexShape[1], texelsInBatch, valuesPerRow, b, row, col);\n return ${s.texture2D}(${r}, uv);\n }\n `; const u = o[0], l = o[1], c = Math.ceil(n[2] / 2), h = c * Math.ceil(n[1] / 2); return `\n vec4 ${i}(int b, int row, int col) {\n vec2 uv = packedUVfrom3D(\n ${u}, ${l}, ${h}, ${c}, b, row, col);\n return ${s.texture2D}(${r}, uv);\n }\n ` }(e, t); default: return function (e, t) { const n = e.name, r = "get" + n.charAt(0).toUpperCase() + n.slice(1), i = Qw(); if (t) return `\n vec4 ${r}(int b2, int b, int row, int col) {\n int valuesPerRow = int(ceil(float(${n}Shape[3]) / 2.0));\n int texelsInBatch = valuesPerRow * int(ceil(float(${n}Shape[2]) / 2.0));\n int index = b * texelsInBatch + (row / 2) * valuesPerRow + (col / 2);\n texelsInBatch *= ${n}Shape[1];\n index = b2 * texelsInBatch + index;\n ivec2 packedTexShape = ivec2(ceil(float(${n}TexShape[0]) / 2.0), ceil(float(${n}TexShape[1]) / 2.0));\n int texR = index / packedTexShape[1];\n int texC = index - texR * packedTexShape[1];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(packedTexShape[1], packedTexShape[0]); return ${i.texture2D}(${n}, uv);\n }\n `; const a = e.shapeInfo.logicalShape, o = a.length, s = e.shapeInfo.texShape, u = [Math.ceil(s[0] / 2), Math.ceil(s[1] / 2)], l = u[0], c = u[1], h = Math.ceil(a[o - 1] / 2); let d = h * Math.ceil(a[o - 2] / 2), f = "int b, int row, int col", p = `b * ${d} + (row / 2) * ${h} + (col / 2)`; for (let e = 2; e < o - 1; e++)f = `int b${e}, ` + f, d *= a[o - e - 1], p = `b${e} * ${d} + ` + p; return `\n vec4 ${r}(${f}) {\n int index = ${p};\n int texR = index / ${c};\n int texC = index - texR * ${c};\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${c}, ${l});\n return ${i.texture2D}(${n}, uv);\n }\n ` }(e, t) } } const lk = "\nvec2 uvFromFlat(int texNumR, int texNumC, int index) {\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\nvec2 packedUVfrom1D(int texNumR, int texNumC, int index) {\n int texelIndex = index / 2;\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", ck = "\nvec2 packedUVfrom2D(int texelsInLogicalRow, int texNumR,\n int texNumC, int row, int col) {\n int texelIndex = (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = texelIndex / texNumC;\n int texC = texelIndex - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", hk = "\nvec2 packedUVfrom3D(int texNumR, int texNumC,\n int texelsInBatch, int texelsInLogicalRow, int b,\n int row, int col) {\n int index = b * texelsInBatch + (row / 2) * texelsInLogicalRow + (col / 2);\n int texR = index / texNumC;\n int texC = index - texR * texNumC;\n return (vec2(texC, texR) + halfCR) / vec2(texNumC, texNumR);\n}\n", dk = "\n float getChannel(vec4 frag, vec2 innerDims) {\n vec2 modCoord = mod(innerDims, 2.);\n return modCoord.x == 0. ?\n (modCoord.y == 0. ? frag.r : frag.g) :\n (modCoord.y == 0. ? frag.b : frag.a);\n }\n float getChannel(vec4 frag, int dim) {\n float modCoord = mod(float(dim), 2.);\n return modCoord == 0. ? frag.r : frag.g;\n }\n"; function fk() { return "\n int getOutputCoords() {\n return 0;\n }\n " } function pk(e) { return `offset${e}` } function mk(e) { const t = e.name, n = P.util.sizeFromShape(e.shapeInfo.logicalShape); return n < 2 ? `return ${t};` : `\n for (int i = 0; i < ${n}; i++) {\n if (i == index) {\n return ${t}[i];\n }\n }\n ` } function gk(e) { if (e <= 1) return "int"; if (2 === e) return "ivec2"; if (3 === e) return "ivec3"; if (4 === e) return "ivec4"; if (5 === e) return "ivec5"; if (6 === e) return "ivec6"; throw Error(`GPU for rank ${e} is not yet supported`) } function yk(e, t, n) { const { newShape: r, keptDims: i } = P.util.squeezeShape(t), a = t.length, o = e && 3 === a && 1 === t[0], s = o ? t.slice(1) : r, u = !e && a > 1 && !P.util.arraysEqual(t, n) && r.length < a || o; return { useSqueezeShape: u, uniformShape: u ? s : t, keptDims: i } } function bk(e, t) { const n = JSON.parse(JSON.stringify(e)); return n.shapeInfo.logicalShape = t, n } function vk(e, t) { return t.map((t => e[t])).join(", ") } function xk(e, t, n) { const r = [], i = []; let a, o, s, u = null, l = null; l = e.getUniformLocation(n, "NAN", !1), 1 === (0, P.env)().getNumber("WEBGL_VERSION") && (u = e.getUniformLocation(n, "INFINITY", !1)); const c = !1; for (const i of t.variableNames) { const a = { name: i, uniform: e.getUniformLocation(n, i, c), offset: e.getUniformLocation(n, `offset${i}`, c) }; t.enableShapeUniforms && (a.shape = e.getUniformLocation(n, `${i}Shape`, c), a.texShape = e.getUniformLocation(n, `${i}TexShape`, c)), r.push(a) } if (t.enableShapeUniforms && (a = e.getUniformLocation(n, "outShape", c), s = e.getUniformLocation(n, "outShapeStrides", c), o = e.getUniformLocation(n, "outTexShape", c)), t.customUniforms) for (const r of t.customUniforms) i.push(e.getUniformLocation(n, r.name, c)); return { variablesLocations: r, customUniformLocations: i, infLoc: u, nanLoc: l, outShapeLocation: a, outShapeStridesLocation: s, outTexShapeLocation: o } } function wk(e, t) { if (e.length !== t.length) throw Error(`Binary was compiled with ${e.length} inputs, but was executed with ${t.length} inputs`); e.forEach(((e, n) => { const r = e.logicalShape, i = t[n], a = i.shape; if (!P.util.arraysEqual(r, a)) throw Error(`Binary was compiled with different shapes than the current args. Shapes ${r} and ${a} must match`); if (e.isUniform && i.isUniform) return; const o = e.texShape, s = i.isUniform ? null : i.texData.texShape; if (!P.util.arraysEqual(o, s)) throw Error(`Binary was compiled with different texture shapes than the current args. Shape ${o} and ${s} must match`) })) } function kk(e) { return (0, P.env)().getBool("WEBGL_USE_SHAPES_UNIFORMS") && e <= 4 }
/**
* @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.
* =============================================================================
*/
class Sk { constructor(e) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outPackingScheme = Vx.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const t = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms ? tk(["r", "c", "d"], e) : ek(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getA(rc.x, rc.y, rc.z);\n }\n\n ${t.output} = result;\n }\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.
* =============================================================================
*/
class _k { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outPackingScheme = Vx.DENSE, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const t = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n ivec3 outCoordsFromFlatIndex(int index) {\n ${this.enableShapeUniforms ? tk(["r", "c", "d"], e) : ek(["r", "c", "d"], e)}\n return ivec3(r, c, d);\n }\n\n void main() {\n ivec2 resTexRC = ivec2(resultUV.yx * vec2(texShape[0], texShape[1]));\n int index = 4 * (resTexRC.x * texShape[1] + resTexRC.y);\n\n vec4 result = vec4(0.);\n\n for (int i=0; i<4; i++) {\n int flatIndex = index + i;\n ivec3 rc = outCoordsFromFlatIndex(flatIndex);\n result[i] = getChannel(getA(rc.x, rc.y, rc.z), vec2(rc.y, rc.z));\n }\n\n ${t.output} = result;\n }\n ` } }
/**
* @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 Ck { constructor(e) { this.variableNames = ["A"], this.outTexUsage = Hx.DOWNLOAD; const t = Qw(); this.outputShape = e, this.userCode = `\n ${ik}\n\n void main() {\n float x = getAAtOutCoords();\n ${t.output} = encode_float(x);\n }\n ` } }
/**
* @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 Ak { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outTexUsage = Hx.DOWNLOAD; const t = Qw(); this.outputShape = e, this.userCode = `\n ${ik}\n\n void main() {\n ivec3 coords = getOutputCoords();\n float x = getChannel(getAAtOutCoords(), vec2(coords.y, coords.z));\n ${t.output} = encode_float(x);\n }\n ` } }
/**
* @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 Tk = { R: 0, G: 1, B: 2, A: 3 }; class Ek { constructor(e, t = !1, n = "RGBA") { this.variableNames = ["A"], this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const r = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let i = "result"; t && (i = "floor(result * 255. + 0.5)"); let a = ""; for (let e = 0; e < n.length; e++) { const t = n[e]; a += `\n if(offset == ${e}) {\n result = values[${Tk[t]}];\n }` } this.userCode = `\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n int flatIndex = getFlatIndex(coords);\n float result = 0.;\n int offset = imod(flatIndex, ${n.length});\n\n flatIndex = idiv(flatIndex, ${n.length}, 1.);\n\n int r = flatIndex / texShape[1];\n if (r < texShape[0]) {\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n vec4 values = ${r.texture2D}(A, uv);\n ${a}\n }\n ${r.output} = vec4(${i}, 0., 0., 0.);\n }\n ` } }
/**
* @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 Nk { constructor(e, t = !1) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.customUniforms = [{ name: "texShape", type: "ivec2" }]; const n = Qw(); this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let r = "", i = "result"; t && (i = "floor(result * 255. + 0.5)"); for (let t = 0; t <= 1; t++)for (let i = 0; i <= 1; i++) { const a = 2 * t + i; r += `\n localCoords = coords;\n if(localCoords[2] + ${i} < ${this.enableShapeUniforms ? "outShape[2]" : `${e[2]}`}) {\n localCoords[2] += ${i};\n if (localCoords[1] + ${t} < ${this.enableShapeUniforms ? "outShape[1]" : `${e[1]}`}) {\n localCoords[1] += ${t};\n\n flatIndex = getFlatIndex(localCoords);\n offset = imod(flatIndex, 4);\n\n flatIndex = idiv(flatIndex, 4, 1.);\n\n int r = flatIndex / texShape[1];\n int c = imod(flatIndex, texShape[1]);\n vec2 uv = (vec2(c, r) + halfCR) / vec2(texShape[1], texShape[0]);\n values = ${n.texture2D}(A, uv);\n\n if (offset == 0) {\n result[${a}] = values[0];\n } else if (offset == 1) {\n result[${a}] = values[1];\n } else if (offset == 2) {\n result[${a}] = values[2];\n } else {\n result[${a}] = values[3];\n }\n }\n }\n ` } this.userCode = `\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 coords = getOutputCoords();\n\n vec4 result = vec4(0.);\n int flatIndex, r, c, offset;\n ivec3 localCoords;\n vec2 uv;\n vec4 values;\n\n ${r}\n\n ${n.output} = ${i};\n }\n ` } }
/**
* @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.
* =============================================================================
*/
function Ik(e) { const t = Qw(); return ow(e, `${t.version}\n precision highp float;\n ${t.attribute} vec3 clipSpacePos;\n ${t.attribute} vec2 uv;\n ${t.varyingVs} vec2 resultUV;\n\n void main() {\n gl_Position = vec4(clipSpacePos, 1);\n resultUV = uv;\n }`) } function Mk(e) { return fw(e, new Float32Array([-1, 1, 0, 0, 1, -1, -1, 0, 0, 0, 1, 1, 0, 1, 1, 1, -1, 0, 1, 0])) } function Fk(e) { return pw(e, new Uint16Array([0, 1, 2, 2, 1, 3])) } function Dk(e, t, n, r, i, a) { yw(t, n); const o = gw(e), s = e.TEXTURE_2D; return ew(e, (() => e.bindTexture(s, o))), ew(e, (() => e.texParameteri(s, e.TEXTURE_WRAP_S, e.CLAMP_TO_EDGE))), ew(e, (() => e.texParameteri(s, e.TEXTURE_WRAP_T, e.CLAMP_TO_EDGE))), ew(e, (() => e.texParameteri(s, e.TEXTURE_MIN_FILTER, e.NEAREST))), ew(e, (() => e.texParameteri(s, e.TEXTURE_MAG_FILTER, e.NEAREST))), 1 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texImage2D(s, 0, r, t, n, 0, i, a, null))) : ew(e, (() => e.texStorage2D(s, 1, r, t, n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))), { texture: o, texShape: [n, t] } } function $k(e) { return e.internalFormatFloat } function Rk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, $k(r), r.textureFormatFloat, e.FLOAT) } function Ok(e) { return e.internalFormatHalfFloat } function zk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, Ok(r), r.textureFormatFloat, r.textureTypeHalfFloat) } function Pk(e) { return e.downloadTextureFormat } function Bk(e, t, n, r) { const [i, a] = Kx(t, n); return Dk(e, i, a, Pk(r), e.RGBA, e.UNSIGNED_BYTE) } function Lk(e) { return e.internalFormatPackedFloat } function jk(e, t, n, r) { const [i, a] = Jx(t, n); return Dk(e, i, a, Lk(r), e.RGBA, e.FLOAT) } function Uk(e) { return e.internalFormatPackedHalfFloat } function Wk(e, t, n, r) { const [i, a] = Jx(t, n); return Dk(e, i, a, Uk(r), e.RGBA, r.textureTypeHalfFloat) } function Vk(e, t, n) { ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, n))); return vw(e, t, "clipSpacePos", n, 3, 20, 0) && vw(e, t, "uv", n, 2, 20, 12) } function Gk(e, t, n, r, i, a) { let o, s, u; ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))), i instanceof Uint8Array ? (o = new Uint8Array(n * r * 4), s = e.UNSIGNED_BYTE, u = e.RGBA) : (o = new Float32Array(n * r * 4), s = e.FLOAT, u = a.internalFormatPackedFloat), o.set(i), 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, n, r, e.RGBA, s, o))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, u, n, r, 0, e.RGBA, s, o))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function Hk(e, t, n) { ew(e, (() => e.bindTexture(e.TEXTURE_2D, t))), n.data instanceof Uint8Array ? 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, n.width, n.height, e.RGBA, e.UNSIGNED_BYTE, n.data))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, n.width, n.height, 0, e.RGBA, e.UNSIGNED_BYTE, n.data))) : 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? ew(e, (() => e.texSubImage2D(e.TEXTURE_2D, 0, 0, 0, e.RGBA, e.UNSIGNED_BYTE, n))) : ew(e, (() => e.texImage2D(e.TEXTURE_2D, 0, e.RGBA, e.RGBA, e.UNSIGNED_BYTE, n))), ew(e, (() => e.bindTexture(e.TEXTURE_2D, null))) } function qk(e, t, n, r) { const i = e.createBuffer(); ew(e, (() => e.bindBuffer(e.PIXEL_PACK_BUFFER, i))); const a = 16 * t * n; return ew(e, (() => e.bufferData(e.PIXEL_PACK_BUFFER, a, e.STREAM_READ))), ew(e, (() => e.readPixels(0, 0, n, t, e.RGBA, e.FLOAT, 0))), ew(e, (() => e.bindBuffer(e.PIXEL_PACK_BUFFER, null))), i } function Yk(e, t, n) { const r = e, i = new Float32Array(n); return r.bindBuffer(r.PIXEL_PACK_BUFFER, t), r.getBufferSubData(r.PIXEL_PACK_BUFFER, 0, i), r.bindBuffer(r.PIXEL_PACK_BUFFER, null), i } function Xk(e, t, n, r) { const [i, a] = Kx(t, n), o = new Uint8Array(t * n * 4); return ew(e, (() => e.readPixels(0, 0, i, a, r.downloadTextureFormat, e.UNSIGNED_BYTE, o))), new Float32Array(o.buffer) } function Kk(e, t, n, r, i, a, o, s) { const u = e, l = new Float32Array(function (e, t) { const [n, r] = Jx(e, t); return n * r * 4 }(a, o)); return u.bindBuffer(u.PIXEL_PACK_BUFFER, t), u.getBufferSubData(u.PIXEL_PACK_BUFFER, 0, l), u.bindBuffer(u.PIXEL_PACK_BUFFER, null), l } function Zk(e, t, n) { const r = new Float32Array(t * n * 4); return ew(e, (() => e.readPixels(0, 0, n, t, e.RGBA, e.FLOAT, r))), r }
/**
* @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.
* =============================================================================
*/
class Jk { constructor(e) { this.outputTexture = null, this.program = null, this.disposed = !1, this.itemsToPoll = []; const t = (0, P.env)().getNumber("WEBGL_VERSION"); if (null != e ? (this.gl = e, Ux(t, e)) : this.gl = Wx(t), e = this.gl, 2 === (0, P.env)().getNumber("WEBGL_VERSION")) { const t = e; this.createVertexArray = () => ew(t, (() => t.createVertexArray())), this.bindVertexArray = e => ew(t, (() => t.bindVertexArray(e))), this.deleteVertexArray = e => ew(t, (() => t.deleteVertexArray(e))), this.getVertexArray = () => ew(t, (() => t.getParameter(t.VERTEX_ARRAY_BINDING))) } else if (null != e) { const t = e.getExtension("OES_vertex_array_object"); if (null == t) throw new Error("All WebGL1 implementations are expected to offer OES_vertex_array_object."); this.createVertexArray = () => ew(e, (() => t.createVertexArrayOES())), this.bindVertexArray = n => ew(e, (() => t.bindVertexArrayOES(n))), this.deleteVertexArray = n => ew(e, (() => t.deleteVertexArrayOES(n))), this.getVertexArray = () => ew(e, (() => e.getParameter(t.VERTEX_ARRAY_BINDING_OES))) } let n = "WEBGL_color_buffer_float"; const r = "EXT_color_buffer_half_float"; if (this.parallelCompilationExtension = this.gl.getExtension("KHR_parallel_shader_compile"), 1 === (0, P.env)().getNumber("WEBGL_VERSION")) { const e = "OES_texture_float", t = "OES_texture_half_float"; if (this.textureFloatExtension = aw(this.gl, e), Gw(this.gl, t)) this.textureHalfFloatExtension = aw(this.gl, t); else if ((0, P.env)().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support half float textures, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true."); if (this.colorBufferFloatExtension = this.gl.getExtension(n), Gw(this.gl, r)) this.colorBufferHalfFloatExtension = aw(this.gl, r); else if ((0, P.env)().get("WEBGL_FORCE_F16_TEXTURES")) throw new Error("GL context does not support color renderable half floats, yet the environment flag WEBGL_FORCE_F16_TEXTURES is set to true.") } else if (n = "EXT_color_buffer_float", Gw(this.gl, n)) this.colorBufferFloatExtension = this.gl.getExtension(n); else { if (!Gw(this.gl, r)) throw new Error("GL context does not support color renderable floats"); this.colorBufferHalfFloatExtension = this.gl.getExtension(r) } this.vertexBuffer = Mk(this.gl), this.indexBuffer = Fk(this.gl), this.framebuffer = bw(this.gl), this.textureConfig = Qx(this.gl, this.textureHalfFloatExtension) } get debug() { return (0, P.env)().getBool("DEBUG") } dispose() { if (this.disposed) return; null != this.program && console.warn("Disposing a GPGPUContext that still has a bound WebGLProgram. This is probably a resource leak, delete the program with GPGPUContext.deleteProgram before disposing."), null != this.outputTexture && console.warn("Disposing a GPGPUContext that still has a bound output matrix texture. This is probably a resource leak, delete the output matrix texture with GPGPUContext.deleteMatrixTexture before disposing."); const e = this.gl; ew(e, (() => e.finish())), ew(e, (() => e.bindFramebuffer(e.FRAMEBUFFER, null))), ew(e, (() => e.deleteFramebuffer(this.framebuffer))), ew(e, (() => e.bindBuffer(e.ARRAY_BUFFER, null))), ew(e, (() => e.bindBuffer(e.ELEMENT_ARRAY_BUFFER, null))), ew(e, (() => e.deleteBuffer(this.indexBuffer))), this.disposed = !0 } createFloat32MatrixTexture(e, t) { return this.throwIfDisposed(), Rk(this.gl, e, t, this.textureConfig) } createFloat16MatrixTexture(e, t) { return this.throwIfDisposed(), zk(this.gl, e, t, this.textureConfig) } createUnsignedBytesMatrixTexture(e, t) { return this.throwIfDisposed(), Bk(this.gl, e, t, this.textureConfig) } uploadPixelDataToTexture(e, t) { this.throwIfDisposed(), Hk(this.gl, e, t) } uploadDenseMatrixToTexture(e, t, n, r) { this.throwIfDisposed(), Gk(this.gl, e, t, n, r, this.textureConfig) } createFloat16PackedMatrixTexture(e, t) { return this.throwIfDisposed(), Wk(this.gl, e, t, this.textureConfig) } createPackedMatrixTexture(e, t) { return this.throwIfDisposed(), jk(this.gl, e, t, this.textureConfig) } deleteMatrixTexture(e) { this.throwIfDisposed(), this.outputTexture === e && (Tw(this.gl, this.framebuffer), this.outputTexture = null), ew(this.gl, (() => this.gl.deleteTexture(e))) } downloadByteEncodedFloatMatrixFromOutputTexture(e, t, n) { return this.downloadMatrixDriver(e, (() => Xk(this.gl, t, n, this.textureConfig))) } downloadPackedMatrixFromBuffer(e, t, n, r, i, a) { return Kk(this.gl, e, 0, 0, 0, i, a, this.textureConfig) } downloadFloat32MatrixFromBuffer(e, t) { return Yk(this.gl, e, t) } createBufferFromTexture(e, t, n) { this.bindTextureToFrameBuffer(e); const r = qk(this.gl, t, n, this.textureConfig); return this.unbindTextureToFrameBuffer(), r } createAndWaitForFence() { const e = this.createFence(this.gl); return this.pollFence(e) } createFence(e) { let t, n; if ((0, P.env)().getBool("WEBGL_FENCE_API_ENABLED")) { const r = e, i = r.fenceSync(r.SYNC_GPU_COMMANDS_COMPLETE, 0); e.flush(), n = () => { const e = r.clientWaitSync(i, 0, 0); return e === r.ALREADY_SIGNALED || e === r.CONDITION_SATISFIED }, t = i } else (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") > 0 ? (t = this.beginQuery(), this.endQuery(), n = () => this.isQueryAvailable(t, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION"))) : n = () => !0; return { query: t, isFencePassed: n } } downloadMatrixFromPackedTexture(e, t, n) { return this.downloadMatrixDriver(e, (() => Zk(this.gl, t, n))) } createProgram(e) { this.throwIfDisposed(); const t = this.gl; null == this.vertexShader && (this.vertexShader = Ik(t)); const n = cw(t); ew(t, (() => t.attachShader(n, this.vertexShader))), ew(t, (() => t.attachShader(n, e))), hw(t, n); const r = Object.assign(n, { vao: this.createVertexArray() }); return this.debug && dw(t, r), r } buildVao(e) { this.setProgram(e), this.bindVertexArray(e.vao); const t = this.gl; ew(t, (() => t.bindBuffer(t.ELEMENT_ARRAY_BUFFER, this.indexBuffer))), Vk(t, e, this.vertexBuffer) } deleteProgram(e) { this.throwIfDisposed(), e === this.program && (this.program = null), null != e && (ew(this.gl, (() => this.gl.deleteProgram(e))), this.deleteVertexArray(e.vao)) } setProgram(e) { this.throwIfDisposed(), this.program = e, null != this.program && this.debug && dw(this.gl, this.program), ew(this.gl, (() => this.gl.useProgram(e))) } getUniformLocation(e, t, n = !0) { return this.throwIfDisposed(), n ? kw(this.gl, e, t) : Sw(this.gl, e, t) } getAttributeLocation(e, t) { return this.throwIfDisposed(), ew(this.gl, (() => this.gl.getAttribLocation(e, t))) } getUniformLocationNoThrow(e, t) { return this.throwIfDisposed(), this.gl.getUniformLocation(e, t) } setInputMatrixTexture(e, t, n) { this.throwIfDisposed(), this.throwIfNoProgram(), _w(this.gl, e, t, n) } setOutputMatrixTexture(e, t, n) { this.setOutputMatrixTextureDriver(e, n, t) } setOutputPackedMatrixTexture(e, t, n) { this.throwIfDisposed(); const [r, i] = Jx(t, n); this.setOutputMatrixTextureDriver(e, r, i) } setOutputMatrixWriteRegion(e, t, n, r) { this.setOutputMatrixWriteRegionDriver(n, e, r, t) } setOutputPackedMatrixWriteRegion(e, t, n, r) { throw new Error("setOutputPackedMatrixWriteRegion not implemented.") } debugValidate() { null != this.program && dw(this.gl, this.program), Ew(this.gl) } executeProgram() { this.throwIfDisposed(), this.throwIfNoProgram(); const e = this.gl; if (this.debug) { const e = this.getVertexArray(); console.assert(e === this.program.vao, "VAO changed between setProgram and executeProgram!"), this.debugValidate() } ew(e, (() => e.drawElements(e.TRIANGLES, 6, e.UNSIGNED_SHORT, 0))) } blockUntilAllProgramsCompleted() { this.throwIfDisposed(), ew(this.gl, (() => this.gl.finish())) } getQueryTimerExtension() { return null == this.disjointQueryTimerExtension && (this.disjointQueryTimerExtension = aw(this.gl, 2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION") ? "EXT_disjoint_timer_query_webgl2" : "EXT_disjoint_timer_query")), this.disjointQueryTimerExtension } getQueryTimerExtensionWebGL2() { return this.getQueryTimerExtension() } getQueryTimerExtensionWebGL1() { return this.getQueryTimerExtension() } beginQuery() { if (2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) { const e = this.gl, t = this.getQueryTimerExtensionWebGL2(), n = e.createQuery(); return e.beginQuery(t.TIME_ELAPSED_EXT, n), n } const e = this.getQueryTimerExtensionWebGL1(), t = e.createQueryEXT(); return e.beginQueryEXT(e.TIME_ELAPSED_EXT, t), t } endQuery() { if (2 === (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) { const e = this.gl, t = this.getQueryTimerExtensionWebGL2(); return void e.endQuery(t.TIME_ELAPSED_EXT) } const e = this.getQueryTimerExtensionWebGL1(); e.endQueryEXT(e.TIME_ELAPSED_EXT) } async waitForQueryAndGetTime(e) { return await P.util.repeatedTry((() => this.disposed || this.isQueryAvailable(e, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")))), this.getQueryTime(e, (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_VERSION")) } getQueryTime(e, t) { if (0 === t) return null; if (2 === t) { const t = this.gl; return t.getQueryParameter(e, t.QUERY_RESULT) / 1e6 } { const t = this.getQueryTimerExtensionWebGL1(); return t.getQueryObjectEXT(e, t.QUERY_RESULT_EXT) / 1e6 } } isQueryAvailable(e, t) { if (0 === t) return !0; if (2 === t) { const t = this.gl, n = this.getQueryTimerExtensionWebGL2(), r = t.getQueryParameter(e, t.QUERY_RESULT_AVAILABLE); return null == this.disjoint && (this.disjoint = this.gl.getParameter(n.GPU_DISJOINT_EXT)), r && !this.disjoint } { const t = this.getQueryTimerExtensionWebGL1(), n = t.getQueryObjectEXT(e, t.QUERY_RESULT_AVAILABLE_EXT); return null == this.disjoint && (this.disjoint = this.gl.getParameter(t.GPU_DISJOINT_EXT)), n && !this.disjoint } } pollFence(e) { return new Promise((t => { this.addItemToPoll((() => e.isFencePassed()), (() => t())) })) } pollItems() { const e = function (e) { let t = 0; for (; t < e.length; ++t) { if (!e[t]()) break } return t - 1 }(this.itemsToPoll.map((e => e.isDoneFn))); for (let t = 0; t <= e; ++t) { const { resolveFn: e } = this.itemsToPoll[t]; e() } this.itemsToPoll = this.itemsToPoll.slice(e + 1) } addItemToPoll(e, t) { if (this.itemsToPoll.push({ isDoneFn: e, resolveFn: t }), this.itemsToPoll.length > 1) return; let n; "setTimeoutCustom" in (0, P.env)().platform && (n = (0, P.env)().platform.setTimeoutCustom.bind((0, P.env)().platform)), P.util.repeatedTry((() => (this.pollItems(), 0 === this.itemsToPoll.length)), (() => 0), null, n) } bindTextureToFrameBuffer(e) { this.throwIfDisposed(), Aw(this.gl, e, this.framebuffer), this.debug && Ew(this.gl) } unbindTextureToFrameBuffer() { null != this.outputTexture ? (Aw(this.gl, this.outputTexture, this.framebuffer), this.debug && Ew(this.gl)) : Tw(this.gl, this.framebuffer) } downloadMatrixDriver(e, t) { this.bindTextureToFrameBuffer(e); const n = t(); return this.unbindTextureToFrameBuffer(), n } setOutputMatrixTextureDriver(e, t, n) { this.throwIfDisposed(); const r = this.gl; Aw(r, e, this.framebuffer), this.debug && Ew(r), this.outputTexture = e, ew(r, (() => r.viewport(0, 0, t, n))), ew(r, (() => r.scissor(0, 0, t, n))) } setOutputMatrixWriteRegionDriver(e, t, n, r) { this.throwIfDisposed(), ew(this.gl, (() => this.gl.scissor(e, t, n, r))) } throwIfDisposed() { if (this.disposed) throw new Error("Attempted to use disposed GPGPUContext.") } throwIfNoProgram() { if (null == this.program) throw new Error("No GPU program is currently set.") } }
/**
* @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.
* =============================================================================
*/
const { addImpl: Qk, bincountImpl: eS, bincountReduceImpl: tS, bitwiseAndImpl: nS, castImpl: rS, ceilImpl: iS, concatImpl: aS, equalImpl: oS, expImpl: sS, expm1Impl: uS, floorImpl: lS, gatherNdImpl: cS, gatherV2Impl: hS, greaterImpl: dS, greaterEqualImpl: fS, lessImpl: pS, lessEqualImpl: mS, linSpaceImpl: gS, logImpl: yS, maxImpl: bS, maximumImpl: vS, minimumImpl: xS, multiplyImpl: wS, negImpl: kS, notEqualImpl: SS, prodImpl: _S, raggedGatherImpl: CS, raggedRangeImpl: AS, raggedTensorToTensorImpl: TS, rangeImpl: ES, rsqrtImpl: NS, scatterImpl: IS, sigmoidImpl: MS, simpleAbsImpl: FS, sliceImpl: DS, sparseFillEmptyRowsImpl: $S, sparseReshapeImpl: RS, sparseSegmentReductionImpl: OS, sqrtImpl: zS, staticRegexReplaceImpl: PS, stridedSliceImpl: BS, stringNGramsImpl: LS, stringSplitImpl: jS, stringToHashBucketFastImpl: US, subImpl: WS, tileImpl: VS, topKImpl: GS, transposeImpl: HS, uniqueImpl: qS } = N;
/**
* @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 YS(e, t) { return ["x", "y", "z", "w", "u", "v"].slice(0, t).map((t => `${e}.${t}`)) } function XS(e, t) { return 1 === t ? [e] : YS(e, 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.
* =============================================================================
*/
class KS { constructor(e) { if (this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0, this.outputShape = e, this.rank = e.length, this.enableShapeUniforms = kk(this.outputShape.length), 0 === this.rank) this.userCode = "\n void main() {\n setOutput(vec4(getA(), 0., 0., 0.));\n }\n "; else { const e = XS("rc", this.rank), t = gk(this.rank), n = this.getOutOfBoundsCondition(e), r = this.getSetup(e), i = this.getOutput(e); this.userCode = `\n void main() {\n ${t} rc = getOutputCoords();\n\n if(${n}) {\n setOutput(vec4(0));\n } else {\n ${r}\n\n setOutput(vec4(${i}));\n }\n }\n ` } } getSourceCoordsArr(e) { const t = []; for (let n = 0; n <= 1; n++)for (let r = 0; r <= 1; r++) { let i = `${0 === n ? "r" : "rp1"}, ${0 === r ? "c" : "cp1"}`; for (let t = 2; t < this.rank; t++)i = `${e[e.length - 1 - t]},` + i; t.push(i) } return t } getOutOfBoundsCondition(e) { if (1 === this.rank) return `rc > ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]}`; let t = ""; for (let n = this.rank - 2; n < this.rank; n++)t += `${e[n]} >= ${this.enableShapeUniforms ? `outShape[${n}]` : this.outputShape[n]}`, n < this.rank - 1 && (t += "||"); return t } getSetup(e) { if (1 === this.rank) return ""; const t = e.slice(-2), n = this.enableShapeUniforms ? `outShape[${this.rank} - 1]` : this.outputShape[this.rank - 1], r = this.enableShapeUniforms ? `outShape[${this.rank} - 2]` : this.outputShape[this.rank - 2]; return `\n int r = ${t[0]};\n int c = ${t[1]};\n int rp1 = r + 1;\n int cp1 = c + 1;\n\n bool cEdge = cp1 >= ${n};\n bool rEdge = rp1 >= ${r};\n ` } getOutput(e) { const t = this.getSourceCoordsArr(e); if (1 === this.rank) { return `getA(rc), (rc + 1 >= ${this.enableShapeUniforms ? "outShape" : this.outputShape[0]} ? 0. : getA(rc + 1)), 0, 0` } return `getA(${t[0]}),\n cEdge ? 0. : getA(${t[1]}),\n rEdge ? 0. : getA(${t[2]}),\n rEdge || cEdge ? 0. : getA(${t[3]})` } }
/**
* @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 ZS { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec3" }], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); let n = ""; for (let e = 0; e < 4; e++) { let t = "thisRC = rc;"; e % 2 == 1 && (t += "thisRC.z += 1;"), e > 1 && (t += "thisRC.y += 1;"), n += `\n ${t}\n ${e > 0 ? "if(thisRC.y < rows && thisRC.z < cols){" : ""}\n int flatIndex = getFlatIndex(thisRC);\n\n ivec3 inputRC = inputCoordsFromReshapedOutCoords(flatIndex);\n vec2 inputRCInnerDims = vec2(float(inputRC.y),float(inputRC.z));\n\n result[${e}] =\n getChannel(getA(inputRC.x, inputRC.y, inputRC.z), inputRCInnerDims);\n ${e > 0 ? "}" : ""}\n ` } var r, i; this.userCode = `\n ${r = t, i = this.enableShapeUniforms, `\n ivec3 inputCoordsFromReshapedOutCoords(int index) {\n ${i ? nk(["r", "c", "d"], "inputShape") : ek(["r", "c", "d"], r)}\n return ivec3(r, c, d);\n }\n `}\n ${this.enableShapeUniforms ? "\n int getFlatIndex(ivec3 coords) {\n return coords.x * outShapeStrides[0] + coords.y * outShapeStrides[1] + coords.z;\n }\n" : rk(e)}\n\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0.);\n\n ivec3 thisRC;\n int rows = ${this.enableShapeUniforms ? "outShape[1]" : e[1]};\n int cols = ${this.enableShapeUniforms ? "outShape[2]" : e[2]};\n\n ${n}\n\n setOutput(result);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
class JS { constructor(e) { this.gpgpu = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0, this.freeTextures = {}, this.usedTextures = {}, this.logEnabled = !1 } acquireTexture(e, t, n) { const r = e_(t, n), i = t_(e, r, n); i in this.freeTextures || (this.freeTextures[i] = []), i in this.usedTextures || (this.usedTextures[i] = []); const a = QS(e, r, this.gpgpu.gl, this.gpgpu.textureConfig, n); if (this.freeTextures[i].length > 0) { this.numFreeTextures--, this.numUsedTextures++, this._numBytesFree -= a, this.log(); const e = this.freeTextures[i].pop(); return this.usedTextures[i].push(e), e } let o; return r === Yx.PACKED_2X2_FLOAT32 ? o = this.gpgpu.createPackedMatrixTexture(e[0], e[1]) : r === Yx.PACKED_2X2_FLOAT16 ? o = this.gpgpu.createFloat16PackedMatrixTexture(e[0], e[1]) : r === Yx.UNPACKED_FLOAT32 ? o = this.gpgpu.createFloat32MatrixTexture(e[0], e[1]) : r === Yx.UNPACKED_FLOAT16 ? o = this.gpgpu.createFloat16MatrixTexture(e[0], e[1]) : r === Yx.PACKED_4X1_UNSIGNED_BYTE && (o = this.gpgpu.createUnsignedBytesMatrixTexture(e[0], e[1])), this.usedTextures[i].push(o), this.numUsedTextures++, this._numBytesAllocated += a, this.log(), o } releaseTexture(e, t, n, r) { if (null == this.freeTextures) return; const i = e_(n, r), a = t_(t, i, r); a in this.freeTextures || (this.freeTextures[a] = []); const o = QS(t, i, this.gpgpu.gl, this.gpgpu.textureConfig, r), s = (0, P.env)().getNumber("WEBGL_DELETE_TEXTURE_THRESHOLD"); -1 !== s && this._numBytesAllocated > s ? (this.gpgpu.deleteMatrixTexture(e.texture), this._numBytesAllocated -= o) : (this.freeTextures[a].push(e), this.numFreeTextures++, this._numBytesFree += o), this.numUsedTextures--; const u = this.usedTextures[a], l = u && u.indexOf(e); if (null == l || l < 0) throw new Error("Cannot release a texture that was never provided by this texture manager"); u[l] = u[u.length - 1], u.pop(), this.log() } log() { if (!this.logEnabled) return; const e = this.numFreeTextures + this.numUsedTextures; console.log("Free/Used", `${this.numFreeTextures} / ${this.numUsedTextures}`, `(${e})`); const t = this._numBytesFree / this._numBytesAllocated; console.log(`Bytes allocated: ${this._numBytesAllocated}`), console.log(`Bytes unused: ${this._numBytesFree} (${Math.round(100 * t)}%)`) } get numBytesAllocated() { return this._numBytesAllocated } get numBytesFree() { return this._numBytesFree } getNumUsedTextures() { return this.numUsedTextures } getNumFreeTextures() { return this.numFreeTextures } dispose() { if (null != this.freeTextures) { for (const e in this.freeTextures) this.freeTextures[e].forEach((e => { this.gpgpu.deleteMatrixTexture(e.texture) })); for (const e in this.usedTextures) this.usedTextures[e].forEach((e => { this.gpgpu.deleteMatrixTexture(e.texture) })); this.freeTextures = null, this.usedTextures = null, this.numUsedTextures = 0, this.numFreeTextures = 0, this._numBytesAllocated = 0, this._numBytesFree = 0 } } } function QS(e, t, n, r, i) { const a = function (e, t) { switch (e) { case Yx.PACKED_2X2_FLOAT32: return Lk(t); case Yx.PACKED_2X2_FLOAT16: return Uk(t); case Yx.UNPACKED_FLOAT32: return $k(t); case Yx.UNPACKED_FLOAT16: return Ok(t); case Yx.PACKED_4X1_UNSIGNED_BYTE: return Pk(t); default: throw new Error(`Unknown physical texture type ${e}`) } }(t, r); let o; if (i) { const [t, n] = Jx(e[0], e[1]); o = t * n } else { const [t, n] = Kx(e[0], e[1]); o = t * n } const s = function (e, t) { const n = e; if (t === n.R32F) return 4; if (t === n.R16F) return 2; if (t === n.RGBA32F) return 16; if (t === e.RGBA) return 16; if (t === n.RGBA16F) return 8; if (t === n.RGBA8) return 4; throw new Error(`Unknown internal format ${t}`) }(n, a); return o * s } function e_(e, t) { if (e === Hx.UPLOAD) return Yx.PACKED_2X2_FLOAT32; if (e === Hx.RENDER || null == e) return function (e) { return (0, P.env)().getBool("WEBGL_RENDER_FLOAT32_ENABLED") ? e ? Yx.PACKED_2X2_FLOAT32 : Yx.UNPACKED_FLOAT32 : e ? Yx.PACKED_2X2_FLOAT16 : Yx.UNPACKED_FLOAT16 }(t); if (e === Hx.DOWNLOAD || e === Hx.PIXELS) return Yx.PACKED_4X1_UNSIGNED_BYTE; throw new Error(`Unknown logical texture type ${e}`) } function t_(e, t, n) { return `${e[0]}_${e[1]}_${t}_${n}` }
/**
* @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.
* =============================================================================
*/
class n_ { constructor(e, t) { this.variableNames = ["A"], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n float unaryOperation(float x) {\n ${t}\n }\n\n void main() {\n float x = getAAtOutCoords();\n float y = unaryOperation(x);\n\n setOutput(y);\n }\n ` } } const r_ = "if (isnan(x)) return x;", i_ = "return abs(x);"; const a_ = r_ + "\n return (x < 0.0) ? 0.0 : x;\n", o_ = r_ + "\n return (x < 0.0) ? 0.0 : min(6.0, x);\n", s_ = "return x;"; class u_ { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n vec4 unaryOperation(vec4 x) {\n ${t}\n }\n\n void main() {\n vec4 x = getAAtOutCoords();\n vec4 y = unaryOperation(x);\n\n setOutput(y);\n }\n ` } }
/**
* @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 l_ { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !1, this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); const t = e.length, n = XS("rc", t), r = gk(t), i = function (e, t) { if (1 === e) return "rc"; let n = ""; for (let r = 0; r < e; r++)n += t[r], r < e - 1 && (n += ","); return n }(t, n), a = n.slice(-2), o = t <= 1 ? "rc" : `vec2(${a.join(",")})`; this.userCode = `\n void main() {\n ${r} rc = getOutputCoords();\n vec4 packedInput = getA(${i});\n\n setOutput(getChannel(packedInput, ${o}));\n }\n ` } }
/**
* @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 c_ = P.kernel_impls.whereImpl, h_ = {}; const d_ = (0, P.env)().getNumber("CPU_HANDOFF_SIZE_THRESHOLD"); class f_ extends P.KernelBackend {
nextDataId() { return f_.nextDataId++ } constructor(e) { if (super(), this.pendingRead = new WeakMap, this.pendingDisposal = new WeakSet, this.dataRefCount = new WeakMap, this.numBytesInGPU = 0, this.uploadWaitMs = 0, this.downloadWaitMs = 0, this.lastGlFlushTime = 0, this.warnedAboutMemory = !1, this.pendingDeletes = 0, this.disposed = !1, !(0, P.env)().getBool("HAS_WEBGL")) throw new Error("WebGL is not supported on this device"); let t; if (null != e) { if (e instanceof Jk) t = e; else { const n = Wx((0, P.env)().getNumber("WEBGL_VERSION"), e); t = new Jk(n) } this.binaryCache = {}, this.gpgpuCreatedLocally = !1 } else { const e = Wx((0, P.env)().getNumber("WEBGL_VERSION")); t = new Jk(e), this.binaryCache = ((n = (0, P.env)().getNumber("WEBGL_VERSION")) in h_ || (h_[n] = {}), h_[n]), this.gpgpuCreatedLocally = !0 } var n; this.gpgpu = t, this.canvas = this.gpgpu.gl.canvas, this.textureManager = new JS(this.gpgpu), this.numMBBeforeWarning = null == (0, P.env)().global.screen ? 1024 : (0, P.env)().global.screen.height * (0, P.env)().global.screen.width * window.devicePixelRatio * 600 / 1024 / 1024, this.texData = new P.DataStorage(this, (0, P.engine)()) } numDataIds() { return this.texData.numDataIds() - this.pendingDeletes } writeTexture(e, t, n, r, i, a) { const o = this.makeTensorInfo(t, n), s = this.texData.get(o.dataId); s.isPacked = !1, s.texture = { texture: e, texShape: [r, i] }, s.texShape = [r, i]; const u = $w(t), l = new Ek(u, !1, a), c = this.runWebGLProgram(l, [o], n, [[r, i]]); return c.shape = t, s.texture = null, this.disposeIntermediateTensorInfo(o), c.dataId } write(e, t, n) { if (((0, P.env)().getBool("WEBGL_CHECK_NUMERICAL_PROBLEMS") || (0, P.env)().getBool("DEBUG")) && this.checkNumericalProblems(e), "complex64" === n && null != e) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); const r = { id: this.nextDataId() }; return this.texData.set(r, { shape: t, dtype: n, values: e, usage: Hx.UPLOAD, refCount: 1 }), r } refCount(e) { if (this.texData.has(e)) { return this.texData.get(e).refCount } return 0 } incRef(e) { this.texData.get(e).refCount++ } decRef(e) { if (this.texData.has(e)) { this.texData.get(e).refCount-- } } move(e, t, n, r, i) { if ((0, P.env)().getBool("DEBUG") && this.checkNumericalProblems(t), "complex64" === r) throw new Error("Cannot write to a complex64 dtype. Please use tf.complex(real, imag)."); this.texData.set(e, { shape: n, dtype: r, values: t, usage: Hx.UPLOAD, refCount: i }) } disposeIntermediateTensorInfo(e) { this.disposeData(e.dataId) } readSync(e) { const t = this.texData.get(e), { values: n, dtype: r, complexTensorInfos: i, slice: a, shape: o, isPacked: s } = t; if (null != a) { let t; t = s ? new u_(o, s_) : new n_(o, s_); const n = this.runWebGLProgram(t, [{ dataId: e, shape: o, dtype: r }], r), i = this.readSync(n.dataId); return this.disposeIntermediateTensorInfo(n), i } if (null != n) return this.convertAndCacheOnCPU(e); if ("string" === r) return n; const u = null != this.activeTimers; let l, c; if (u && (l = P.util.now()), "complex64" === r) { const e = this.readSync(i.real.dataId), t = this.readSync(i.imag.dataId); c = P.backend_util.mergeRealAndImagArrays(e, t) } else c = this.getValuesFromTexture(e); return u && (this.downloadWaitMs += P.util.now() - l), this.convertAndCacheOnCPU(e, c) } async read(e) { if (this.pendingRead.has(e)) { const t = this.pendingRead.get(e); return new Promise((e => t.push(e))) } const t = this.texData.get(e), { values: n, shape: r, slice: i, dtype: a, complexTensorInfos: o, isPacked: s } = t; if (null != i) { let t; t = s ? new u_(r, s_) : new n_(r, s_); const n = this.runWebGLProgram(t, [{ dataId: e, shape: r, dtype: a }], a), i = this.read(n.dataId); return this.disposeIntermediateTensorInfo(n), i } if (null != n) return this.convertAndCacheOnCPU(e); if ((0, P.env)().getBool("DEBUG") && !(0, P.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED") && 2 === (0, P.env)().getNumber("WEBGL_VERSION")) throw new Error("tensor.data() with WEBGL_DOWNLOAD_FLOAT_ENABLED=false and WEBGL_VERSION=2 not yet supported."); let u, l, c = null; if ("complex64" !== a && (0, P.env)().get("WEBGL_BUFFER_SUPPORTED")) { u = this.decode(e); const t = this.texData.get(u.dataId); c = this.gpgpu.createBufferFromTexture(t.texture.texture, ...Zx(r)) } if (this.pendingRead.set(e, []), "complex64" !== a && await this.gpgpu.createAndWaitForFence(), "complex64" === a) { const e = await Promise.all([this.read(o.real.dataId), this.read(o.imag.dataId)]), t = e[0], n = e[1]; l = P.backend_util.mergeRealAndImagArrays(t, n) } else if (null == c) l = this.getValuesFromTexture(e); else { const e = P.util.sizeFromShape(r); l = this.gpgpu.downloadFloat32MatrixFromBuffer(c, e) } if (null != u && this.disposeIntermediateTensorInfo(u), null != c) { const e = this.gpgpu.gl; ew(e, (() => e.deleteBuffer(c))) } const h = this.convertAndCacheOnCPU(e, l), d = this.pendingRead.get(e); return this.pendingRead.delete(e), d.forEach((e => e(h))), this.pendingDisposal.has(e) && (this.pendingDisposal.delete(e), this.disposeData(e) && (0, P.engine)().removeDataId(e, this), this.pendingDeletes--), h } readToGPU(e, t = {}) { const n = this.texData.get(e), { values: r, shape: i, slice: a, dtype: o, isPacked: s, texture: u } = n; if ("complex64" === o) throw new Error("Does not support reading texture for complex64 dtype."); if (null != a) { let n; n = s ? new u_(i, s_) : new n_(i, s_); const r = this.runWebGLProgram(n, [{ dataId: e, shape: i, dtype: o }], o), a = this.readToGPU(r, t); return this.disposeIntermediateTensorInfo(r), a } if (null == u) throw null != r ? new Error("Data is not on GPU but on CPU.") : new Error("There is no data on GPU or CPU."); const l = this.decode(e, t.customTexShape), c = (0, P.engine)().makeTensorFromTensorInfo(l), h = this.texData.get(l.dataId); return Object.assign({ tensorRef: c }, h.texture) } bufferSync(e) { const t = this.readSync(e.dataId); if ("string" === e.dtype) try { const n = t.map((e => P.util.decodeString(e))); return (0, P.buffer)(e.shape, e.dtype, n) } catch (e) { throw new Error("Failed to decode encoded string bytes into utf-8") } return (0, P.buffer)(e.shape, e.dtype, t) } checkNumericalProblems(e) { if (null != e) for (let t = 0; t < e.length; t++) { const n = e[t]; if (!rw(n)) { if ((0, P.env)().getBool("WEBGL_RENDER_FLOAT32_CAPABLE")) throw Error(`The value ${n} cannot be represented with your current settings. Consider enabling float32 rendering: 'tf.env().set('WEBGL_RENDER_FLOAT32_ENABLED', true);'`); throw Error(`The value ${n} cannot be represented on this device.`) } } } getValuesFromTexture(e) { const { shape: t, dtype: n, isPacked: r } = this.texData.get(e), i = P.util.sizeFromShape(t); if ((0, P.env)().getBool("WEBGL_DOWNLOAD_FLOAT_ENABLED")) { const n = this.decode(e), r = this.texData.get(n.dataId), a = this.gpgpu.downloadMatrixFromPackedTexture(r.texture.texture, ...Zx(t)).subarray(0, i); return this.disposeIntermediateTensorInfo(n), a } const a = (0, P.env)().getBool("WEBGL_PACK") && !0 === r, o = a ? $w(t) : t, s = a ? new Ak(o) : new Ck(o), u = this.runWebGLProgram(s, [{ shape: o, dtype: n, dataId: e }], "float32"), l = this.texData.get(u.dataId), c = this.gpgpu.downloadByteEncodedFloatMatrixFromOutputTexture(l.texture.texture, l.texShape[0], l.texShape[1]).subarray(0, i); return this.disposeIntermediateTensorInfo(u), c } timerAvailable() { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 } time(e) { const t = this.activeTimers, n = []; let r = !1; null == this.programTimersStack ? (this.programTimersStack = n, r = !0) : this.activeTimers.push(n), this.activeTimers = n, e(); const i = P.util.flatten(this.activeTimers.map((e => e.query))).filter((e => null != e)), a = P.util.flatten(this.activeTimers.map((e => e.name))).filter((e => null != e)); this.activeTimers = t, r && (this.programTimersStack = null); const o = { uploadWaitMs: this.uploadWaitMs, downloadWaitMs: this.downloadWaitMs, kernelMs: null, wallMs: null }; return (async () => { if ((0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) { const e = await Promise.all(i); o.kernelMs = P.util.sum(e), o.getExtraProfileInfo = () => e.map(((e, t) => ({ name: a[t], ms: e }))).map((e => `${e.name}: ${e.ms}`)).join(", ") } else o.kernelMs = { error: "WebGL query timers are not supported in this environment." }; return this.uploadWaitMs = 0, this.downloadWaitMs = 0, o })() } memory() { return { unreliable: !1, numBytesInGPU: this.numBytesInGPU, numBytesInGPUAllocated: this.textureManager.numBytesAllocated, numBytesInGPUFree: this.textureManager.numBytesFree } } startTimer() { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? this.gpgpu.beginQuery() : { startMs: P.util.now(), endMs: null } } endTimer(e) { return (0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0 ? (this.gpgpu.endQuery(), e) : (e.endMs = P.util.now(), e) } async getQueryTime(e) { if ((0, P.env)().getNumber("WEBGL_DISJOINT_QUERY_TIMER_EXTENSION_RELIABLE") > 0) return this.gpgpu.waitForQueryAndGetTime(e); const t = e; return t.endMs - t.startMs } disposeData(e, t = !1) { if (this.pendingDisposal.has(e)) return !1; if (!this.texData.has(e)) return !0; if (t ? this.texData.get(e).refCount = 0 : this.texData.get(e).refCount--, !t && this.texData.get(e).refCount > 0) return !1; if (this.pendingRead.has(e)) return this.pendingDisposal.add(e), this.pendingDeletes++, !1; this.releaseGPUData(e); const { complexTensorInfos: n } = this.texData.get(e); return null != n && (this.disposeData(n.real.dataId, t), this.disposeData(n.imag.dataId, t)), this.texData.delete(e), !0 } releaseGPUData(e) { const { texture: t, dtype: n, texShape: r, usage: i, isPacked: a, slice: o } = this.texData.get(e), s = o && o.origDataId || e, u = this.dataRefCount.get(s); u > 1 ? this.dataRefCount.set(s, u - 1) : (this.dataRefCount.delete(s), null != t && (this.numBytesInGPU -= this.computeBytes(r, n), this.textureManager.releaseTexture(t, r, i, a))); const l = this.texData.get(e); l.texture = null, l.texShape = null, l.isPacked = !1, l.slice = null } getTexture(e) { return this.uploadToGPU(e), this.texData.get(e).texture.texture } getDataInfo(e) { return this.texData.get(e) } shouldExecuteOnCPU(e, t = d_) { return (0, P.env)().getBool("WEBGL_CPU_FORWARD") && e.every((e => null == this.texData.get(e.dataId).texture && P.util.sizeFromShape(e.shape) < t)) } getGPGPUContext() { return this.gpgpu } where(e) { P.backend_util.warn("tf.where() in webgl locks the UI thread. Call tf.whereAsync() instead"); const t = e.dataSync(); return c_(e.shape, t) } packedUnaryOp(e, t, n) { const r = new u_(e.shape, t), i = this.compileAndRun(r, [e], n); return (0, P.engine)().makeTensorFromTensorInfo(i) } abs(e) { if (this.shouldExecuteOnCPU([e]) && "complex64" !== e.dtype) { const t = FS(this.texData.get(e.dataId).values); return this.makeOutput(e.shape, e.dtype, t) } if ((0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS")) return this.packedUnaryOp(e, i_, e.dtype); const t = new n_(e.shape, i_), n = this.compileAndRun(t, [e]); return (0, P.engine)().makeTensorFromTensorInfo(n) } makeTensorInfo(e, t, n) { let r; if ("string" === t && null != n && n.length > 0 && P.util.isString(n[0])) { const i = n.map((e => P.util.encodeString(e))); r = this.write(i, e, t) } else r = this.write(n, e, t); return this.texData.get(r).usage = null, { dataId: r, shape: e, dtype: t } } makeOutput(e, t, n) { return (0, P.engine)().makeTensorFromTensorInfo(this.makeTensorInfo(e, t, n), this) } unpackTensor(e) { const t = new l_(e.shape); return this.runWebGLProgram(t, [e], e.dtype) } packTensor(e) { const t = new KS(e.shape); return this.runWebGLProgram(t, [e], e.dtype, null, !0) } packedReshape(e, t) { const n = [Fw(e.shape), ...Dw(e.shape)], r = { dtype: e.dtype, shape: n, dataId: e.dataId }, i = [Fw(t), ...Dw(t)], a = new ZS(i, n), o = [n], s = this.runWebGLProgram(a, [r], e.dtype, o, !0); return { dataId: s.dataId, shape: t, dtype: s.dtype } } decode(e, t) { const n = this.texData.get(e), { isPacked: r, shape: i, dtype: a } = n; if (null != t) { const e = P.util.sizeFromShape(i), n = t[0] * t[1] * 4; P.util.assert(e <= n, (() => "customTexShape is too small. Row * Column * 4 should be equal or larger than the size of the tensor data.")) } const o = $w(i); let s; s = r ? new _k(o) : new Sk(o); const u = [null != t ? t : Zx(o)]; return { dtype: a, shape: i, dataId: this.runWebGLProgram(s, [{ shape: o, dtype: a, dataId: e }], a, u, !0, t).dataId } } runWebGLProgram(e, t, n, r, i = !1, a) {
const o = this.makeTensorInfo(e.outputShape, n), s = this.texData.get(o.dataId); if (e.packedOutput && (s.isPacked = !0), e.outPackingScheme === Vx.DENSE) { const t = null != a ? a : Zx(e.outputShape); s.texShape = t.map((e => 2 * e)) } if (null != e.outTexUsage && (s.usage = e.outTexUsage), 0 === P.util.sizeFromShape(o.shape)) return s.values = P.util.getTypedArrayFromDType(o.dtype, 0), o; const u = [], l = t.map((t => { if ("complex64" === t.dtype) throw new Error("GPGPUProgram does not support complex64 input. For complex64 dtypes, please separate the program into real and imaginary parts."); let n = this.texData.get(t.dataId); if (null == n.texture) { if (!e.packedInputs && P.util.sizeFromShape(t.shape) <= (0, P.env)().getNumber("WEBGL_SIZE_UPLOAD_UNIFORM")) return { shape: t.shape, texData: null, isUniform: !0, uniformValues: n.values }; e.packedInputs && (n.isPacked = !0, n.shape = t.shape) } if (this.uploadToGPU(t.dataId), !!n.isPacked != !!e.packedInputs) t = n.isPacked ? this.unpackTensor(t) : this.packTensor(t), u.push(t), n = this.texData.get(t.dataId); else if (n.isPacked && !zw(n.shape, t.shape)) { const e = t, r = t.shape; t.shape = n.shape, t = this.packedReshape(t, r), u.push(t), n = this.texData.get(t.dataId), e.shape = r } return { shape: t.shape, texData: n, isUniform: !1 } })); this.uploadToGPU(o.dataId); const c = { shape: o.shape, texData: s, isUniform: !1 }, h = function (e, t, n) { let r = ""; t.concat(n).forEach((t => { const i = null != t.texData && null != t.texData.slice && t.texData.slice.flatOffset > 0; if (e.enableShapeUniforms && !t.isUniform) { const a = t.texData.texShape, { useSqueezeShape: o, uniformShape: s, keptDims: u } = yk(e.packedInputs, t.shape, a); let l = "", c = "", h = ""; if (1 === s.length && e.packedInputs) { const e = [Math.ceil(a[0] / 2), Math.ceil(a[1] / 2)]; l = `${e[0] > 1}_${e[1] > 1}` } else if (2 !== s.length || e.packedInputs) { if (s.length > 2 && !e.packedInputs) { const e = P.util.computeStrides(s); h = `${e[0] === a[1]}_${e[e.length - 1] === a[1]}` } } else c = `${s[0] > 1}_${s[1] > 1}`; const d = t.shape.length, f = 2 === s.length && P.util.arraysEqual(t.shape, a), p = 1 === P.util.sizeFromShape(t.shape), m = P.backend_util.getBroadcastDims(t.shape, n.shape), g = !e.packedInputs && d === n.shape.length && P.util.arraysEqual(a, n.texData.texShape), y = e.packedInputs || s.length > 2 ? "" : `${a[0] > 1}_${a[1] > 1}`; r += `${d}_${g}_${o ? u : ""}_${s.length}_${p}_${m}_${f}_${l}_${c}_${h}_${y}_${i}` } else { const e = t.isUniform ? "uniform" : t.texData.texShape; r += `${t.shape}_${e}_${i}` } })); const i = e.userCode; let a = e.constructor.name; return a += "_" + r + "_" + i + `${(0, P.env)().getNumber("WEBGL_VERSION")}`, a }(e, l, c), d = this.getAndSaveBinary(h, (() =>
/**
* @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.
* =============================================================================
*/
function (e, t, n, r) { const i = n.map(((e, n) => { const r = { logicalShape: e.shape, texShape: e.isUniform ? null : e.texData.texShape, isUniform: e.isUniform, isPacked: !e.isUniform && e.texData.isPacked, flatOffset: null }; return null != e.texData && null != e.texData.slice && e.texData.slice.flatOffset > 0 && (r.flatOffset = e.texData.slice.flatOffset), { name: t.variableNames[n], shapeInfo: r } })), a = i.map((e => e.shapeInfo)), o = { logicalShape: r.shape, texShape: r.texData.texShape, isUniform: !1, isPacked: r.texData.isPacked, flatOffset: null }, s = ok(i, o, t), u = sw(e.gl, s), l = e.createProgram(u); return (0, P.env)().get("ENGINE_COMPILE_ONLY") ? { program: t, fragmentShader: u, source: s, webGLProgram: l, inShapeInfos: a, outShapeInfo: o, variablesLocations: null, customUniformLocations: null, infLoc: null, nanLoc: null, outShapeLocation: null, outShapeStridesLocation: null, outTexShapeLocation: null } : (e.buildVao(l), Object.assign({ program: t, fragmentShader: u, source: s, webGLProgram: l, inShapeInfos: a, outShapeInfo: o }, xk(e, t, l))) }(this.gpgpu, e, l, c))), f = null != this.activeTimers; let p; f && (p = this.startTimer()), (0, P.env)().get("ENGINE_COMPILE_ONLY") || function (e, t, n, r, i) { t.program.enableShapeUniforms || (wk(t.inShapeInfos, n), wk([t.outShapeInfo], [r])); const a = r.texData.texture, o = r.texData.texShape; r.texData.isPacked ? e.setOutputPackedMatrixTexture(a.texture, o[0], o[1]) : e.setOutputMatrixTexture(a.texture, o[0], o[1]), e.setProgram(t.webGLProgram), e.bindVertexArray(t.webGLProgram.vao), 1 === (0, P.env)().getNumber("WEBGL_VERSION") && null !== t.infLoc && e.gl.uniform1f(t.infLoc, 1 / 0), null !== t.nanLoc && e.gl.uniform1f(t.nanLoc, NaN); for (let r = 0; r < n.length; ++r) { const i = n[r], { uniform: a, offset: o, shape: s, texShape: u } = t.variablesLocations[r]; if (s) { const { uniformShape: n } = yk(t.program.packedInputs, i.shape, i.texData.texShape); switch (n.length) { case 1: e.gl.uniform1iv(s, new Int32Array(n)); break; case 2: e.gl.uniform2iv(s, new Int32Array(n)); break; case 3: e.gl.uniform3iv(s, new Int32Array(n)); break; case 4: e.gl.uniform4iv(s, new Int32Array(n)) } } if (u && e.gl.uniform2i(u, i.texData.texShape[0], i.texData.texShape[1]), null != a) if (i.isUniform) if (P.util.sizeFromShape(i.shape) < 2) e.gl.uniform1f(a, i.uniformValues[0]); else { let t = i.uniformValues; t instanceof Float32Array || (t = new Float32Array(t)), e.gl.uniform1fv(a, t) } else null != i.texData.slice && null != o && e.gl.uniform1i(o, i.texData.slice.flatOffset), e.setInputMatrixTexture(i.texData.texture.texture, a, r) } const s = t.outShapeLocation; if (s) switch (r.shape.length) { case 1: e.gl.uniform1iv(s, new Int32Array(r.shape)); break; case 2: e.gl.uniform2iv(s, new Int32Array(r.shape)); break; case 3: e.gl.uniform3iv(s, new Int32Array(r.shape)); break; case 4: e.gl.uniform4iv(s, new Int32Array(r.shape)) }if (t.outShapeStridesLocation) { const n = P.util.computeStrides(r.shape); switch (r.shape.length) { case 2: e.gl.uniform1iv(t.outShapeStridesLocation, new Int32Array(n)); break; case 3: e.gl.uniform2iv(t.outShapeStridesLocation, new Int32Array(n)); break; case 4: e.gl.uniform3iv(t.outShapeStridesLocation, new Int32Array(n)) } } if (t.outTexShapeLocation && e.gl.uniform2i(t.outTexShapeLocation, r.texData.texShape[0], r.texData.texShape[1]), t.program.customUniforms && i) for (let n = 0; n < t.program.customUniforms.length; ++n) { const r = t.program.customUniforms[n], a = t.customUniformLocations[n], o = i[n]; if ("float" === r.type) e.gl.uniform1fv(a, o); else if ("vec2" === r.type) e.gl.uniform2fv(a, o); else if ("vec3" === r.type) e.gl.uniform3fv(a, o); else if ("vec4" === r.type) e.gl.uniform4fv(a, o); else if ("int" === r.type) e.gl.uniform1iv(a, o); else if ("ivec2" === r.type) e.gl.uniform2iv(a, o); else if ("ivec3" === r.type) e.gl.uniform3iv(a, o); else { if ("ivec4" !== r.type) throw Error(`uniform type ${r.type} is not supported yet.`); e.gl.uniform4iv(a, o) } } e.executeProgram() }(this.gpgpu, d, l, c, r), u.forEach((e => this.disposeIntermediateTensorInfo(e))), f && (p = this.endTimer(p), this.activeTimers.push({ name: e.constructor.name, query: this.getQueryTime(p) })); const m = (0, P.env)().getNumber("WEBGL_FLUSH_THRESHOLD"); if (m > 0) { const e = P.util.now(); e - this.lastGlFlushTime > m && (this.gpgpu.gl.flush(), this.lastGlFlushTime = e) } if (!(0, P.env)().getBool("WEBGL_LAZILY_UNPACK") && s.isPacked && !1 === i) { const e = this.unpackTensor(o); return this.disposeIntermediateTensorInfo(o), e } return o
} compileAndRun(e, t, n, r, i = !1) { n = n || t[0].dtype; return this.runWebGLProgram(e, t, n, r, i) } getAndSaveBinary(e, t) { return e in this.binaryCache || (this.binaryCache[e] = t()), this.binaryCache[e] } getTextureManager() { return this.textureManager } dispose() { if (!this.disposed) { if (!(0, P.env)().getBool("IS_TEST")) { Object.keys(this.binaryCache).forEach((e => { this.gpgpu.deleteProgram(this.binaryCache[e].webGLProgram), delete this.binaryCache[e] })) } this.textureManager.dispose(), null != this.canvas && "undefined" != typeof HTMLCanvasElement && this.canvas instanceof HTMLCanvasElement ? this.canvas.remove() : this.canvas = null, this.gpgpuCreatedLocally && (this.gpgpu.program = null, this.gpgpu.dispose()), this.disposed = !0 } } floatPrecision() { return null == this.floatPrecisionValue && (this.floatPrecisionValue = (0, P.tidy)((() => { if (!(0, P.env)().get("WEBGL_RENDER_FLOAT32_ENABLED")) { const e = (0, P.env)().getBool("DEBUG"); (0, P.env)().set("DEBUG", !1); const t = this.abs((0, P.scalar)(1e-8)).dataSync()[0]; if ((0, P.env)().set("DEBUG", e), t > 0) return 32 } return 16 }))), this.floatPrecisionValue } epsilon() { return 32 === this.floatPrecision() ? 1e-7 : 1e-4 } uploadToGPU(e) { const t = this.texData.get(e), { shape: n, dtype: r, values: i, texture: a, usage: o, isPacked: s } = t; if (null != a) return; const u = null != this.activeTimers; let l; u && (l = P.util.now()); let c = t.texShape; if (null == c && (c = Rw(n, s), t.texShape = c), null != i) { const e = $w(n); let a, o = c[1], h = c[0]; const d = i instanceof Uint8Array || i instanceof Uint8ClampedArray; !s && d || ([o, h] = Jx(c[0], c[1])), a = s ? new Nk(e, d) : new Ek(e, d); const f = d ? [h, o] : c, p = this.makeTensorInfo(f, r), m = this.texData.get(p.dataId); m.usage = d ? Hx.PIXELS : Hx.UPLOAD, m.texShape = f, this.gpgpu.uploadDenseMatrixToTexture(this.getTexture(p.dataId), o, h, i); const g = [[h, o]], y = !0, b = this.runWebGLProgram(a, [p], r, g, y), v = this.texData.get(b.dataId); t.texShape = v.texShape, t.isPacked = v.isPacked, t.usage = v.usage, (0, P.env)().get("ENGINE_COMPILE_ONLY") ? this.disposeData(b.dataId) : (t.texture = v.texture, t.values = null, this.texData.delete(b.dataId)), this.disposeIntermediateTensorInfo(p), u && (this.uploadWaitMs += P.util.now() - l) } else { const e = this.acquireTexture(c, o, r, s); t.texture = e } } convertAndCacheOnCPU(e, t) { const n = this.texData.get(e), { dtype: r } = n; return null != t && (n.values = function (e, t) { if ("float32" === t || "complex64" === t) return e; if ("int32" === t || "bool" === t) { const n = "int32" === t ? new Int32Array(e.length) : new Uint8Array(e.length); for (let t = 0; t < n.length; ++t)n[t] = Math.round(e[t]); return n } throw new Error(`Unknown dtype ${t}`) }(t, r)), n.values } acquireTexture(e, t, n, r) { if (this.numBytesInGPU += this.computeBytes(e, n), !this.warnedAboutMemory && this.numBytesInGPU > 1024 * this.numMBBeforeWarning * 1024) { const e = (this.numBytesInGPU / 1024 / 1024).toFixed(2); this.warnedAboutMemory = !0, console.warn(`High memory usage in GPU: ${e} MB, most likely due to a memory leak`) } return this.textureManager.acquireTexture(e, t, r) } computeBytes(e, t) { return e[0] * e[1] * P.util.bytesPerElement(t) } checkCompileCompletion() { for (const [, e] of Object.entries(this.binaryCache)) this.checkCompletion_(e) } async checkCompileCompletionAsync() { const e = []; if (this.gpgpu.parallelCompilationExtension) { for (const [, t] of Object.entries(this.binaryCache)) e.push(this.checkCompletionAsync_(t)); return Promise.all(e) } for (const [, t] of Object.entries(this.binaryCache)) { const n = new Promise((e => { try { this.checkCompletion_(t), e(!0) } catch (e) { throw e } })); e.push(n) } return Promise.all(e) } async checkCompletionAsync_(e) { return this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.parallelCompilationExtension.COMPLETION_STATUS_KHR) ? this.checkCompletion_(e) : (await (0, P.nextFrame)(), this.checkCompletionAsync_(e)) } checkCompletion_(e) { if (!1 === this.gpgpu.gl.getProgramParameter(e.webGLProgram, this.gpgpu.gl.LINK_STATUS)) { if (console.log(this.gpgpu.gl.getProgramInfoLog(e.webGLProgram)), !1 === this.gpgpu.gl.getShaderParameter(e.fragmentShader, this.gpgpu.gl.COMPILE_STATUS)) throw lw(e.source, this.gpgpu.gl.getShaderInfoLog(e.fragmentShader)), new Error("Failed to compile fragment shader."); throw new Error("Failed to link vertex and fragment shaders.") } return !0 } getUniformLocations() { for (const e of Object.values(this.binaryCache)) { this.gpgpu.buildVao(e.webGLProgram); const { variablesLocations: t, customUniformLocations: n, infLoc: r, nanLoc: i, outShapeLocation: a, outShapeStridesLocation: o, outTexShapeLocation: s } = xk(this.gpgpu, e.program, e.webGLProgram); e.variablesLocations = t, e.customUniformLocations = n, e.infLoc = r, e.nanLoc = i, e.outShapeLocation = a, e.outShapeStridesLocation = o, e.outTexShapeLocation = s } } createTensorFromGPUData(e, t, n) { e.channels = e.channels || "RGBA"; const { texture: r, height: i, width: a, channels: o } = e, s = (0, P.engine)().backend; if (!s.gpgpu.gl.isTexture(r)) throw new Error("The texture is invalid. Also, please make sure the texture and the TFJS WebGL backend are using the same canvas. If you want to use your own custom canvas, you have to create and use the custom TFJS WebGL backend created from the canvas through 'new tf.MathBackendWebGL(customCanvas)'."); const u = s.writeTexture(r, t, n, i, a, o); return (0, P.engine)().makeTensorFromDataId(u, t, n, s) }
} f_.nextDataId = 0;
/** @license See the LICENSE file. */
const p_ = "4.22.0";
/**
* @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 m_() { (0, P.env)().set("WEBGL_FORCE_F16_TEXTURES", !0) }
/**
* @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.
* =============================================================================
*/
P.device_util.isBrowser() && (0, P.registerBackend)("webgl", (() => new f_), 2); const g_ = { forceHalfFloat: m_ }, y_ = "\n if (isnan(a)) return a;\n if (isnan(b)) return b;\n"; class b_ { constructor(e, t, n) { this.variableNames = ["A", "B"], this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.enableShapeUniforms = kk(this.outputShape.length), this.userCode = `\n float binaryOperation(float a, float b) {\n ${e}\n }\n\n void main() {\n float a = getAAtOutCoords();\n float b = getBAtOutCoords();\n setOutput(binaryOperation(a, b));\n }\n ` } }
/**
* @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 v_ = "\n result.r = isNaN.r ? NAN : result.r;\n result.g = isNaN.g ? NAN : result.g;\n result.b = isNaN.b ? NAN : result.b;\n result.a = isNaN.a ? NAN : result.a;\n"; class x_ { constructor(e, t, n, r = !1) { this.variableNames = ["A", "B"], this.supportsBroadcasting = !0, this.packedInputs = !0, this.packedOutput = !0, this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n); const i = this.outputShape.length; this.enableShapeUniforms = kk(i); let a = ""; if (r) if (0 === i || 1 === P.util.sizeFromShape(this.outputShape)) a = "\n result.y = 0.;\n result.z = 0.;\n result.w = 0.;\n "; else { if (a = `\n ${gk(i)} coords = getOutputCoords();\n `, 1 === i) this.enableShapeUniforms ? a += "\n result.y = (coords + 1) >= outShape ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n " : a += `\n result.y = (coords + 1) >= ${this.outputShape[0]} ? 0. : result.y;\n result.z = 0.;\n result.w = 0.;\n `; else { const e = XS("coords", i); this.enableShapeUniforms ? a += `\n bool nextRowOutOfBounds =\n (${e[i - 2]} + 1) >= outShape[${i} - 2];\n bool nextColOutOfBounds =\n (${e[i - 1]} + 1) >= outShape[${i} - 1];\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n ` : a += `\n bool nextRowOutOfBounds =\n (${e[i - 2]} + 1) >= ${this.outputShape[i - 2]};\n bool nextColOutOfBounds =\n (${e[i - 1]} + 1) >= ${this.outputShape[i - 1]};\n result.y = nextColOutOfBounds ? 0. : result.y;\n result.z = nextRowOutOfBounds ? 0. : result.z;\n result.w = nextColOutOfBounds || nextRowOutOfBounds ? 0. : result.w;\n ` } } this.userCode = `\n vec4 binaryOperation(vec4 a, vec4 b) {\n ${e}\n }\n\n void main() {\n vec4 a = getAAtOutCoords();\n vec4 b = getBAtOutCoords();\n\n vec4 result = binaryOperation(a, b);\n ${a}\n\n setOutput(result);\n }\n ` } }
/**
* @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 w_(e) { const { inputs: t, backend: n } = e, { x: r } = t; return n.incRef(r.dataId), { dataId: r.dataId, shape: r.shape, dtype: r.dtype } } const k_ = { kernelName: P.Identity, backendName: "webgl", kernelFunc: w_ };
/**
* @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 S_(e) { const { inputs: t, backend: n } = e, { real: r, imag: i } = t, a = n.makeTensorInfo(r.shape, "complex64"), o = n.texData.get(a.dataId), s = w_({ inputs: { x: r }, backend: n }), u = w_({ inputs: { x: i }, backend: n }); return o.complexTensorInfos = { real: s, imag: u }, a } const __ = { kernelName: P.Complex, backendName: "webgl", kernelFunc: S_ }, C_ = "return (a < 0.) ? b * a : a;", A_ = "\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; const T_ = { kernelName: P.LeakyRelu, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { alpha: a } = r, o = n.makeTensorInfo([], "float32", P.util.createScalarValue(a, "float32")), s = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(A_, i.shape, o.shape) : new b_(C_, i.shape, o.shape), u = n.runWebGLProgram(s, [i, o], "float32"); return n.disposeIntermediateTensorInfo(o), u } }, E_ = "return (a < 0.) ? b * a : a;", N_ = "\n vec4 aLessThanZero = vec4(lessThan(a, vec4(0.)));\n return (aLessThanZero * (b * a)) + ((vec4(1.0) - aLessThanZero) * a);\n"; const I_ = { kernelName: P.Prelu, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r, alpha: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(N_, r.shape, i.shape) : new b_(E_, r.shape, i.shape); return n.runWebGLProgram(a, [r, i], "float32") } }, M_ = "if (isnan(x)) return x;"; function F_({ opSnippet: e, packedOpSnippet: t, cpuKernelImpl: n, dtype: r }) { return ({ inputs: i, backend: a }) => { const { x: o } = i, s = a, u = r || o.dtype; if (s.shouldExecuteOnCPU([o]) && null != n) { const e = s.texData.get(o.dataId), t = n(e.values, u); return s.makeTensorInfo(o.shape, u, t) } let l; return l = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") && null != t ? new u_(o.shape, t) : new n_(o.shape, e), s.runWebGLProgram(l, [o], u) } } function D_({ opSnippet: e, packedOpSnippet: t, checkOutOfBounds: n = !1, supportsComplex: r = !1, cpuKernelImpl: i, dtype: a }) { return ({ inputs: o, backend: s }) => { const { a: u, b: l } = o, c = s; if (r && "complex64" === u.dtype) { const t = c.texData.get(u.dataId), n = c.texData.get(l.dataId), [r, i] = [[t.complexTensorInfos.real, n.complexTensorInfos.real], [t.complexTensorInfos.imag, n.complexTensorInfos.imag]].map((t => { const [n, r] = t, i = { dataId: n.dataId, dtype: n.dtype, shape: u.shape }, a = { dataId: r.dataId, dtype: r.dtype, shape: l.shape }, o = new b_(e, u.shape, l.shape); return c.runWebGLProgram(o, [i, a], (0, P.upcastType)(n.dtype, r.dtype)) })), a = S_({ inputs: { real: r, imag: i }, backend: c }); return c.disposeIntermediateTensorInfo(r), c.disposeIntermediateTensorInfo(i), a } const h = a || (0, P.upcastType)(u.dtype, l.dtype); if (("string" === u.dtype || "string" === l.dtype || c.shouldExecuteOnCPU([u, l])) && null != i) { const e = c.texData.get(u.dataId).values, t = c.texData.get(l.dataId).values, n = "string" === u.dtype ? P.backend_util.fromUint8ToStringArray(e) : e, r = "string" === u.dtype ? P.backend_util.fromUint8ToStringArray(t) : t, [a, o] = i(u.shape, l.shape, n, r, h), s = c.makeTensorInfo(o, h); return c.texData.get(s.dataId).values = a, s } let d; return d = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") && null != t ? new x_(t, u.shape, l.shape, n) : new b_(e, u.shape, l.shape), c.runWebGLProgram(d, [u, l], h) } } function $_(e, t = !1) { if ("linear" === e) return "return x;"; if ("relu" === e) return t ? "\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" : a_; if ("elu" === e) return t ? "\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n" : "return (x >= 0.0) ? x : (exp(x) - 1.0);"; if ("relu6" === e) return t ? "\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" : o_; if ("prelu" === e) return t ? N_ : E_; if ("leakyrelu" === e) return t ? A_ : C_; if ("sigmoid" === e) return "return 1.0 / (1.0 + exp(-1.0 * x));"; throw new Error(`Activation ${e} has not been implemented for the WebGL backend.`) }
/**
* @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 R_ { constructor(e, t, n, r = !1, i = !1, a = !1, o = null, s = !1, u = !1) { this.variableNames = ["matrixA", "matrixB"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = n, this.enableShapeUniforms = kk(this.outputShape.length); const l = r ? e[1] : e[2], c = Math.ceil(l / 2), h = r ? "i * 2, rc.y" : "rc.y, i * 2", d = i ? "rc.z, i * 2" : "i * 2, rc.z", f = r ? ["a.xxyy", "a.zzww"] : ["a.xxzz", "a.yyww"], p = i ? ["b.xzxz", "b.ywyw"] : ["b.xyxy", "b.zwzw"]; let m = "", g = ""; o && (m = s ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${o}\n }` : u ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${o}\n }` : `vec4 activation(vec4 x) {\n ${o}\n }`, g = "result = activation(result);"); const y = a ? "result += getBiasAtOutCoords();" : ""; a && this.variableNames.push("bias"), s && this.variableNames.push("preluActivationWeights"), u && this.variableNames.push("leakyreluAlpha"); let b = "rc.x", v = "rc.x"; e[0] < t[0] ? b = `imod(rc.x, ${e[0]})` : t[0] < e[0] && (v = `imod(rc.x, ${t[0]})`), this.userCode = `\n ${m}\n // Don't use uniform for sharedDimensionPacked for performance.\n const float sharedDimension = ${c}.0;\n\n vec4 dot2x2ARowBCol(ivec3 rc) {\n vec4 result = vec4(0);\n int batchA = ${b};\n int batchB = ${v};\n for (int i = 0; i < ${c}; i++) {\n vec4 a = getMatrixA(batchA, ${h});\n vec4 b = getMatrixB(batchB, ${d});\n\n // These swizzled products need to be separately added.\n // See: https://github.com/tensorflow/tfjs/issues/1735\n result += (${f[0]} * ${p[0]});\n result += (${f[1]} * ${p[1]});\n }\n return result;\n }\n\n void main() {\n ivec3 rc = getOutputCoords();\n vec4 result = dot2x2ARowBCol(rc);\n\n ${y}\n\n ${g}\n\n setOutput(result);\n }\n ` } }
/**
* @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 O_ = "return areal * breal - aimag * bimag;", z_ = "return areal * bimag + aimag * breal;"; class P_ { constructor(e, t, n) { this.variableNames = ["AReal", "AImag", "BReal", "BImag"], this.outputShape = P.backend_util.assertAndGetBroadcastShape(t, n), this.userCode = `\n float binaryOpComplex(\n float areal, float aimag, float breal, float bimag) {\n ${e}\n }\n\n void main() {\n float areal = getARealAtOutCoords();\n float aimag = getAImagAtOutCoords();\n float breal = getBRealAtOutCoords();\n float bimag = getBImagAtOutCoords();\n setOutput(binaryOpComplex(areal, aimag, breal, bimag));\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const B_ = "return a * b;"; function L_(e) { const { inputs: t, backend: n } = e, { a: r, b: i } = t, a = P.backend_util.upcastType(r.dtype, i.dtype); if ("complex64" === r.dtype) { const e = n.texData.get(r.dataId), t = n.texData.get(i.dataId), a = new P_(O_, r.shape, i.shape), o = new P_(z_, r.shape, i.shape), s = [{ dataId: e.complexTensorInfos.real.dataId, dtype: e.complexTensorInfos.real.dtype, shape: r.shape }, { dataId: e.complexTensorInfos.imag.dataId, dtype: e.complexTensorInfos.imag.dtype, shape: r.shape }, { dataId: t.complexTensorInfos.real.dataId, dtype: t.complexTensorInfos.real.dtype, shape: i.shape }, { dataId: t.complexTensorInfos.imag.dataId, dtype: t.complexTensorInfos.imag.dtype, shape: i.shape }], u = n.runWebGLProgram(a, s, "float32"), l = n.runWebGLProgram(o, s, "float32"), c = S_({ inputs: { real: u, imag: l }, backend: n }); return n.disposeIntermediateTensorInfo(u), n.disposeIntermediateTensorInfo(l), c } if (n.shouldExecuteOnCPU([r, i])) { const e = n.texData.get(r.dataId), t = n.texData.get(i.dataId), [o, s] = wS(r.shape, i.shape, e.values, t.values, a), u = n.makeTensorInfo(s, a); return n.texData.get(u.dataId).values = o, u } let o; return o = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_(B_, r.shape, i.shape) : new b_(B_, r.shape, i.shape), n.runWebGLProgram(o, [r, i], a) } const j_ = { kernelName: P.Multiply, backendName: "webgl", kernelFunc: L_ };
/**
* @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 U_(e) {
const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { shape: a } = r, o = n, s = P.util.sizeFromShape(i.shape), u = P.util.inferFromImplicitShape(a, s), l = P.util.sizeFromShape(u); P.util.assert(s === l, (() => `The new shape (${u}) has ${l} elements and the old shape (${i.shape}) has ${s} elements. The new shape and old shape must have the same number of elements.`)); const c = o.texData.get(i.dataId); return !c.isPacked || zw(i.shape, u) || null !== c.texture && zw(c.shape, u) ? (o.incRef(i.dataId), { dataId: i.dataId, shape: u, dtype: i.dtype }) :
/**
* @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 (e, t, n) { const r = [Fw(e.shape), ...Dw(e.shape)], i = { dtype: e.dtype, shape: r, dataId: e.dataId }, a = [Fw(t), ...Dw(t)], o = new ZS(a, r), s = [r], u = n.runWebGLProgram(o, [i], e.dtype, s, !0); return { dataId: u.dataId, shape: t, dtype: u.dtype } }(i, u, o)
} const W_ = { kernelName: P.Reshape, backendName: "webgl", kernelFunc: U_ };
/**
* @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.
* =============================================================================
*/
class V_ { constructor(e, t) { this.variableNames = ["x"]; const { windowSize: n, batchSize: r, inSize: i, outSize: a } = e; this.outputShape = [r, a]; const o = 4 * Math.floor(n / 4), s = n % 4; let u = "sumValue += dot(values, ones);"; if (null != t) { const e = 1 / t; u = `sumValue += dot(values * ${P.util.isInt(e) ? e.toPrecision(2) : e}, ones);` } let l = ""; i % n > 0 && (l = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return 0.0;\n }\n `), this.userCode = `\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${l}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${o}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${u}\n }\n\n int inIdx = inOffset + ${o};\n if (${1 === s}) {\n vec4 values = vec4(getValue(batch, inIdx), 0.0, 0.0, 0.0);\n\n ${u}\n } else if (${2 === s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1), 0.0, 0.0);\n\n ${u}\n } else if (${3 === s}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2), 0.0);\n\n ${u}\n }\n setOutput(sumValue);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
class G_ { constructor(e, t) { this.variableNames = ["x"]; const { windowSize: n, batchSize: r, inSize: i, outSize: a } = e; this.outputShape = [r, a]; let o = "0.0", s = ""; "prod" === t ? o = "1.0" : "min" === t ? (o = "1.0 / 1e-20", s = "min") : "max" === t && (o = "-1.0 / 1e-20", s = "max"); let u = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "sum" === t ? u = "sumValue" : "prod" === t ? u = "prodValue" : "all" === t ? u = "allValue" : "any" === t && (u = "anyValue"); const l = 4 * Math.floor(n / 4), c = n % 4; let h = `\n if (${"sum" === t}) {\n sumValue += dot(values, ones);\n } else if (${"prod" === t}) {\n vec2 tmp = vec2(values[0], values[1]) * vec2(values[2], values[3]);\n prodValue *= tmp[0] * tmp[1];\n } else {\n minMaxValue = ${s}(values, minMaxValue);\n if (${"min" === t} || ${"max" === t}) {\n minMaxValue = ${s}(values, minMaxValue);\n bvec4 isNaN = isnan(values);\n if (isNaN.r || isNaN.g || isNaN.b || isNaN.a) {\n minMaxValue = vec4(NAN);\n }\n }\n }\n `, d = "vec4"; "all" === t ? (o = "1.0", h = "\n bool reducedAllValue = all(values);\n float floatedReducedAllValue = float(reducedAllValue);\n allValue = float(allValue >= 1.0 && floatedReducedAllValue >= 1.0);\n ", d = "bvec4") : "any" === t && (o = "0.0", h = "\n bool reducedAnyValue = any(values);\n float floatedReducedAnyValue = float(reducedAnyValue);\n anyValue = float(anyValue >= 1.0 || floatedReducedAnyValue >= 1.0);\n ", d = "bvec4"); let f = ""; i % n > 0 && (f = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return initializationValue;\n }\n `), this.userCode = `\n const float initializationValue = ${o};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float getValue(int batch, int inIdx) {\n ${f}\n return getX(batch, inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${n};\n\n vec4 minMaxValue = vec4(${o});\n float prodValue = 1.0;\n float sumValue = 0.0;\n float allValue = 1.0;\n float anyValue = 0.0;\n\n for (int i = 0; i < ${l}; i += 4) {\n int inIdx = inOffset + i;\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n ${h}\n }\n\n int inIdx = inOffset + ${l};\n if (${1 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${2 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n ${h}\n } else if (${3 === c}) {\n ${d} values = ${d}(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n ${h}\n }\n setOutput(${u});\n }\n ` } } function H_(e, t, n, r) {
const i =
/**
* @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 (e) { const t = []; for (; 0 === t.length || 1 !== t[t.length - 1].outSize;) { const n = t.length ? t[t.length - 1].outSize : e[1], r = P.backend_util.computeOptimalWindowSize(n); t.push({ inSize: n, windowSize: r, outSize: Math.ceil(n / r) }) } return t }(e.shape); let a = e; for (let o = 0; o < i.length; o++) { const { inSize: s, windowSize: u, outSize: l } = i[o]; let c, h; c = "mean" === n ? 0 === o ? new V_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }, s) : new V_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }) : new G_({ windowSize: u, inSize: s, batchSize: e.shape[0], outSize: l }, n), h = a, a = r.runWebGLProgram(c, [a], t), h.dataId !== e.dataId && r.disposeIntermediateTensorInfo(h) } return a
}
/**
* @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.
* =============================================================================
*/
class q_ { constructor(e, t) { this.variableNames = ["A"]; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; this.outputShape = n, this.rank = n.length; const r = gk(this.rank), i = function (e) { const t = e.length; if (t > 6) throw Error(`Transpose for rank ${t} is not yet supported`); const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u", "resRC.v"], r = new Array(t); for (let t = 0; t < e.length; t++)r[e[t]] = n[t]; return r.join() }(t); this.userCode = `\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${i}));\n }\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.
* =============================================================================
*/
class Y_ { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[t[r]]; if (this.outputShape = n, this.rank = n.length, this.rank > 6) throw Error(`Packed transpose for rank ${this.rank} is not yet supported.`); const r = gk(this.rank), i = YS("rc", this.rank), a = new Array(this.rank); for (let e = 0; e < t.length; e++)a[t[e]] = i[e]; const o = `vec2(${a.slice(-2).join()})`, s = `++${i[this.rank - 1]} < ${n[this.rank - 1]}`, u = `getChannel(getA(${a.join()}), ${o})`; this.userCode = `\n void main() {\n ${r} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result[0] = ${u};\n if(${s}) {\n result[1] = ${u};\n }\n --${i[this.rank - 1]};\n if(++${i[this.rank - 2]} < ${n[this.rank - 2]}) {\n result[2] = ${u};\n if(${s}) {\n result[3] = ${u};\n }\n }\n setOutput(result);\n }\n ` } }
/**
* @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 X_(e, t, n) { const r = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new Y_(e.shape, t) : new q_(e.shape, t); return n.runWebGLProgram(r, [e], e.dtype) }
/**
* @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 K_(e) {
const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r;
/**
* @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.
* =============================================================================
*/
return function (e, t, n, r) { const i = t, a = e.shape.length, o = P.util.parseAxisParam(i, e.shape); let s = o; const u = P.backend_util.getAxesPermutation(s, a), l = null != u; let c = e; l && (c = X_(e, u, r), s = P.backend_util.getInnerMostAxes(s.length, a)), P.backend_util.assertAxesAreInnerMostDims("sum", s, a); const [h, d] = P.backend_util.computeOutAndReduceShapes(c.shape, s); let f = h; n && (f = P.backend_util.expandShapeToKeepDim(h, o)); const p = P.util.sizeFromShape(d), m = U_({ inputs: { x: c }, attrs: { shape: [P.util.sizeFromShape(e.shape) / p, p] }, backend: r }), g = H_(m, (0, P.sumOutType)(e.dtype), "sum", r), y = U_({ inputs: { x: g }, attrs: { shape: f }, backend: r }); return r.disposeIntermediateTensorInfo(m), r.disposeIntermediateTensorInfo(g), l && r.disposeIntermediateTensorInfo(c), y }(i, a, o, n)
} const Z_ = { kernelName: P.Sum, backendName: "webgl", kernelFunc: K_ };
/**
* @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 J_(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { perm: a } = r, o = n, s = i.shape.length, u = new Array(s); for (let e = 0; e < u.length; e++)u[e] = i.shape[a[e]]; let l; if (o.shouldExecuteOnCPU([i])) { const e = o.texData.get(i.dataId).values, t = HS(e, i.shape, i.dtype, a, u); l = o.makeTensorInfo(u, i.dtype); o.texData.get(l.dataId).values = t } else l = X_(i, a, o); return l } const Q_ = { kernelName: P.Transpose, backendName: "webgl", kernelFunc: J_ }; function eC({ a: e, b: t, transposeA: n, transposeB: r, backend: i, bias: a = null, preluActivationWeights: o = null, leakyreluAlpha: s = 0, activation: u = null }) { const l = e.shape.length, c = t.shape.length, h = n ? e.shape[l - 2] : e.shape[l - 1], d = r ? t.shape[c - 1] : t.shape[c - 2], f = n ? e.shape[l - 1] : e.shape[l - 2], p = r ? t.shape[c - 2] : t.shape[c - 1], m = e.shape.slice(0, -2), g = t.shape.slice(0, -2), y = P.util.sizeFromShape(m), b = P.util.sizeFromShape(g), v = P.broadcast_util.assertAndGetBroadcastShape(e.shape.slice(0, -2), t.shape.slice(0, -2)).concat([f, p]); P.util.assert(h === d, (() => `Error in matMul: inner shapes (${h}) and (${d}) of Tensors with shapes ${e.shape} and ${t.shape} and transposeA=${n} and transposeB=${r} must match.`)); const x = n ? [y, h, f] : [y, f, h], w = r ? [b, p, d] : [b, d, p], k = U_({ inputs: { x: e }, backend: i, attrs: { shape: x } }), S = U_({ inputs: { x: t }, backend: i, attrs: { shape: w } }), _ = [k, S], C = Math.max(y, b), A = n ? k.shape[1] : k.shape[2], T = null != a, E = null != o, N = "leakyrelu" === u, I = null != u ? $_(u, !0) : null; let M; if ((1 === f || 1 === p) && A > 1e3 && !1 === (T || E || N || null != I)) { let e = k, t = S; n && (e = J_({ inputs: { x: k }, backend: i, attrs: { perm: [0, 2, 1] } }), _.push(e)), r && (t = J_({ inputs: { x: S }, backend: i, attrs: { perm: [0, 2, 1] } }), _.push(t)); const a = 1 === p; let o = e; 1 !== p && (o = U_({ inputs: { x: e }, backend: i, attrs: { shape: [C, A, 1] } }), _.push(o)); const s = 1 === p ? 2 : 1; let u = t; a && (u = U_({ inputs: { x: t }, backend: i, attrs: { shape: [C, 1, A] } }), _.push(u)); const l = L_({ inputs: { a: o, b: u }, backend: i }); M = K_({ inputs: { x: l }, backend: i, attrs: { axis: s, keepDims: !0 } }), _.push(l) } else { const u = (0, P.upcastType)(e.dtype, t.dtype), l = new R_(x, w, [C, f, p], n, r, T, I, E, N), c = [k, S]; if (null != a && c.push(a), E && c.push(o), N) { const e = i.makeTensorInfo([], "float32", P.util.createScalarValue(s, "float32")); c.push(e), _.push(e) } M = i.runWebGLProgram(l, c, u) } const F = U_({ inputs: { x: M }, backend: i, attrs: { shape: v } }); _.push(M); for (const e of _) i.disposeIntermediateTensorInfo(e); return F } const tC = {
kernelName: P._FusedMatMul, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a, bias: o, preluActivationWeights: s } = t, { transposeA: u, transposeB: l, activation: c, leakyreluAlpha: h } = r; return eC({ a: i, b: a, transposeA: u, transposeB: l, backend: n, bias: o, preluActivationWeights: s, leakyreluAlpha: h, activation: c }) }
}, nC = "return abs(x);"; const rC = { kernelName: P.Abs, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; if (n.shouldExecuteOnCPU([r]) && "complex64" !== r.dtype) { const e = n.texData.get(r.dataId), t = FS(e.values); return n.makeTensorInfo(r.shape, r.dtype, t) } let i; return i = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? new u_(r.shape, nC) : new n_(r.shape, nC), n.runWebGLProgram(i, [r], r.dtype) } }, iC = F_({ opSnippet: r_ + "\n if (abs(x) > 1.) {\n return NAN;\n }\n return acos(x);\n" }), aC = { kernelName: P.Acos, backendName: "webgl", kernelFunc: iC }, oC = F_({ opSnippet: r_ + "\n if (x < 1.0) return NAN;\nreturn log(x + sqrt(x * x - 1.0));" }), sC = { kernelName: P.Acosh, backendName: "webgl", kernelFunc: oC }, uC = "return a + b;", lC = D_({ opSnippet: uC, packedOpSnippet: uC, supportsComplex: !0, cpuKernelImpl: Qk }), cC = { kernelName: P.Add, backendName: "webgl", kernelFunc: lC };
/**
* @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.
* =============================================================================
*/
class hC { constructor(e, t) { this.outputShape = [], this.outputShape = e, this.variableNames = t.map(((e, t) => `T${t}`)); const n = []; this.variableNames.forEach((e => { n.push(`float v${e} = get${e}AtOutCoords();`) })); const r = this.variableNames.map((e => `v${e}`)).join(" + "); this.userCode = `\n void main() {\n ${n.join("\n ")}\n\n float result = ${r};\n setOutput(result);\n }\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.
* =============================================================================
*/
class dC { constructor(e, t) { this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.variableNames = t.map(((e, t) => `T${t}`)); const n = []; this.variableNames.forEach((e => { n.push(`vec4 v${e} = get${e}AtOutCoords();`) })); const r = this.variableNames.map((e => `v${e}`)).join(" + "); this.userCode = `\n void main() {\n ${n.join("\n ")}\n\n vec4 result = ${r};\n setOutput(result);\n }\n ` } } const fC = {
kernelName: P.AddN, backendName: "webgl", kernelFunc:
/**
* @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 e(t) { const { inputs: n, backend: r } = t, i = n; if (1 === i.length) return w_({ inputs: { x: i[0] }, backend: r }); if (i.length > (0, P.env)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER")) { const t = Math.floor(i.length / 2), n = e({ inputs: i.slice(0, t), backend: r }), a = e({ inputs: i.slice(t), backend: r }); return e({ inputs: [n, a], backend: r }) } const a = i.map((e => e.dtype)).reduce(((e, t) => (0, P.upcastType)(e, t))), o = i.map((e => e.shape)), s = (0, P.env)().getBool("WEBGL_PACK") ? new dC(i[0].shape, o) : new hC(i[0].shape, o); return r.runWebGLProgram(s, i, a) }
}; const pC = {
kernelName: P.All, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, s)), P.backend_util.assertAxesAreInnerMostDims("all", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "all", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g }
}; const mC = {
kernelName: P.Any, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, s)), P.backend_util.assertAxesAreInnerMostDims("any", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "any", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g }
};
/**
* @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.
* =============================================================================
*/
class gC { constructor(e, t, n) { this.variableNames = ["A"]; const { windowSize: r, batchSize: i, outSize: a } = e; n || this.variableNames.push("bestIndicesA"), this.outputShape = [i, a]; const o = "max" === t ? ">" : "<", s = n ? "inOffset + i;" : "round(getBestIndicesA(batch, inOffset + i));"; this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = outIdx * ${r};\n\n int bestIndex = inOffset;\n float bestValue = getA(batch, bestIndex);\n\n for (int i = 0; i < ${r}; i++) {\n int inIdx = ${s};\n float candidate = getA(batch, inIdx);\n if (candidate ${o} bestValue) {\n bestValue = candidate;\n bestIndex = inIdx;\n }\n }\n setOutput(float(bestIndex));\n }\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.
* =============================================================================
*/
class yC { constructor(e, t, n, r) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, P.util.assert(e.length > 2, (() => `Packed arg${n.charAt(0).toUpperCase() + n.slice(1)} supports only inputs with rank above 2.`)); const i = e[e.length - 1], a = Math.ceil(i / t); this.outputShape = e.slice(0, -1), a > 1 && this.outputShape.push(a), r || this.variableNames.push("bestIndicesA"); const o = this.outputShape, s = o.length, u = gk(s), l = XS("coords", s); let c, h; if (1 === a) { h = s + 1; const e = gk(h); c = `\n ${e} sourceLocR = ${e}(${l.join()}, 0);\n ++${l[s - 1]};\n ${e} sourceLocG = ${e}(${l.join()}, 0);\n ++${l[s - 2]};\n ${e} sourceLocA = ${e}(${l.join()}, 0);\n --${l[s - 1]};\n ${e} sourceLocB = ${e}(${l.join()}, 0);\n --${l[s - 2]};` } else h = s, c = `\n ${u} sourceLocR = coords;\n ++${l[s - 1]};\n ${u} sourceLocG = coords;\n ++${l[s - 2]};\n ${u} sourceLocA = coords;\n --${l[s - 1]};\n ${u} sourceLocB = coords;\n --${l[s - 2]};`; const d = ["x", "y", "z", "w", "u", "v"].slice(0, h), f = "." + d[h - 1], p = d.map((e => "int " + e)), m = XS("sourceLocR", h - 1).concat("inIdx.r"), g = XS("sourceLocG", h - 1).concat("inIdx.g"), y = XS("sourceLocB", h - 1).concat("inIdx.b"), b = XS("sourceLocA", h - 1).concat("inIdx.a"), v = "max" === n ? "greaterThan" : "lessThan", x = r ? "" : `\n inIdx = round(vec4(getBestIndicesAChannel(${m.join()}),\n getBestIndicesAChannel(${g.join()}),\n getBestIndicesAChannel(${y.join()}),\n getBestIndicesAChannel(${b.join()})));`, w = `vec4(\n getAChannel(${m.join()}),\n hasNextCol ? getAChannel(${g.join()}) : 0.,\n hasNextRow ? getAChannel(${y.join()}) : 0.,\n hasNextRow && hasNextCol ? getAChannel(${b.join()}) : 0.)`, k = r ? "" : `\n float getBestIndicesAChannel(${p.join()}) {\n return getChannel(getBestIndicesA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }`; this.userCode = `\n float getAChannel(${p.join()}) {\n return getChannel(getA(${d.join()}),\n vec2(${d.slice(-2).join()}));\n }\n ${k}\n void main() {\n ${u} coords = getOutputCoords();\n bool hasNextCol = ${l[s - 1]} < ${o[s - 1] - 1};\n bool hasNextRow = ${l[s - 2]} < ${o[s - 2] - 1};\n ${c}\n ivec4 srcIdx = ivec4(sourceLocR${f}, sourceLocG${f},\n sourceLocB${f}, sourceLocA${f}) * ${t};\n ivec4 inIdx = srcIdx;\n vec4 bestIndex = vec4(inIdx);\n vec4 bestValue = ${w};\n\n for (int i = 0; i < ${t}; i++) {\n inIdx = srcIdx;\n ${x}\n vec4 candidate = ${w};\n bvec4 nan = isnan(candidate);\n bvec4 replace = bvec4(\n vec4(${v}(candidate, bestValue)) * (vec4(1.0) - vec4(nan)));\n\n bestValue = vec4(replace.x ? candidate.x : bestValue.x,\n replace.y ? candidate.y : bestValue.y,\n replace.z ? candidate.z : bestValue.z,\n replace.w ? candidate.w : bestValue.w);\n bestIndex = mix(bestIndex, vec4(inIdx), vec4(replace));\n srcIdx++;\n }\n setOutput(bestIndex);\n }\n ` } }
/**
* @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 bC(e, t, n, r = null) { let i = t.shape[0], a = t.shape[1]; null != r && (i = r.shape[0], a = r.shape[1]); const o = P.backend_util.computeOptimalWindowSize(a), s = { windowSize: o, inSize: a, batchSize: i, outSize: Math.ceil(a / o) }, u = new gC(s, n, null == r), l = [t]; null != r && l.push(r); const c = e.runWebGLProgram(u, l, "int32"); if (1 === c.shape[1]) return c; const h = bC(e, t, n, c); return e.disposeIntermediateTensorInfo(c), h } function vC(e, t, n, r = null) { const i = null != r ? r.shape : t.shape, a = i[i.length - 1], o = P.backend_util.computeOptimalWindowSize(a), s = new yC(i, o, n, null == r), u = null == r ? [t] : [t, r], l = e.runWebGLProgram(s, u, "int32"); if (l.shape.length === t.shape.length) { const r = vC(e, t, n, l); return e.disposeIntermediateTensorInfo(l), r } return l } function xC(e, t, n, r) { const i = [n]; if (P.backend_util.assertAxesAreInnerMostDims("arg" + r.charAt(0).toUpperCase() + r.slice(1), i, t.shape.length), !(0, P.env)().getBool("WEBGL_PACK_REDUCE") || t.shape.length <= 2) { const n = [], a = e.texData.get(t.dataId); let o = t; null !== a && a.isPacked && (o = e.unpackTensor(t), n.push(o)); const [s, u] = P.backend_util.computeOutAndReduceShapes(o.shape, i), l = P.util.sizeFromShape(u), c = U_({ inputs: { x: o }, backend: e, attrs: { shape: [-1, l] } }); n.push(c); const h = bC(e, c, r); n.push(h); const d = U_({ inputs: { x: h }, backend: e, attrs: { shape: s } }); return n.forEach((t => e.disposeIntermediateTensorInfo(t))), d } return vC(e, t, r) } const wC = {
kernelName: P.ArgMax, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = J_({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMax", [o[0]], u.shape.length); const c = xC(n, u, o[0], "max"); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), c }
}; const kC = {
kernelName: P.ArgMin, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a } = r; let o = P.util.parseAxisParam(a, i.shape); const s = P.backend_util.getAxesPermutation(o, i.shape.length); let u = i; const l = []; null != s && (u = J_({ inputs: { x: i }, backend: n, attrs: { perm: s } }), l.push(u), o = P.backend_util.getInnerMostAxes(o.length, u.shape.length)), P.backend_util.assertAxesAreInnerMostDims("argMin", [o[0]], u.shape.length); const c = xC(n, u, o[0], "min"); return l.forEach((e => n.disposeIntermediateTensorInfo(e))), c }
}, SC = F_({ opSnippet: r_ + "\n if (abs(x) > 1.) {\n return NAN;\n }\n return asin(x);\n" }), _C = { kernelName: P.Asin, backendName: "webgl", kernelFunc: SC }, CC = F_({ opSnippet: r_ + "return log(x + sqrt(x * x + 1.0));" }), AC = { kernelName: P.Asinh, backendName: "webgl", kernelFunc: CC }, TC = F_({ opSnippet: r_ + "\n return atan(x);\n" }), EC = { kernelName: P.Atan, backendName: "webgl", kernelFunc: TC }, NC = D_({ opSnippet: y_ + "\n return atan(a, b);\n", packedOpSnippet: "\n vec4 result = atan(a, b);\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n" }), IC = { kernelName: P.Atan2, backendName: "webgl", kernelFunc: NC }, MC = F_({ opSnippet: r_ + "\n if ((x < -1.0) || (x > 1.0)) return NAN;\nreturn (log(1.0 + x) - log(1.0 - x)) / 2.0;" }), FC = { kernelName: P.Atanh, backendName: "webgl", kernelFunc: MC };
/**
* @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.
* =============================================================================
*/
class DC { constructor(e, t, n, r = !1, i = !1) { if (this.variableNames = ["x"], "avg" === t && n) throw new Error("Cannot compute positions for average pool."); const a = e.filterWidth, o = e.strideHeight, s = e.strideWidth, u = e.dilationHeight, l = e.dilationWidth, c = e.effectiveFilterHeight, h = e.effectiveFilterWidth, d = e.padInfo.top, f = e.padInfo.left; this.outputShape = e.outShape; const p = "avg" === t, m = `((batch * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + d`, g = `(xR * ${e.inWidth} + xC) * ${e.inChannels} + d`; let y = "0.0"; if (p || (y = "-1.0 / 1e-20"), n) { const t = ">="; return void (this.userCode = `\n const ivec2 strides = ivec2(${o}, ${s});\n const ivec2 pads = ivec2(${d}, ${f});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n float avgValue = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${h};\n wC += ${l}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xR, xC, d);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r ? i ? m : g : `wR * ${h} + wC`};\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `) } let b = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "avg" === t && (b = "avgValue / max(count, 1.0)"); const v = 4 * Math.floor(a / 4), x = a % 4, w = `\n if (${p}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `; this.userCode = `\n const ivec2 strides = ivec2(${o}, ${s});\n const ivec2 pads = ivec2(${d}, ${f});\n const float initializationValue = ${y};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xR, int xC, int d) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xR, xC, d);\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d = coords[3];\n\n ivec2 xRCCorner = coords.yz * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // max/min x(?, ?, d) to get y(yR, yC, d).\n // ? = to be determined\n vec4 minMaxValue = vec4(${y});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wR = 0; wR < ${c};\n wR += ${u}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${v}; wC += 4) {\n int xC = xCCorner + wC * ${l};\n\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n getValue(batch, xR, xC + 3 * ${l}, d)\n );\n\n ${w}\n }\n\n int xC = xCCorner + ${v};\n if (${1 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${2 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n initializationValue,\n initializationValue\n );\n\n ${w}\n } else if (${3 === x}) {\n vec4 values = vec4(\n getValue(batch, xR, xC, d),\n getValue(batch, xR, xC + ${l}, d),\n getValue(batch, xR, xC + 2 * ${l}, d),\n initializationValue\n );\n\n ${w}\n }\n }\n setOutput(${b});\n }\n ` } } class $C { constructor(e, t, n, r = !1, i = !1) { if (this.variableNames = ["x"], "avg" === t && n) throw new Error("Cannot compute positions for average pool."); const a = e.filterWidth, o = e.strideDepth, s = e.strideHeight, u = e.strideWidth, l = e.dilationDepth, c = e.dilationHeight, h = e.dilationWidth, d = e.effectiveFilterDepth, f = e.effectiveFilterHeight, p = e.effectiveFilterWidth, m = e.padInfo.front, g = e.padInfo.top, y = e.padInfo.left; this.outputShape = e.outShape; const b = "avg" === t; let v = "0.0"; if (b || (v = "-1.0 / 1e-20"), n) { const t = ">="; return void (this.userCode = `\n const ivec3 strides =\n ivec3(${o}, ${s}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, ch) to get y(yD, yR, yC, ch).\n // ? = to be determined\n float minMaxValue = 0.0;\n float minMaxValueFound = 0.0;\n int minMaxPosition = 0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${f};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${p};\n wC += ${h}) {\n int xC = xCCorner + wC;\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float value = getX(batch, xD, xR, xC, ch);\n\n // If a min / max value has already been found, use it. If not,\n // use the current value.\n float currMinMaxValue = mix(\n value, minMaxValue, minMaxValueFound);\n if (value ${t} currMinMaxValue) {\n minMaxValue = value;\n minMaxValueFound = 1.0;\n minMaxPosition = ${r ? i ? `(((batch * ${e.inDepth} + xD) * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `((xD * ${e.inHeight} + xR) * ${e.inWidth} + xC) * ${e.inChannels} + ch` : `wD * ${f} * ${p} +\n wR * ${p} + wC`};\n }\n }\n }\n }\n setOutput(float(minMaxPosition));\n }\n `) } let x = `${t}(${t}(${t}(minMaxValue[0], minMaxValue[1]), minMaxValue[2]), minMaxValue[3])`; "avg" === t && (x = "avgValue / max(count, 1.0)"); const w = 4 * Math.floor(a / 4), k = a % 4, S = `\n if (${b}) {\n avgValue += dot(values, ones);\n } else {\n minMaxValue = max(values, minMaxValue);\n }\n `; this.userCode = `\n const ivec3 strides =\n ivec3(${o}, ${s}, ${u});\n const ivec3 pads = ivec3(${m}, ${g}, ${y});\n const float initializationValue = ${v};\n const vec4 ones = vec4(1.0, 1.0, 1.0, 1.0);\n\n float count = 0.0;\n\n float getValue(int batch, int xD, int xR, int xC, int ch) {\n if (xC < 0 || xC >= ${e.inWidth}) {\n return initializationValue;\n }\n count += 1.0;\n return getX(batch, xD, xR, xC, ch);\n }\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 xCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xDCorner = xCorner.x;\n int xRCorner = xCorner.y;\n int xCCorner = xCorner.z;\n\n // max/min x(?, ?, ?, d) to get y(yD, yR, yC, ch).\n // ? = to be determined\n vec4 minMaxValue = vec4(${v});\n float avgValue = 0.0;\n count = 0.0;\n\n for (int wD = 0; wD < ${d};\n wD += ${l}) {\n int xD = xDCorner + wD;\n\n if (xD < 0 || xD >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${f};\n wR += ${c}) {\n int xR = xRCorner + wR;\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${w}; wC += 4) {\n int xC = xCCorner + wC * ${h};\n\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n getValue(batch, xD, xR, xC + 3 * ${h}, ch)\n );\n\n ${S}\n }\n\n int xC = xCCorner + ${w};\n if (${1 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${2 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n initializationValue,\n initializationValue\n );\n\n ${S}\n } else if (${3 === k}) {\n vec4 values = vec4(\n getValue(batch, xD, xR, xC, ch),\n getValue(batch, xD, xR, xC + ${h}, ch),\n getValue(batch, xD, xR, xC + 2 * ${h}, ch),\n initializationValue\n );\n\n ${S}\n }\n }\n }\n setOutput(${x});\n }\n ` } } const RC = {
kernelName: P.AvgPool, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; Zw(i, "avgPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in avgPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) return w_({ inputs: { x: i }, backend: n }); const c = new DC(l, "avg", !1); return n.runWebGLProgram(c, [i], "float32") }
}; const OC = {
kernelName: P.AvgPool3D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dimRoundingMode: u, dataFormat: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, u, l), h = new $C(c, "avg", !1); return n.runWebGLProgram(h, [i], "float32") }
};
/**
* @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.
* =============================================================================
*/
class zC { constructor(e) { this.variableNames = ["dy"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = e.dilationHeight, o = e.dilationWidth, s = e.effectiveFilterHeight, u = e.effectiveFilterWidth, l = s - 1 - e.padInfo.top, c = u - 1 - e.padInfo.left, h = 1 / (t * n); this.userCode = `\n const ivec2 pads = ivec2(${l}, ${c});\n const float avgMultiplier = float(${h});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${s};\n wR += ${a}) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${u};\n wC+= ${o}) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n setOutput(dotProd);\n }\n ` } } class PC { constructor(e) { this.variableNames = ["dy"], this.outputShape = e.inShape; const t = e.filterDepth, n = e.filterHeight, r = e.filterWidth, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = e.dilationDepth, u = e.dilationHeight, l = e.dilationWidth, c = e.effectiveFilterDepth, h = e.effectiveFilterHeight, d = e.effectiveFilterWidth, f = c - 1 - e.padInfo.front, p = h - 1 - e.padInfo.top, m = d - 1 - e.padInfo.left, g = 1 / (t * n * r); this.userCode = `\n const ivec3 pads = ivec3(${f}, ${p}, ${m});\n const float avgMultiplier = float(${g});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, d) with pos mask(:, :, :, ch) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${c};\n wD += ${s}) {\n float dyD = float(dyDCorner + wD) / ${i}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${h};\n wR += ${u}) {\n float dyR = float(dyRCorner + wR) / ${a}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${d};\n wC += ${l}) {\n float dyC = float(dyCCorner + wC) / ${o}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n\n dotProd += dyValue * avgMultiplier;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const BC = {
kernelName: P.AvgPool3DGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, [1, 1, 1], l, c), d = new PC(h); return n.runWebGLProgram(d, [i], o.dtype) }
}; const LC = {
kernelName: P.AvgPoolGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a; Zw([i, a], "avgPoolGrad"); const { filterSize: s, strides: u, pad: l } = r, c = P.backend_util.computePool2DInfo(o.shape, s, u, 1, l), h = new zC(c); return n.runWebGLProgram(h, [i], o.dtype) }
}; const jC = {
kernelName: P.BatchMatMul, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { a: i, b: a } = t, { transposeA: o, transposeB: s } = r; return eC({ a: i, b: a, transposeA: o, transposeB: s, backend: n }) }
};
/**
* @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.
* =============================================================================
*/
class UC { constructor(e, t, n, r, i, a) { this.outputShape = [], this.variableNames = ["x", "mean", "variance"], P.backend_util.assertAndGetBroadcastShape(e, t), P.backend_util.assertAndGetBroadcastShape(e, n); let o = "0.0"; null != r && (P.backend_util.assertAndGetBroadcastShape(e, r), this.variableNames.push("offset"), o = "getOffsetAtOutCoords()"); let s = "1.0"; null != i && (P.backend_util.assertAndGetBroadcastShape(e, i), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `\n void main() {\n float x = getXAtOutCoords();\n float mean = getMeanAtOutCoords();\n float variance = getVarianceAtOutCoords();\n float offset = ${o};\n float scale = ${s};\n float inv = scale * inversesqrt(variance + float(${a}));\n setOutput(dot(vec3(x, -mean, offset), vec3(inv, inv, 1)));\n }\n ` } }
/**
* @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 WC { constructor(e, t, n, r, i, a) { this.packedInputs = !0, this.packedOutput = !0, this.variableNames = ["x", "mean", "variance"], P.backend_util.assertAndGetBroadcastShape(e, t), P.backend_util.assertAndGetBroadcastShape(e, n); let o = "vec4(0.0)"; null != r && (P.backend_util.assertAndGetBroadcastShape(e, r), this.variableNames.push("offset"), o = "getOffsetAtOutCoords()"); let s = "vec4(1.0)"; null != i && (P.backend_util.assertAndGetBroadcastShape(e, i), this.variableNames.push("scale"), s = "getScaleAtOutCoords()"), this.outputShape = e, this.userCode = `\n void main() {\n vec4 offset = ${o};\n vec4 scale = ${s};\n\n vec4 x = getXAtOutCoords();\n vec4 mean = getMeanAtOutCoords();\n vec4 variance = getVarianceAtOutCoords();\n\n vec4 inv = scale * inversesqrt(variance + vec4(${a}));\n\n setOutput((x - mean) * inv + offset);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const VC = { kernelName: P.FusedBatchNorm, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r, mean: i, variance: a, offset: o, scale: s } = e; P.util.assert(i.shape.length === a.shape.length, (() => "Batch normalization gradient requires mean and variance to have equal ranks.")), P.util.assert(null == o || i.shape.length === o.shape.length, (() => "Batch normalization gradient requires mean and offset to have equal ranks.")), P.util.assert(null == s || i.shape.length === s.shape.length, (() => "Batch normalization gradient requires mean and scale to have equal ranks.")); let { varianceEpsilon: u } = n; null == u && (u = .001); const l = [r, i, a]; let c = null; null != o && (c = o.shape, l.push(o)); let h = null; null != s && (h = s.shape, l.push(s)); const d = (0, P.env)().getBool("WEBGL_PACK_NORMALIZATION") ? new WC(r.shape, i.shape, a.shape, c, h, u) : new UC(r.shape, i.shape, a.shape, c, h, u); return t.runWebGLProgram(d, l, l[0].dtype) } };
/**
* @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.
* =============================================================================
*/
class GC { constructor(e) { this.variableNames = ["source"], this.outputShape = e, this.rank = e.length; const t = gk(this.rank); this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }]; const n = function (e) { if (1 === e) return "sourceLoc"; if (e <= 6) return HC.slice(0, e).map((e => "sourceLoc." + e)).join(","); throw Error(`Slicing for rank ${e} is not yet supported`) }(this.rank); let r; r = `\n ${t} sourceLoc;\n ${t} coords = getOutputCoords();\n ${e.map(((e, t) => `sourceLoc.${HC[t]} = start[${t}] + coords.${HC[t]};`)).join("\n")}\n `, this.userCode = `\n void main() {\n ${r}\n setOutput(getSource(${n}));\n }\n ` } } const HC = ["x", "y", "z", "w", "u", "v"];
/**
* @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.
* =============================================================================
*/
class qC { constructor(e) { this.variableNames = ["source"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = e, this.rank = e.length, this.customUniforms = [{ name: "start", arrayIndex: this.rank, type: "int" }]; const t = gk(this.rank), n = XS("coords", this.rank), r = XS("sourceLoc", this.rank), i = 1 === this.rank ? "sourceLoc" : `vec2(${r.slice(-2).join()})`, a = `getChannel(getSource(${r.join()}), ${i})`, o = `\n result.x = ${a};\n if (++${n[this.rank - 1]} < ${e[this.rank - 1]}) {\n ++${r[this.rank - 1]};\n result.y = ${a};\n --${r[this.rank - 1]};\n }\n `, s = 1 === this.rank ? "" : `\n --${n[this.rank - 1]};\n if (++${n[this.rank - 2]} < ${e[this.rank - 2]}) {\n ++${r[this.rank - 2]};\n result.z = ${a};\n if (++${n[this.rank - 1]} < ${e[this.rank - 1]}) {\n ++${r[this.rank - 1]};\n result.w = ${a};\n }\n }\n `, u = this.rank <= 4 ? `sourceLoc = coords +\n ${t}(${e.map(((e, t) => `start[${t}]`)).join()});` : e.map(((e, t) => `${r[t]} = ${n[t]} + start[${t}];`)).join("\n"); this.userCode = `\n void main() {\n ${t} coords = getOutputCoords();\n ${t} sourceLoc;\n ${u}\n vec4 result = vec4(0.);\n ${o}\n ${s}\n setOutput(result);\n }\n ` } } function YC(e) {
const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, size: o } = r, [s, u] = P.slice_util.parseSliceParams(i, a, o); if (P.slice_util.assertParamsValid(i, s, u), 0 === P.util.sizeFromShape(u)) return n.makeTensorInfo(u, i.dtype, []); if (n.shouldExecuteOnCPU([i]) || "string" === i.dtype) { const e = n.texData.get(i.dataId), t = DS(e.values, s, u, i.shape, i.dtype); return n.makeTensorInfo(u, i.dtype, t) } const { isPacked: l } = n.texData.get(i.dataId), c = P.slice_util.isSliceContinous(i.shape, s, u); if (l || !c) { const e = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new qC(u) : new GC(u), t = [s]; return n.runWebGLProgram(e, [i], i.dtype, t) } return n.uploadToGPU(i.dataId),
/**
* @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 (e, t, n, r) { const i = r.texData.get(e.dataId), a = r.makeTensorInfo(n, e.dtype), o = r.texData.get(a.dataId); Object.assign(o, i), o.refCount = 1, o.shape = n, o.dtype = e.dtype; let s = P.slice_util.computeFlatOffset(t, P.util.computeStrides(e.shape)); i.slice && (s += i.slice.flatOffset), o.slice = { flatOffset: s, origDataId: i.slice && i.slice.origDataId || e.dataId }; const u = r.dataRefCount.get(o.slice.origDataId) || 1; return r.dataRefCount.set(o.slice.origDataId, u + 1), a }(i, s, u, n)
} const XC = { kernelName: P.Slice, backendName: "webgl", kernelFunc: YC }, KC = { kernelName: P.BatchToSpaceND, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, crops: o } = r; P.util.assert(i.shape.length <= 4, (() => "batchToSpaceND for rank > 4 with a WebGL backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = P.backend_util.getReshaped(i.shape, a, s), l = P.backend_util.getPermuted(u.length, a.length), c = P.backend_util.getReshapedPermuted(i.shape, a, s), h = P.backend_util.getSliceBeginCoords(o, a.length), d = P.backend_util.getSliceSize(c, o, a.length), f = [], p = U_({ inputs: { x: i }, backend: n, attrs: { shape: u } }), m = J_({ inputs: { x: p }, backend: n, attrs: { perm: l } }), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: c } }), y = YC({ inputs: { x: g }, backend: n, attrs: { begin: h, size: d } }); return f.push(p), f.push(m), f.push(g), f.forEach((e => n.disposeIntermediateTensorInfo(e))), y } }; const ZC = {
kernelName: P.Bincount, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o } = r, s = n.readSync(i.dataId), u = n.readSync(a.dataId), l = eS(s, u, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, l) }
}; const JC = { kernelName: P.BitwiseAnd, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { a: r, b: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS"), o = (0, P.env)().getNumber("WEBGL_VERSION"); if (n.shouldExecuteOnCPU([r, i]) || 1 === o) { const e = n.texData.get(r.dataId).values, t = n.texData.get(i.dataId).values, [a, o] = nS(r.shape, i.shape, e, t, r.dtype), s = n.makeTensorInfo(o, r.dtype); return n.texData.get(s.dataId).values = a, s } let s; return s = a ? new x_("\n int r = int(a.r) & int(b.r);\n int g = int(a.g) & int(b.g);\n int rb = int(a.b) & int(b.b);\n int ra = int(a.a) & int(b.a);\n return vec4(r, g, rb, ra);\n", r.shape, i.shape, !1) : new b_("\n return float(int(a.r) & int(b.r));\n", r.shape, i.shape), n.runWebGLProgram(s, [r, i], r.dtype) } }; const QC = {
kernelName: P.BroadcastArgs, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { s0: r, s1: i } = t, a = n.readSync(r.dataId), o = n.readSync(i.dataId), s = P.backend_util.assertAndGetBroadcastShape(Array.from(a), Array.from(o)); return n.makeTensorInfo([s.length], "int32", Int32Array.from(s)) }
}, eA = D_({ opSnippet: "return float(a != b);", cpuKernelImpl: SS, dtype: "bool" }), tA = { kernelName: P.NotEqual, backendName: "webgl", kernelFunc: eA };
/**
* @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 nA(e) { const { inputs: t, backend: n } = e, { input: r } = t; return w_({ inputs: { x: n.texData.get(r.dataId).complexTensorInfos.real }, backend: n }) } const rA = { kernelName: P.Real, backendName: "webgl", kernelFunc: nA }; const iA = {
kernelName: P.Cast, backendName: "webgl", kernelFunc:
/**
* @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 e(t) { const { inputs: n, backend: r, attrs: i } = t, { x: a } = n, { dtype: o } = i; if ("complex64" === o) { if ("complex64" === a.dtype) return w_({ inputs: { x: a }, backend: r }); const t = P.zeros(a.shape), n = e({ inputs: { x: a }, backend: r, attrs: { dtype: "float32" } }), i = S_({ inputs: { real: n, imag: t }, backend: r }); return t.dispose(), r.disposeIntermediateTensorInfo(n), i } if ("complex64" === a.dtype) { const t = nA({ inputs: { input: a }, backend: r }), n = e({ inputs: { x: t }, backend: r, attrs: { dtype: o } }); return r.disposeIntermediateTensorInfo(t), n } if (!P.util.hasEncodingLoss(a.dtype, o)) { const e = w_({ inputs: { x: a }, backend: r }); return { dataId: e.dataId, shape: e.shape, dtype: o } } if (r.shouldExecuteOnCPU([a])) { const e = r.texData.get(a.dataId).values, [t, n, i] = rS(e, a.shape, a.dtype, o); return r.makeTensorInfo(t, n, i) } if ("int32" === o) return function (e, t) { const n = new n_(e.shape, "return float(int(x));"), r = t.runWebGLProgram(n, [e], "int32"); return { dataId: r.dataId, shape: r.shape, dtype: r.dtype } }(a, r); if ("bool" === o) { const e = r.makeTensorInfo([], "bool", P.util.getTypedArrayFromDType("bool", 1)), t = eA({ inputs: { a, b: e }, backend: r }); return r.disposeIntermediateTensorInfo(e), t } throw new Error(`Error in Cast: failed to cast ${a.dtype} to ${o}`) }
}, aA = "return ceil(x);", oA = F_({ opSnippet: aA, packedOpSnippet: aA, cpuKernelImpl: iS }), sA = { kernelName: P.Ceil, backendName: "webgl", kernelFunc: oA };
/**
* @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.
* =============================================================================
*/
class uA { constructor(e) { this.variableNames = ["A"], this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = "\n\n void main() {\n float value = getAAtOutCoords();\n if (isnan(value)) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, minVal, maxVal));\n }\n " } }
/**
* @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 lA { constructor(e) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "minVal", type: "float" }, { name: "maxVal", type: "float" }], this.outputShape = e, this.userCode = "\n void main() {\n vec4 value = getAAtOutCoords();\n\n if (any(isnan(value))) {\n setOutput(value);\n return;\n }\n\n setOutput(clamp(value, vec4(minVal), vec4(maxVal)));\n }\n " } } const cA = {
kernelName: P.ClipByValue, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { clipValueMin: a, clipValueMax: o } = r; let s; s = (0, P.env)().getBool("WEBGL_PACK_CLIP") ? new lA(i.shape) : new uA(i.shape); const u = [[a], [o]]; return n.runWebGLProgram(s, [i], i.dtype, u) }
};
/**
* @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 hA { constructor(e) { this.variableNames = ["real", "imag"], this.outputShape = e, this.userCode = "\n void main() {\n float re = abs(getRealAtOutCoords());\n float im = abs(getImagAtOutCoords());\n float mx = max(re, im);\n\n // sadly the length function in glsl is not underflow-safe\n // (at least not on Intel GPUs). So the safe solution is\n // to ensure underflow-safety in all cases.\n setOutput(\n mx == 0.0 ? 0.0 : mx * length(vec2(1, min(re, im)/mx))\n );\n }\n " } }
/**
* @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 dA(e, t) { return { dataId: t.dataId, dtype: t.dtype, shape: e.shape } } const fA = { kernelName: P.ComplexAbs, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = n.texData.get(r.dataId), a = new hA(r.shape), o = [dA(r, i.complexTensorInfos.real), dA(r, i.complexTensorInfos.imag)]; return n.runWebGLProgram(a, o, o[0].dtype) } };
/**
* @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.
* =============================================================================
*/
class pA { constructor(e) { this.outputShape = [], this.outputShape = P.backend_util.computeOutShape(e, 1), this.variableNames = e.map(((e, t) => `T${t}`)); const t = new Array(e.length - 1); t[0] = e[0][1]; for (let n = 1; n < t.length; n++)t[n] = t[n - 1] + e[n][1]; const n = [`if (yC < ${t[0]}) setOutput(getT0(yR, yC));`]; for (let e = 1; e < t.length; e++) { const r = t[e - 1]; n.push(`else if (yC < ${t[e]}) setOutput(getT${e}(yR, yC-${r}));`) } const r = t.length, i = t[t.length - 1]; n.push(`else setOutput(getT${r}(yR, yC-${i}));`), this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int yR = coords.x;\n int yC = coords.y;\n\n ${n.join("\n ")}\n }\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.
* =============================================================================
*/
class mA { constructor(e, t) { this.packedInputs = !0, this.packedOutput = !0, this.outputShape = [], this.outputShape = P.backend_util.computeOutShape(e, t); const n = this.outputShape, r = n.length, i = gk(r), a = XS("coords", r), o = ["x", "y", "z", "w", "u", "v"].slice(0, r); this.variableNames = e.map(((e, t) => `T${t}`)); const s = new Array(e.length - 1); s[0] = e[0][t]; for (let n = 1; n < s.length; n++)s[n] = s[n - 1] + e[n][t]; const u = o[t], l = o.slice(-2), c = o.join(); let h = `if (${u} < ${s[0]}) {\n return getChannel(\n getT0(${c}), vec2(${l.join()}));\n }`; for (let e = 1; e < s.length; e++) { const t = s[e - 1]; h += `\n if (${u} < ${s[e]} && ${u} >= ${s[e - 1]}) {\n return getChannel(\n getT${e}(${gA(o, u, t)}),\n vec2(${gA(l, u, t)}));\n }` } const d = s.length, f = s[s.length - 1]; h += `\n return getChannel(\n getT${d}(${gA(o, u, f)}),\n vec2(${gA(l, u, f)}));`, this.userCode = `\n float getValue(${o.map((e => "int " + e))}) {\n ${h}\n }\n\n void main() {\n ${i} coords = getOutputCoords();\n vec4 result = vec4(getValue(${a}), 0., 0., 0.);\n\n ${a[r - 1]} = ${a[r - 1]} + 1;\n if (${a[r - 1]} < ${n[r - 1]}) {\n result.g = getValue(${a});\n }\n\n ${a[r - 2]} = ${a[r - 2]} + 1;\n if (${a[r - 2]} < ${n[r - 2]}) {\n result.a = getValue(${a});\n }\n\n ${a[r - 1]} = ${a[r - 1]} - 1;\n if (${a[r - 2]} < ${n[r - 2]} &&\n ${a[r - 1]} < ${n[r - 1]}) {\n result.b = getValue(${a});\n }\n setOutput(result);\n }\n ` } } function gA(e, t, n) { const r = e.indexOf(t); return e.map(((e, t) => t === r ? `${e} - ${n}` : e)).join() }
/**
* @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 yA(e) { const { inputs: t, backend: n } = e, { input: r } = t; return w_({ inputs: { x: n.texData.get(r.dataId).complexTensorInfos.imag }, backend: n }) } const bA = { kernelName: P.Imag, backendName: "webgl", kernelFunc: yA };
/**
* @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 vA(e, t, n) { const r = e[0].dtype; if ("complex64" === r) { const r = e.map((e => nA({ inputs: { input: e }, backend: n }))), i = e.map((e => yA({ inputs: { input: e }, backend: n }))), a = vA(r, t, n), o = vA(i, t, n), s = S_({ inputs: { real: a, imag: o }, backend: n }); return r.forEach((e => n.disposeIntermediateTensorInfo(e))), i.forEach((e => n.disposeIntermediateTensorInfo(e))), n.disposeIntermediateTensorInfo(a), n.disposeIntermediateTensorInfo(o), s } let i = n.shouldExecuteOnCPU(e); if ("string" === r && (i = !0), i) { const i = e.map((e => { const r = P.util.sizeFromShape(e.shape.slice(t)); return U_({ inputs: { x: e }, backend: n, attrs: { shape: [-1, r] } }) })), a = i.map((e => ({ vals: n.readSync(e.dataId), shape: e.shape }))), o = P.backend_util.computeOutShape(i.map((e => e.shape)), 1), s = 1 === i[0].shape[0], u = aS(a, o, r, s), l = P.backend_util.computeOutShape(e.map((e => e.shape)), t), c = n.makeTensorInfo(l, r, u); return i.forEach((e => n.disposeIntermediateTensorInfo(e))), c } const a = e.filter((e => P.util.sizeFromShape(e.shape) > 0)), o = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") && a[0].shape.length > 1; if (1 === a.length) { const t = o ? new n_(e[0].shape, s_) : new u_(e[0].shape, s_); return n.runWebGLProgram(t, e, r) } const s = (0, P.env)().getNumber("WEBGL_MAX_TEXTURES_IN_SHADER"); if (a.length > s) { const e = []; for (let r = 0; r < a.length; r += s) { const i = a.slice(r, r + s); e.push(vA(i, t, n)) } const r = vA(e, t, n); for (const t of e) n.disposeIntermediateTensorInfo(t); return r } if (o) { const e = new mA(a.map((e => e.shape)), t); return n.runWebGLProgram(e, a, r) } const { tensors2D: u, outShape: l } = function (e, t, n) { const r = P.backend_util.computeOutShape(e.map((e => e.shape)), t), i = e.map((e => U_({ inputs: { x: e }, attrs: { shape: [-1, P.util.sizeFromShape(e.shape.slice(t))] }, backend: n }))); return { tensors2D: i, outShape: r } }(a, t, n), c = new pA(u.map((e => e.shape))), h = n.runWebGLProgram(c, u, r); u.forEach((e => n.disposeIntermediateTensorInfo(e))); const d = U_({ inputs: { x: h }, attrs: { shape: l }, backend: n }); return n.disposeIntermediateTensorInfo(h), d }
/**
* @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 xA(e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r, a = P.util.parseAxisParam(i, t[0].shape)[0], o = t.map((e => e.shape)); P.backend_util.assertParamsConsistent(o, a); const s = P.backend_util.computeOutShape(t.map((e => e.shape)), a); if (0 === P.util.sizeFromShape(s)) return n.makeTensorInfo(s, t[0].dtype, []); const u = t.filter((e => P.util.sizeFromShape(e.shape) > 0)); return 1 === u.length ? w_({ inputs: { x: u[0] }, backend: n }) : vA(u, a, n) } const wA = { kernelName: P.Concat, backendName: "webgl", kernelFunc: xA };
/**
* @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.
* =============================================================================
*/
class kA { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const a = e.padInfo.top, o = e.padInfo.left, s = e.strideHeight, u = e.strideWidth, l = e.dilationHeight, c = e.dilationWidth, h = e.filterHeight, d = e.filterWidth, f = 4 * Math.floor(e.inChannels / 4), p = e.inChannels % 4, m = "channelsLast" === e.dataFormat, g = m ? 1 : 2, y = m ? 2 : 3, b = m ? 3 : 1; let v = "", x = ""; n && (v = r ? `float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `\n float activation(float x) {\n ${n}\n }\n `, x = "result = activation(result);"); const w = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${v}\n\n const ivec2 strides = ivec2(${s}, ${u});\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d2 = coords[${b}];\n\n ivec2 xRCCorner =\n ivec2(coords[${g}], coords[${y}]) * strides - pads;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, d2) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${h}; wR++) {\n int xR = xRCorner + wR * ${l};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${c};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${f}; d1 += 4) {\n vec4 wValues = vec4(\n getW(wR, wC, d1, d2),\n getW(wR, wC, d1 + 1, d2),\n getW(wR, wC, d1 + 2, d2),\n getW(wR, wC, d1 + 3, d2)\n );\n\n if (${m}) {\n vec4 xValues = vec4(\n getX(batch, xR, xC, d1),\n getX(batch, xR, xC, d1 + 1),\n getX(batch, xR, xC, d1 + 2),\n getX(batch, xR, xC, d1 + 3)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec4 xValues = vec4(\n getX(batch, d1, xR, xC),\n getX(batch, d1 + 1, xR, xC),\n getX(batch, d1 + 2, xR, xC),\n getX(batch, d1 + 3, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n\n if (${1 === p}) {\n\n if (${m}) {\n dotProd +=\n getX(batch, xR, xC, ${f}) *\n getW(wR, wC, ${f}, d2);\n } else {\n dotProd +=\n getX(batch, ${f}, xR, xC) *\n getW(wR, wC, ${f}, d2);\n }\n\n } else if (${2 === p}) {\n vec2 wValues = vec2(\n getW(wR, wC, ${f}, d2),\n getW(wR, wC, ${f} + 1, d2)\n );\n\n if (${m}) {\n vec2 xValues = vec2(\n getX(batch, xR, xC, ${f}),\n getX(batch, xR, xC, ${f} + 1)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec2 xValues = vec2(\n getX(batch, ${f}, xR, xC),\n getX(batch, ${f} + 1, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n } else if (${3 === p}) {\n vec3 wValues = vec3(\n getW(wR, wC, ${f}, d2),\n getW(wR, wC, ${f} + 1, d2),\n getW(wR, wC, ${f} + 2, d2)\n );\n\n if (${m}) {\n vec3 xValues = vec3(\n getX(batch, xR, xC, ${f}),\n getX(batch, xR, xC, ${f} + 1),\n getX(batch, xR, xC, ${f} + 2)\n );\n dotProd += dot(xValues, wValues);\n } else {\n vec3 xValues = vec3(\n getX(batch, ${f}, xR, xC),\n getX(batch, ${f} + 1, xR, xC),\n getX(batch, ${f} + 2, xR, xC)\n );\n dotProd += dot(xValues, wValues);\n }\n\n }\n }\n }\n\n float result = dotProd;\n ${w}\n ${x}\n setOutput(result);\n }\n ` } } class SA { constructor(e) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const t = e.padInfo.front, n = e.padInfo.top, r = e.padInfo.left, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = e.dilationDepth, u = e.dilationHeight, l = e.dilationWidth, c = e.filterDepth, h = e.filterHeight, d = e.filterWidth, f = 4 * Math.floor(e.inChannels / 4), p = e.inChannels % 4; this.userCode = `\n const ivec3 strides = ivec3(${i}, ${a}, ${o});\n const ivec3 pads = ivec3(${t}, ${n}, ${r});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d2 = coords.u;\n\n ivec3 xFRCCorner = ivec3(coords.y, coords.z, coords.w) * strides - pads;\n int xFCorner = xFRCCorner.x;\n int xRCorner = xFRCCorner.y;\n int xCCorner = xFRCCorner.z;\n\n // Convolve x(?, ?, ?, d1) with w(:, :, :, d1, d2) to get\n // y(yF, yR, yC, d2). ? = to be determined. : = across all\n // values in that axis.\n float dotProd = 0.0;\n for (int wF = 0; wF < ${c}; wF++) {\n int xF = xFCorner + wF * ${s};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int wR = 0; wR < ${h}; wR++) {\n int xR = xRCorner + wR * ${u};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int wC = 0; wC < ${d}; wC++) {\n int xC = xCCorner + wC * ${l};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n for (int d1 = 0; d1 < ${f}; d1 += 4) {\n vec4 xValues = vec4(\n getX(batch, xF, xR, xC, d1),\n getX(batch, xF, xR, xC, d1 + 1),\n getX(batch, xF, xR, xC, d1 + 2),\n getX(batch, xF, xR, xC, d1 + 3)\n );\n vec4 wValues = vec4(\n getW(wF, wR, wC, d1, d2),\n getW(wF, wR, wC, d1 + 1, d2),\n getW(wF, wR, wC, d1 + 2, d2),\n getW(wF, wR, wC, d1 + 3, d2)\n );\n\n dotProd += dot(xValues, wValues);\n }\n\n if (${1 === p}) {\n dotProd +=\n getX(batch, xF, xR, xC, ${f}) *\n getW(wF, wR, wC, ${f}, d2);\n } else if (${2 === p}) {\n vec2 xValues = vec2(\n getX(batch, xF, xR, xC, ${f}),\n getX(batch, xF, xR, xC, ${f} + 1)\n );\n vec2 wValues = vec2(\n getW(wF, wR, wC, ${f}, d2),\n getW(wF, wR, wC, ${f} + 1, d2)\n );\n dotProd += dot(xValues, wValues);\n } else if (${3 === p}) {\n vec3 xValues = vec3(\n getX(batch, xF, xR, xC, ${f}),\n getX(batch, xF, xR, xC, ${f} + 1),\n getX(batch, xF, xR, xC, ${f} + 2)\n );\n vec3 wValues = vec3(\n getW(wF, wR, wC, ${f}, d2),\n getW(wF, wR, wC, ${f} + 1, d2),\n getW(wF, wR, wC, ${f} + 2, d2)\n );\n dotProd += dot(xValues, wValues);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
class _A { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.padInfo.left, o = e.strideWidth, s = e.dilationWidth, u = e.filterHeight, l = e.filterWidth, c = l; let h = "\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;"; for (let e = 0; e < l; e++)h += `\n vec4 xTexelC${2 * e};\n int xTexelC${2 * e}Ready;\n vec4 xTexelC${2 * e + 1};\n int xTexelC${2 * e + 1}Ready;\n vec4 xC${e};`; h += `\n for (int r = 0; r < ${u}; r++) {\n for (int d1 = 0; d1 < ${e.inChannels}; d1 += 2) {\n `; for (let e = 0; e < l; e++)h += `\n xTexelC${2 * e} = vec4(0.0);\n xTexelC${2 * e}Ready = 0;\n xTexelC${2 * e + 1} = vec4(0.0);\n xTexelC${2 * e + 1}Ready = 0;\n xC${e} = vec4(0.0);`; h += "\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n "; for (let t = 0; t < (c + 1) / 2; t++) { const n = 2 * t; if (h += `\n xC = xCCorner + ${n * s};\n `, 1 === o) { if (n < l && (a % 2 == 1 ? (h += `\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n `, h += 1 === s && n > 0 ? `\n xC${n} = vec4(xTexelC${n - 2}.zw, xTexelC${n}.xy);\n ` : `\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${n} = vec4(previous.zw, xTexelC${n}.xy);\n } else {\n xC${n} = vec4(0.0, 0.0, xTexelC${n}.xy);\n }\n `) : h += `\n if (xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xC${n} = xTexelC${n};\n `, n + 1 < l)) { const e = a % 2 == 0 ? P.util.nearestLargerEven(s) : s; s % 2 == 0 && a % 2 == 1 || s % 2 != 0 && a % 2 != 1 ? (h += `\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n `, h += s > 1 ? `\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${n + 1} = vec4(previous.zw, xTexelC${n + 1}.xy);\n } else {\n xC${n + 1} = vec4(0.0, 0.0, xTexelC${n + 1}.xy);\n }\n ` : `\n xC${n + 1} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.xy);\n `) : h += 1 === e ? `\n xC${n + 1} = xTexelC${n};\n ` : `\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n + 1} = xTexelC${n + 1};\n ` } } else n < l && (a % 2 == 1 ? (h += `\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.0);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.zw);\n `, n + 1 < l && (h += `\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${n + 1} = vec4(xTexelC${n + 1}.xy, final.xy);\n `)) : (h += `\n if(xC >= 0 && xC < inDims[1] && xTexelC${n}Ready == 0) {\n xTexelC${n} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${n}.zw = vec2(0.0);\n }\n xTexelC${n}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${n + 1}Ready == 0) {\n xTexelC${n + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${n + 1}.zw = vec2(0.);\n }\n xTexelC${n + 1}Ready = 1;\n }\n\n xC${n} = vec4(\n xTexelC${n}.xy, xTexelC${n + 1}.xy);\n `, n + 1 < l && (h += `\n xC${n + 1} = vec4(xTexelC${n}.zw, xTexelC${n + 1}.zw);\n `))); n < l && (h += `\n wTexel = getW(r, ${n}, d1, d2);\n dotProd += xC${n}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `, n + 1 < l && (h += `\n wTexel = getW(r, ${n + 1}, d1, d2);\n dotProd += xC${n + 1}.xxzz * vec4(wTexel.xy, wTexel.xy);\n if(d1 + 1 < ${e.inChannels}) {\n dotProd += xC${n + 1}.yyww * vec4(wTexel.zw, wTexel.zw);\n }\n `)) } h += "\n }\n ", h += "\n }\n ", h += "\n }\n "; let d = "", f = ""; n && (d = r ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `vec4 activation(vec4 x) {\n ${n}\n }`, f = "result = activation(result);"); const p = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${d}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${h}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${p}\n ${f}\n setOutput(result);\n }\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.
* =============================================================================
*/
class CA { constructor(e, t) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "inputShape", type: "ivec4" }, { name: "pad", type: "ivec2" }, { name: "stride", type: "ivec2" }, { name: "dilation", type: "ivec2" }, { name: "inChannels", type: "int" }, { name: "itemsPerBlockRow", type: "int" }, { name: "outWidth", type: "int" }], this.outputShape = e, this.enableShapeUniforms = kk(this.outputShape.length); const { dataFormat: n } = t, r = Qw(), i = "channelsLast" === n, a = i ? 1 : 2, o = i ? 2 : 3, s = this.enableShapeUniforms ? "if(blockIndex < outShape[2] && pos < outShape[1]) {" : `if(blockIndex < ${e[2]} && pos < ${e[1]}) {`; let u = ""; for (let e = 0; e <= 1; e++)for (let t = 0; t <= 1; t++)u += `\n blockIndex = rc.z + ${t};\n pos = rc.y + ${e};\n\n ${s}\n offsetY = int(blockIndex / outWidth) * stride[0] - pad[0];\n d0 = offsetY + dilation[0] * (pos / itemsPerBlockRow);\n\n if(d0 < inputShape[${a}] && d0 >= 0) {\n // Use custom imod instead mod. On Intel GPU, mod may generate\n // unexpected value.\n // https://github.com/tensorflow/tfjs/issues/5447\n offsetX = imod(blockIndex, outWidth) * stride[1] - pad[1];\n d1 = offsetX + dilation[1] * (imod(pos, itemsPerBlockRow) /\n inChannels);\n\n if(d1 < inputShape[${o}] && d1 >= 0) {\n\n ch = imod(pos, inChannels);\n\n if (${i}) {\n innerDims = vec2(d1, ch);\n result[${2 * e + t}] = getChannel(\n getA(rc.x, d0, int(innerDims.x),\n int(innerDims.y)), innerDims);\n } else {\n innerDims = vec2(d0, d1);\n result[${2 * e + t}] = getChannel(\n getA(rc.x, ch, int(innerDims.x),\n int(innerDims.y)), innerDims);\n }\n }\n }\n }\n `; this.userCode = `\n void main() {\n ivec3 rc = getOutputCoords();\n\n vec4 result = vec4(0);\n\n int blockIndex, pos, offsetY, d0, offsetX, d1, ch;\n vec2 innerDims;\n\n ${u}\n\n ${r.output} = result;\n }\n ` } }
/**
* @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 AA(e, t) { const n = e.length; return n >= 3 ? t ? [...e.slice(0, -3), e[n - 3] * e[n - 2], e[n - 1]] : [...e.slice(0, -3), e[n - 3], e[n - 2] * e[n - 1]] : !t && 1 === n && e[0] > 1 ? [e[0], 1] : null } function TA({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const u = e.shape, l = r.texData.get(e.dataId), c = n.inChannels, h = u[0] * u[1] * u[2], d = n.outChannels, f = "channelsLast" === n.dataFormat, p = !1; let m; const g = []; if (null != a) { const e = AA(a.shape, f); null != e && (a = U_({ inputs: { x: a }, backend: r, attrs: { shape: e } }), g.push(a)) } if (null != i) { const e = AA(i.shape, f); null != e && (i = U_({ inputs: { x: i }, backend: r, attrs: { shape: e } }), g.push(i)) } if (!((1 === h || 1 === d) && c > 1e3) && l.isPacked && f && null != l.texture && u[2] % 2 != 0 && P.util.arraysEqual(l.shape.slice(-3), u.slice(-3))) { const c = u[0] * u[1] * (u[2] + 1), h = { dataId: e.dataId, shape: [1, c, n.inChannels], dtype: e.dtype }, d = l.shape; l.shape = l.shape.slice(), l.shape[l.shape.length - 2]++, P.util.assert(zw(l.shape, h.shape), (() => `packed reshape ${l.shape} to ${h.shape} isn't free`)); const f = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, n.inChannels, n.outChannels] } }); g.push(f); const y = eC({ a: h, b: f, backend: r, transposeA: false, transposeB: p, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }), b = r.texData.get(y.dataId); P.util.assert(b.isPacked, (() => "batchMatMul result is expected to be packed")), l.shape = d, b.shape = n.outShape, m = w_({ inputs: { x: y }, backend: r }), m.shape = n.outShape, g.push(y) } else { const u = n.outHeight * n.outWidth, l = U_({ inputs: { x: e }, backend: r, attrs: { shape: f ? [n.batchSize, u, n.inChannels] : [n.batchSize, n.inChannels, u] } }), c = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, n.inChannels, n.outChannels] } }), h = eC({ a: f ? l : c, b: f ? c : l, transposeA: !f, transposeB: p, backend: r, bias: i, activation: s, preluActivationWeights: a, leakyreluAlpha: o }); m = U_({ inputs: { x: h }, backend: r, attrs: { shape: n.outShape } }), g.push(l), g.push(c), g.push(h) } for (const e of g) r.disposeIntermediateTensorInfo(e); return m } function EA({ x: e, filter: t, convInfo: n, backend: r, bias: i = null, preluActivationWeights: a = null, leakyreluAlpha: o = 0, activation: s = null }) { const { filterWidth: u, filterHeight: l, inChannels: c, outWidth: h, outHeight: d, dataFormat: f } = n, p = "channelsLast" === f, m = u * l * c, g = d * h, y = [n.batchSize, m, g], b = []; if (null != a) { const e = AA(a.shape, p); null != e && (a = U_({ inputs: { x: a }, backend: r, attrs: { shape: e } }), b.push(a)) } if (null != i) { const e = AA(i.shape, p); null != e && (i = U_({ inputs: { x: i }, backend: r, attrs: { shape: e } }), b.push(i)) } const v = U_({ inputs: { x: t }, backend: r, attrs: { shape: [1, m, P.util.sizeFromShape(t.shape) / m] } }); b.push(v); const x = new CA(y, n), w = [e.shape, [n.padInfo.top, n.padInfo.left], [n.strideHeight, n.strideWidth], [n.dilationHeight, n.dilationWidth], [n.inChannels], [n.filterWidth * n.inChannels], [n.outWidth]], k = r.runWebGLProgram(x, [e], "float32", w), S = U_({ inputs: { x: k }, backend: r, attrs: { shape: y } }); b.push(k), b.push(S); const _ = null != i, C = null != a, A = "leakyrelu" === s, T = s ? $_(s, !0) : null, E = new R_(p ? S.shape : v.shape, p ? v.shape : S.shape, p ? [n.batchSize, g, n.outChannels] : [n.batchSize, n.outChannels, g], !0, !1, _, T, C, A), N = p ? [S, v] : [v, S]; if (i && N.push(i), C && N.push(a), A) { const e = r.makeTensorInfo([], "float32", P.util.createScalarValue(o, "float32")); N.push(e), b.push(e) } const I = r.runWebGLProgram(E, N, "float32"), M = U_({ inputs: { x: I }, backend: r, attrs: { shape: n.outShape } }); b.push(I); for (const e of b) r.disposeIntermediateTensorInfo(e); return M } const NA = {
kernelName: P.Conv2D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dataFormat: u, dilations: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, l, s, c, !1, h); let f; if (1 !== d.filterHeight || 1 !== d.filterWidth || 1 !== d.dilationHeight || 1 !== d.dilationWidth || 1 !== d.strideHeight || 1 !== d.strideWidth || "SAME" !== d.padInfo.type && "VALID" !== d.padInfo.type) if (d.strideWidth <= 2 && "channelsLast" === h && (0, P.env)().getBool("WEBGL_EXP_CONV")) { const e = new _A(d), t = [[d.padInfo.top, d.padInfo.left], [d.strideHeight, d.strideWidth], [d.dilationHeight, d.dilationWidth], [d.inHeight, d.inWidth]]; f = n.runWebGLProgram(e, [i, a], "float32", t) } else if ((0, P.env)().getBool("WEBGL_CONV_IM2COL")) f = EA({ x: i, filter: a, convInfo: d, backend: n }); else { const e = new kA(d); f = n.runWebGLProgram(e, [i, a], "float32") } else f = TA({ x: i, filter: a, convInfo: d, backend: n }); const p = U_({ inputs: { x: f }, backend: n, attrs: { shape: d.outShape } }); return n.disposeIntermediateTensorInfo(f), p }
};
/**
* @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.
* =============================================================================
*/
class IA { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideHeight, n = e.strideWidth, r = e.padInfo.top, i = e.padInfo.left, a = "channelsLast" === e.dataFormat; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int d2 = coords.w;\n\n // Convolve x(?, ?, d1) with dy(:, :, d2) to get dw(wR, wC, d1, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${i};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n ${a ? "float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);" : "float dyValue = getDy(b, d2, yR, yC);\n float xValue = getX(b, d1, xR, xC);\n dotProd += (xValue * dyValue);"}\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class MA { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = "channelsLast" === e.dataFormat, o = t - 1 - e.padInfo.top, s = n - 1 - e.padInfo.left, u = a ? 1 : 2, l = a ? 2 : 3, c = a ? 3 : 1; this.userCode = `\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[${c}];\n\n ivec2 dyCorner = ivec2(coords[${u}], coords[${l}]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n // Convolve dy(?, ?, d2) with w(:, :, d1, d2) to compute dx(xR, xC, d1).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n\n if (${a}) {\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n } else {\n float xValue = getDy(batch, d2, idyR, idyC);\n float wValue = getW(wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class FA { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideDepth, n = e.strideHeight, r = e.strideWidth, i = e.padInfo.front, a = e.padInfo.top, o = e.padInfo.left; this.userCode = `\n void main() {\n ivec5 coords = getOutputCoords();\n int wF = coords.x;\n int wR = coords.y;\n int wC = coords.z;\n int d1 = coords.w;\n int d2 = coords.u;\n\n float dotProd = 0.0;\n\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yF = 0; yF < ${e.outDepth}; yF++) {\n int xF = wF + yF * ${t} - ${i};\n\n if (xF < 0 || xF >= ${e.inDepth}) {\n continue;\n }\n\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${n} - ${a};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${r} - ${o};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yF, yR, yC, d2);\n float xValue = getX(b, xF, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class DA { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterDepth, n = e.filterHeight, r = e.filterWidth, i = e.strideDepth, a = e.strideHeight, o = e.strideWidth, s = t - 1 - e.padInfo.front, u = n - 1 - e.padInfo.top, l = r - 1 - e.padInfo.left; this.userCode = `\n const ivec3 pads = ivec3(${s}, ${u}, ${l});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.u;\n\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyFCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n float dotProd = 0.0;\n for (int wF = 0; wF < ${t}; wF++) {\n float dyF = float(dyFCorner + wF) / ${i}.0;\n\n if (dyF < 0.0 || dyF >= ${e.outDepth}.0 || fract(dyF) > 0.0) {\n continue;\n }\n int idyF = int(dyF);\n\n int wFPerm = ${t} - 1 - wF;\n\n for (int wR = 0; wR < ${n}; wR++) {\n float dyR = float(dyRCorner + wR) / ${a}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${n} - 1 - wR;\n\n for (int wC = 0; wC < ${r}; wC++) {\n float dyC = float(dyCCorner + wC) / ${o}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${r} - 1 - wC;\n\n for (int d2 = 0; d2 < ${e.outChannels}; d2++) {\n float xValue = getDy(batch, idyF, idyR, idyC, d2);\n float wValue = getW(wFPerm, wRPerm, wCPerm, d1, d2);\n dotProd += xValue * wValue;\n }\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const $A = {
kernelName: P.Conv2DBackpropFilter, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, dataFormat: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.convertConv2DDataFormat(u), d = P.backend_util.computeConv2DInfo(i.shape, c, o, 1, s, l, !1, h), f = new IA(d); return n.runWebGLProgram(f, [i, a], "float32") }
};
/**
* @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.
* =============================================================================
*/
class RA { constructor(e) { this.variableNames = ["dy", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "strides", type: "vec2" }], this.outputShape = e.inShape, this.enableShapeUniforms = kk(this.outputShape.length); const t = e.filterHeight, n = e.filterWidth, r = t - 1 - e.padInfo.top, i = n - 1 - e.padInfo.left; this.userCode = `\n const ivec2 pads = ivec2(${r}, ${i});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n\n ivec2 dyCorner = ivec2(coords[1], coords[2]) - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n vec4 result = vec4(0.);\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / strides[0];\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n int wCPerm = ${n} - 1 - wC;\n\n float dyC = float(dyCCorner + wC) / strides[1];\n bool idyCVal = (dyC >= 0.0) && (dyC < ${e.outWidth}.0)\n && (fract(dyC) == 0.0);\n int idyC = int(dyC);\n\n float dyC2 = float(dyCCorner + wC + 1) / strides[1];\n bool idyCVal2 = (dyC2 >= 0.0) && (dyC2 < ${e.outWidth}.0)\n && (fract(dyC2) == 0.0);\n int idyC2 = int(dyC2);\n\n if (idyCVal && idyCVal2) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec4 dySample2 = (idyC / 2 == idyC2 / 2) ?\n dySample : getDy(batch, idyR, idyC2, d2);\n\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n\n dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample2.xy : dySample2.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC, d2);\n vec2 dyValue = mod(float(idyC), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.xy += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n } else if (idyCVal2) {\n for (int d2 = 0; d2 < ${e.outChannels}; d2 += 2) {\n vec4 wValue = getW(wRPerm, wCPerm, d1, d2);\n vec4 dySample = getDy(batch, idyR, idyC2, d2);\n vec2 dyValue = mod(float(idyC2), 2.) == 0. ?\n dySample.xy : dySample.zw;\n result.zw += vec2(dot(dyValue, wValue.xy),\n dot(dyValue, wValue.zw));\n }\n }\n }\n }\n setOutput(result);\n }\n ` } } const OA = {
kernelName: P.Conv2DBackpropInput, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { inputShape: o, strides: s, pad: u, dataFormat: l, dimRoundingMode: c } = r, h = P.backend_util.convertConv2DDataFormat(l), d = P.backend_util.computeConv2DInfo(o, a.shape, s, 1, u, c, !1, h); if ((0, P.env)().getBool("WEBGL_PACK_CONV2DTRANSPOSE") && "channelsLast" === h) { const e = [[d.strideHeight, d.strideWidth]], t = new RA(d); return n.runWebGLProgram(t, [i, a], "float32", e) } { const e = new MA(d); return n.runWebGLProgram(e, [i, a], "float32") } }
}; const zA = {
kernelName: P.Conv3D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, a.shape, o, u, s), c = new SA(l); return n.runWebGLProgram(c, [i, a], "float32") }
}; const PA = {
kernelName: P.Conv3DBackpropFilterV2, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, pad: s, filterShape: u } = r, l = P.backend_util.computeConv3DInfo(i.shape, u, o, 1, s), c = new FA(l); return n.runWebGLProgram(c, [i, a], "float32") }
}; const BA = {
kernelName: P.Conv3DBackpropInputV2, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { pad: o, strides: s, inputShape: u } = r, l = P.backend_util.computeConv3DInfo(u, a.shape, s, 1, o), c = new DA(l); return n.runWebGLProgram(c, [i, a], "float32") }
}, LA = F_({ opSnippet: M_ + "\n return cos(x);\n", packedOpSnippet: `\n vec4 result = cos(x);\n bvec4 isNaN = isnan(x);\n ${v_}\n return result;\n` }), jA = { kernelName: P.Cos, backendName: "webgl", kernelFunc: LA }, UA = F_({ opSnippet: "\n float e2x = exp(-x);\n return (e2x + 1.0 / e2x) / 2.0;\n" }), WA = { kernelName: P.Cosh, backendName: "webgl", kernelFunc: UA };
/**
* @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.
* =============================================================================
*/
class VA { constructor(e, t, n, r, i) { this.variableNames = ["Image", "Boxes", "BoxInd"], this.outputShape = []; const [a, o, s, u] = e, [l] = t, [c, h] = n; this.outputShape = [l, c, h, u]; const d = "bilinear" === r ? 1 : 0, [f, p] = [o - 1 + ".0", s - 1 + ".0"], [m, g, y] = c > 1 ? ["" + (o - 1) / (c - 1), "(y2-y1) * height_ratio", `y1*${f} + float(y)*(height_scale)`] : ["0.0", "0.0", `0.5 * (y1+y2) * ${f}`], [b, v, x] = h > 1 ? ["" + (s - 1) / (h - 1), "(x2-x1) * width_ratio", `x1*${p} + float(x)*(width_scale)`] : ["0.0", "0.0", `0.5 * (x1+x2) * ${p}`]; this.userCode = `\n const float height_ratio = float(${m});\n const float width_ratio = float(${b});\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int y = coords[1];\n int x = coords[2];\n int d = coords[3];\n\n // get box vals\n float y1 = getBoxes(b,0);\n float x1 = getBoxes(b,1);\n float y2 = getBoxes(b,2);\n float x2 = getBoxes(b,3);\n\n // get image in batch index\n int bInd = round(getBoxInd(b));\n if(bInd < 0 || bInd >= ${a}) {\n return;\n }\n\n float height_scale = ${g};\n float width_scale = ${v};\n\n float in_y = ${y};\n if( in_y < 0.0 || in_y > ${f} ) {\n setOutput(float(${i}));\n return;\n }\n float in_x = ${x};\n if( in_x < 0.0 || in_x > ${p} ) {\n setOutput(float(${i}));\n return;\n }\n\n vec2 sourceFracIndexCR = vec2(in_x,in_y);\n if(${d} == 1) {\n // Compute the four integer indices.\n ivec2 sourceFloorCR = ivec2(sourceFracIndexCR);\n ivec2 sourceCeilCR = ivec2(ceil(sourceFracIndexCR));\n\n float topLeft = getImage(b, sourceFloorCR.y, sourceFloorCR.x, d);\n float bottomLeft = getImage(b, sourceCeilCR.y, sourceFloorCR.x, d);\n float topRight = getImage(b, sourceFloorCR.y, sourceCeilCR.x, d);\n float bottomRight = getImage(b, sourceCeilCR.y, sourceCeilCR.x, d);\n\n vec2 fracCR = sourceFracIndexCR - vec2(sourceFloorCR);\n\n float top = topLeft + (topRight - topLeft) * fracCR.x;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracCR.x;\n float newValue = top + (bottom - top) * fracCR.y;\n setOutput(newValue);\n } else {\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestCR = ivec2(floor(\n sourceFracIndexCR + vec2(0.5,0.5)));\n float newValue = getImage(b, sourceNearestCR.y, sourceNearestCR.x, d);\n setOutput(newValue);\n }\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const GA = { kernelName: P.CropAndResize, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { image: i, boxes: a, boxInd: o } = t, { cropSize: s, method: u, extrapolationValue: l } = r, c = new VA(i.shape, a.shape, s, u, l); return n.runWebGLProgram(c, [i, a, o], "float32") } }; var HA, qA; (qA = HA || (HA = {})).Prod = "*", qA.Sum = "+"; class YA { constructor(e, t, n, r) { this.op = e, this.outputShape = t, this.variableNames = ["x"], this.customUniforms = [{ name: "index", type: "float" }]; const i = this.outputShape.length, a = this.op === HA.Prod ? "1.0" : "0.0", o = n ? a : `getX(${XA(i, "coords", this.op)})`, s = this.outputShape[this.outputShape.length - 1]; let u = "", l = ""; n ? (u = r ? "end != " + (s - 1) : "end != 0", l = r ? "end + 1" : "end - 1") : (u = r ? `end + pow2 < ${s}` : "end >= pow2", l = r ? "end + pow2" : "end - pow2"), this.userCode = `\n void main() {\n ${gk(i)} coords = getOutputCoords();\n int end = ${KA(i, "coords", this.op)};\n float val = ${o};\n int pow2 = int(pow(2.0, index));\n if (${u}) {\n int idx = ${l};\n ${KA(i, "coords", this.op)} = idx;\n val ${this.op}= getX(${XA(i, "coords", this.op)});\n }\n setOutput(val);\n }\n ` } } function XA(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.x, ${t}.y`; if (3 === e) return `${t}.x, ${t}.y, ${t}.z`; if (4 === e) return `${t}.x, ${t}.y, ${t}.z, ${t}.w`; throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`) } function KA(e, t, n) { if (1 === e) return `${t}`; if (2 === e) return `${t}.y`; if (3 === e) return `${t}.z`; if (4 === e) return `${t}.w`; throw new Error(`Cumulative ${n} for rank ${e} is not yet supported`) }
/**
* @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 ZA(e, t, n, r, i, a) { const o = t.shape.length, s = P.backend_util.getAxesPermutation([r], o); let u = t; null != s && (u = J_({ inputs: { x: t }, backend: n, attrs: { perm: s } })); const l = P.backend_util.getInnerMostAxes(1, o)[0]; if (l !== o - 1) throw new Error(`WebGL cumprod shader expects an inner-most axis=${t.shape.length - 1} but got axis=${r}`); const c = u.shape[l]; let h = w_({ inputs: { x: u }, backend: n }); for (let t = 0; t <= Math.ceil(Math.log2(c)) - 1; t++) { const r = new YA(e, u.shape, !1, a), i = [[t]], o = h; h = n.runWebGLProgram(r, [h], h.dtype, i), n.disposeIntermediateTensorInfo(o) } if (i) { const t = new YA(e, u.shape, i, a), r = h; h = n.runWebGLProgram(t, [h], h.dtype), n.disposeIntermediateTensorInfo(r) } if (null != s) { const e = J_({ inputs: { x: h }, backend: n, attrs: { perm: P.backend_util.getUndoAxesPermutation(s) } }); return n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(u), e } return h } const JA = {
kernelName: P.Cumprod, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return ZA(HA.Prod, i, n, a, o, s) }
}; const QA = {
kernelName: P.Cumsum, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, exclusive: o, reverse: s } = r; return ZA(HA.Sum, i, n, a, o, s) }
}; const eT = {
kernelName: P.DenseBincount, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, weights: a } = t, { size: o, binaryOutput: s } = r; if (1 === i.shape.length) { const e = n.readSync(i.dataId), t = n.readSync(a.dataId), r = eS(e, t, a.dtype, a.shape, o); return n.makeTensorInfo([o], a.dtype, r) } if (2 === i.shape.length) { const e = n.bufferSync(i), t = n.bufferSync(a), r = tS(e, t, o, s); return n.makeTensorInfo(r.shape, a.dtype, r.values) } throw new Error(`Error in denseBincount: input must be at most rank 2, but got rank${i.shape.length}.`) }
};
/**
* @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 tT { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = [], this.outputShape = e, this.blockSize = t, this.dataFormat = n, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int h = ${this.getHeightCoordString()};\n int w = ${this.getWidthCoordString()};\n int d = ${this.getDepthCoordString()};\n\n int in_h = h / ${t};\n int offset_h = imod(h, ${t});\n int in_w = w / ${t};\n int offset_w = imod(w, ${t});\n int offset_d = (offset_h * ${t} + offset_w) *\n ${this.getOutputDepthSize()};\n int in_d = d + offset_d;\n\n float result = ${this.getInputSamplingString()};\n setOutput(result);\n }\n ` } getHeightCoordString() { return "NHWC" === this.dataFormat ? "coords[1]" : "coords[2]" } getWidthCoordString() { return "NHWC" === this.dataFormat ? "coords[2]" : "coords[3]" } getDepthCoordString() { return "NHWC" === this.dataFormat ? "coords[3]" : "coords[1]" } getOutputDepthSize() { return "NHWC" === this.dataFormat ? this.outputShape[3] : this.outputShape[1] } getInputSamplingString() { return "NHWC" === this.dataFormat ? "getX(b, in_h, in_w, in_d)" : "getX(b, in_d, in_h, in_w)" } } const nT = {
kernelName: P.DepthToSpace, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockSize: a, dataFormat: o } = r, s = i.shape[0], u = ("NHWC" === o ? i.shape[1] : i.shape[2]) * a, l = ("NHWC" === o ? i.shape[2] : i.shape[3]) * a, c = ("NHWC" === o ? i.shape[3] : i.shape[1]) / (a * a), h = new tT("NHWC" === o ? [s, u, l, c] : [s, c, u, l], a, o); return n.runWebGLProgram(h, [i], i.dtype) }
};
/**
* @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.
* =============================================================================
*/
class rT { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.filterHeight, o = e.filterWidth, s = e.outChannels / e.inChannels; let u = "", l = ""; n && (u = r ? `float activation(float a) {\n float b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `float activation(float a) {\n float b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `\n float activation(float x) {\n ${n}\n }\n `, l = "result = activation(result);"); const c = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${u}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${s};\n int q = d2 - d1 * ${s};\n\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n // Convolve x(?, ?, d1) with w(:, :, d1, q) to get y(yR, yC, d2).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n // TO DO(dsmilkov): Flatten the two for loops and vec4 the operations.\n for (int wR = 0; wR < ${a}; wR++) {\n int xR = xRCorner + wR * dilations[0];\n\n if (xR < 0 || xR >= inDims[0]) {\n continue;\n }\n\n for (int wC = 0; wC < ${o}; wC++) {\n int xC = xCCorner + wC * dilations[1];\n\n if (xC < 0 || xC >= inDims[1]) {\n continue;\n }\n\n float xVal = getX(batch, xR, xC, d1);\n float wVal = getW(wR, wC, d1, q);\n dotProd += xVal * wVal;\n }\n }\n\n float result = dotProd;\n ${c}\n ${l}\n setOutput(result);\n }\n ` } }
/**
* @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 iT { constructor(e, t = !1, n = null, r = !1, i = !1) { this.variableNames = ["x", "W"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "pads", type: "ivec2" }, { name: "strides", type: "ivec2" }, { name: "dilations", type: "ivec2" }, { name: "inDims", type: "ivec2" }], this.outputShape = e.outShape, this.enableShapeUniforms = kk(this.outputShape.length); const a = e.outChannels / e.inChannels, o = e.padInfo.left, s = e.strideWidth, u = e.dilationWidth, l = e.filterHeight, c = e.filterWidth, h = c; let d = "\n int xR; int xC; int xCOffset;\n vec4 wTexel; vec4 previous; vec4 final;"; for (let e = 0; e < c; e++)d += `\n vec4 xTexelC${2 * e};\n int xTexelC${2 * e}Ready;\n vec4 xTexelC${2 * e + 1};\n int xTexelC${2 * e + 1}Ready;\n vec4 xC${e};`; d += `\n for (int r = 0; r < ${l}; r++) {\n `; for (let e = 0; e < c; e++)d += `\n xTexelC${2 * e} = vec4(0.0);\n xTexelC${2 * e}Ready = 0;\n xTexelC${2 * e + 1} = vec4(0.0);\n xTexelC${2 * e + 1}Ready = 0;\n xC${e} = vec4(0.0);`; d += "\n xR = xRCorner + r * dilations[0];\n if (xR >=0 && xR < inDims[0]) {\n "; for (let e = 0; e < (h + 1) / 2; e++) { const t = 2 * e; if (d += `\n xC = xCCorner + ${t * u};\n `, 1 === s) { if (t < c && (o % 2 == 1 ? (d += `\n xCOffset = xC + 1;\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n `, d += 1 === u && t > 0 ? `\n xC${t} = vec4(xTexelC${t - 2}.zw, xTexelC${t}.xy);\n ` : `\n xCOffset = xC + 1 - 2;\n\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n previous.zw = vec2(0.0);\n }\n\n xC${t} = vec4(previous.zw, xTexelC${t}.xy);\n } else {\n xC${t} = vec4(0.0, 0.0, xTexelC${t}.xy);\n }\n `) : d += `\n if (xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xC${t} = xTexelC${t};\n `, t + 1 < c)) { const e = o % 2 == 0 ? P.util.nearestLargerEven(u) : u; u % 2 == 0 && o % 2 == 1 || u % 2 != 0 && o % 2 != 1 ? (d += `\n xCOffset = xC + imod(pads[1], 2) + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n `, d += u > 1 ? `\n xCOffset -= 2;\n if (xCOffset >= 0 && xCOffset < inDims[1]) {\n previous = getX(batch, xR, xCOffset, d1);\n xC${t + 1} = vec4(previous.zw, xTexelC${t + 1}.xy);\n } else {\n xC${t + 1} = vec4(0.0, 0.0, xTexelC${t + 1}.xy);\n }\n ` : `\n xC${t + 1} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.xy);\n `) : d += 1 === e ? `\n xC${t + 1} = xTexelC${t};\n ` : `\n xCOffset = xC + ${e};\n\n if (xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t + 1} = xTexelC${t + 1};\n ` } } else t < c && (o % 2 == 1 ? (d += `\n xCOffset = xC + 1 - strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xCOffset, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n if(xC + 1 >= 0 && xC + 1 < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xC + 1, d1);\n // Need to manually clear unused channels in case\n // we're reading from recycled texture.\n if (xC + 2 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.0);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.zw);\n `, t + 1 < c && (d += `\n final = vec4(0.0);\n xCOffset = xC + 1 + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1]) {\n final = getX(batch, xR, xCOffset, d1);\n }\n xC${t + 1} = vec4(xTexelC${t + 1}.xy, final.xy);\n `)) : (d += `\n if(xC >= 0 && xC < inDims[1] && xTexelC${t}Ready == 0) {\n xTexelC${t} = getX(batch, xR, xC, d1);\n if (xC + 1 >= inDims[1]) {\n xTexelC${t}.zw = vec2(0.0);\n }\n xTexelC${t}Ready = 1;\n }\n\n xCOffset = xC + strides[1];\n if(xCOffset >= 0 && xCOffset < inDims[1] && xTexelC${t + 1}Ready == 0) {\n xTexelC${t + 1} = getX(batch, xR, xCOffset, d1);\n if (xCOffset + 1 >= inDims[1]) {\n xTexelC${t + 1}.zw = vec2(0.);\n }\n xTexelC${t + 1}Ready = 1;\n }\n\n xC${t} = vec4(\n xTexelC${t}.xy, xTexelC${t + 1}.xy);\n `, t + 1 < c && (d += `\n xC${t + 1} = vec4(xTexelC${t}.zw, xTexelC${t + 1}.zw);\n `))); t < c && (d += `\n wTexel = getW(r, ${t}, d1, q);\n dotProd += xC${t} * vec4(wTexel.xz, wTexel.xz);\n `, t + 1 < c && (d += `\n wTexel = getW(r, ${t + 1}, d1, q);\n dotProd += xC${t + 1} * vec4(wTexel.xz, wTexel.xz);\n `)) } d += "\n }\n ", d += "\n }\n "; let f = "", p = ""; n && (f = r ? `vec4 activation(vec4 a) {\n vec4 b = getPreluActivationWeightsAtOutCoords();\n ${n}\n }` : i ? `vec4 activation(vec4 a) {\n vec4 b = getLeakyreluAlphaAtOutCoords();\n ${n}\n }` : `vec4 activation(vec4 x) {\n ${n}\n }`, p = "result = activation(result);"); const m = t ? "result += getBiasAtOutCoords();" : ""; t && this.variableNames.push("bias"), r && this.variableNames.push("preluActivationWeights"), i && this.variableNames.push("leakyreluAlpha"), this.userCode = `\n ${f}\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n ivec2 xRCCorner = coords.yz * strides - pads;\n int d2 = coords.w;\n int d1 = d2 / ${a};\n int q = d2 - d1 * ${a};\n int xRCorner = xRCCorner.x;\n int xCCorner = xRCCorner.y;\n\n //intialize dotProd with a small epsilon seems to reduce GPU accuracy loss.\n vec4 dotProd = vec4(0.000000000000001);\n\n ${d}\n\n vec4 result = dotProd - vec4(0.000000000000001);\n ${m}\n ${p}\n setOutput(result);\n }\n ` } } const aT = {
kernelName: P.DepthwiseConv2dNative, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u, dimRoundingMode: l } = r; let c = u; null == c && (c = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, c), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${o} and dilations '${c}'`)); const h = P.backend_util.computeConv2DInfo(i.shape, a.shape, o, c, s, l, !0); let d; d = (0, P.env)().getBool("WEBGL_PACK_DEPTHWISECONV") && h.strideWidth <= 2 && h.outChannels / h.inChannels == 1 ? new iT(h) : new rT(h); const f = [[h.padInfo.top, h.padInfo.left], [h.strideHeight, h.strideWidth], [h.dilationHeight, h.dilationWidth], [h.inHeight, h.inWidth]]; return n.runWebGLProgram(d, [i, a], "float32", f) }
};
/**
* @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 oT { constructor(e) { this.variableNames = ["x", "dy"], this.outputShape = e.filterShape; const t = e.strideHeight, n = e.strideWidth, r = e.padInfo.top, i = e.padInfo.left, a = e.outChannels / e.inChannels; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int wR = coords.x;\n int wC = coords.y;\n int d1 = coords.z;\n int dm = coords.w;\n int d2 = d1 * ${a} + dm;\n\n float dotProd = 0.0;\n\n // TO DO: Vec4 over the batch size\n for (int b = 0; b < ${e.batchSize}; b++) {\n for (int yR = 0; yR < ${e.outHeight}; yR++) {\n int xR = wR + yR * ${t} - ${r};\n\n if (xR < 0 || xR >= ${e.inHeight}) {\n continue;\n }\n\n for (int yC = 0; yC < ${e.outWidth}; yC++) {\n int xC = wC + yC * ${n} - ${i};\n\n if (xC < 0 || xC >= ${e.inWidth}) {\n continue;\n }\n\n float dyValue = getDy(b, yR, yC, d2);\n float xValue = getX(b, xR, xC, d1);\n dotProd += (xValue * dyValue);\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } class sT { constructor(e) { this.variableNames = ["dy", "W"], this.outputShape = e.inShape; const t = e.filterHeight, n = e.filterWidth, r = e.strideHeight, i = e.strideWidth, a = t - 1 - e.padInfo.top, o = n - 1 - e.padInfo.left, s = e.outChannels / e.inChannels; this.userCode = `\n const ivec2 pads = ivec2(${a}, ${o});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords[0];\n int d1 = coords[3];\n ivec2 dyCorner = coords.yz - pads;\n int dyRCorner = dyCorner.x;\n int dyCCorner = dyCorner.y;\n\n float dotProd = 0.0;\n\n for (int wR = 0; wR < ${t}; wR++) {\n float dyR = float(dyRCorner + wR) / ${r}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n int wRPerm = ${t} - 1 - wR;\n\n for (int wC = 0; wC < ${n}; wC++) {\n float dyC = float(dyCCorner + wC) / ${i}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n int wCPerm = ${n} - 1 - wC;\n\n // TO DO: Vec4 over the channelMul\n for (int dm = 0; dm < ${s}; dm++) {\n int d2 = d1 * ${s} + dm;\n float xValue = getDy(batch, idyR, idyC, d2);\n float wValue = getW(wRPerm, wCPerm, d1, dm);\n dotProd += xValue * wValue;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const uT = {
kernelName: P.DepthwiseConv2dNativeBackpropFilter, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, dy: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, filterShape: c } = r, h = P.backend_util.computeConv2DInfo(i.shape, c, o, s, u, l, !0), d = new oT(h); return n.runWebGLProgram(d, [i, a], "float32") }
}; const lT = {
kernelName: P.DepthwiseConv2dNativeBackpropInput, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, filter: a } = t, { strides: o, dilations: s, pad: u, dimRoundingMode: l, inputShape: c } = r, h = P.backend_util.computeConv2DInfo(c, a.shape, o, s, u, l, !0), d = new sT(h); return n.runWebGLProgram(d, [i, a], "float32") }
};
/**
* @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.
* =============================================================================
*/
class cT { constructor(e) { this.variableNames = ["X"], this.outputShape = [e, e], this.userCode = "\n void main() {\n ivec2 coords = getOutputCoords();\n float val = coords[0] == coords[1] ? getX(coords[0]) : 0.0;\n setOutput(val);\n }\n " } } const hT = {
kernelName: P.Diag, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { x: r } = t, i = [...r.shape, ...r.shape], a = P.util.sizeFromShape(r.shape), o = U_({ inputs: { x: r }, backend: n, attrs: { shape: [a] } }), s = new cT(a), u = n.runWebGLProgram(s, [o], o.dtype), l = U_({ inputs: { x: u }, backend: n, attrs: { shape: i } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(u), l }
};
/**
* @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.
* =============================================================================
*/
class dT { constructor(e) { this.variableNames = ["x", "W"], this.outputShape = e.outShape; const { inHeight: t, inWidth: n, padInfo: r, strideHeight: i, strideWidth: a, filterHeight: o, filterWidth: s, dilationHeight: u, dilationWidth: l } = e, { top: c, left: h } = r; this.userCode = `\n const ivec2 strides = ivec2(${i}, ${a});\n const ivec2 pads = ivec2(${c}, ${h});\n const float neg_infinity = -3.4e38;\n\n void main() {\n ivec4 coords = getOutputCoords();\n int batch = coords.x;\n int d1 = coords.w;\n ivec2 outTopLeftCorner =\n coords.yz * strides - pads;\n int hBeg = outTopLeftCorner.x;\n int wBeg = outTopLeftCorner.y;\n\n float curVal = neg_infinity;\n for (int h = 0; h < ${o}; h++) {\n int hIn = hBeg + h * ${u};\n\n if (hIn >= 0 && hIn < ${t}) {\n for (int w = 0; w < ${s}; w++) {\n int wIn = wBeg + w * ${l};\n\n if (wIn >= 0 && wIn < ${n}) {\n float xVal = getX(batch, hIn, wIn, d1);\n float wVal = getW(h, w, d1);\n\n float val = xVal + wVal;\n if (val > curVal) {\n curVal = val;\n }\n }\n }\n }\n }\n\n float result = curVal;\n setOutput(result);\n }\n ` } } const fT = {
kernelName: P.Dilation2D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a } = t, { strides: o, pad: s, dilations: u } = r, l = P.backend_util.computeDilation2DInfo(i.shape, a.shape, o, s, "NHWC", u); let c; const h = new dT(l); c = n.runWebGLProgram(h, [i, a], "float32"); const d = U_({ inputs: { x: c }, backend: n, attrs: { shape: l.outShape } }); return n.disposeIntermediateTensorInfo(c), d }
}; const pT = {
kernelName: P.Einsum, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { equation: i } = r, a = t, { allDims: o, summedDims: s, idDims: u } = P.backend_util.decodeEinsumEquation(i, a.length); P.backend_util.checkEinsumDimSizes(o.length, u, a); const { path: l, steps: c } = P.backend_util.getEinsumComputePath(s, u), h = c.length; let d = null, f = o.length; const p = []; for (let e = 0; e < h; ++e) { for (const t of c[e]) { const { permutationIndices: e, expandDims: r } = P.backend_util.getEinsumPermutation(f, u[t]); let i; P.backend_util.isIdentityPermutation(e) ? i = a[t] : (i = J_({ inputs: { x: a[t] }, backend: n, attrs: { perm: e } }), p.push(i)); const o = i.shape.slice(); for (let e = 0; e < r.length; ++e)o.splice(r[e], 0, 1); P.util.arraysEqual(i.shape, o) || (i = U_({ inputs: { x: i }, backend: n, attrs: { shape: o } }), p.push(i)), null === d ? d = i : (d = L_({ inputs: { a: i, b: d }, backend: n }), p.push(d)) } e < h - 1 && (l[e] >= 0 && (d = K_({ inputs: { x: d }, backend: n, attrs: { axis: l[e] - (o.length - f), keepDims: !1 } }), p.push(d)), f--) } for (const e of p) e !== d && n.disposeIntermediateTensorInfo(e); return d }
}, mT = F_({ opSnippet: "return (x >= 0.0) ? x : (exp(x) - 1.0);", packedOpSnippet: "\n vec4 result;\n\n result.r = (x.r >= 0.0) ? x.r : (exp(x.r) - 1.0);\n result.g = (x.g >= 0.0) ? x.g : (exp(x.g) - 1.0);\n result.b = (x.b >= 0.0) ? x.b : (exp(x.b) - 1.0);\n result.a = (x.a >= 0.0) ? x.a : (exp(x.a) - 1.0);\n\n return result;\n" }), gT = { kernelName: P.Elu, backendName: "webgl", kernelFunc: mT }, yT = { kernelName: P.EluGrad, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n } = e, { dy: r, y: i } = t, a = (0, P.env)().getBool("WEBGL_PACK_BINARY_OPERATIONS") ? new x_("\n vec4 bGTEZero = vec4(greaterThanEqual(b, vec4(0.)));\n return (bGTEZero * a) + ((vec4(1.0) - bGTEZero) * (a * (b + vec4(1.0))));\n", r.shape, i.shape) : new b_("return (b >= 0.0) ? a : a * (b + 1.0);", r.shape, i.shape); return n.runWebGLProgram(a, [r, i], r.dtype) } }, bT = D_({ opSnippet: "return float(a == b);", packedOpSnippet: "\n return vec4(equal(a, b));\n", dtype: "bool", cpuKernelImpl: oS }), vT = { kernelName: P.Equal, backendName: "webgl", kernelFunc: bT }, xT = F_({ opSnippet: `\n // Error function is calculated approximately with elementary function.\n // See "Handbook of Mathematical Functions with Formulas,\n // Graphs, and Mathematical Tables", Abramowitz and Stegun.\n float p = ${P.backend_util.ERF_P};\n float a1 = ${P.backend_util.ERF_A1};\n float a2 = ${P.backend_util.ERF_A2};\n float a3 = ${P.backend_util.ERF_A3};\n float a4 = ${P.backend_util.ERF_A4};\n float a5 = ${P.backend_util.ERF_A5};\n\n float sign = sign(x);\n x = abs(x);\n float t = 1.0 / (1.0 + p * x);\n return sign * (1.0 - (((((a5*t + a4)*t) + a3)*t + a2)*t + a1)*t*exp(-x*x));\n` }), wT = { kernelName: P.Erf, backendName: "webgl", kernelFunc: xT }, kT = F_({ opSnippet: M_ + "\n return exp(x);\n", packedOpSnippet: "\n vec4 result = exp(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n", cpuKernelImpl: sS, dtype: "float32" }), ST = { kernelName: P.Exp, backendName: "webgl", kernelFunc: kT };
/**
* @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 _T(e) { const { inputs: t, attrs: n, backend: r } = e, { dim: i } = n, { input: a } = t, o = a.shape.length, s = a.shape.slice(); let u = i; return i < 0 && (P.util.assert(-(o + 1) <= i, (() => `Axis must be in the interval [${-(o + 1)}, ${o}]`)), u = o + i + 1), s.splice(u, 0, 1), U_({ inputs: { x: a }, backend: r, attrs: { shape: s } }) } const CT = { kernelName: P.ExpandDims, backendName: "webgl", kernelFunc: _T }, AT = "return exp(x) - 1.0;", TT = F_({ opSnippet: AT, packedOpSnippet: AT, cpuKernelImpl: uS }), ET = { kernelName: P.Expm1, backendName: "webgl", kernelFunc: TT };
/**
* @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 NT { constructor(e, t, n) { this.variableNames = ["real", "imag"]; const r = t[1]; this.outputShape = t; const i = n ? `2.0 * ${Math.PI}` : `-2.0 * ${Math.PI}`, a = n ? `${r}.0` : "1.0"; let o; if ("real" === e) o = "return real * expR - imag * expI;"; else { if ("imag" !== e) throw new Error(`FFT component must be either "real" or "imag", got ${e}.`); o = "return real * expI + imag * expR;" } this.userCode = `\n const float exponentMultiplier = ${i};\n\n float unaryOpComplex(float real, float expR, float imag, float expI) {\n ${o}\n }\n\n float mulMatDFT(int batch, int index) {\n float indexRatio = float(index) / float(${r});\n float exponentMultiplierTimesIndexRatio =\n exponentMultiplier * indexRatio;\n\n float result = 0.0;\n\n for (int i = 0; i < ${r}; i++) {\n // x = (-2|2 * PI / N) * index * i;\n float x = exponentMultiplierTimesIndexRatio * float(i);\n float expR = cos(x);\n float expI = sin(x);\n float real = getReal(batch, i);\n float imag = getImag(batch, i);\n\n result +=\n unaryOpComplex(real, expR, imag, expI) / ${a};\n }\n\n return result;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n setOutput(mulMatDFT(coords[0], coords[1]));\n }\n ` } }
/**
* @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 IT(e, t, n) { const r = n.texData.get(e.dataId), i = P.util.sizeFromShape(e.shape), a = e.shape[e.shape.length - 1], o = U_({ inputs: { x: e }, backend: n, attrs: { shape: [i / a, a] } }), s = o.shape, u = new NT("real", s, t), l = new NT("imag", s, t), c = [{ dataId: r.complexTensorInfos.real.dataId, dtype: r.complexTensorInfos.real.dtype, shape: s }, { dataId: r.complexTensorInfos.imag.dataId, dtype: r.complexTensorInfos.imag.dtype, shape: s }], h = n.runWebGLProgram(u, c, "float32"), d = n.runWebGLProgram(l, c, "float32"), f = S_({ inputs: { real: h, imag: d }, backend: n }); n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d); const p = U_({ inputs: { x: f }, backend: n, attrs: { shape: e.shape } }); return n.disposeIntermediateTensorInfo(o), n.disposeIntermediateTensorInfo(f), p } const MT = {
kernelName: P.FFT, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { input: r } = t; return IT(r, !1, 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.
* =============================================================================
*/
class FT { constructor(e, t) { this.outputShape = [], this.customUniforms = [{ name: "value", type: "float" }], this.variableNames = ["x"], this.outputShape = e, this.userCode = "\n void main() {\n // Input can be obtained from uniform value.\n setOutput(value);\n }\n " } }
/**
* @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 DT(e) { const { backend: t, attrs: n } = e, { shape: r, value: i } = n; let { dtype: a } = n; if (a = a || P.util.inferDtype(i), "string" === a) { const e = P.util.getArrayFromDType(a, P.util.sizeFromShape(r)); return e.fill(i), t.makeTensorInfo(r, a, e) } { const e = new FT(r, i), n = [[i]]; return t.runWebGLProgram(e, [], a, n) } } const $T = { kernelName: P.Fill, backendName: "webgl", kernelFunc: DT };
/**
* @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.
* =============================================================================
*/
class RT { constructor(e) { this.variableNames = ["Image"], this.outputShape = []; const t = e[2]; this.outputShape = e, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n\n int coordX = ${t} - x - 1;\n float outputValue;\n if(coordX >= 0 && coordX < ${t}) {\n outputValue = getImage(coords[0], coords[1], coordX, coords[3]);\n } else {\n outputValue = getImage(coords[0], coords[1], coords[2], coords[3]);\n }\n setOutput(outputValue);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const OT = { kernelName: P.FlipLeftRight, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t }) => { const { image: n } = e, r = t, i = new RT(n.shape); return r.runWebGLProgram(i, [n], n.dtype) } }, zT = "return floor(x);", PT = F_({ opSnippet: zT, packedOpSnippet: zT, cpuKernelImpl: lS }), BT = { kernelName: P.Floor, backendName: "webgl", kernelFunc: PT }, LT = D_({ opSnippet: "\n float s = sign(a) * sign(b);\n int ia = round(a);\n int ib = round(b);\n if (ib != 0) {\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n return float(idiv(ia, ib, s));\n } else {\n return NAN;\n }\n", packedOpSnippet: "\n ivec4 ia = round(a);\n ivec4 ib = round(b);\n bvec4 cond = notEqual(ib, ivec4(0));\n ivec4 result = ivec4(0);\n vec4 s = sign(a) * sign(b);\n\n // Windows (D3D) wants guaranteed non-zero int division at compile-time.\n if (cond[0]) {\n result[0] = idiv(ia[0], ib[0], s[0]);\n }\n if (cond[1]) {\n result[1] = idiv(ia[1], ib[1], s[1]);\n }\n if (cond[2]) {\n result[2] = idiv(ia[2], ib[2], s[2]);\n }\n if (cond[3]) {\n result[3] = idiv(ia[3], ib[3], s[3]);\n }\n return vec4(result);\n", dtype: "int32" }), jT = { kernelName: P.FloorDiv, backendName: "webgl", kernelFunc: LT };
/**
* @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 UT { constructor(e) { this.variableNames = ["A"]; const t = Qw(), [n, r] = e; this.outputShape = e, this.userCode = `\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n vec2 uv = (vec2(texC, texR) + halfCR) / vec2(${r}.0, ${n}.0);\n\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n setOutput(floor(value * 255.0 + 0.5));\n }\n ` } }
/**
* @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 WT { constructor(e) { this.variableNames = ["A"], this.packedInputs = !1, this.packedOutput = !0; const t = Qw(), [n, r] = e; this.outputShape = e, this.userCode = `\n void main() {\n ivec3 coords = getOutputCoords();\n int texR = coords[0];\n int texC = coords[1];\n int depth = coords[2];\n\n vec4 result = vec4(0.);\n\n for(int row=0; row<=1; row++) {\n for(int col=0; col<=1; col++) {\n texC = coords[1] + row;\n depth = coords[2] + col;\n\n vec2 uv = (vec2(texC, texR) + halfCR) /\n vec2(${r}.0, ${n}.0);\n vec4 values = ${t.texture2D}(A, uv);\n float value;\n if (depth == 0) {\n value = values.r;\n } else if (depth == 1) {\n value = values.g;\n } else if (depth == 2) {\n value = values.b;\n } else if (depth == 3) {\n value = values.a;\n }\n\n result[row * 2 + col] = floor(value * 255.0 + 0.5);\n }\n }\n\n ${t.output} = result;\n }\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 VT = { kernelName: P.FromPixels, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e; let { pixels: i } = t; const { numChannels: a } = r, o = "undefined" != typeof HTMLVideoElement && i instanceof HTMLVideoElement, s = "undefined" != typeof HTMLImageElement && i instanceof HTMLImageElement, [u, l] = o ? [i.videoWidth, i.videoHeight] : [i.width, i.height], c = [l, u], h = [l, u, a]; if (s || o) { const e = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); null != GT && e === HT || (HT = e, GT = document.createElement("canvas").getContext("2d", { willReadFrequently: HT })), GT.canvas.width = u, GT.canvas.height = l, GT.drawImage(i, 0, 0, u, l), i = GT.canvas } const d = n.makeTensorInfo(c, "int32"); n.texData.get(d.dataId).usage = Hx.PIXELS, n.gpgpu.uploadPixelDataToTexture(n.getTexture(d.dataId), i); const f = (0, P.env)().getBool("WEBGL_PACK") ? new WT(h) : new UT(h), p = n.runWebGLProgram(f, [d], "int32"); return n.disposeData(d.dataId), p } }; let GT, HT = (0, P.env)().getBool("CANVAS2D_WILL_READ_FREQUENTLY_FOR_GPU"); const qT = {
kernelName: P.FusedConv2D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dataFormat: c, dilations: h, dimRoundingMode: d, activation: f, leakyreluAlpha: p } = r, m = P.backend_util.convertConv2DDataFormat(c), g = P.backend_util.computeConv2DInfo(i.shape, a.shape, u, h, l, d, !1, m); let y; const b = [], v = null != o, x = null != s, w = "leakyrelu" === f, k = () => { const e = [i, a], t = (e, t) => { if ("NCHW" === t && 1 === e.shape.length && 1 !== e.shape[0]) { const t = U_({ inputs: { x: e }, backend: n, attrs: { shape: [e.shape[0], 1, 1] } }); return b.push(t), t } return e }; if (v && e.push(t(o, c)), x && e.push(t(s, c)), w) { const t = n.makeTensorInfo([], "float32", P.util.createScalarValue(p, "float32")); e.push(t), b.push(t) } return e }; if (1 !== g.filterHeight || 1 !== g.filterWidth || 1 !== g.dilationHeight || 1 !== g.dilationWidth || 1 !== g.strideHeight || 1 !== g.strideWidth || "SAME" !== g.padInfo.type && "VALID" !== g.padInfo.type) if (g.strideWidth <= 2 && "channelsLast" === m && (0, P.env)().getBool("WEBGL_EXP_CONV")) { const e = f ? $_(f, !0) : null, t = new _A(g, v, e, x, w), r = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], i = k(); y = n.runWebGLProgram(t, i, "float32", r) } else if ((0, P.env)().getBool("WEBGL_CONV_IM2COL")) y = EA({ x: i, filter: a, convInfo: g, backend: n, bias: o, activation: f, preluActivationWeights: s, leakyreluAlpha: p }); else { const e = f ? $_(f, !1) : null, t = new kA(g, v, e, x, w), r = k(); y = n.runWebGLProgram(t, r, "float32") } else y = TA({ x: i, filter: a, convInfo: g, backend: n, bias: o, activation: f, preluActivationWeights: s, leakyreluAlpha: p }); const S = U_({ inputs: { x: y }, backend: n, attrs: { shape: g.outShape } }); return b.push(y), b.forEach((e => n.disposeIntermediateTensorInfo(e))), S }
}; const YT = {
kernelName: P.FusedDepthwiseConv2D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, filter: a, bias: o, preluActivationWeights: s } = t, { strides: u, pad: l, dilations: c, dimRoundingMode: h, activation: d, leakyreluAlpha: f } = r, p = []; let m = c; null == m && (m = [1, 1]), P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(u, m), (() => `Error in depthwiseConv2d: Either strides or dilations must be 1. Got strides ${u} and dilations '${m}'`)); const g = P.backend_util.computeConv2DInfo(i.shape, a.shape, u, m, l, h, !0), y = (0, P.env)().getBool("WEBGL_PACK_DEPTHWISECONV") && g.strideWidth <= 2 && g.outChannels / g.inChannels == 1, b = d ? $_(d, y) : null, v = [i, a], x = null != o, w = null != s, k = "leakyrelu" === d; if (x && v.push(o), w && v.push(s), k) { const e = n.makeTensorInfo([], "float32", P.util.createScalarValue(f, "float32")); v.push(e), p.push(e) } let S; S = y ? new iT(g, x, b, w, k) : new rT(g, x, b, w, k); const _ = [[g.padInfo.top, g.padInfo.left], [g.strideHeight, g.strideWidth], [g.dilationHeight, g.dilationWidth], [g.inHeight, g.inWidth]], C = n.runWebGLProgram(S, v, "float32", _); return p.forEach((e => n.disposeIntermediateTensorInfo(e))), C }
}; class XT { constructor(e, t, n, r) { this.sliceDim = e, this.strides = t, this.paramsShape = r, this.variableNames = ["x", "indices"], this.outputShape = n; const i = gk(n.length); let a = "\n int index;"; for (let e = 0; e < this.sliceDim; e++)a += `\n index = round(getIndices(coords[0], ${e}));\n out_of_bounds = out_of_bounds || index < 0;\n out_of_bounds = out_of_bounds || index >= ${this.paramsShape[e]};\n flattenIndex += index * ${this.strides[e]};`; this.userCode = `\n void main() {\n ${i} coords = getOutputCoords();\n int flattenIndex = 0;\n bool out_of_bounds = false;\n\n ${a}\n\n setOutput(out_of_bounds ? 0.0 : getX(flattenIndex, coords[1]));\n }\n ` } } const KT = {
kernelName: P.GatherNd, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { params: r, indices: i } = t, a = i.shape, o = a[a.length - 1], s = P.util.sizeFromShape(r.shape), [u, l, c, h] = P.backend_util.prepareAndValidate(r, i), d = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l, o] } }), f = U_({ inputs: { x: r }, backend: n, attrs: { shape: [P.util.sizeFromShape(r.shape) / c, c] } }); if (n.shouldExecuteOnCPU([r, i]) || "string" === r.dtype) { const e = n.readSync(i.dataId), t = n.bufferSync(r), a = cS(e, t, r.dtype, l, o, c, h, r.shape, s); return n.makeTensorInfo(u, r.dtype, a.values) } const p = new XT(o, h, [l, c], r.shape), m = n.runWebGLProgram(p, [f, d], f.dtype), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: u } }); return n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(m), g }
};
/**
* @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.
* =============================================================================
*/
class ZT { constructor(e, t) { this.variableNames = ["A", "indices"], this.outputShape = t, this.rank = t.length; const n = gk(this.rank), r = function (e) { const t = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], n = []; for (let r = 0; r < e.length; r++)2 === r ? n.push("index") : n.push(`${t[r]}`); return n.join() }(e); this.userCode = `\n void main() {\n ${n} resRC = getOutputCoords();\n int index = int(getIndices(resRC.x, resRC.z));\n float inBounds = (index >= 0) && (index < ${e[2]}) ? 1.0 : 0.0;\n setOutput(inBounds * getA(${r}));\n }\n ` } }
/**
* @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 JT(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, indices: a } = t, { axis: o, batchDims: s } = r, u = P.util.parseAxisParam(o, i.shape)[0]; if ((0, P.env)().get("DEBUG")) { const e = n.readSync(a.dataId), t = i.shape[u]; for (let n = 0; n < e.length; ++n) { const r = e[n]; P.util.assert(r <= t - 1 && r >= 0, (() => `GatherV2: the index value ${r} is not in [0, ${t - 1}]`)) } } const l = P.backend_util.segment_util.collectGatherOpShapeInfo(i, a, u, s), c = P.util.sizeFromShape(a.shape), h = [], d = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l.batchSize, l.outerSize, l.dimSize, l.sliceSize] } }), f = U_({ inputs: { x: a }, backend: n, attrs: { shape: [l.batchSize, c / l.batchSize] } }); h.push(d), h.push(f); const p = [l.batchSize, l.outerSize, c / l.batchSize, l.sliceSize]; if (n.shouldExecuteOnCPU([i, a]) || "string" === i.dtype) { const e = n.bufferSync(f), t = n.bufferSync(d), r = hS(t, e, p); return h.forEach((e => n.disposeIntermediateTensorInfo(e))), n.makeTensorInfo(l.outputShape, r.dtype, r.values) } const m = new ZT(d.shape, p), g = n.runWebGLProgram(m, [d, f], d.dtype); h.push(g); const y = U_({ inputs: { x: g }, backend: n, attrs: { shape: l.outputShape } }); return h.forEach((e => n.disposeIntermediateTensorInfo(e))), y } const QT = { kernelName: P.GatherV2, backendName: "webgl", kernelFunc: JT }, eE = D_({ opSnippet: "return float(a > b);", packedOpSnippet: "\n return vec4(greaterThan(a, b));\n", cpuKernelImpl: dS, dtype: "bool" }), tE = { kernelName: P.Greater, backendName: "webgl", kernelFunc: eE }, nE = D_({ opSnippet: "return float(a >= b);", packedOpSnippet: "\n return vec4(greaterThanEqual(a, b));\n", dtype: "bool", cpuKernelImpl: fS }), rE = { kernelName: P.GreaterEqual, backendName: "webgl", kernelFunc: nE }; const iE = {
kernelName: P.IFFT, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { input: r } = t; return IT(r, !0, n) }
}, aE = F_({ opSnippet: "return float(!isnan(x) && !isinf(x));", dtype: "bool" }), oE = { kernelName: P.IsFinite, backendName: "webgl", kernelFunc: aE }, sE = F_({ opSnippet: "return float(isinf(x));", dtype: "bool" }), uE = { kernelName: P.IsInf, backendName: "webgl", kernelFunc: sE }, lE = F_({ opSnippet: "return float(isnan(x));", dtype: "bool" }), cE = { kernelName: P.IsNan, backendName: "webgl", kernelFunc: lE }, hE = D_({ opSnippet: "return float(a < b);", packedOpSnippet: "\n return vec4(lessThan(a, b));\n", cpuKernelImpl: pS, dtype: "bool" }), dE = { kernelName: P.Less, backendName: "webgl", kernelFunc: hE }, fE = D_({ opSnippet: "return float(a <= b);", packedOpSnippet: "\n return vec4(lessThanEqual(a, b));\n", cpuKernelImpl: mS, dtype: "bool" }), pE = { kernelName: P.LessEqual, backendName: "webgl", kernelFunc: fE }; const mE = {
kernelName: P.LinSpace, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { backend: t, attrs: n } = e, { start: r, stop: i, num: a } = n, o = gS(r, i, a); return t.makeTensorInfo([o.length], "float32", o) }
}, gE = F_({ opSnippet: M_ + "\n return x < 0.0 ? 0./0. : log(x);\n", packedOpSnippet: "\n vec4 result = log(x);\n bvec4 isNaN = isnan(x);\n result.r = isNaN.r ? x.r : (x.r < 0.0 ? 0./0. : result.r);\n result.g = isNaN.g ? x.g : (x.g < 0.0 ? 0./0. : result.g);\n result.b = isNaN.b ? x.b : (x.b < 0.0 ? 0./0. : result.b);\n result.a = isNaN.a ? x.a : (x.a < 0.0 ? 0./0. : result.a);\n return result;\n", cpuKernelImpl: yS }), yE = { kernelName: P.Log, backendName: "webgl", kernelFunc: gE }, bE = F_({ opSnippet: M_ + "\n return log(1.0 + x);\n" }), vE = { kernelName: P.Log1p, backendName: "webgl", kernelFunc: bE }, xE = D_({ opSnippet: "return float(a >= 1.0 && b >= 1.0);", packedOpSnippet: "\n return vec4(\n vec4(greaterThanEqual(a, vec4(1.0))) *\n vec4(greaterThanEqual(b, vec4(1.0))));\n", dtype: "bool" }), wE = { kernelName: P.LogicalAnd, backendName: "webgl", kernelFunc: xE }, kE = F_({ opSnippet: "return float(!(x >= 1.0));" }), SE = { kernelName: P.LogicalNot, backendName: "webgl", kernelFunc: kE }, _E = D_({ opSnippet: "return float(a >= 1.0 || b >= 1.0);", packedOpSnippet: "\n return min(\n vec4(greaterThanEqual(a, vec4(1.0))) +\n vec4(greaterThanEqual(b, vec4(1.0))),\n vec4(1.0));\n", dtype: "bool" }), CE = { kernelName: P.LogicalOr, backendName: "webgl", kernelFunc: _E };
/**
* @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.
* =============================================================================
*/
class AE { constructor(e, t, n, r, i) { this.variableNames = ["x"], this.outputShape = []; const a = t, o = e[3] - 1; let s; this.outputShape = e; const u = `float(${n}) + float(${r}) * sum`; s = .5 === i ? `inversesqrt(${u})` : 1 === i ? `1.0/(${u})` : `exp(log(${u}) * float(-${i}));`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n int d = coords[3];\n float x = getX(b, r, c, d);\n float sum = 0.0;\n for (int j = -${a}; j <= ${a}; j++) {\n int idx = d + j;\n if (idx >= 0 && idx <= ${o}) {\n float z = getX(b, r, c, idx);\n sum += z * z;\n }\n }\n float val = x * ${s};\n setOutput(val);\n }\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.
* =============================================================================
*/
class TE { constructor(e, t, n, r, i) { this.variableNames = ["x"], this.outputShape = [], this.packedInputs = !0, this.packedOutput = !0; const a = t, o = e[3] - 1; let s; this.outputShape = e; const u = `float(${n}) + float(${r}) * sum`; s = .5 === i ? `inversesqrt(${u})` : 1 === i ? `1.0/(${u})` : `exp(log(${u}) * float(-${i}));`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords.x;\n int r = coords.y;\n int c = coords.z;\n int d = coords.w;\n\n bool hasNextCol = d < ${this.outputShape[3]};\n bool hasNextRow = c < ${this.outputShape[2]};\n\n vec4 sum = vec4(0.);\n vec4 xFragAtOutputCoords = getX(b, r, c, d);\n\n vec4 xAtOutputCoords = vec4(\n getChannel(xFragAtOutputCoords, vec2(c, d)),\n hasNextCol ?\n getChannel(xFragAtOutputCoords, vec2(c, d + 1)) : 0.0,\n hasNextRow ?\n getChannel(xFragAtOutputCoords , vec2(c + 1, d)) : 0.0,\n (hasNextRow && hasNextCol) ?\n getChannel(xFragAtOutputCoords, vec2(c + 1, d + 1)) : 0.0\n );\n\n int firstChannel = d - ${a};\n vec2 cache = vec2(0.);\n if(firstChannel >= 0){\n vec4 firstChannelFrag = getX(b, r, c, firstChannel);\n cache.x = getChannel(firstChannelFrag, vec2(c, firstChannel));\n if(hasNextRow){\n cache.y = getChannel(firstChannelFrag, vec2(c + 1, firstChannel));\n }\n }\n\n ivec2 depth = ivec2(d, d + 1);\n for (int j = - ${a}; j <= ${a}; j++) {\n ivec2 idx = depth + j;\n bvec2 aboveLowerBound = greaterThanEqual(idx, ivec2(0));\n bvec2 belowUpperBound = lessThanEqual(idx, ivec2(${o}));\n\n bool depthInRange = aboveLowerBound.x && belowUpperBound.x;\n bool depthPlusOneInRange = aboveLowerBound.y && belowUpperBound.y;\n\n if(depthInRange || depthPlusOneInRange){\n vec4 z = vec4(0.);\n vec4 xFragAtCurrentDepth;\n z.xz = cache.xy;\n if(depthPlusOneInRange && hasNextCol){\n xFragAtCurrentDepth = idx.y != d ?\n getX(b, r, c, idx.y) : xFragAtOutputCoords;\n z.y = getChannel(xFragAtCurrentDepth, vec2(c, idx.y));\n if(hasNextRow){\n z.w = getChannel(xFragAtCurrentDepth, vec2(c + 1, idx.y));\n }\n }\n cache.xy = z.yw;\n sum += z * z;\n }\n }\n vec4 result = xAtOutputCoords * ${s};\n setOutput(result);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const EE = { kernelName: P.LRN, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { depthRadius: a, bias: o, alpha: s, beta: u } = r, l = (0, P.env)().getBool("WEBGL_PACK_NORMALIZATION") ? new TE(i.shape, a, o, s, u) : new AE(i.shape, a, o, s, u); return n.runWebGLProgram(l, [i], i.dtype) } };
/**
* @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 NE { constructor(e, t, n, r, i) { this.variableNames = ["inputImage", "outputImage", "dy"], this.outputShape = [], this.outputShape = e, this.depth = e[3], this.depthRadius = t, this.bias = n, this.alpha = r, this.beta = i, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int r = coords[1];\n int c = coords[2];\n\n float result = 0.0;\n for (int d = 0; d < ${this.depth}; ++d) {\n int depthBegin = int(max(0.0, float(d - ${t})));\n int depthEnd = int(min(float(${this.depth}),\n float(d + ${t} + 1)));\n\n const int MIN_DEPTH_BEGIN = 0;\n const int MAX_DEPTH_END = ${this.depth};\n\n float norm = 0.0;\n for (int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k) {\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd) {\n norm += getInputImage(b, r, c, k) * getInputImage(b, r, c, k);\n }\n else {\n break;\n }\n }\n\n norm = float(${r}) * norm + float(${n});\n\n for(int k = MIN_DEPTH_BEGIN; k < MAX_DEPTH_END; ++k){\n if (k < depthBegin){\n continue;\n }\n else if (k >= depthBegin && k < depthEnd){\n float dyi = -2.0 * float(${r})\n * float(${i})\n * getInputImage(b, r, c, k) * getOutputImage(b, r, c, d)\n / norm;\n if (k == d) {\n dyi += pow(norm, -1.0 * ${i});\n }\n if (k == coords[3]) {\n dyi *= getDy(b, r, c, d);\n result += dyi;\n }\n }\n else {\n break;\n }\n }\n }\n setOutput(result);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const IE = { kernelName: P.LRNGrad, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i, y: a, dy: o } = t, { depthRadius: s, bias: u, alpha: l, beta: c } = r, h = new NE(i.shape, s, u, l, c); return n.runWebGLProgram(h, [i, a, o], i.dtype) } };
/**
* @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 ME(e) {
const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reductionIndices: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s), h = null != c, d = n.shouldExecuteOnCPU([i]); let f = i; if (h) { if (d) { const e = n.texData.get(f.dataId).values, t = new Array(s); for (let e = 0; e < t.length; e++)t[e] = i.shape[c[e]]; const r = HS(e, i.shape, i.dtype, c, t); f = n.makeTensorInfo(t, i.dtype); n.texData.get(f.dataId).values = r } else f = X_(i, c, n); l = P.backend_util.getInnerMostAxes(l.length, s) } P.backend_util.assertAxesAreInnerMostDims("max", l, s); const [p, m] = P.backend_util.computeOutAndReduceShapes(f.shape, l); let g, y = p; if (o && (y = P.backend_util.expandShapeToKeepDim(p, u)), d) { const e = n.texData.get(f.dataId).values, t = bS(e, P.util.sizeFromShape(m), y, i.dtype); g = n.makeTensorInfo(y, i.dtype); n.texData.get(g.dataId).values = t } else g =
/**
* @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 (e, t, n, r) { const i = P.util.sizeFromShape(t), a = U_({ inputs: { x: e }, attrs: { shape: [P.util.sizeFromShape(e.shape) / i, i] }, backend: r }), o = H_(a, e.dtype, "max", r), s = U_({ inputs: { x: o }, attrs: { shape: n }, backend: r }); return r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s }(f, m, y, n); return h && n.disposeIntermediateTensorInfo(f), g
} const FE = { kernelName: P.Max, backendName: "webgl", kernelFunc: ME }, DE = D_({ opSnippet: y_ + "\n return max(a, b);\n", packedOpSnippet: "\n vec4 result = vec4(max(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n", cpuKernelImpl: vS }), $E = { kernelName: P.Maximum, backendName: "webgl", kernelFunc: DE }; const RE = {
kernelName: P.MaxPool, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; Zw(i, "maxPool"); const { filterSize: a, strides: o, pad: s, dimRoundingMode: u } = r; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(o, 1), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${o} and dilations '1'`)); const l = P.backend_util.computePool2DInfo(i.shape, a, o, 1, s, u); if (1 === l.filterWidth && 1 === l.filterHeight && P.util.arraysEqual(l.inShape, l.outShape)) return w_({ inputs: { x: i }, backend: n }); const c = new DC(l, "max", !1); return n.runWebGLProgram(c, [i], i.dtype) }
}; const OE = {
kernelName: P.MaxPool3D, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { filterSize: a, strides: o, pad: s, dataFormat: u, dimRoundingMode: l } = r, c = P.backend_util.computePool3DInfo(i.shape, a, o, [1, 1, 1], s, l, u), h = new $C(c, "max", !1); return n.runWebGLProgram(h, [i], i.dtype) }
};
/**
* @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.
* =============================================================================
*/
class zE { constructor(e) { this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape; const t = e.strideHeight, n = e.strideWidth, r = e.dilationHeight, i = e.effectiveFilterHeight, a = e.effectiveFilterWidth, o = i - 1 - e.padInfo.top, s = a - 1 - e.padInfo.left, u = i * a - 1; this.userCode = `\n const ivec2 pads = ivec2(${o}, ${s});\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n\n ivec2 dyRCCorner = coords.yz - pads;\n int dyRCorner = dyRCCorner.x;\n int dyCCorner = dyRCCorner.y;\n\n // Convolve dy(?, ?, d) with pos mask(:, :, d) to get dx(xR, xC, d).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n for (int wR = 0; wR < ${i};\n wR += ${r}) {\n float dyR = float(dyRCorner + wR) / ${t}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 || fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${a}; wC++) {\n float dyC = float(dyCCorner + wC) / ${n}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(b, idyR, idyC, d);\n int maxPosValue = ${u} - int(getMaxPos(b, idyR, idyC, d));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue = wR * ${a} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n setOutput(dotProd);\n }\n ` } } class PE { constructor(e) { this.variableNames = ["dy", "maxPos"], this.outputShape = e.inShape; const t = e.strideDepth, n = e.strideHeight, r = e.strideWidth, i = e.dilationDepth, a = e.dilationHeight, o = e.dilationWidth, s = e.effectiveFilterDepth, u = e.effectiveFilterHeight, l = e.effectiveFilterWidth, c = s - 1 - e.padInfo.front, h = u - 1 - e.padInfo.top, d = l - 1 - e.padInfo.left, f = s * u * l - 1; this.userCode = `\n const ivec3 pads = ivec3(${c}, ${h}, ${d});\n\n void main() {\n ivec5 coords = getOutputCoords();\n int batch = coords.x;\n int ch = coords.u;\n\n ivec3 dyCorner = ivec3(coords.y, coords.z, coords.w) - pads;\n int dyDCorner = dyCorner.x;\n int dyRCorner = dyCorner.y;\n int dyCCorner = dyCorner.z;\n\n // Convolve dy(?, ?, ?, ch) with pos mask(:, :, :, d) to get\n // dx(xD, xR, xC, ch).\n // ? = to be determined. : = across all values in that axis.\n float dotProd = 0.0;\n\n for (int wD = 0; wD < ${s};\n wD += ${i}) {\n float dyD = float(dyDCorner + wD) / ${t}.0;\n\n if (dyD < 0.0 || dyD >= ${e.outDepth}.0 || fract(dyD) > 0.0) {\n continue;\n }\n int idyD = int(dyD);\n\n for (int wR = 0; wR < ${u};\n wR += ${a}) {\n float dyR = float(dyRCorner + wR) / ${n}.0;\n\n if (dyR < 0.0 || dyR >= ${e.outHeight}.0 ||\n fract(dyR) > 0.0) {\n continue;\n }\n int idyR = int(dyR);\n\n for (int wC = 0; wC < ${l};\n wC += ${o}) {\n float dyC = float(dyCCorner + wC) / ${r}.0;\n\n if (dyC < 0.0 || dyC >= ${e.outWidth}.0 ||\n fract(dyC) > 0.0) {\n continue;\n }\n int idyC = int(dyC);\n\n float dyValue = getDy(batch, idyD, idyR, idyC, ch);\n int maxPosValue = ${f} -\n int(getMaxPos(batch, idyD, idyR, idyC, ch));\n\n // Get the current value, check it against the value from the\n // position matrix.\n int curPosValue =\n wD * ${u} * ${l} +\n wR * ${l} + wC;\n float mask = float(maxPosValue == curPosValue ? 1.0 : 0.0);\n\n dotProd += dyValue * mask;\n }\n }\n }\n setOutput(dotProd);\n }\n ` } } const BE = {
kernelName: P.MaxPool3DGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a } = t, o = a, { filterSize: s, strides: u, pad: l, dimRoundingMode: c } = r, h = P.backend_util.computePool3DInfo(o.shape, s, u, [1, 1, 1], l, c), d = new $C(h, "max", !0), f = n.runWebGLProgram(d, [o], o.dtype), p = new PE(h), m = n.runWebGLProgram(p, [i, f], o.dtype); return n.disposeIntermediateTensorInfo(f), m }
}; const LE = {
kernelName: P.MaxPoolGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { dy: i, input: a, output: o } = t, s = a; Zw([a, o], "maxPoolGrad"); const { filterSize: u, strides: l, pad: c, dimRoundingMode: h } = r, d = P.backend_util.computePool2DInfo(s.shape, u, l, 1, c, h), f = new DC(d, "max", !0), p = n.runWebGLProgram(f, [s], s.dtype), m = new zE(d), g = n.runWebGLProgram(m, [i, p], s.dtype); return n.disposeIntermediateTensorInfo(p), g }
};
/**
* @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.
* =============================================================================
*/
const jE = {
kernelName: P.MaxPoolWithArgmax, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => {
const { x: r } = e, { filterSize: i, strides: a, pad: o, includeBatchInIndex: s } = t, u = n; P.util.assert(4 === r.shape.length, (() => `Error in maxPool: input must be rank 4 but got rank ${r.shape.length}.`)); const l = [1, 1]; P.util.assert(P.backend_util.eitherStridesOrDilationsAreOne(a, l), (() => `Error in maxPool: Either strides or dilations must be 1. Got strides ${a} and dilations '${l}'`)); const c = P.backend_util.computePool2DInfo(r.shape, i, a, l, o), [h, d] =
/**
* @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 (e, t, n, r) { let i = new DC(n, "max", !1); const a = r.runWebGLProgram(i, [e], "float32"); return i = new DC(n, "max", !0, !0, t), [a, r.runWebGLProgram(i, [e], "float32")] }(r, s, c, u); return [h, d]
}
};
/**
* @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.
* =============================================================================
*/
const UE = {
kernelName: P.Mean, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => {
const { x: r } = e, { keepDims: i, axis: a } = t, o = n, s = r.shape.length, u = P.util.parseAxisParam(a, r.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s), h = null != c, d = o.shouldExecuteOnCPU([r]), f = []; let p = r; if (h) { if (d) { const e = o.texData.get(p.dataId).values, t = new Array(s); for (let e = 0; e < t.length; e++)t[e] = r.shape[c[e]]; const n = HS(e, r.shape, r.dtype, c, t); p = o.makeTensorInfo(t, r.dtype); o.texData.get(p.dataId).values = n } else p = X_(r, c, o); f.push(p), l = P.backend_util.getInnerMostAxes(l.length, s) } P.backend_util.assertAxesAreInnerMostDims("sum", l, s); const [m, g] = P.backend_util.computeOutAndReduceShapes(p.shape, l); let y = m; i && (y = P.backend_util.expandShapeToKeepDim(m, u)); const b =
/**
* @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 (e, t, n, r) { const i = P.util.sizeFromShape(t), a = U_({ inputs: { x: e }, attrs: { shape: [P.util.sizeFromShape(e.shape) / i, i] }, backend: r }), o = H_(a, "float32", "mean", r), s = U_({ inputs: { x: o }, attrs: { shape: n }, backend: r }); return r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s }(p, g, y, o); for (const e of f) o.disposeIntermediateTensorInfo(e); return b
}
}; const WE = {
kernelName: P.Min, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = P.util.parseAxisParam(a, i.shape); let l = u; const c = P.backend_util.getAxesPermutation(l, s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), l = P.backend_util.getInnerMostAxes(l.length, i.shape.length)), P.backend_util.assertAxesAreInnerMostDims("min", l, s); const [d, f] = P.backend_util.computeOutAndReduceShapes(h.shape, l), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, P.util.sizeFromShape(f)] } }), m = H_(p, p.dtype, "min", n); let g; if (o) { g = U_({ inputs: { x: m }, backend: n, attrs: { shape: P.backend_util.expandShapeToKeepDim(d, u) } }) } else g = U_({ inputs: { x: m }, backend: n, attrs: { shape: d } }); return n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), null != c && n.disposeIntermediateTensorInfo(h), g }
}, VE = D_({ opSnippet: y_ + "\n return min(a, b);\n", packedOpSnippet: "\n vec4 result = vec4(min(a, b));\n bvec4 isNaNA = isnan(a);\n bvec4 isNaNB = isnan(b);\n bvec4 isNaN = bvec4(isNaNA.x || isNaNB.x, isNaNA.y || isNaNB.y, isNaNA.z || isNaNB.z, isNaNA.w || isNaNB.w);\n " + v_ + "\n return result;\n", cpuKernelImpl: xS }), GE = { kernelName: P.Minimum, backendName: "webgl", kernelFunc: VE };
/**
* @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.
* =============================================================================
*/
class HE { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, r), u = "reflect" === n ? 0 : 1; this.userCode = 1 !== r ? `\n ${i} start = ${i}(${a});\n ${i} end = ${i}(${o});\n\n void main() {\n ${i} outC = getOutputCoords();\n for (int i = 0; i < ${r}; i++) {\n if (outC[i] < start[i]) {\n outC[i] = start[i] * 2 - outC[i] - ${u};\n } else if(outC[i] >= end[i]) {\n outC[i] = (end[i] - 1) * 2 - outC[i] + ${u};\n }\n }\n ${i} coords = outC - start;\n setOutput(getX(${s}));\n }\n ` : `\n int start = ${a};\n int end = ${o};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start) {\n outC = start * 2 - outC - ${u};\n } else if(outC >= end) {\n outC = (end - 1) * 2 - outC + ${u};\n }\n setOutput(getX(outC - start));\n }\n ` } }
/**
* @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.
* =============================================================================
*/
class qE { constructor(e, t, n) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = XS("rc", r), u = XS("source", r), l = `${s[r - 1]} < ${this.outputShape[r - 1]}`, c = 1 === r ? "source" : `vec2(${u.slice(-2).join()})`, h = "reflect" === n ? 0 : 1; let d = ""; if (1 === r) { const e = `\n ${i} source = rc;\n if (source < start) {\n source = start * 2 - source - ${h};\n } else if (source >= end) {\n source = (end - 1) * 2 - source + ${h};\n }\n source -= start;\n `; d = `\n ${i} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n ` } else { const e = `\n ${i} source = rc;\n ${i} lt = ${i}(lessThan(source, start));\n ${i} gte = ${i}(greaterThanEqual(source, end));\n ${i} orig = 1 - (lt + gte);\n source = orig * source +\n lt * (start * 2 - source - ${h}) +\n gte * ((end - 1) * 2 - source + ${h});\n source -= start;\n `; d = `\n ${i} rc = outputLoc;\n ${e}\n result[0] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[1] = getChannel(getX(${u.join()}), ${c});\n }\n rc = outputLoc;\n ${s[r - 2]} += 1;\n if(${s[r - 2]} < ${this.outputShape[r - 2]}) {\n ${e}\n result[2] = getChannel(getX(${u.join()}), ${c});\n ${s[r - 1]} += 1;\n if(${l}) {\n ${e}\n result[3] = getChannel(getX(${u.join()}), ${c});\n }\n }\n ` } this.userCode = `\n const ${i} start = ${i}(${a});\n const ${i} end = ${i}(${o});\n\n void main() {\n ${i} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${d}\n setOutput(result);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const YE = { kernelName: P.MirrorPad, backendName: "webgl", kernelFunc: ({ inputs: e, backend: t, attrs: n }) => { const { x: r } = e, { paddings: i, mode: a } = n, o = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new qE(r.shape, i, a) : new HE(r.shape, i, a); return t.runWebGLProgram(o, [r], r.dtype) } }, XE = D_({ opSnippet: "if (b == 0.0) return NAN;\n return mod(a, b);", packedOpSnippet: "\n vec4 result = mod(a, b);\n bvec4 isNaN = equal(b, vec4(0.0));\n " + v_ + "\n return result;\n" }), KE = { kernelName: P.Mod, backendName: "webgl", kernelFunc: XE };
/**
* @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.
* =============================================================================
*/
class ZE { constructor(e, t, n) { this.variableNames = ["probs"], this.customUniforms = [{ name: "seed", type: "float" }], this.outputShape = [e, n], this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n\n float r = random(seed);\n float cdf = 0.0;\n\n for (int i = 0; i < ${t - 1}; i++) {\n cdf += getProbs(batch, i);\n\n if (r < cdf) {\n setOutput(float(i));\n return;\n }\n }\n\n // If no other event happened, last event happened.\n setOutput(float(${t - 1}));\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const JE = D_({ opSnippet: "\nif (a == b) {\n return 1.0;\n};\nreturn a / b;", packedOpSnippet: "\n // vec4 one = vec4(equal(a, b));\n // return one + (vec4(1.0) - one) * a / b;\n vec4 result = a / b;\n if(a.x == b.x) {\n result.x = 1.;\n }\n if(a.y == b.y) {\n result.y = 1.;\n }\n if(a.z == b.z) {\n result.z = 1.;\n }\n if(a.w == b.w) {\n result.w = 1.;\n }\n\n return result;\n", checkOutOfBounds: !0 }), QE = { kernelName: P.RealDiv, backendName: "webgl", kernelFunc: JE }, eN = "return a - b;", tN = D_({ opSnippet: eN, packedOpSnippet: eN, supportsComplex: !0, cpuKernelImpl: WS }), nN = { kernelName: P.Sub, backendName: "webgl", kernelFunc: tN };
/**
* @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 rN(e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { dim: a } = r, o = P.util.parseAxisParam([a], i.shape), s = ME({ inputs: { x: i }, backend: n, attrs: { reductionIndices: o, keepDims: !1 } }), u = P.backend_util.expandShapeToKeepDim(s.shape, o), l = U_({ inputs: { x: s }, backend: n, attrs: { shape: u } }), c = tN({ inputs: { a: i, b: l }, backend: n }), h = kT({ inputs: { x: c }, backend: n }), d = K_({ inputs: { x: h }, backend: n, attrs: { axis: o, keepDims: !1 } }), f = U_({ inputs: { x: d }, backend: n, attrs: { shape: u } }), p = JE({ inputs: { a: h, b: f }, backend: n }); return n.disposeIntermediateTensorInfo(s), n.disposeIntermediateTensorInfo(l), n.disposeIntermediateTensorInfo(c), n.disposeIntermediateTensorInfo(h), n.disposeIntermediateTensorInfo(d), n.disposeIntermediateTensorInfo(f), p } const iN = { kernelName: P.Softmax, backendName: "webgl", kernelFunc: rN }; const aN = {
kernelName: P.Multinomial, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { logits: i } = t, { numSamples: a, seed: o, normalized: s } = r, u = s ? i : rN({ inputs: { logits: i }, backend: n, attrs: { dim: i.shape.length - 1 } }), l = u.shape[0], c = u.shape[1], h = new ZE(l, c, a), d = [[o]], f = n.runWebGLProgram(h, [u], "int32", d); return s || n.disposeIntermediateTensorInfo(u), f }
}, oN = r_ + "\n return -x;\n"; const sN = { kernelName: P.Neg, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n } = e, { x: r } = t; if (n.shouldExecuteOnCPU([r])) { const e = n.texData.get(r.dataId), [t, i] = kS(e.values, r.shape, r.dtype); return n.makeTensorInfo(i, r.dtype, t) } let i; return i = (0, P.env)().getBool("WEBGL_PACK_UNARY_OPERATIONS") ? new u_(r.shape, "\n vec4 result = -x;\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n") : new n_(r.shape, oN), n.runWebGLProgram(i, [r], r.dtype) } }, uN = P.kernel_impls.nonMaxSuppressionV3Impl; const lN = { kernelName: P.NonMaxSuppressionV3, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u } = r, l = n.readSync(i.dataId), c = n.readSync(a.dataId), { selectedIndices: h } = uN(l, c, o, s, u); return n.makeTensorInfo([h.length], "int32", new Int32Array(h)) } }, cN = P.kernel_impls.nonMaxSuppressionV4Impl; const hN = { kernelName: P.NonMaxSuppressionV4, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, padToMaxOutputSize: l } = r, c = n.readSync(i.dataId), h = n.readSync(a.dataId), { selectedIndices: d, validOutputs: f } = cN(c, h, o, s, u, l); return [n.makeTensorInfo([d.length], "int32", new Int32Array(d)), n.makeTensorInfo([], "int32", new Int32Array([f]))] } }, dN = P.kernel_impls.nonMaxSuppressionV5Impl; const fN = { kernelName: P.NonMaxSuppressionV5, backendName: "webgl", kernelFunc: function (e) { P.backend_util.warn("tf.nonMaxSuppression() in webgl locks the UI thread. Call tf.nonMaxSuppressionAsync() instead"); const { inputs: t, backend: n, attrs: r } = e, { boxes: i, scores: a } = t, { maxOutputSize: o, iouThreshold: s, scoreThreshold: u, softNmsSigma: l } = r, c = n.readSync(i.dataId), h = n.readSync(a.dataId), d = o, f = s, p = u, m = l, { selectedIndices: g, selectedScores: y } = dN(c, h, d, f, p, m); return [n.makeTensorInfo([g.length], "int32", new Int32Array(g)), n.makeTensorInfo([y.length], "float32", new Float32Array(y))] } };
/**
* @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.
* =============================================================================
*/
class pN { constructor(e, t, n, r) { this.variableNames = ["indices"], this.outputShape = [e, t], this.userCode = `\n void main() {\n ivec2 coords = getOutputCoords();\n int index = round(getIndices(coords.x));\n setOutput(mix(float(${r}), float(${n}),\n float(index == coords.y)));\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const mN = { kernelName: P.OneHot, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { indices: i } = t, { dtype: a, depth: o, onValue: s, offValue: u } = r, l = P.util.sizeFromShape(i.shape), c = new pN(l, o, s, u), h = U_({ inputs: { x: i }, backend: n, attrs: { shape: [l] } }), d = n.runWebGLProgram(c, [h], a); n.disposeIntermediateTensorInfo(h); const f = U_({ inputs: { x: d }, backend: n, attrs: { shape: [...i.shape, o] } }); return n.disposeIntermediateTensorInfo(d), f } };
/**
* @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 gN(e) { const { inputs: t, backend: n } = e, { x: r } = t; if ("complex64" === r.dtype) { const e = nA({ inputs: { input: r }, backend: n }), t = gN({ inputs: { x: e }, backend: n }), i = yA({ inputs: { input: r }, backend: n }), a = gN({ inputs: { x: i }, backend: n }), o = S_({ inputs: { real: t, imag: a }, backend: n }); return n.disposeIntermediateTensorInfo(e), n.disposeIntermediateTensorInfo(t), n.disposeIntermediateTensorInfo(i), n.disposeIntermediateTensorInfo(a), o } return DT({ attrs: { shape: r.shape, dtype: r.dtype, value: "string" === r.dtype ? "" : 0 }, backend: n }) } const yN = { kernelName: P.ZerosLike, backendName: "webgl", kernelFunc: gN }; const bN = {
kernelName: P.OnesLike, backendName: "webgl", kernelFunc:
/**
* @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 e(t) { const { inputs: n, backend: r } = t, { x: i } = n; if ("string" === i.dtype) throw new Error("onesLike is not supported under string dtype"); if ("complex64" === i.dtype) { const t = nA({ inputs: { input: i }, backend: r }), n = e({ inputs: { x: t }, backend: r }), a = yA({ inputs: { input: i }, backend: r }), o = gN({ inputs: { x: a }, backend: r }), s = S_({ inputs: { real: n, imag: o }, backend: r }); return r.disposeIntermediateTensorInfo(t), r.disposeIntermediateTensorInfo(n), r.disposeIntermediateTensorInfo(a), r.disposeIntermediateTensorInfo(o), s } return DT({ attrs: { shape: i.shape, dtype: i.dtype, value: 1 }, backend: r }) }
}; const vN = {
kernelName: P.Pack, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { axis: i } = r; if (1 === t.length) return _T({ inputs: { input: t[0] }, backend: n, attrs: { dim: i } }); const a = t[0].shape, o = t[0].dtype; t.forEach((e => { P.util.assertShapesMatch(a, e.shape, "All tensors passed to stack must have matching shapes"), P.util.assert(o === e.dtype, (() => "All tensors passed to stack must have matching dtypes")) })); const s = [], u = xA({ inputs: t.map((e => { const t = _T({ inputs: { input: e }, backend: n, attrs: { dim: i } }); return s.push(t), t })), backend: n, attrs: { axis: i } }); return s.forEach((e => n.disposeIntermediateTensorInfo(e))), u }
};
/**
* @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.
* =============================================================================
*/
class xN { constructor(e, t, n) { this.variableNames = ["x"], this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = ["coords[0]", "coords[1]", "coords[2]", "coords[3]"].slice(0, r); this.userCode = 1 !== r ? `\n ${i} start = ${i}(${a});\n ${i} end = ${i}(${o});\n\n void main() {\n ${i} outC = getOutputCoords();\n if (any(lessThan(outC, start)) || any(greaterThanEqual(outC, end))) {\n setOutput(value);\n } else {\n ${i} coords = outC - start;\n setOutput(getX(${s}));\n }\n }\n ` : `\n int start = ${a};\n int end = ${o};\n\n void main() {\n int outC = getOutputCoords();\n if (outC < start || outC >= end) {\n setOutput(value);\n } else {\n setOutput(getX(outC - start));\n }\n }\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.
* =============================================================================
*/
class wN { constructor(e, t, n) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0, this.customUniforms = [{ name: "value", type: "float" }], this.outputShape = t.map(((t, n) => t[0] + e[n] + t[1])); const r = e.length, i = gk(r), a = t.map((e => e[0])).join(","), o = t.map(((t, n) => t[0] + e[n])).join(","), s = XS("rc", r), u = XS("source", r), l = `${s[r - 1]} < ${this.outputShape[r - 1]}`, c = 1 === r ? "source" : `vec2(${u.slice(-2).join()})`, h = [`${i} rc = outputLoc;`, `${s[r - 1]} += 1;\n if(${l}) {\n `, 1 === r ? "" : `}\n rc = outputLoc;\n ${s[r - 2]} += 1;\n if(${s[r - 2]} < ${this.outputShape[r - 2]}) {`, 1 === r ? "" : ` ${s[r - 1]} += 1;\n if(${l}) {`], d = 1 === r ? "rc < start || rc >= end" : "any(lessThan(rc, start)) || any(greaterThanEqual(rc, end))"; let f = ""; for (let e = 0, t = 1 === r ? 2 : 4; e < t; e++)f += `\n ${h[e]}\n if (${d}) {\n result[${e}] = float(value);\n } else {\n ${i} source = rc - start;\n result[${e}] = getChannel(getX(${u.join()}), ${c});\n }\n `; f += 1 === r ? "} " : "}}", this.userCode = `\n const ${i} start = ${i}(${a});\n const ${i} end = ${i}(${o});\n\n void main() {\n ${i} outputLoc = getOutputCoords();\n vec4 result = vec4(0.);\n ${f}\n setOutput(result);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const kN = e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { paddings: a, constantValue: o } = r; if (0 === P.util.sizeFromShape(i.shape)) { return DT({ backend: n, attrs: { shape: a.map(((e, t) => e[0] + i.shape[t] + e[1])), value: o, dtype: i.dtype } }) } const s = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new wN(i.shape, a, o) : new xN(i.shape, a, o), u = [[o]]; return n.runWebGLProgram(s, [i], i.dtype, u) }, SN = { kernelName: P.PadV2, backendName: "webgl", kernelFunc: kN }, _N = D_({ opSnippet: "\n if(a < 0.0 && floor(b) < b){\n return NAN;\n }\n if (b == 0.0) {\n return 1.0;\n }\n return (round(mod(b, 2.0)) != 1) ?\n pow(abs(a), b) : sign(a) * pow(abs(a), b);\n", packedOpSnippet: "\n // isModRound1 has 1 for components with round(mod(b, 2.0)) == 1, 0 otherwise.\n vec4 isModRound1 = vec4(equal(round(mod(b, 2.0)), ivec4(1)));\n vec4 multiplier = sign(a) * isModRound1 + (vec4(1.0) - isModRound1);\n vec4 result = multiplier * pow(abs(a), b);\n\n // Ensure that a^0 = 1, including 0^0 = 1 as this correspond to TF and JS\n bvec4 isExpZero = equal(b, vec4(0.0));\n result.r = isExpZero.r ? 1.0 : result.r;\n result.g = isExpZero.g ? 1.0 : result.g;\n result.b = isExpZero.b ? 1.0 : result.b;\n result.a = isExpZero.a ? 1.0 : result.a;\n\n bvec4 isNaN1 = lessThan(a, vec4(0.0));\n bvec4 isNaN2 = lessThan(floor(b), b);\n bvec4 isNaN = bvec4(isNaN1.x && isNaN2.x, isNaN1.y && isNaN2.y, isNaN1.z && isNaN2.z, isNaN1.w && isNaN2.w);\n " + v_ + "\n return result;\n" }), CN = { kernelName: P.Pow, backendName: "webgl", kernelFunc: _N }; const AN = {
kernelName: P.Prod, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { axis: a, keepDims: o } = r, s = i.shape.length, u = [], l = P.util.parseAxisParam(a, i.shape); let c = l; const h = P.backend_util.getAxesPermutation(c, s); let d, f = i; if (null != h && (f = J_({ inputs: { x: i }, backend: n, attrs: { perm: h } }), c = P.backend_util.getInnerMostAxes(c.length, s), u.push(f)), P.backend_util.assertAxesAreInnerMostDims("prod", c, s), n.shouldExecuteOnCPU([f])) { const e = n.texData.get(f.dataId).values, { outVals: t, outShape: r, outDtype: i } = _S(f.shape, f.dtype, e, c); d = n.makeTensorInfo(r, i, t) } else { const [e, t] = P.backend_util.computeOutAndReduceShapes(f.shape, c), r = P.util.sizeFromShape(t), a = U_({ inputs: { x: f }, backend: n, attrs: { shape: [-1, r] } }), o = H_(a, (0, P.sumOutType)(i.dtype), "prod", n); d = U_({ inputs: { x: o }, backend: n, attrs: { shape: e } }), u.push(a), u.push(o) } if (o) { u.push(d); const e = P.backend_util.expandShapeToKeepDim(d.shape, l); d = U_({ inputs: { x: d }, backend: n, attrs: { shape: e } }) } return u.forEach((e => n.disposeIntermediateTensorInfo(e))), d }
}; const TN = {
kernelName: P.RaggedGather, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { paramsNestedSplits: i, paramsDenseValues: a, indices: o } = t, { outputRaggedRank: s } = r, u = i.map((e => n.readSync(e.dataId))), l = i.map((e => e.shape)), c = n.readSync(a.dataId), h = n.readSync(o.dataId), [d, f, p] = CS(u, l, c, a.shape, a.dtype, h, o.shape, s), m = d.map((e => n.makeTensorInfo([e.length], "int32", e))), g = n.makeTensorInfo(p, a.dtype, f); return m.concat([g]) }
}; const EN = {
kernelName: P.RaggedRange, backendName: "webgl", kernelFunc:
/**
* @license
* Copyright 2022 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 (e) { const { inputs: t, backend: n } = e, { starts: r, limits: i, deltas: a } = t, o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = AS(o, r.shape, r.dtype, s, i.shape, u, a.shape); return [n.makeTensorInfo([l.length], "int32", l), n.makeTensorInfo([c.length], r.dtype, c)] }
}; const NN = {
kernelName: P.RaggedTensorToTensor, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { shape: i, values: a, defaultValue: o, rowPartitionTensors: s } = t, { rowPartitionTypes: u } = r, l = n.readSync(i.dataId), c = n.readSync(a.dataId), h = n.readSync(o.dataId), d = s.map((e => n.readSync(e.dataId))), f = s.map((e => e.shape)), [p, m] = TS(l, i.shape, c, a.shape, a.dtype, h, o.shape, d, f, u); return n.makeTensorInfo(p, a.dtype, m) }
}, IN = e => { const { backend: t, attrs: n } = e, { start: r, stop: i, step: a, dtype: o } = n, s = ES(r, i, a, o); return t.makeTensorInfo([s.length], o, s) }, MN = { kernelName: P.Range, backendName: "webgl", kernelFunc: IN }, FN = F_({ opSnippet: "return 1.0 / x;" }), DN = { kernelName: P.Reciprocal, backendName: "webgl", kernelFunc: FN }, $N = F_({ opSnippet: r_ + "\n return (x < 0.0) ? 0.0 : x;\n", packedOpSnippet: "\n vec4 result = x * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" }), RN = { kernelName: P.Relu, backendName: "webgl", kernelFunc: $N }, ON = F_({ opSnippet: r_ + "\n return (x < 0.0) ? 0.0 : min(6.0, x);\n", packedOpSnippet: "\n vec4 result = min(x, vec4(6.)) * vec4(greaterThanEqual(x, vec4(0.0)));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n" }), zN = { kernelName: P.Relu6, backendName: "webgl", kernelFunc: ON };
/**
* @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.
* =============================================================================
*/
class PN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n]; let h; h = i ? "(vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC - vec2(0.5)" : "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0] / c[0]},\n ${l[1] / c[1]});\n const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec2 sourceFloorRC = ivec2(max(sourceFracIndexRC, vec2(0.0)));\n ivec2 sourceCeilRC = ivec2(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n float topLeft = getA(b, sourceFloorRC.x, sourceFloorRC.y, d);\n float bottomLeft = getA(b, sourceCeilRC.x, sourceFloorRC.y, d);\n float topRight = getA(b, sourceFloorRC.x, sourceCeilRC.y, d);\n float bottomRight = getA(b, sourceCeilRC.x, sourceCeilRC.y, d);\n\n vec2 fracRC = sourceFracIndexRC - vec2(sourceFloorRC);\n\n float top = topLeft + (topRight - topLeft) * fracRC.y;\n float bottom = bottomLeft + (bottomRight - bottomLeft) * fracRC.y;\n float newValue = top + (bottom - top) * fracRC.x;\n\n setOutput(newValue);\n }\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.
* =============================================================================
*/
class BN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n]; let h; h = i ? "(vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC - vec3(0.5)" : "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0] / c[0]},\n ${l[1] / c[1]},\n ${l[1] / c[1]});\n const vec3 inputShapeRC = vec3(${o}.0, ${s}.0,\n ${s}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${h};\n\n // Compute the four integer indices.\n ivec3 sourceFloorRC = ivec3(max(sourceFracIndexRC, vec3(0.0)));\n ivec3 sourceCeilRC = ivec3(\n min(inputShapeRC - 1.0, ceil(sourceFracIndexRC)));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u - 1};\n bool hasNextRow = coords.z < ${n - 1};\n\n // In parallel, construct four corners for all four components in\n // packed 2x2 cell.\n vec4 topLeft = vec4(\n getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 bottomLeft = vec4(\n getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceFloorRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceFloorRC.z, d + 1) : 0.0);\n\n vec4 topRight = vec4(\n getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceFloorRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceFloorRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec4 bottomRight = vec4(\n getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d),\n hasNextCol ? getAValue(b, sourceCeilRC.x, sourceCeilRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceCeilRC.x, sourceCeilRC.z, d + 1) : 0.0);\n\n vec3 fracRC = sourceFracIndexRC - vec3(sourceFloorRC);\n\n vec4 top = mix(topLeft, topRight, fracRC.yyzz);\n vec4 bottom = mix(bottomLeft, bottomRight, fracRC.yyzz);\n vec4 newValue = mix(top, bottom, fracRC.x);\n\n setOutput(newValue);\n }\n ` } } const LN = {
kernelName: P.ResizeBilinear, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r, [u, l] = s, c = (0, P.env)().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new BN(i.shape, u, l, a, o) : new PN(i.shape, u, l, a, o); return n.runWebGLProgram(c, [i], "float32") }
};
/**
* @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 jN { constructor(e, t, n) { this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t; const [, r, i] = t, [, a, o] = e, s = [n && a > 1 ? r - 1 : r, n && o > 1 ? i - 1 : i], u = [n && a > 1 ? a - 1 : a, n && o > 1 ? o - 1 : o], l = s[0] / u[0], c = s[1] / u[1], h = 1 / l, d = 1 / c, f = 2 * Math.ceil(h) + 2, p = 2 * Math.ceil(d) + 2; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${h});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${f});\n const int winWidth = int(${p});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(startRLerp - float(winHeight / 2));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(startCLerp - float(winWidth / 2));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${a}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${o}) {\n continue;\n }\n\n float dxR = float(dyR) * heightScale;\n int topDxRIndex = int(floor(dxR));\n int bottomDxRIndex = int(min(ceil(dxR), ${r - 1}.0));\n float dxRLerp = dxR - float(topDxRIndex);\n float inverseDxRLerp = 1.0 - dxRLerp;\n\n float dxC = float(dyC) * widthScale;\n int leftDxCIndex = int(floor(dxC));\n int rightDxCIndex = int(min(ceil(dxC), ${i - 1}.0));\n float dxCLerp = dxC - float(leftDxCIndex);\n float inverseDxCLerp = 1.0 - dxCLerp;\n\n if (r == topDxRIndex && c == leftDxCIndex) {\n // topLeft\n accumulator +=\n getDy(b, dyR, dyC, d) * inverseDxRLerp * inverseDxCLerp;\n }\n\n if (r == topDxRIndex && c == rightDxCIndex) {\n // topRight\n accumulator += getDy(b, dyR, dyC, d) * inverseDxRLerp * dxCLerp;\n }\n\n if (r == bottomDxRIndex && c == leftDxCIndex) {\n // bottomLeft\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * inverseDxCLerp;\n }\n\n if (r == bottomDxRIndex && c == rightDxCIndex) {\n // bottomRight\n accumulator += getDy(b, dyR, dyC, d) * dxRLerp * dxCLerp;\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n ` } } const UN = {
kernelName: P.ResizeBilinearGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, s = new jN(a.shape, i.shape, o); return n.runWebGLProgram(s, [a], a.dtype) }
};
/**
* @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 WN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n], h = r ? "0.5" : "0.0"; let d; d = i ? "max((vec2(yRC) + vec2(0.5)) * effectiveInputOverOutputRatioRC, vec2(0.0))" : "vec2(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec2 effectiveInputOverOutputRatioRC = vec2(\n ${l[0] / c[0]},\n ${l[1] / c[1]});\n const vec2 inputShapeRC = vec2(${o}.0, ${s}.0);\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n ivec2 yRC = coords.yz;\n\n // Fractional source index.\n vec2 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec2 sourceNearestRC = ivec2(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h})));\n float newValue = getA(b, sourceNearestRC.x, sourceNearestRC.y, d);\n\n setOutput(newValue);\n }\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.
* =============================================================================
*/
class VN { constructor(e, t, n, r, i) { this.variableNames = ["A"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = []; const [a, o, s, u] = e; this.outputShape = [a, t, n, u]; const l = [r && t > 1 ? o - 1 : o, r && n > 1 ? s - 1 : s], c = [r && t > 1 ? t - 1 : t, r && n > 1 ? n - 1 : n], h = r ? "0.5" : "0.0"; let d; d = i ? "max((vec3(yRC) + vec3(0.5)) * effectiveInputOverOutputRatioRC, vec3(0.0))" : "vec3(yRC) * effectiveInputOverOutputRatioRC", this.userCode = `\n const vec3 effectiveInputOverOutputRatioRC = vec3(\n ${l[0] / c[0]},\n ${l[1] / c[1]},\n ${l[1] / c[1]});\n const vec3 inputShapeRC = vec3(${o}.0, ${s}.0,\n ${s}.0);\n\n float getAValue(int b, int r, int c, int d) {\n return getChannel(getA(b, r, c, d), vec2(c, d));\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n // Calculate values for next column in yRC.z.\n ivec3 yRC = coords.yzz + ivec3(0, 0, 1);\n\n // Fractional source index.\n vec3 sourceFracIndexRC = ${d};\n\n // Compute the coordinators of nearest neighbor point.\n ivec3 sourceNearestRC = ivec3(\n min(inputShapeRC - 1.0, floor(sourceFracIndexRC + ${h})));\n\n // Should we calculate next column and row elements in 2x2 packed cell.\n bool hasNextCol = d < ${u - 1};\n bool hasNextRow = coords.z < ${n - 1};\n\n vec4 newValue = vec4(\n getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d),\n hasNextCol ? getAValue(b, sourceNearestRC.x, sourceNearestRC.y, d + 1)\n : 0.0,\n hasNextRow ? getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d)\n : 0.0,\n (hasNextRow && hasNextCol) ?\n getAValue(b, sourceNearestRC.x, sourceNearestRC.z, d + 1) : 0.0);\n\n setOutput(newValue);\n }\n ` } } const GN = {
kernelName: P.ResizeNearestNeighbor, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i } = t, { alignCorners: a, halfPixelCenters: o, size: s } = r, [u, l] = s, c = (0, P.env)().getBool("WEBGL_PACK_IMAGE_OPERATIONS") ? new VN(i.shape, u, l, a, o) : new WN(i.shape, u, l, a, o); return n.runWebGLProgram(c, [i], i.dtype) }
};
/**
* @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 HN { constructor(e, t, n) { this.variableNames = ["dy"], this.outputShape = [], this.outputShape = t; const [, r, i] = t, [, a, o] = e, s = [n && a > 1 ? r - 1 : r, n && o > 1 ? i - 1 : i], u = [n && a > 1 ? a - 1 : a, n && o > 1 ? o - 1 : o], l = s[0] / u[0], c = s[1] / u[1], h = 1 / l, d = 1 / c, f = 2 * Math.ceil(h) + 2, p = 2 * Math.ceil(d) + 2; this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int b = coords[0];\n int d = coords[3];\n int r = coords[1];\n int c = coords[2];\n\n float accumulator = 0.0;\n\n const float heightScale = float(${l});\n const float widthScale = float(${c});\n\n const float invHeightScale = float(${h});\n const float invWidthScale = float(${d});\n\n const int winHeight = int(${f});\n const int winWidth = int(${p});\n\n // Compute bounds for where in dy we will look\n float startRLerp = floor(float(r) * invHeightScale);\n int startDyR = int(floor(startRLerp - float(winHeight / 2)));\n\n float startCLerp = floor(float(c) * invWidthScale);\n int startDyC = int(floor(startCLerp - float(winWidth / 2)));\n\n // Loop over dy\n for (int dyROffset = 0; dyROffset < winHeight; dyROffset++) {\n int dyR = dyROffset + startDyR;\n\n // Guard against the window exceeding the bounds of dy\n if (dyR < 0 || dyR >= ${a}) {\n continue;\n }\n\n for (int dyCOffset = 0; dyCOffset < winWidth; dyCOffset++) {\n int dyC = dyCOffset + startDyC;\n\n // Guard against the window exceeding the bounds of dy\n if (dyC < 0 || dyC >= ${o}) {\n continue;\n }\n\n float sourceFracRow =\n float(${s[0]}) *\n (float(dyR) / float(${u[0]}));\n\n float sourceFracCol =\n float(${s[1]}) *\n (float(dyC) / float(${u[1]}));\n\n int sourceNearestRow = int(min(\n float(int(${r}) - 1),\n ${n} ? float(round(sourceFracRow)) :\n float(floor(sourceFracRow))));\n\n int sourceNearestCol = int(min(\n float(int(${i}) - 1),\n ${n} ? float(round(sourceFracCol)) :\n float(floor(sourceFracCol))));\n\n if (r == sourceNearestRow && c == sourceNearestCol) {\n accumulator += getDy(b, dyR, dyC, d);\n }\n }\n }\n // End loop over dy\n\n setOutput(accumulator);\n }\n ` } } const qN = {
kernelName: P.ResizeNearestNeighborGrad, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { images: i, dy: a } = t, { alignCorners: o } = r, s = new HN(a.shape, i.shape, o); return n.runWebGLProgram(s, [a], a.dtype) }
};
/**
* @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.
* =============================================================================
*/
class YN { constructor(e, t) { this.variableNames = ["x"]; const n = e.length; if (n > 4) throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`); if (this.outputShape = e, 1 === n) return void (this.userCode = `\n void main() {\n int coord = getOutputCoords();\n setOutput(getX(${e[0]} - coord - 1));\n }\n `); const r = e.map(((n, r) => (n => -1 !== t.indexOf(n) && 1 !== e[n] ? `${e[n]} - coords[${n}] - 1` : `coords[${n}]`)(r))).join(","), i = gk(n); this.userCode = `\n void main() {\n ${i} coords = getOutputCoords();\n setOutput(getX(${r}));\n }\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.
* =============================================================================
*/
class XN { constructor(e, t) { this.variableNames = ["x"], this.packedInputs = !0, this.packedOutput = !0; const n = e.length; if (n > 4) throw new Error(`WebGL backend: Reverse of rank-${n} tensor is not yet supported`); this.outputShape = e; const r = XS("rc", n), i = `${r[n - 1]} + 1 < ${this.outputShape[n - 1]}`, a = `${r[n - 2]} + 1 < ${this.outputShape[n - 2]}`, o = gk(n); function s(n) { const r = e.map(((r, i) => function (n, r) { return -1 !== t.indexOf(n) && 1 !== e[n] ? `${e[n]} - ${r[n]} - 1` : `${r[n]}` }(i, n))); return `getChannel(getX(${r.join(",")}), vec2(${r.slice(-2).join(",")}))` } this.userCode = 1 === n ? `\n void main(){\n int rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = getChannel(getX(${e[0]} - rc - 1),\n ${e[0]} - rc - 1);\n if(${i}){\n result.g = getChannel(getX(${e[0]} - (rc + 1) - 1),\n ${e[0]} - (rc + 1) - 1);\n }\n setOutput(result);\n }\n ` : `\n void main() {\n ${o} rc = getOutputCoords();\n vec4 result = vec4(0.);\n result.r = ${function (e) { return s(e) }(r.slice())};\n if(${i}){\n result.g = ${function (e) { return e[n - 1] = "(" + e[n - 1] + " + 1)", s(e) }(r.slice())};\n }\n if(${a}) {\n result.b = ${function (e) { return e[n - 2] = "(" + e[n - 2] + " + 1)", s(e) }(r.slice())};\n if(${i}) {\n result.a = ${function (e) { return e[n - 1] = "(" + e[n - 1] + " + 1)", e[n - 2] = "(" + e[n - 2] + " + 1)", s(e) }(r.slice())};\n }\n }\n setOutput(result);\n }\n ` } } const KN = {
kernelName: P.Reverse, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { dims: a } = r, o = i.shape.length, s = P.util.parseAxisParam(a, i.shape); if (0 === o) return w_({ inputs: { x: i }, backend: n }); const u = (0, P.env)().getBool("WEBGL_PACK_ARRAY_OPERATIONS") ? new XN(i.shape, s) : new YN(i.shape, s); return n.runWebGLProgram(u, [i], i.dtype) }
};
/**
* @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.
* =============================================================================
*/
class ZN { constructor(e, t) { this.variableNames = ["Image"], this.outputShape = [], this.customUniforms = [{ name: "params", type: "vec4" }]; const n = e[1], r = e[2]; this.outputShape = e; let i = ""; i = "number" == typeof t ? `float outputValue = ${t.toFixed(2)};` : `\n vec3 fill = vec3(${t.join(",")});\n float outputValue = fill[coords[3]];`, this.userCode = `\n void main() {\n ivec4 coords = getOutputCoords();\n int x = coords[2];\n int y = coords[1];\n float coordXFloat = (float(x) - params[0]) * params[3] -\n (float(y) - params[1]) * params[2];\n float coordYFloat = (float(x) - params[0]) * params[2] +\n (float(y) - params[1]) * params[3];\n int coordX = int(round(coordXFloat + params[0]));\n int coordY = int(round(coordYFloat + params[1]));\n ${i}\n if(coordX >= 0 && coordX < ${r} && coordY >= 0 && coordY < ${n}) {\n outputValue = getImage(coords[0], coordY, coordX, coords[3]);\n }\n setOutput(outputValue);\n }\n ` } }
/**
* @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.
* =============================================================================
*/
const JN = { kernelName: P.RotateWithOffset, backendName: "webgl", kernelFunc: ({ inputs: e, attrs: t, backend: n }) => { const { image: r } = e, { radians: i, fillValue: a, center: o } = t, s = n, u = new ZN(r.shape, a), [l, c] = P.backend_util.getImageCenter(o, r.shape[1], r.shape[2]), h = [[l, c, Math.sin(i), Math.cos(i)]]; return s.runWebGLProgram(u, [r], r.dtype, h) } }, QN = F_({ opSnippet: "\n // OpenGL ES does not support round function.\n // The algorithm is based on banker's rounding.\n float base = floor(x);\n if ((x - base) < 0.5) {\n return floor(x);\n } else if ((x - base) > 0.5) {\n return ceil(x);\n } else {\n if (mod(base, 2.0) == 0.0) {\n return base;\n } else {\n return base + 1.0;\n }\n }\n" }), eI = { kernelName: P.Round, backendName: "webgl", kernelFunc: QN }, tI = F_({ opSnippet: "return inversesqrt(x);", cpuKernelImpl: NS }), nI = { kernelName: P.Rsqrt, backendName: "webgl", kernelFunc: tI };
/**
* @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 rI { constructor(e, t, n, r, i, a, o = !0, s = !1) { this.variableNames = ["updates", "indices", "defaultValue"], this.outputShape = a; const u = gk(i.length), l = gk(a.length); let c = ""; 1 === n ? c = "i" : 2 === n && (c = "i, j"); const h = `getIndices(${c})`; let d = ""; 1 === r ? d = "i" : 2 === r && (d = "i, coords[1]"); const f = `getUpdates(${d})`; let p = ""; s && (p = "coords[0], coords[1]"); const m = `getDefaultValue(${p})`, g = t > 1 ? "strides[j]" : "strides"; this.userCode = `\n ${u} strides = ${u}(${i});\n\n void main() {\n ${l} coords = getOutputCoords();\n float sum = 0.0;\n bool found = false;\n for (int i = 0; i < ${e}; i++) {\n int flattenedIndex = 0;\n for (int j = 0; j < ${t}; j++) {\n int index = round(${h});\n flattenedIndex += index * ${g};\n }\n if (flattenedIndex == coords[0]) {\n sum += ${f};\n found = true;\n }\n }\n setOutput(mix(${m}, sum, float(found)));\n }\n ` } }
/**
* @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.
* =============================================================================
*/
class iI { constructor(e, t, n, r, i, a, o = !0, s = !1) { this.variableNames = ["updates", "indices", "defaultValue"], this.packedInputs = !0, this.packedOutput = !0, this.outputShape = a; const u = gk(i.length), l = gk(a.length); let c = ""; 1 === n ? c = "i" : 2 === n && (c = "i, j"); const h = `getIndices(${c})`; let d = ""; 1 === r ? d = "i" : 2 === r && (d = "i, coords[1]"); const f = `getUpdates(${d})`; let p = ""; s && (p = "coords[0], coords[1]"); const m = `getDefaultValue(${p})`, g = t > 1 ? "strides[j]" : "strides", y = t > 1 ? "strides[j + 1]" : "strides"; this.userCode = `\n ${u} strides = ${u}(${i});\n\n void main() {\n ${l} coords = getOutputCoords();\n vec4 sum = vec4(0.);\n vec4 found = vec4(0.);\n for (int i = 0; i < ${e}; i+=2) {\n ivec2 flattenedIndex = ivec2(0);\n for (int j = 0; j < ${t}; j+=2) {\n ivec4 index = round(${h});\n flattenedIndex += index.xz * ${g};\n if (j + 1 < ${t}) {\n flattenedIndex += index.yw * ${y};\n }\n }\n if (flattenedIndex[0] == coords[0] || flattenedIndex[1] == coords[0] ||\n flattenedIndex[0] == coords[0] + 1 || flattenedIndex[1] == coords[0] + 1) {\n vec4 updVals = ${f};\n if (flattenedIndex[0] == coords[0]) {\n sum.xy += updVals.xy;\n found.xy = vec2(1.);\n } else if (flattenedIndex[0] == coords[0] + 1) {\n sum.zw += updVals.xy;\n found.zw = vec2(1.);\n }\n if (flattenedIndex[1] == coords[0]) {\n sum.xy += updVals.zw;\n found.xy = vec2(1.);\n } else if (flattenedIndex[1] == coords[0] + 1) {\n sum.zw += updVals.zw;\n found.zw = vec2(1.);\n }\n }\n }\n setOutput(mix(${m}, sum, found));\n }\n ` } } const aI = {
kernelName: P.ScatterNd, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { indices: i, updates: a } = t, { shape: o } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(a, i, o), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(o, i.dtype); const f = U_({ inputs: { x: i }, backend: n, attrs: { shape: [u, s] } }), p = U_({ inputs: { x: a }, backend: n, attrs: { shape: [u, l] } }), m = n.makeTensorInfo([], "float32", new Float32Array([0])); let g; g = (0, P.env)().getBool("WEBGL_PACK") ? new iI(u, s, f.shape.length, p.shape.length, c, d) : new rI(u, s, f.shape.length, p.shape.length, c, d); const y = n.runWebGLProgram(g, [p, f, m], p.dtype), b = U_({ inputs: { x: y }, backend: n, attrs: { shape: o } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(y), n.disposeIntermediateTensorInfo(m), b }
};
/**
* @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.
* =============================================================================
*/
class oI { constructor(e, t, n, r) { this.variableNames = ["sortedSequence", "values"], this.customUniforms = [{ name: "numInputs", type: "int" }], this.outputShape = [e, n]; const i = `for (int i = 0; i < ${Math.ceil(Math.log2(t + 1))}; ++i) { if (left >= right) break;`, a = 2 === (0, P.env)().getNumber("WEBGL_VERSION") ? "while (left < right) {" : i, o = "left" === r ? "<" : "<="; this.userCode = `\n int findBound(int batch, float value) {\n int left = 0;\n int right = numInputs;\n int mid;\n ${a}\n mid = (left + right) / 2;\n if (getSortedSequence(batch, mid) ${o} value) {\n left = mid + 1;\n } else {\n right = mid;\n }\n }\n return right;\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int valueIndex = coords[1];\n\n float value = getValues(batch, valueIndex);\n\n setOutput(float(findBound(batch, value)));\n }\n ` } } const sI = {
kernelName: P.SearchSorted, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { sortedSequence: i, values: a } = t, { side: o } = r, s = new oI(i.shape[0], i.shape[1], a.shape[1], o), u = [[i.shape[1]]]; return n.runWebGLProgram(s, [i, a], "int32", u) }
};
/**
* @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.
* =============================================================================
*/
class uI { constructor(e, t, n) { let r, i; if (this.variableNames = ["c", "a", "b"], this.outputShape = t, n > 4) throw Error(`Where for rank ${n} is not yet supported`); if (1 === n) i = "resRC", r = "resRC"; else { const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w"], a = [], o = []; for (let r = 0; r < t.length; r++)o.push(`${n[r]}`), r < e && a.push(`${n[r]}`); r = a.join(), i = o.join() } const a = gk(n); this.userCode = `\n void main() {\n ${a} resRC = getOutputCoords();\n float cVal = getC(${r});\n if (cVal >= 1.0) {\n setOutput(getA(${i}));\n } else {\n setOutput(getB(${i}));\n }\n }\n ` } } const lI = {
kernelName: P.Select, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { condition: r, t: i, e: a } = t, o = new uI(r.shape.length, i.shape, i.shape.length); return n.runWebGLProgram(o, [r, i, a], (0, P.upcastType)(i.dtype, a.dtype)) }
}, cI = F_({ opSnippet: `\n // Stable and Attracting Fixed Point (0, 1) for Normalized Weights.\n // see: https://arxiv.org/abs/1706.02515\n float scaleAlpha = ${P.backend_util.SELU_SCALEALPHA};\n float scale = ${P.backend_util.SELU_SCALE};\n return (x >= 0.0) ? scale * x : scaleAlpha * (exp(x) - 1.0);\n` }), hI = { kernelName: P.Selu, backendName: "webgl", kernelFunc: cI }, dI = F_({ opSnippet: M_ + "\n return 1.0 / (1.0 + exp(-1.0 * x));\n", packedOpSnippet: "\n vec4 result = 1.0 / (1.0 + exp(-1.0 * x));\n bvec4 isNaN = isnan(x);\n\n result.r = isNaN.r ? x.r : result.r;\n result.g = isNaN.g ? x.g : result.g;\n result.b = isNaN.b ? x.b : result.b;\n result.a = isNaN.a ? x.a : result.a;\n\n return result;\n", cpuKernelImpl: MS }), fI = { kernelName: P.Sigmoid, backendName: "webgl", kernelFunc: dI }, pI = F_({ opSnippet: "\n if (isnan(x)) { return 0.0; }\n return sign(x);\n" }), mI = { kernelName: P.Sign, backendName: "webgl", kernelFunc: pI }, gI = F_({ opSnippet: M_ + "\n return sin(x);\n", packedOpSnippet: `\n vec4 result = sin(x);\n bvec4 isNaN = isnan(x);\n ${v_}\n return result;\n` }), yI = { kernelName: P.Sin, backendName: "webgl", kernelFunc: gI }, bI = F_({ opSnippet: "\n float e2x = exp(x);\n return (e2x - 1.0 / e2x) / 2.0;\n" }), vI = { kernelName: P.Sinh, backendName: "webgl", kernelFunc: bI }, xI = F_({ opSnippet: "\n float epsilon = 1.1920928955078125e-7;\n float threshold = log(epsilon) + 2.0;\n\n bool too_large = x > -threshold;\n bool too_small = x < threshold;\n\n float result;\n float exp_x = exp(x);\n\n if (too_large){\n result = x;\n }\n else if (too_small){\n result = exp_x;\n }\n else{\n result = log(exp_x + 1.0);\n }\n return result;\n" }), wI = { kernelName: P.Softplus, backendName: "webgl", kernelFunc: xI }, kI = { kernelName: P.SpaceToBatchND, backendName: "webgl", kernelFunc: e => { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { blockShape: a, paddings: o } = r; P.util.assert(i.shape.length <= 4, (() => "spaceToBatchND for rank > 4 with a WebGL backend not implemented yet")); const s = a.reduce(((e, t) => e * t)), u = [[0, 0]]; u.push(...o); for (let e = 1 + a.length; e < i.shape.length; ++e)u.push([0, 0]); const l = [], c = kN({ inputs: { x: i }, backend: n, attrs: { paddings: u, constantValue: 0 } }), h = P.backend_util.getReshaped(c.shape, a, s, !1), d = P.backend_util.getPermuted(h.length, a.length, !1), f = P.backend_util.getReshapedPermuted(c.shape, a, s, !1), p = U_({ inputs: { x: c }, backend: n, attrs: { shape: h } }), m = J_({ inputs: { x: p }, backend: n, attrs: { perm: d } }), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: f } }); return l.push(c), l.push(p), l.push(m), l.forEach((e => n.disposeIntermediateTensorInfo(e))), g } }; const SI = {
kernelName: P.SparseFillEmptyRows, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { indices: r, values: i, denseShape: a, defaultValue: o } = t; if (1 !== a.shape.length) throw new Error(`Dense shape must be a vector, saw:\n ${a.shape}`); if (2 !== r.shape.length) throw new Error(`Indices must be a matrix, saw:\n ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Values must be a vector, saw:\n ${i.shape}`); if (0 !== o.shape.length) throw new Error(`Default value must be a scalar, saw:\n ${o.shape}`); const s = n.readSync(r.dataId), u = n.readSync(i.dataId), l = n.readSync(a.dataId), c = n.readSync(o.dataId)[0], [h, d, f, p, m] = $S(s, r.shape, r.dtype, u, i.dtype, l, c); return [n.makeTensorInfo(d, r.dtype, h), n.makeTensorInfo([d[0]], i.dtype, f), n.makeTensorInfo([p.length], "bool", new Uint8Array(p.map((e => Number(e))))), n.makeTensorInfo([m.length], r.dtype, new Int32Array(m))] }
}; const _I = {
kernelName: P.SparseReshape, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { inputIndices: r, inputShape: i, newShape: a } = t; if (2 !== r.shape.length) throw new Error(`Input indices should be a matrix but received shape ${r.shape}`); if (1 !== i.shape.length) throw new Error(`Input shape should be a vector but received shape ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Target shape should be a vector but received shape ${a.shape}`); const o = Array.from(n.readSync(i.dataId)), s = n.readSync(r.dataId), u = Array.from(n.readSync(a.dataId)), [l, c, h] = RS(s, r.shape, r.dtype, o, u); return [n.makeTensorInfo(c, r.dtype, l), n.makeTensorInfo([h.length], a.dtype, new Int32Array(h))] }
}; const CI = {
kernelName: P.SparseSegmentMean, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); const o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = OS(o, r.shape, r.dtype, s, u, !0); return n.makeTensorInfo(c, r.dtype, l) }
}; const AI = {
kernelName: P.SparseSegmentSum, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n } = e, { data: r, indices: i, segmentIds: a } = t; if (r.shape.length < 1) throw new Error("Data should be at least 1 dimensional but received scalar"); if (1 !== i.shape.length) throw new Error(`Indices should be a vector but received shape\n ${i.shape}`); if (1 !== a.shape.length) throw new Error(`Segment ids should be a vector but received shape\n ${a.shape}`); const o = n.readSync(r.dataId), s = n.readSync(i.dataId), u = n.readSync(a.dataId), [l, c] = OS(o, r.shape, r.dtype, s, u); return n.makeTensorInfo(c, r.dtype, l) }
}; const TI = {
kernelName: P.SparseToDense, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { sparseIndices: i, sparseValues: a, defaultValue: o } = t, { outputShape: s } = r, { sliceRank: u, numUpdates: l, sliceSize: c, strides: h, outputSize: d } = P.backend_util.calculateShapes(a, i, s), f = !1; if ("string" === a.dtype) { const e = n.bufferSync(i), t = n.bufferSync(a), r = P.util.decodeString(n.readSync(o.dataId)[0]), p = IS(e, t, s, d, c, l, u, h, r, f); return n.makeTensorInfo(s, p.dtype, p.values) } const p = new rI(l, u, i.shape.length, a.shape.length, h, [d, 1], f), m = n.runWebGLProgram(p, [a, i, o], a.dtype), g = U_({ inputs: { x: m }, backend: n, attrs: { shape: s } }); return n.disposeIntermediateTensorInfo(m), g }
}; const EI = {
kernelName: P.SplitV, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { numOrSizeSplits: a, axis: o } = r, s = P.util.parseAxisParam(o, i.shape)[0], u = P.backend_util.prepareSplitSize(i, a, s), l = i.shape.length, c = new Array(l).fill(0), h = i.shape.slice(); return u.map((e => { const t = [...h]; t[s] = e; const r = YC({ inputs: { x: i }, backend: n, attrs: { begin: c, size: t } }); return c[s] += e, r })) }
}, NI = "return sqrt(x);", II = F_({ opSnippet: NI, packedOpSnippet: NI, cpuKernelImpl: zS }), MI = { kernelName: P.Sqrt, backendName: "webgl", kernelFunc: II }, FI = F_({ opSnippet: "return x * x;" }), DI = { kernelName: P.Square, backendName: "webgl", kernelFunc: FI }, $I = "return (a - b) * (a - b);", RI = D_({ opSnippet: $I, packedOpSnippet: $I }), OI = { kernelName: P.SquaredDifference, backendName: "webgl", kernelFunc: RI }; const zI = {
kernelName: P.StaticRegexReplace, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t; if ("string" !== i.dtype) throw new Error("Input must be of datatype string"); const a = n.readSync(i.dataId), o = P.backend_util.fromUint8ToStringArray(a), s = PS(o, "string", r); return n.makeTensorInfo(i.shape, "string", s) }
}; const PI = {
kernelName: P.Step, backendName: "webgl", kernelFunc:
/**
* @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 ({ inputs: e, attrs: t, backend: n }) { const { x: r } = e, i = r_ + `\n return x > 0.0 ? 1.0 : float(${t.alpha});\n `, a = new n_(r.shape, i); return n.runWebGLProgram(a, [r], r.dtype) }
};
/**
* @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.
* =============================================================================
*/
class BI { constructor(e, t, n) { this.variableNames = ["x"], this.outputShape = n; const r = n.length, i = gk(n.length), a = gk(n.length); let o = ""; if (1 === r) o = "coords * strides + begin"; else { let e = 0; o = n.map(((t, r) => (e++, 1 === n.length ? `coords * strides[${r}] + begin[${r}]` : `coords[${e - 1}] * strides[${r}] + begin[${r}]`))).join(",") } this.userCode = `\n ${i} begin = ${i}(${e});\n ${i} strides = ${i}(${t});\n\n void main() {\n ${a} coords = getOutputCoords();\n setOutput(getX(${o}));\n }\n ` } } const LI = {
kernelName: P.StridedSlice, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { begin: a, end: o, strides: s, beginMask: u, endMask: l, ellipsisMask: c, newAxisMask: h, shrinkAxisMask: d } = r, { finalShapeSparse: f, finalShape: p, isIdentity: m, sliceDim0: g, isSimpleSlice: y, begin: b, end: v, strides: x } = P.slice_util.sliceInfo(i.shape, a, o, s, u, l, c, h, d); let w; if (m) w = U_({ inputs: { x: i }, backend: n, attrs: { shape: p } }); else if (g || y) { P.util.assert(i.shape.length >= 1, (() => `Input must have rank at least 1, got: ${i.shape.length}`)); const e = P.slice_util.computeOutShape(b, v, x), t = YC({ inputs: { x: i }, backend: n, attrs: { begin: b, size: e } }); w = U_({ inputs: { x: t }, backend: n, attrs: { shape: p } }), n.disposeIntermediateTensorInfo(t) } else { if (n.shouldExecuteOnCPU([i])) { const e = n.readSync(i.dataId), t = (0, P.buffer)(i.shape, i.dtype, e), r = BS(f, t, x, b); w = n.makeTensorInfo(p, i.dtype, r.values) } else { const e = new BI(b, x, f); w = n.runWebGLProgram(e, [i], i.dtype) } } const k = U_({ inputs: { x: w }, backend: n, attrs: { shape: p } }); return n.disposeIntermediateTensorInfo(w), k }
}; const jI = {
kernelName: P.StringNGrams, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { separator: i, nGramWidths: a, leftPad: o, rightPad: s, padWidth: u, preserveShortSequences: l } = r, { data: c, dataSplits: h } = t, d = n.readSync(c.dataId), f = n.readSync(h.dataId), [p, m] = LS(d, f, i, a, o, s, u, l); return [n.makeTensorInfo([p.length], "string", p), n.makeTensorInfo(h.shape, "int32", m)] }
}; const UI = {
kernelName: P.StringSplit, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { skipEmpty: i } = r, { input: a, delimiter: o } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (1 !== a.shape.length) throw new Error(`Input must be a vector, got shape: ${a.shape}`); if (0 !== o.shape.length) throw new Error(`Delimiter must be a scalar, got shape: ${o.shape}`); const s = n.readSync(a.dataId), u = n.readSync(o.dataId)[0], [l, c, h] = jS(s, u, i), d = c.length; return [n.makeTensorInfo([d, 2], "int32", l), n.makeTensorInfo([d], "string", c), n.makeTensorInfo([2], "int32", new Int32Array(h))] }
}; const WI = {
kernelName: P.StringToHashBucketFast, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { numBuckets: i } = r, { input: a } = t; if ("string" !== a.dtype) throw new Error("Input must be of datatype string"); if (i <= 0) throw new Error("Number of buckets must be at least 1"); const o = n.readSync(a.dataId), s = US(o, i); return n.makeTensorInfo(a.shape, "int32", s) }
}, VI = F_({ opSnippet: "return tan(x);" }), GI = { kernelName: P.Tan, backendName: "webgl", kernelFunc: VI }, HI = F_({ opSnippet: "\n float e2x = exp(-2.0 * abs(x));\n return sign(x) * (1.0 - e2x) / (1.0 + e2x);\n" }), qI = { kernelName: P.Tanh, backendName: "webgl", kernelFunc: HI }; const YI = {
kernelName: P.TensorScatterUpdate, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { tensor: i, indices: a, updates: o } = t, { } = r, { sliceRank: s, numUpdates: u, sliceSize: l, strides: c, outputSize: h } = P.backend_util.calculateShapes(o, a, i.shape), d = [h / l, l]; if (0 === h) return n.makeTensorInfo(i.shape, a.dtype); const f = U_({ inputs: { x: a }, backend: n, attrs: { shape: [u, s] } }), p = U_({ inputs: { x: o }, backend: n, attrs: { shape: [u, l] } }), m = U_({ inputs: { x: i }, backend: n, attrs: { shape: d } }), g = new rI(u, s, f.shape.length, p.shape.length, c, d, !1, !0), y = n.runWebGLProgram(g, [p, f, m], m.dtype), b = U_({ inputs: { x: y }, backend: n, attrs: { shape: i.shape } }); return n.disposeIntermediateTensorInfo(f), n.disposeIntermediateTensorInfo(p), n.disposeIntermediateTensorInfo(m), n.disposeIntermediateTensorInfo(y), b }
};
/**
* @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.
* =============================================================================
*/
class XI { constructor(e, t) { this.variableNames = ["A"]; const n = new Array(e.length); for (let r = 0; r < n.length; r++)n[r] = e[r] * t[r]; this.outputShape = n, this.rank = n.length; const r = gk(this.rank), i = function (e) { const t = e.length; if (t > 5) throw Error(`Tile for rank ${t} is not yet supported`); if (1 === t) return `imod(resRC, ${e[0]})`; const n = ["resRC.x", "resRC.y", "resRC.z", "resRC.w", "resRC.u"], r = []; for (let t = 0; t < e.length; t++)r.push(`imod(${n[t]}, ${e[t]})`); return r.join() }(e); this.userCode = `\n void main() {\n ${r} resRC = getOutputCoords();\n setOutput(getA(${i}));\n }\n ` } }
/**
* @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 KI(e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { reps: a } = r; if ("string" === i.dtype || i.shape.length > 5) { const e = n.readSync(i.dataId), t = "string" === i.dtype ? e.map((e => P.util.decodeString(e))) : e, r = (0, P.buffer)(i.shape, i.dtype, t), o = VS(r, a); return n.makeTensorInfo(o.shape, o.dtype, o.values) } const o = new XI(i.shape, a); return n.runWebGLProgram(o, [i], i.dtype) } const ZI = { kernelName: P.Tile, backendName: "webgl", kernelFunc: KI }; class JI { constructor(e) { this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "negativeInf", type: "float" }, { name: "dir", type: "int" }, { name: "inc", type: "int" }], this.outputShape = e, this.userCode = "\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // We compare elements pair-wise within a group of size 2 * inc.\n // The comparing rule for each group alternates between ascending\n // and descending. Within each group, we compare each pair at\n // positions i and i+inc. To decide whether an element at position i\n // is x0 or x1, we mod it by 2 * inc, if the result is smaller than\n // inc, it is in the first half of the group, we denote it as x0,\n // otherwise we denote it as x1.\n // For example, as shown in the Bitonic top K paper referenced above,\n // Figure5(a) shows that element[1] is in the\n // second half of the group when group size is 2, but it is in the\n // first half of the group when group size is 4.\n\n bool isFirstInPair = imod(elemIdx, 2 * inc) < inc;\n int i = isFirstInPair ? elemIdx : elemIdx - inc;\n\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + inc : int(getIndices(batch, i + inc));\n float x0 = i0 < n ? getX(batch, i0) : negativeInf;\n float x1 = i1 < n ? getX(batch, i1) : negativeInf;\n\n // Denotes which direction indices are in (ascending or descending).\n bool reverse = imod(elemIdx, 2 * dir) >= dir;\n bool isGreater = x0 > x1 || (x0 == x1 && i1 > i0);\n if (reverse == isGreater) { // Elements in opposite order of direction\n int iTemp = i0;\n i0 = i1;\n i1 = iTemp;\n }\n if (isFirstInPair) {\n setOutput(float(i0));\n } else {\n setOutput(float(i1));\n }\n }\n " } } class QI { constructor(e) { this.variableNames = ["x", "indices"], this.customUniforms = [{ name: "n", type: "int" }, { name: "firstPass", type: "int" }, { name: "k", type: "int" }], this.outputShape = e, this.userCode = "\n void main() {\n // Takes max of indices (0, k), (1, k + 1), (2, k + 2) ...\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int elemIdx = coords[1];\n\n // The output size is half of the previous size.\n // If the previous sequence is | | | | _ _ _ _ | | | | _ _ _ _ (k=4),\n // we only need to output the indices at positions |, the indices at\n // positions _ can be thrown away, see Figure5(b) After Phase 2\n // (Merge phase) in the Bitonic Top K paper referenced above.\n // For example, the paper shows we only need to output the orange bars.\n // The output sequence should look like this | | | | | | | |.\n // Because the sequence is halved, to map the output index back\n // to the previous sequence to find the corresponding value,\n // we need to double the index. When we double the index,\n // we basically interpolate a position, so 2i looks like\n // | _ | _ | _ | _ | _ | _ | _. We move the | to the first k position\n // of each 2k positions by - elemIdx % k. E.g. for output at\n // index 4,5,6,7, we want to get the corresponding element at\n // original index 8,9,10,11, for output at index 8,9,10,11,\n // we want to get the corresponding element at original index\n // 16,17,18,19, so on and so forth.\n\n int i = elemIdx < k ? elemIdx : (elemIdx * 2 - imod(elemIdx, k));\n int i0 = firstPass == 1 ? i : int(getIndices(batch, i));\n int i1 = firstPass == 1 ? i + k : int(getIndices(batch, i + k));\n\n float x0 = getX(batch, i0);\n float x1 = i1 < n ? getX(batch, i1) : x0;\n\n setOutput(x0 >= x1 ? float(i0) : float(i1));\n }\n " } }
/**
* @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 eM(e, t) { null !== t && e.disposeIntermediateTensorInfo(t) } function tM(e) { let t = 1; for (; t < e;)t *= 2; return t } const nM = { kernelName: P.TopK, backendName: "webgl", kernelFunc: function (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i } = t, { k: a, sorted: o } = r, s = (0, P.env)().getNumber("TOPK_LAST_DIM_CPU_HANDOFF_SIZE_THRESHOLD"), u = (0, P.env)().getNumber("TOPK_K_CPU_HANDOFF_THRESHOLD"), l = i.shape, c = l[l.length - 1]; if (n.shouldExecuteOnCPU([i]) || c < s || a > u) { const e = n.readSync(i.dataId), [t, r] = GS(e, l, i.dtype, a, o); return [n.makeTensorInfo(t.shape, t.dtype, t.values), n.makeTensorInfo(r.shape, r.dtype, r.values)] } if (0 === a) return l[l.length - 1] = 0, [n.makeTensorInfo(l, i.dtype, []), n.makeTensorInfo(l, "int32", [])]; if (1 === c) return [i, DT({ attrs: { shape: l, dtype: "int32", value: 0 }, backend: n })]; const h = n.texData.get(i.dataId), d = null !== h && h.isPacked, f = d ? n.unpackTensor(i) : i, p = P.util.sizeFromShape(l) / c, m = U_({ inputs: { x: f }, attrs: { shape: [p, c] }, backend: n }); d && eM(n, f); const g = tM(a), y = tM(c); let b = null; const v = () => null === b ? [m, m] : [m, b], x = (e, t, r) => { const i = v(), a = new JI(r), o = [[c], [null === b ? 1 : 0], [Number.NEGATIVE_INFINITY], [e], [t]], s = b; b = n.runWebGLProgram(a, i, "int32", o), eM(n, s) }; for (let e = 1; e < g; e *= 2) { const t = 2 * e; for (let n = e; n >= 1; n /= 2)x(t, n, [p, y]) } for (let e = y; e > g; e /= 2) { const t = v(), r = new QI([p, e / 2]), i = [[c], [null === b ? 1 : 0], [g]], a = b; b = n.runWebGLProgram(r, t, "int32", i), eM(n, a); const o = g / 2, s = 2 * o; for (let e = o; e >= 1; e /= 2)x(s, e, b.shape) } let w = b; b = YC({ inputs: { x: b }, backend: n, attrs: { begin: 0, size: [p, a] } }), eM(n, w); let k = JT({ inputs: { x: m, indices: b }, backend: n, attrs: { axis: 1, batchDims: 1 } }); eM(n, m); const S = l.slice(0, -1); S.push(a), w = b, b = U_({ inputs: { x: b }, attrs: { shape: S }, backend: n }), eM(n, w); const _ = k; return k = U_({ inputs: { x: k }, attrs: { shape: S }, backend: n }), eM(n, _), [k, b] } };
/**
* @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.
* =============================================================================
*/
class rM { constructor(e, t, n, r, i, a) { this.variableNames = ["Image", "Transforms"], this.outputShape = a; const o = "nearest" === n ? 1 : 2; let s; switch (r) { case "constant": default: s = 1; break; case "reflect": s = 2; break; case "wrap": s = 3; break; case "nearest": s = 4 }this.userCode = `\n float mapCoord(float outCoord, float len) {\n float inCoord = outCoord;\n if(${s} == 2) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n if (inCoord < sz2) {\n inCoord = sz2 * float(int(float(-inCoord / sz2))) +\n inCoord;\n }\n inCoord = inCoord < -len ? inCoord + sz2 : -inCoord - 1.0;\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz2 = 2.0 * len;\n inCoord -= sz2 * float(int(float(inCoord / sz2)));\n if (inCoord >= len) {\n inCoord = sz2 - inCoord - 1.0;\n }\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 3) {\n if (inCoord < 0.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord += len * (float(int(float(-inCoord / sz))) + 1.0);\n }\n } else if (inCoord > len - 1.0) {\n if (len <= 1.0) {\n inCoord = 0.0;\n } else {\n float sz = len - 1.0;\n inCoord -= len * float(int(float(inCoord / sz)));\n }\n }\n return clamp(inCoord, 0.0, len - 1.0);\n } else if (${s} == 4) {\n return clamp(outCoord, 0.0, len - 1.0);\n } else {\n return outCoord;\n }\n }\n\n float readWithFillValue(int batch, int coordY, int coordX,\n int channel) {\n float outputValue;\n if (0 <= coordY && coordY < ${e} && 0 <= coordX && coordX < ${t}) {\n outputValue = getImage(batch, coordY, coordX, channel);\n } else {\n outputValue = float(${i});\n }\n return outputValue;\n }\n\n void main() {\n ivec4 coords = getOutputCoords();\n float outputValue;\n int batch = coords[0];\n int x = coords[2];\n int y = coords[1];\n int channel = coords[3];\n float xf = float(x);\n float yf = float(y);\n float a1 = getTransforms(batch, 0);\n float a2 = getTransforms(batch, 1);\n float a3 = getTransforms(batch, 2);\n float b1 = getTransforms(batch, 3);\n float b2 = getTransforms(batch, 4);\n float b3 = getTransforms(batch, 5);\n float c1 = getTransforms(batch, 6);\n float c2 = getTransforms(batch, 7);\n float projection = c1 * xf + c2 * yf + 1.0;\n if (projection == 0.0) {\n outputValue = float(${i});\n } else {\n float inX = (a1 * xf + a2 * yf + a3) / projection;\n float inY = (b1 * xf + b2 * yf + b3) / projection;\n float mapX = mapCoord(inX, float(${t}));\n float mapY = mapCoord(inY, float(${e}));\n\n if (${o} == 1) {\n int coordY = int(round(mapY));\n int coordX = int(round(mapX));\n outputValue = readWithFillValue(batch, coordY, coordX,\n channel);\n } else {\n float yFloor = floor(mapY);\n float xFloor = floor(mapX);\n float yCeil = yFloor + 1.0;\n float xCeil = xFloor + 1.0;\n float valueYFloor = (xCeil - mapX) *\n readWithFillValue(batch, int(yFloor), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yFloor), int(xCeil), channel);\n float valueYCeil = (xCeil - mapX) *\n readWithFillValue(batch, int(yCeil), int(xFloor), channel) +\n (mapX - xFloor) *\n readWithFillValue(batch, int(yCeil), int(xCeil), channel);\n outputValue = (yCeil - mapY) * valueYFloor +\n (mapY - yFloor) * valueYCeil;\n }\n }\n setOutput(outputValue);\n }\n ` } } const iM = {
kernelName: P.Transform, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { image: i, transforms: a } = t, { interpolation: o, fillMode: s, fillValue: u, outputShape: l } = r, [c, h, d, f] = i.shape, [p, m] = null != l ? l : [h, d], g = new rM(h, d, o, s, u, [c, p, m, f]); return n.runWebGLProgram(g, [i, a], "float32") }
}; const aM = {
kernelName: P.Unique, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, attrs: n, backend: r } = e, { axis: i } = n, { x: a } = t; Zw(a, "unique"), console.warn("WARNING: ", "UI might be locked temporarily as data is being downloaded"); const o = r.readSync(a.dataId), { outputValues: s, outputShape: u, indices: l } = qS(o, i, a.shape, a.dtype); return [r.makeTensorInfo(u, a.dtype, s), r.makeTensorInfo([l.length], "int32", l)] }
}; const oM = {
kernelName: P.Unpack, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { value: i } = t; let { axis: a } = r; a < 0 && (a += i.shape.length); const o = i, s = o.shape.length, u = i.shape[a], l = new Array(s - 1); let c = 0; for (let e = 0; e < s; e++)e !== a && (l[c++] = o.shape[e]); const h = [], d = new Array(s).fill(0), f = o.shape.slice(); f[a] = 1; const p = new Array(u); for (let e = 0; e < p.length; e++) { d[a] = e; const t = YC({ inputs: { x: o }, backend: n, attrs: { begin: d, size: f } }), r = U_({ inputs: { x: t }, backend: n, attrs: { shape: l } }); p[e] = r, h.push(t) } return h.forEach((e => n.disposeIntermediateTensorInfo(e))), p }
};
/**
* @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 sM { constructor(e, t) { this.variableNames = ["x", "segmentIds"]; const n = e.windowSize, r = e.batchSize, i = e.inSize, a = e.numSegments, o = a * Math.ceil(i / n); this.outputShape = [r, o]; const s = 4 * Math.floor(n / 4), u = n % 4, l = "\n sumValue += dot(values, segFilter);\n "; let c = ""; i % n > 0 && (c = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return initializationValue;\n }\n `); let h = ""; i % n > 0 && (h = `\n if (inIdx < 0 || inIdx >= ${i}) {\n return -1.0;\n }\n `), this.userCode = `\n const float initializationValue = 0.0;\n\n float getValue(int batch, int inIdx) {\n ${c}\n return getX(batch, inIdx);\n }\n\n float getSegmentIdAtIndex(int inIdx) {\n ${h}\n return getSegmentIds(inIdx);\n }\n\n void main() {\n ivec2 coords = getOutputCoords();\n int batch = coords[0];\n int outIdx = coords[1];\n int inOffset = int(floor(float(outIdx) / float(\n ${a})) * float(${n}));\n int currentSeg = int(mod(float(outIdx), float(${a})));\n\n float sumValue = 0.0;\n\n for (int i = 0; i < ${s}; i += 4) {\n int inIdx = inOffset + i;\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n getValue(batch, inIdx + 3)\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 3)) == currentSeg ? 1 : 0\n );\n\n ${l}\n }\n\n int inIdx = inOffset + ${s};\n if (${1 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n initializationValue,\n initializationValue,\n initializationValue\n );\n\n int inIdxSeg = int(getSegmentIdAtIndex(inIdx));\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${2 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n initializationValue,\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n 0,\n 0\n );\n\n ${l}\n } else if (${3 === u}) {\n vec4 values = vec4(\n getValue(batch, inIdx),\n getValue(batch, inIdx + 1),\n getValue(batch, inIdx + 2),\n initializationValue\n );\n\n vec4 segFilter = vec4(\n int(getSegmentIdAtIndex(inIdx)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 1)) == currentSeg ? 1 : 0,\n int(getSegmentIdAtIndex(inIdx + 2)) == currentSeg ? 1 : 0,\n 0\n );\n\n ${l}\n }\n setOutput(sumValue);\n }\n ` } } const uM = {
kernelName: P.UnsortedSegmentSum, backendName: "webgl", kernelFunc:
/**
* @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 (e) { const { inputs: t, backend: n, attrs: r } = e, { x: i, segmentIds: a } = t, { numSegments: o } = r, s = i.shape.length, u = []; let l = 0; const c = P.backend_util.getAxesPermutation([l], s); let h = i; null != c && (h = J_({ inputs: { x: i }, backend: n, attrs: { perm: c } }), u.push(h), l = P.backend_util.getInnerMostAxes(1, s)[0]); const d = P.backend_util.segment_util.computeOutShape(h.shape, l, o), f = P.util.sizeFromShape([h.shape[l]]), p = U_({ inputs: { x: h }, backend: n, attrs: { shape: [-1, f] } }); u.push(p); const m = (0, P.sumOutType)(i.dtype), g = (e, t, r, i, a) => { const o = e.shape[0], s = e.shape[1], l = P.backend_util.segment_util.segOpComputeOptimalWindowSize(s, a), c = new sM({ windowSize: l, inSize: s, batchSize: o, numSegments: a }, t), h = n.compileAndRun(c, [e, r], i); if (u.push(h), h.shape[1] === a) return h; const d = IN({ backend: n, attrs: { start: 0, stop: a, step: 1, dtype: "float32" } }), f = KI({ inputs: { x: d }, backend: n, attrs: { reps: [s / l] } }); u.push(d), u.push(f); return g(h, t, f, i, a) }, y = U_({ inputs: { x: g(p, "unsortedSegmentSum", a, m, o) }, backend: n, attrs: { shape: d } }); let b = y; if (null != c) { u.push(y); const e = P.backend_util.getUndoAxesPermutation(c); b = J_({ inputs: { x: b }, backend: n, attrs: { perm: e } }) } return u.forEach((e => n.disposeIntermediateTensorInfo(e))), b }
}, lM = [tC, rC, aC, sC, cC, fC, pC, mC, wC, kC, _C, AC, EC, IC, FC, RC, OC, BC, LC, jC, VC, KC, ZC, JC, QC, iA, sA, cA, __, fA, wA, NA, $A, OA, zA, PA, BA, jA, WA, GA, JA, QA, eT, nT, aT, uT, lT, hT, fT, pT, gT, yT, vT, wT, ST, CT, ET, MT, $T, OT, BT, jT, VT, qT, YT, KT, QT, tE, rE, k_, iE, bA, oE, uE, cE, T_, dE, pE, mE, yE, vE, wE, SE, CE, EE, IE, FE, $E, RE, OE, BE, LE, jE, UE, WE, GE, YE, KE, aN, j_, sN, lN, hN, fN, tA, mN, bN, vN, SN, CN, I_, AN, TN, EN, NN, MN, rA, QE, DN, RN, zN, W_, LN, UN, GN, qN, KN, JN, eI, nI, aI, sI, lI, hI, fI, mI, yI, vI, XC, iN, wI, kI, SI, _I, CI, AI, TI, EI, MI, DI, OI, zI, PI, LI, jI, UI, WI, nN, Z_, GI, qI, YI, ZI, nM, iM, Q_, aM, oM, uM, yN]; for (const e of lM) (0, P.registerKernel)(e);
/** @license See the LICENSE file. */
const cM = { "tfjs-core": P.version_core, "tfjs-backend-cpu": Dg, "tfjs-backend-webgl": p_, "tfjs-data": rp, "tfjs-layers": Fo, "tfjs-converter": Vd, tfjs: "4.22.0" }; function hM(e, t) { return t ? new Promise(((n, r) => { e.then((e => { t(e), n(e) })).catch((e => { t(void 0, e), r(e) })) })) : e } const dM = e => "undefined" != typeof HTMLVideoElement && e instanceof HTMLVideoElement, fM = e => "undefined" != typeof HTMLAudioElement && e instanceof HTMLAudioElement, pM = e => "undefined" != typeof HTMLCanvasElement && (e instanceof HTMLCanvasElement || e instanceof OffscreenCanvas), mM = e => "undefined" != typeof HTMLImageElement && e instanceof HTMLImageElement, gM = e => "undefined" == typeof ImageData ? "object" == typeof e && (e.data instanceof Uint8ClampedArray || e.data instanceof Uint8Array) && "number" == typeof e.width && "number" == typeof e.height : e instanceof ImageData, yM = e => !!e && (pM(e) || mM(e) || dM(e)), bM = e => { if (yM(e)) return e; if ("object" == typeof e) { if (yM(e.canvas)) return e.canvas; if (yM(e.elt)) return e.elt } return null }; class vM { constructor(...e) { e.forEach((e => this.addArg(e))) } addArg(e) { var t; if (null != e) switch (typeof e) { case "string": this.set({ string: e }); break; case "number": this.set({ number: e }); break; case "function": this.set({ callback: e }); break; case "object": { ((t = e) instanceof P.Tensor && 3 === t.rank || gM(e)) && this.set({ image: e }); const n = bM(e); n && (this.set({ image: n }), dM(n) && this.set({ audio: n, video: n })), fM(e) ? this.set({ audio: e }) : Array.isArray(e) ? this.set({ array: e }) : this.set({ options: e }); break } default: throw new Error("invalid argument") } } set(e, t = !0) { Object.keys(e).forEach((n => { t && this.has(n) && console.warn(`Received multiple ${n} arguments, but only a single ${n} is supported.\n The last ${n} will be used.`), this[n] = e[n] })) } has(e) { return void 0 !== this[e] } require(e, t) { if (this.has(e)) return this; throw new Error(t || `An argument for ${e} must be provided.`) } } function xM(...e) { return new vM(...e) } function wM(e) { return Boolean(e && "function" == typeof e && e.prototype && e.prototype.registerMethod) } const kM = new class { constructor() { this.didSetupPreload = !1, this.p5Constructor = void 0, this.p5Extensions = void 0, this.ml5Library = void 0, this.methodsToPreload = [], this.findAndSetP5() } findAndSetP5() { let e; "undefined" != typeof window ? e = window : "undefined" != typeof globalThis && (e = globalThis), e && (wM(e.p5) && (this.p5Constructor = e.p5, this.registerPreloads()), function (e) { return Boolean(e && "function" == typeof e.loadImage) }(e) && (this.p5Extensions = e)) } setP5(e) { wM(e) ? (this.p5Constructor = e, this.p5Extensions = e.prototype, this.registerPreloads()) : console.warn("Invalid p5 object provided to ml5.setP5().") } setupP5Integration(e, t, n) { this.methodsToPreload = t, this.ml5Library = e, this.checkP5() ? this.registerPreloads() : this.registerAsyncConstructors(e, n) } registerAsyncConstructors(e, t) { this.methodsToPreload.forEach((n => { var r; t.includes(n) || (e[n] = (r = e[n], (...e) => { const t = r(...e); return t.ready ? t.ready.then((() => t)) : Promise.resolve(t) })) })) } registerPreloads() { if (this.didSetupPreload) return; const e = this.p5Constructor, t = this.ml5Library, n = this.methodsToPreload; if (!e || !t) return; const r = { ...t }, i = this; e.prototype.ml5Init = function () { const e = this._incrementPreload.bind(this), a = this._decrementPreload.bind(this); n.forEach((n => { t[n] = function (...t) { e(); const i = r[n](...t); return i.ready.then((() => { a() })), i } })), i.didSetupPreload = !0 }, e.prototype.ml5Remove = function () { n.forEach((e => { t[e] = r[e] })), i.didSetupPreload = !1 }, e.prototype.registerMethod("init", e.prototype.ml5Init), e.prototype.registerMethod("remove", e.prototype.ml5Remove) } get p5Instance() { return this.p5Extensions || this.findAndSetP5(), this.p5Extensions } checkP5() { return !!this.p5Instance } getBlob(e) { return new Promise(((t, n) => { e.toBlob((e => { e ? t(e) : n(new Error("Canvas could not be converted to Blob.")) })) })) } loadAsync(e) { return new Promise(((t, n) => { this.p5Instance.loadImage(e, (e => { t(e) }), (() => { n(new Error(`Could not load image from url ${e}`)) })) })) } async rawToBlob(e, t, n) { const r = Array.from(e), i = document.createElement("canvas"), a = i.getContext("2d"); i.width = t, i.height = n; const o = a.createImageData(t, n), { data: s } = o; for (let e = 0; e < t * n * 4; e += 1)s[e] = r[e]; return a.putImageData(o, 0, 0), this.getBlob(i) } async ImageDataToBlob(e, t, n) { const r = document.createElement("canvas"), i = r.getContext("2d"); return r.width = t, r.height = n, i.putImageData(e, 0, 0), this.getBlob(r) } async blobToP5Image(e) { return this.checkP5() && "undefined" != typeof URL ? this.loadAsync(URL.createObjectURL(e)) : null } }, SM = e => { const t = gM(e) ? e : bM(e); if (pM(t)) return t; if (!t) throw new Error("Invalid image. Image must be one of: HTMLCanvasElement, HTMLImageElement, HTMLVideoElement, ImageData, p5.Image, p5.Graphics, or p5.Video."); const n = t.videoWidth || t.width, r = t.videoHeight || t.height, i = document.createElement("canvas"); i.width = n, i.height = r; const a = i.getContext("2d"); return gM(e) ? a.putImageData(e, 0, 0) : a.drawImage(t, 0, 0, n, r), i }; function _M(e, t = null) { return P.tidy((() => { let n = P.browser.fromPixels(e); t && (n = P.image.resizeBilinear(n, t)); const r = (e => { const t = Math.min(e.shape[0], e.shape[1]), n = e.shape[0] / 2 - t / 2, r = e.shape[1] / 2 - t / 2; return e.slice([n, r, 0], [t, t, 3]) })(n); return r.expandDims(0).toFloat().div(P.scalar(127)).sub(P.scalar(1)) })) } function CM(e) { return yM(e) || gM(e) } async function AM(e, t) { e && (dM(e) || fM(e)) ? (t && await P.nextFrame(), 0 === e.readyState && await new Promise(((t, n) => { e.addEventListener("error", (() => n(e.error))), e.addEventListener("loadeddata", t) }))) : e && mM(e) && (e.complete || await new Promise(((t, n) => { e.addEventListener("error", n), e.addEventListener("load", t) }))) } function TM(e, t, n) { return P.tidy((() => { const r = P.browser.fromPixels(e); return P.image.resizeBilinear(r, [n, t]).clipByValue(0, 255) })) } const EM = async (e, t, n) => { const r = document.createElement("a"); r.style.display = "none", document.body.appendChild(r); const i = new Blob([e], { type: n }); r.href = URL.createObjectURL(i), r.download = t, r.click() }, NM = (e = 0, t = 1) => Math.random() * (t - e) + e, IM = (e = 0, t = 1) => { let n, r, i, a, o, s; if (s) n = r, s = !1; else { do { i = NM(0, 2) - 1, a = NM(0, 2) - 1, o = i * i + a * a } while (o >= 1); o = Math.sqrt(-2 * Math.log(o) / o), n = i * o, r = a * o, s = !0 } return n * t + e }; const MM = class { constructor() { this.isTrained = !1, this.isCompiled = !1, this.isLayered = !1, this.model = null, this.init = this.init.bind(this), this.createModel = this.createModel.bind(this), this.addLayer = this.addLayer.bind(this), this.compile = this.compile.bind(this), this.setOptimizerFunction = this.setOptimizerFunction.bind(this), this.train = this.train.bind(this), this.predict = this.predict.bind(this), this.classify = this.classify.bind(this), this.save = this.save.bind(this), this.load = this.load.bind(this), this.init() } init() { this.createModel() } createModel(e = "sequential") { return e.toLowerCase(), this.model = is(), this.model } addLayer(e) { this.model.add(e), this.model.layers.length >= 2 && (this.isLayered = !0) } compile(e) { this.model.compile(e), this.isCompiled = !0 } setOptimizerFunction(e, t) { return t.call(this, e) } async train(e) { const t = e, n = t.inputs, r = t.outputs, { batchSize: i, epochs: a, shuffle: o, validationSplit: s, whileTraining: u } = t; await this.model.fit(n, r, { batchSize: i, epochs: a, shuffle: o, validationSplit: s, callbacks: u }), n.dispose(), r.dispose(), this.isTrained = !0 } predictSync(e) { const t = P.tidy((() => this.model.predict(e))), n = t.arraySync(); return t.dispose(), e.dispose(), n } async predict(e) { const t = P.tidy((() => this.model.predict(e))), n = await t.array(); return t.dispose(), e.dispose(), n } async classify(e) { return this.predict(e) } classifySync(e) { return this.predictSync(e) } async save(e = "model") { await this.model.save(P.io.withSaveHandler((async t => { this.weightsManifest = { modelTopology: t.modelTopology, weightsManifest: [{ paths: [`./${e}.weights.bin`], weights: t.weightSpecs }] }, await EM(t.weightData, `${e}.weights.bin`, "application/octet-stream"), await EM(JSON.stringify(this.weightsManifest), `${e}.json`, "text/plain") }))) } async load(e) { if (e instanceof FileList) { const t = Array.from(e), n = t.find((e => e.name.includes(".json") && !e.name.includes("_meta"))), r = t.find((e => e.name.includes(".bin"))); this.model = await ts(P.io.browserFiles([n, r])) } else this.model = e instanceof Object ? await ts(P.io.http(e.model, { weightUrlConverter: t => e.weights || t })) : await ts(e); this.isCompiled = !0, this.isLayered = !0, this.isTrained = !0 } dispose() { this.model.dispose() } mutate(e = .1, t) { P.tidy((() => { const n = this.model.getWeights(), r = []; for (let i = 0; i < n.length; i += 1) { const a = n[i], { shape: o } = n[i], s = a.dataSync().slice(); for (let n = 0; n < s.length; n += 1)Math.random() < e && (s[n] = t ? t(s[n]) : Math.min(Math.max(s[n] + IM(), -1), 1)); const u = P.tensor(s, o); r[i] = u } this.model.setWeights(r) })) } crossover(e) { return P.tidy((() => { const t = this.model.getWeights(), n = e.model.getWeights(), r = []; for (let e = 0; e < t.length; e += 1) { const i = t[e], a = n[e], { shape: o } = t[e], s = i.dataSync().slice(), u = a.dataSync().slice(); for (let e = 0; e < s.length; e += 1)Math.random() < .5 && (s[e] = u[e]); const l = P.tensor(s, o); r[e] = l } this.model.setWeights(r) })) } }; function FM(e, t) { return function () { return e.apply(t, arguments) } } const { toString: DM } = Object.prototype, { getPrototypeOf: $M } = Object, RM = (OM = Object.create(null), e => { const t = DM.call(e); return OM[t] || (OM[t] = t.slice(8, -1).toLowerCase()) }); var OM; const zM = e => (e = e.toLowerCase(), t => RM(t) === e), PM = e => t => typeof t === e, { isArray: BM } = Array, LM = PM("undefined"); const jM = zM("ArrayBuffer"); const UM = PM("string"), WM = PM("function"), VM = PM("number"), GM = e => null !== e && "object" == typeof e, HM = e => { if ("object" !== RM(e)) return !1; const t = $M(e); return !(null !== t && t !== Object.prototype && null !== Object.getPrototypeOf(t) || Symbol.toStringTag in e || Symbol.iterator in e) }, qM = zM("Date"), YM = zM("File"), XM = zM("Blob"), KM = zM("FileList"), ZM = zM("URLSearchParams"), [JM, QM, eF, tF] = ["ReadableStream", "Request", "Response", "Headers"].map(zM); function nF(e, t, { allOwnKeys: n = !1 } = {}) { if (null == e) return; let r, i; if ("object" != typeof e && (e = [e]), BM(e)) for (r = 0, i = e.length; r < i; r++)t.call(null, e[r], r, e); else { const i = n ? Object.getOwnPropertyNames(e) : Object.keys(e), a = i.length; let o; for (r = 0; r < a; r++)o = i[r], t.call(null, e[o], o, e) } } function rF(e, t) { t = t.toLowerCase(); const n = Object.keys(e); let r, i = n.length; for (; i-- > 0;)if (r = n[i], t === r.toLowerCase()) return r; return null } const iF = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof self ? self : "undefined" != typeof window ? window : global, aF = e => !LM(e) && e !== iF; const oF = (sF = "undefined" != typeof Uint8Array && $M(Uint8Array), e => sF && e instanceof sF); var sF; const uF = zM("HTMLFormElement"), lF = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), cF = zM("RegExp"), hF = (e, t) => { const n = Object.getOwnPropertyDescriptors(e), r = {}; nF(n, ((n, i) => { let a; !1 !== (a = t(n, i, e)) && (r[i] = a || n) })), Object.defineProperties(e, r) }, dF = "abcdefghijklmnopqrstuvwxyz", fF = "0123456789", pF = { DIGIT: fF, ALPHA: dF, ALPHA_DIGIT: dF + dF.toUpperCase() + fF }; const mF = zM("AsyncFunction"), gF = (yF = "function" == typeof setImmediate, bF = WM(iF.postMessage), yF ? setImmediate : bF ? (vF = `axios@${Math.random()}`, xF = [], iF.addEventListener("message", (({ source: e, data: t }) => { e === iF && t === vF && xF.length && xF.shift()() }), !1), e => { xF.push(e), iF.postMessage(vF, "*") }) : e => setTimeout(e)); var yF, bF, vF, xF; const wF = "undefined" != typeof queueMicrotask ? queueMicrotask.bind(iF) : "undefined" != typeof process && process.nextTick || gF, kF = { isArray: BM, isArrayBuffer: jM, isBuffer: function (e) { return null !== e && !LM(e) && null !== e.constructor && !LM(e.constructor) && WM(e.constructor.isBuffer) && e.constructor.isBuffer(e) }, isFormData: e => { let t; return e && ("function" == typeof FormData && e instanceof FormData || WM(e.append) && ("formdata" === (t = RM(e)) || "object" === t && WM(e.toString) && "[object FormData]" === e.toString())) }, isArrayBufferView: function (e) { let t; return t = "undefined" != typeof ArrayBuffer && ArrayBuffer.isView ? ArrayBuffer.isView(e) : e && e.buffer && jM(e.buffer), t }, isString: UM, isNumber: VM, isBoolean: e => !0 === e || !1 === e, isObject: GM, isPlainObject: HM, isReadableStream: JM, isRequest: QM, isResponse: eF, isHeaders: tF, isUndefined: LM, isDate: qM, isFile: YM, isBlob: XM, isRegExp: cF, isFunction: WM, isStream: e => GM(e) && WM(e.pipe), isURLSearchParams: ZM, isTypedArray: oF, isFileList: KM, forEach: nF, merge: function e() { const { caseless: t } = aF(this) && this || {}, n = {}, r = (r, i) => { const a = t && rF(n, i) || i; HM(n[a]) && HM(r) ? n[a] = e(n[a], r) : HM(r) ? n[a] = e({}, r) : BM(r) ? n[a] = r.slice() : n[a] = r }; for (let e = 0, t = arguments.length; e < t; e++)arguments[e] && nF(arguments[e], r); return n }, extend: (e, t, n, { allOwnKeys: r } = {}) => (nF(t, ((t, r) => { n && WM(t) ? e[r] = FM(t, n) : e[r] = t }), { allOwnKeys: r }), e), trim: e => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), stripBOM: e => (65279 === e.charCodeAt(0) && (e = e.slice(1)), e), inherits: (e, t, n, r) => { e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", { value: t.prototype }), n && Object.assign(e.prototype, n) }, toFlatObject: (e, t, n, r) => { let i, a, o; const s = {}; if (t = t || {}, null == e) return t; do { for (i = Object.getOwnPropertyNames(e), a = i.length; a-- > 0;)o = i[a], r && !r(o, e, t) || s[o] || (t[o] = e[o], s[o] = !0); e = !1 !== n && $M(e) } while (e && (!n || n(e, t)) && e !== Object.prototype); return t }, kindOf: RM, kindOfTest: zM, endsWith: (e, t, n) => { e = String(e), (void 0 === n || n > e.length) && (n = e.length), n -= t.length; const r = e.indexOf(t, n); return -1 !== r && r === n }, toArray: e => { if (!e) return null; if (BM(e)) return e; let t = e.length; if (!VM(t)) return null; const n = new Array(t); for (; t-- > 0;)n[t] = e[t]; return n }, forEachEntry: (e, t) => { const n = (e && e[Symbol.iterator]).call(e); let r; for (; (r = n.next()) && !r.done;) { const n = r.value; t.call(e, n[0], n[1]) } }, matchAll: (e, t) => { let n; const r = []; for (; null !== (n = e.exec(t));)r.push(n); return r }, isHTMLForm: uF, hasOwnProperty: lF, hasOwnProp: lF, reduceDescriptors: hF, freezeMethods: e => { hF(e, ((t, n) => { if (WM(e) && -1 !== ["arguments", "caller", "callee"].indexOf(n)) return !1; const r = e[n]; WM(r) && (t.enumerable = !1, "writable" in t ? t.writable = !1 : t.set || (t.set = () => { throw Error("Can not rewrite read-only method '" + n + "'") })) })) }, toObjectSet: (e, t) => { const n = {}, r = e => { e.forEach((e => { n[e] = !0 })) }; return BM(e) ? r(e) : r(String(e).split(t)), n }, toCamelCase: e => e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g, (function (e, t, n) { return t.toUpperCase() + n })), noop: () => { }, toFiniteNumber: (e, t) => null != e && Number.isFinite(e = +e) ? e : t, findKey: rF, global: iF, isContextDefined: aF, ALPHABET: pF, generateString: (e = 16, t = pF.ALPHA_DIGIT) => { let n = ""; const { length: r } = t; for (; e--;)n += t[Math.random() * r | 0]; return n }, isSpecCompliantForm: function (e) { return !!(e && WM(e.append) && "FormData" === e[Symbol.toStringTag] && e[Symbol.iterator]) }, toJSONObject: e => { const t = new Array(10), n = (e, r) => { if (GM(e)) { if (t.indexOf(e) >= 0) return; if (!("toJSON" in e)) { t[r] = e; const i = BM(e) ? [] : {}; return nF(e, ((e, t) => { const a = n(e, r + 1); !LM(a) && (i[t] = a) })), t[r] = void 0, i } } return e }; return n(e, 0) }, isAsyncFn: mF, isThenable: e => e && (GM(e) || WM(e)) && WM(e.then) && WM(e.catch), setImmediate: gF, asap: wF }; function SF(e, t, n, r, i) { Error.call(this), Error.captureStackTrace ? Error.captureStackTrace(this, this.constructor) : this.stack = (new Error).stack, this.message = e, this.name = "AxiosError", t && (this.code = t), n && (this.config = n), r && (this.request = r), i && (this.response = i, this.status = i.status ? i.status : null) } kF.inherits(SF, Error, { toJSON: function () { return { message: this.message, name: this.name, description: this.description, number: this.number, fileName: this.fileName, lineNumber: this.lineNumber, columnNumber: this.columnNumber, stack: this.stack, config: kF.toJSONObject(this.config), code: this.code, status: this.status } } }); const _F = SF.prototype, CF = {};["ERR_BAD_OPTION_VALUE", "ERR_BAD_OPTION", "ECONNABORTED", "ETIMEDOUT", "ERR_NETWORK", "ERR_FR_TOO_MANY_REDIRECTS", "ERR_DEPRECATED", "ERR_BAD_RESPONSE", "ERR_BAD_REQUEST", "ERR_CANCELED", "ERR_NOT_SUPPORT", "ERR_INVALID_URL"].forEach((e => { CF[e] = { value: e } })), Object.defineProperties(SF, CF), Object.defineProperty(_F, "isAxiosError", { value: !0 }), SF.from = (e, t, n, r, i, a) => { const o = Object.create(_F); return kF.toFlatObject(e, o, (function (e) { return e !== Error.prototype }), (e => "isAxiosError" !== e)), SF.call(o, e.message, t, n, r, i), o.cause = e, o.name = e.name, a && Object.assign(o, a), o }; const AF = SF; function TF(e) { return kF.isPlainObject(e) || kF.isArray(e) } function EF(e) { return kF.endsWith(e, "[]") ? e.slice(0, -2) : e } function NF(e, t, n) { return e ? e.concat(t).map((function (e, t) { return e = EF(e), !n && t ? "[" + e + "]" : e })).join(n ? "." : "") : t } const IF = kF.toFlatObject(kF, {}, null, (function (e) { return /^is[A-Z]/.test(e) })); const MF = function (e, t, n) { if (!kF.isObject(e)) throw new TypeError("target must be an object"); t = t || new FormData; const r = (n = kF.toFlatObject(n, { metaTokens: !0, dots: !1, indexes: !1 }, !1, (function (e, t) { return !kF.isUndefined(t[e]) }))).metaTokens, i = n.visitor || l, a = n.dots, o = n.indexes, s = (n.Blob || "undefined" != typeof Blob && Blob) && kF.isSpecCompliantForm(t); if (!kF.isFunction(i)) throw new TypeError("visitor must be a function"); function u(e) { if (null === e) return ""; if (kF.isDate(e)) return e.toISOString(); if (!s && kF.isBlob(e)) throw new AF("Blob is not supported. Use a Buffer instead."); return kF.isArrayBuffer(e) || kF.isTypedArray(e) ? s && "function" == typeof Blob ? new Blob([e]) : Buffer.from(e) : e } function l(e, n, i) { let s = e; if (e && !i && "object" == typeof e) if (kF.endsWith(n, "{}")) n = r ? n : n.slice(0, -2), e = JSON.stringify(e); else if (kF.isArray(e) && function (e) { return kF.isArray(e) && !e.some(TF) }(e) || (kF.isFileList(e) || kF.endsWith(n, "[]")) && (s = kF.toArray(e))) return n = EF(n), s.forEach((function (e, r) { !kF.isUndefined(e) && null !== e && t.append(!0 === o ? NF([n], r, a) : null === o ? n : n + "[]", u(e)) })), !1; return !!TF(e) || (t.append(NF(i, n, a), u(e)), !1) } const c = [], h = Object.assign(IF, { defaultVisitor: l, convertValue: u, isVisitable: TF }); if (!kF.isObject(e)) throw new TypeError("data must be an object"); return function e(n, r) { if (!kF.isUndefined(n)) { if (-1 !== c.indexOf(n)) throw Error("Circular reference detected in " + r.join(".")); c.push(n), kF.forEach(n, (function (n, a) { !0 === (!(kF.isUndefined(n) || null === n) && i.call(t, n, kF.isString(a) ? a.trim() : a, r, h)) && e(n, r ? r.concat(a) : [a]) })), c.pop() } }(e), t }; function FF(e) { const t = { "!": "%21", "'": "%27", "(": "%28", ")": "%29", "~": "%7E", "%20": "+", "%00": "\0" }; return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g, (function (e) { return t[e] })) } function DF(e, t) { this._pairs = [], e && MF(e, this, t) } const $F = DF.prototype; $F.append = function (e, t) { this._pairs.push([e, t]) }, $F.toString = function (e) { const t = e ? function (t) { return e.call(this, t, FF) } : FF; return this._pairs.map((function (e) { return t(e[0]) + "=" + t(e[1]) }), "").join("&") }; const RF = DF; function OF(e) { return encodeURIComponent(e).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]") } function zF(e, t, n) { if (!t) return e; const r = n && n.encode || OF; kF.isFunction(n) && (n = { serialize: n }); const i = n && n.serialize; let a; if (a = i ? i(t, n) : kF.isURLSearchParams(t) ? t.toString() : new RF(t, n).toString(r), a) { const t = e.indexOf("#"); -1 !== t && (e = e.slice(0, t)), e += (-1 === e.indexOf("?") ? "?" : "&") + a } return e } const PF = class { constructor() { this.handlers = [] } use(e, t, n) { return this.handlers.push({ fulfilled: e, rejected: t, synchronous: !!n && n.synchronous, runWhen: n ? n.runWhen : null }), this.handlers.length - 1 } eject(e) { this.handlers[e] && (this.handlers[e] = null) } clear() { this.handlers && (this.handlers = []) } forEach(e) { kF.forEach(this.handlers, (function (t) { null !== t && e(t) })) } }, BF = { silentJSONParsing: !0, forcedJSONParsing: !0, clarifyTimeoutError: !1 }, LF = { isBrowser: !0, classes: { URLSearchParams: "undefined" != typeof URLSearchParams ? URLSearchParams : RF, FormData: "undefined" != typeof FormData ? FormData : null, Blob: "undefined" != typeof Blob ? Blob : null }, protocols: ["http", "https", "file", "blob", "url", "data"] }, jF = "undefined" != typeof window && "undefined" != typeof document, UF = "object" == typeof navigator && navigator || void 0, WF = jF && (!UF || ["ReactNative", "NativeScript", "NS"].indexOf(UF.product) < 0), VF = "undefined" != typeof WorkerGlobalScope && self instanceof WorkerGlobalScope && "function" == typeof self.importScripts, GF = jF && window.location.href || "http://localhost", HF = { ...D, ...LF }; const qF = function (e) { function t(e, n, r, i) { let a = e[i++]; if ("__proto__" === a) return !0; const o = Number.isFinite(+a), s = i >= e.length; if (a = !a && kF.isArray(r) ? r.length : a, s) return kF.hasOwnProp(r, a) ? r[a] = [r[a], n] : r[a] = n, !o; r[a] && kF.isObject(r[a]) || (r[a] = []); return t(e, n, r[a], i) && kF.isArray(r[a]) && (r[a] = function (e) { const t = {}, n = Object.keys(e); let r; const i = n.length; let a; for (r = 0; r < i; r++)a = n[r], t[a] = e[a]; return t }(r[a])), !o } if (kF.isFormData(e) && kF.isFunction(e.entries)) { const n = {}; return kF.forEachEntry(e, ((e, r) => { t(function (e) { return kF.matchAll(/\w+|\[(\w*)]/g, e).map((e => "[]" === e[0] ? "" : e[1] || e[0])) }(e), r, n, 0) })), n } return null }; const YF = { transitional: BF, adapter: ["xhr", "http", "fetch"], transformRequest: [function (e, t) { const n = t.getContentType() || "", r = n.indexOf("application/json") > -1, i = kF.isObject(e); i && kF.isHTMLForm(e) && (e = new FormData(e)); if (kF.isFormData(e)) return r ? JSON.stringify(qF(e)) : e; if (kF.isArrayBuffer(e) || kF.isBuffer(e) || kF.isStream(e) || kF.isFile(e) || kF.isBlob(e) || kF.isReadableStream(e)) return e; if (kF.isArrayBufferView(e)) return e.buffer; if (kF.isURLSearchParams(e)) return t.setContentType("application/x-www-form-urlencoded;charset=utf-8", !1), e.toString(); let a; if (i) { if (n.indexOf("application/x-www-form-urlencoded") > -1) return function (e, t) { return MF(e, new HF.classes.URLSearchParams, Object.assign({ visitor: function (e, t, n, r) { return HF.isNode && kF.isBuffer(e) ? (this.append(t, e.toString("base64")), !1) : r.defaultVisitor.apply(this, arguments) } }, t)) }(e, this.formSerializer).toString(); if ((a = kF.isFileList(e)) || n.indexOf("multipart/form-data") > -1) { const t = this.env && this.env.FormData; return MF(a ? { "files[]": e } : e, t && new t, this.formSerializer) } } return i || r ? (t.setContentType("application/json", !1), function (e, t, n) { if (kF.isString(e)) try { return (t || JSON.parse)(e), kF.trim(e) } catch (e) { if ("SyntaxError" !== e.name) throw e } return (n || JSON.stringify)(e) }(e)) : e }], transformResponse: [function (e) { const t = this.transitional || YF.transitional, n = t && t.forcedJSONParsing, r = "json" === this.responseType; if (kF.isResponse(e) || kF.isReadableStream(e)) return e; if (e && kF.isString(e) && (n && !this.responseType || r)) { const n = !(t && t.silentJSONParsing) && r; try { return JSON.parse(e) } catch (e) { if (n) { if ("SyntaxError" === e.name) throw AF.from(e, AF.ERR_BAD_RESPONSE, this, null, this.response); throw e } } } return e }], timeout: 0, xsrfCookieName: "XSRF-TOKEN", xsrfHeaderName: "X-XSRF-TOKEN", maxContentLength: -1, maxBodyLength: -1, env: { FormData: HF.classes.FormData, Blob: HF.classes.Blob }, validateStatus: function (e) { return e >= 200 && e < 300 }, headers: { common: { Accept: "application/json, text/plain, */*", "Content-Type": void 0 } } }; kF.forEach(["delete", "get", "head", "post", "put", "patch"], (e => { YF.headers[e] = {} })); const XF = YF, KF = kF.toObjectSet(["age", "authorization", "content-length", "content-type", "etag", "expires", "from", "host", "if-modified-since", "if-unmodified-since", "last-modified", "location", "max-forwards", "proxy-authorization", "referer", "retry-after", "user-agent"]), ZF = Symbol("internals"); function JF(e) { return e && String(e).trim().toLowerCase() } function QF(e) { return !1 === e || null == e ? e : kF.isArray(e) ? e.map(QF) : String(e) } function eD(e, t, n, r, i) { return kF.isFunction(r) ? r.call(this, t, n) : (i && (t = n), kF.isString(t) ? kF.isString(r) ? -1 !== t.indexOf(r) : kF.isRegExp(r) ? r.test(t) : void 0 : void 0) } class tD { constructor(e) { e && this.set(e) } set(e, t, n) { const r = this; function i(e, t, n) { const i = JF(t); if (!i) throw new Error("header name must be a non-empty string"); const a = kF.findKey(r, i); (!a || void 0 === r[a] || !0 === n || void 0 === n && !1 !== r[a]) && (r[a || t] = QF(e)) } const a = (e, t) => kF.forEach(e, ((e, n) => i(e, n, t))); if (kF.isPlainObject(e) || e instanceof this.constructor) a(e, t); else if (kF.isString(e) && (e = e.trim()) && !/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())) a((e => { const t = {}; let n, r, i; return e && e.split("\n").forEach((function (e) { i = e.indexOf(":"), n = e.substring(0, i).trim().toLowerCase(), r = e.substring(i + 1).trim(), !n || t[n] && KF[n] || ("set-cookie" === n ? t[n] ? t[n].push(r) : t[n] = [r] : t[n] = t[n] ? t[n] + ", " + r : r) })), t })(e), t); else if (kF.isHeaders(e)) for (const [t, r] of e.entries()) i(r, t, n); else null != e && i(t, e, n); return this } get(e, t) { if (e = JF(e)) { const n = kF.findKey(this, e); if (n) { const e = this[n]; if (!t) return e; if (!0 === t) return function (e) { const t = Object.create(null), n = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g; let r; for (; r = n.exec(e);)t[r[1]] = r[2]; return t }(e); if (kF.isFunction(t)) return t.call(this, e, n); if (kF.isRegExp(t)) return t.exec(e); throw new TypeError("parser must be boolean|regexp|function") } } } has(e, t) { if (e = JF(e)) { const n = kF.findKey(this, e); return !(!n || void 0 === this[n] || t && !eD(0, this[n], n, t)) } return !1 } delete(e, t) { const n = this; let r = !1; function i(e) { if (e = JF(e)) { const i = kF.findKey(n, e); !i || t && !eD(0, n[i], i, t) || (delete n[i], r = !0) } } return kF.isArray(e) ? e.forEach(i) : i(e), r } clear(e) { const t = Object.keys(this); let n = t.length, r = !1; for (; n--;) { const i = t[n]; e && !eD(0, this[i], i, e, !0) || (delete this[i], r = !0) } return r } normalize(e) { const t = this, n = {}; return kF.forEach(this, ((r, i) => { const a = kF.findKey(n, i); if (a) return t[a] = QF(r), void delete t[i]; const o = e ? function (e) { return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, ((e, t, n) => t.toUpperCase() + n)) }(i) : String(i).trim(); o !== i && delete t[i], t[o] = QF(r), n[o] = !0 })), this } concat(...e) { return this.constructor.concat(this, ...e) } toJSON(e) { const t = Object.create(null); return kF.forEach(this, ((n, r) => { null != n && !1 !== n && (t[r] = e && kF.isArray(n) ? n.join(", ") : n) })), t } [Symbol.iterator]() { return Object.entries(this.toJSON())[Symbol.iterator]() } toString() { return Object.entries(this.toJSON()).map((([e, t]) => e + ": " + t)).join("\n") } get [Symbol.toStringTag]() { return "AxiosHeaders" } static from(e) { return e instanceof this ? e : new this(e) } static concat(e, ...t) { const n = new this(e); return t.forEach((e => n.set(e))), n } static accessor(e) { const t = (this[ZF] = this[ZF] = { accessors: {} }).accessors, n = this.prototype; function r(e) { const r = JF(e); t[r] || (!function (e, t) { const n = kF.toCamelCase(" " + t);["get", "set", "has"].forEach((r => { Object.defineProperty(e, r + n, { value: function (e, n, i) { return this[r].call(this, t, e, n, i) }, configurable: !0 }) })) }(n, e), t[r] = !0) } return kF.isArray(e) ? e.forEach(r) : r(e), this } } tD.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]), kF.reduceDescriptors(tD.prototype, (({ value: e }, t) => { let n = t[0].toUpperCase() + t.slice(1); return { get: () => e, set(e) { this[n] = e } } })), kF.freezeMethods(tD); const nD = tD; function rD(e, t) { const n = this || XF, r = t || n, i = nD.from(r.headers); let a = r.data; return kF.forEach(e, (function (e) { a = e.call(n, a, i.normalize(), t ? t.status : void 0) })), i.normalize(), a } function iD(e) { return !(!e || !e.__CANCEL__) } function aD(e, t, n) { AF.call(this, null == e ? "canceled" : e, AF.ERR_CANCELED, t, n), this.name = "CanceledError" } kF.inherits(aD, AF, { __CANCEL__: !0 }); const oD = aD; function sD(e, t, n) { const r = n.config.validateStatus; n.status && r && !r(n.status) ? t(new AF("Request failed with status code " + n.status, [AF.ERR_BAD_REQUEST, AF.ERR_BAD_RESPONSE][Math.floor(n.status / 100) - 4], n.config, n.request, n)) : e(n) } const uD = function (e, t) { e = e || 10; const n = new Array(e), r = new Array(e); let i, a = 0, o = 0; return t = void 0 !== t ? t : 1e3, function (s) { const u = Date.now(), l = r[o]; i || (i = u), n[a] = s, r[a] = u; let c = o, h = 0; for (; c !== a;)h += n[c++], c %= e; if (a = (a + 1) % e, a === o && (o = (o + 1) % e), u - i < t) return; const d = l && u - l; return d ? Math.round(1e3 * h / d) : void 0 } }; const lD = function (e, t) { let n, r, i = 0, a = 1e3 / t; const o = (t, a = Date.now()) => { i = a, n = null, r && (clearTimeout(r), r = null), e.apply(null, t) }; return [(...e) => { const t = Date.now(), s = t - i; s >= a ? o(e, t) : (n = e, r || (r = setTimeout((() => { r = null, o(n) }), a - s))) }, () => n && o(n)] }, cD = (e, t, n = 3) => { let r = 0; const i = uD(50, 250); return lD((n => { const a = n.loaded, o = n.lengthComputable ? n.total : void 0, s = a - r, u = i(s); r = a; e({ loaded: a, total: o, progress: o ? a / o : void 0, bytes: s, rate: u || void 0, estimated: u && o && a <= o ? (o - a) / u : void 0, event: n, lengthComputable: null != o, [t ? "download" : "upload"]: !0 }) }), n) }, hD = (e, t) => { const n = null != e; return [r => t[0]({ lengthComputable: n, total: e, loaded: r }), t[1]] }, dD = e => (...t) => kF.asap((() => e(...t))), fD = HF.hasStandardBrowserEnv ? (pD = new URL(HF.origin), mD = HF.navigator && /(msie|trident)/i.test(HF.navigator.userAgent), e => (e = new URL(e, HF.origin), pD.protocol === e.protocol && pD.host === e.host && (mD || pD.port === e.port))) : () => !0; var pD, mD; const gD = HF.hasStandardBrowserEnv ? { write(e, t, n, r, i, a) { const o = [e + "=" + encodeURIComponent(t)]; kF.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), kF.isString(r) && o.push("path=" + r), kF.isString(i) && o.push("domain=" + i), !0 === a && o.push("secure"), document.cookie = o.join("; ") }, read(e) { const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)")); return t ? decodeURIComponent(t[3]) : null }, remove(e) { this.write(e, "", Date.now() - 864e5) } } : { write() { }, read: () => null, remove() { } }; function yD(e, t) { return e && !/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t) ? function (e, t) { return t ? e.replace(/\/?\/$/, "") + "/" + t.replace(/^\/+/, "") : e }(e, t) : t } const bD = e => e instanceof nD ? { ...e } : e; function vD(e, t) { t = t || {}; const n = {}; function r(e, t, n, r) { return kF.isPlainObject(e) && kF.isPlainObject(t) ? kF.merge.call({ caseless: r }, e, t) : kF.isPlainObject(t) ? kF.merge({}, t) : kF.isArray(t) ? t.slice() : t } function i(e, t, n, i) { return kF.isUndefined(t) ? kF.isUndefined(e) ? void 0 : r(void 0, e, 0, i) : r(e, t, 0, i) } function a(e, t) { if (!kF.isUndefined(t)) return r(void 0, t) } function o(e, t) { return kF.isUndefined(t) ? kF.isUndefined(e) ? void 0 : r(void 0, e) : r(void 0, t) } function s(n, i, a) { return a in t ? r(n, i) : a in e ? r(void 0, n) : void 0 } const u = { url: a, method: a, data: a, baseURL: o, transformRequest: o, transformResponse: o, paramsSerializer: o, timeout: o, timeoutMessage: o, withCredentials: o, withXSRFToken: o, adapter: o, responseType: o, xsrfCookieName: o, xsrfHeaderName: o, onUploadProgress: o, onDownloadProgress: o, decompress: o, maxContentLength: o, maxBodyLength: o, beforeRedirect: o, transport: o, httpAgent: o, httpsAgent: o, cancelToken: o, socketPath: o, responseEncoding: o, validateStatus: s, headers: (e, t, n) => i(bD(e), bD(t), 0, !0) }; return kF.forEach(Object.keys(Object.assign({}, e, t)), (function (r) { const a = u[r] || i, o = a(e[r], t[r], r); kF.isUndefined(o) && a !== s || (n[r] = o) })), n } const xD = e => { const t = vD({}, e); let n, { data: r, withXSRFToken: i, xsrfHeaderName: a, xsrfCookieName: o, headers: s, auth: u } = t; if (t.headers = s = nD.from(s), t.url = zF(yD(t.baseURL, t.url), e.params, e.paramsSerializer), u && s.set("Authorization", "Basic " + btoa((u.username || "") + ":" + (u.password ? unescape(encodeURIComponent(u.password)) : ""))), kF.isFormData(r)) if (HF.hasStandardBrowserEnv || HF.hasStandardBrowserWebWorkerEnv) s.setContentType(void 0); else if (!1 !== (n = s.getContentType())) { const [e, ...t] = n ? n.split(";").map((e => e.trim())).filter(Boolean) : []; s.setContentType([e || "multipart/form-data", ...t].join("; ")) } if (HF.hasStandardBrowserEnv && (i && kF.isFunction(i) && (i = i(t)), i || !1 !== i && fD(t.url))) { const e = a && o && gD.read(o); e && s.set(a, e) } return t }, wD = "undefined" != typeof XMLHttpRequest && function (e) { return new Promise((function (t, n) { const r = xD(e); let i = r.data; const a = nD.from(r.headers).normalize(); let o, s, u, l, c, { responseType: h, onUploadProgress: d, onDownloadProgress: f } = r; function p() { l && l(), c && c(), r.cancelToken && r.cancelToken.unsubscribe(o), r.signal && r.signal.removeEventListener("abort", o) } let m = new XMLHttpRequest; function g() { if (!m) return; const r = nD.from("getAllResponseHeaders" in m && m.getAllResponseHeaders()); sD((function (e) { t(e), p() }), (function (e) { n(e), p() }), { data: h && "text" !== h && "json" !== h ? m.response : m.responseText, status: m.status, statusText: m.statusText, headers: r, config: e, request: m }), m = null } m.open(r.method.toUpperCase(), r.url, !0), m.timeout = r.timeout, "onloadend" in m ? m.onloadend = g : m.onreadystatechange = function () { m && 4 === m.readyState && (0 !== m.status || m.responseURL && 0 === m.responseURL.indexOf("file:")) && setTimeout(g) }, m.onabort = function () { m && (n(new AF("Request aborted", AF.ECONNABORTED, e, m)), m = null) }, m.onerror = function () { n(new AF("Network Error", AF.ERR_NETWORK, e, m)), m = null }, m.ontimeout = function () { let t = r.timeout ? "timeout of " + r.timeout + "ms exceeded" : "timeout exceeded"; const i = r.transitional || BF; r.timeoutErrorMessage && (t = r.timeoutErrorMessage), n(new AF(t, i.clarifyTimeoutError ? AF.ETIMEDOUT : AF.ECONNABORTED, e, m)), m = null }, void 0 === i && a.setContentType(null), "setRequestHeader" in m && kF.forEach(a.toJSON(), (function (e, t) { m.setRequestHeader(t, e) })), kF.isUndefined(r.withCredentials) || (m.withCredentials = !!r.withCredentials), h && "json" !== h && (m.responseType = r.responseType), f && ([u, c] = cD(f, !0), m.addEventListener("progress", u)), d && m.upload && ([s, l] = cD(d), m.upload.addEventListener("progress", s), m.upload.addEventListener("loadend", l)), (r.cancelToken || r.signal) && (o = t => { m && (n(!t || t.type ? new oD(null, e, m) : t), m.abort(), m = null) }, r.cancelToken && r.cancelToken.subscribe(o), r.signal && (r.signal.aborted ? o() : r.signal.addEventListener("abort", o))); const y = function (e) { const t = /^([-+\w]{1,25})(:?\/\/|:)/.exec(e); return t && t[1] || "" }(r.url); y && -1 === HF.protocols.indexOf(y) ? n(new AF("Unsupported protocol " + y + ":", AF.ERR_BAD_REQUEST, e)) : m.send(i || null) })) }, kD = (e, t) => { const { length: n } = e = e ? e.filter(Boolean) : []; if (t || n) { let n, r = new AbortController; const i = function (e) { if (!n) { n = !0, o(); const t = e instanceof Error ? e : this.reason; r.abort(t instanceof AF ? t : new oD(t instanceof Error ? t.message : t)) } }; let a = t && setTimeout((() => { a = null, i(new AF(`timeout ${t} of ms exceeded`, AF.ETIMEDOUT)) }), t); const o = () => { e && (a && clearTimeout(a), a = null, e.forEach((e => { e.unsubscribe ? e.unsubscribe(i) : e.removeEventListener("abort", i) })), e = null) }; e.forEach((e => e.addEventListener("abort", i))); const { signal: s } = r; return s.unsubscribe = () => kF.asap(o), s } }, SD = function* (e, t) { let n = e.byteLength; if (!t || n < t) return void (yield e); let r, i = 0; for (; i < n;)r = i + t, yield e.slice(i, r), i = r }, _D = async function* (e) { if (e[Symbol.asyncIterator]) return void (yield* e); const t = e.getReader(); try { for (; ;) { const { done: e, value: n } = await t.read(); if (e) break; yield n } } finally { await t.cancel() } }, CD = (e, t, n, r) => { const i = async function* (e, t) { for await (const n of _D(e)) yield* SD(n, t) }(e, t); let a, o = 0, s = e => { a || (a = !0, r && r(e)) }; return new ReadableStream({ async pull(e) { try { const { done: t, value: r } = await i.next(); if (t) return s(), void e.close(); let a = r.byteLength; if (n) { let e = o += a; n(e) } e.enqueue(new Uint8Array(r)) } catch (e) { throw s(e), e } }, cancel: e => (s(e), i.return()) }, { highWaterMark: 2 }) }, AD = "function" == typeof fetch && "function" == typeof Request && "function" == typeof Response, TD = AD && "function" == typeof ReadableStream, ED = AD && ("function" == typeof TextEncoder ? (ND = new TextEncoder, e => ND.encode(e)) : async e => new Uint8Array(await new Response(e).arrayBuffer())); var ND; const ID = (e, ...t) => { try { return !!e(...t) } catch (e) { return !1 } }, MD = TD && ID((() => { let e = !1; const t = new Request(HF.origin, { body: new ReadableStream, method: "POST", get duplex() { return e = !0, "half" } }).headers.has("Content-Type"); return e && !t })), FD = TD && ID((() => kF.isReadableStream(new Response("").body))), DD = { stream: FD && (e => e.body) }; var $D; AD && ($D = new Response, ["text", "arrayBuffer", "blob", "formData", "stream"].forEach((e => { !DD[e] && (DD[e] = kF.isFunction($D[e]) ? t => t[e]() : (t, n) => { throw new AF(`Response type '${e}' is not supported`, AF.ERR_NOT_SUPPORT, n) }) }))); const RD = async (e, t) => { const n = kF.toFiniteNumber(e.getContentLength()); return null == n ? (async e => { if (null == e) return 0; if (kF.isBlob(e)) return e.size; if (kF.isSpecCompliantForm(e)) { const t = new Request(HF.origin, { method: "POST", body: e }); return (await t.arrayBuffer()).byteLength } return kF.isArrayBufferView(e) || kF.isArrayBuffer(e) ? e.byteLength : (kF.isURLSearchParams(e) && (e += ""), kF.isString(e) ? (await ED(e)).byteLength : void 0) })(t) : n }, OD = { http: null, xhr: wD, fetch: AD && (async e => { let { url: t, method: n, data: r, signal: i, cancelToken: a, timeout: o, onDownloadProgress: s, onUploadProgress: u, responseType: l, headers: c, withCredentials: h = "same-origin", fetchOptions: d } = xD(e); l = l ? (l + "").toLowerCase() : "text"; let f, p = kD([i, a && a.toAbortSignal()], o); const m = p && p.unsubscribe && (() => { p.unsubscribe() }); let g; try { if (u && MD && "get" !== n && "head" !== n && 0 !== (g = await RD(c, r))) { let e, n = new Request(t, { method: "POST", body: r, duplex: "half" }); if (kF.isFormData(r) && (e = n.headers.get("content-type")) && c.setContentType(e), n.body) { const [e, t] = hD(g, cD(dD(u))); r = CD(n.body, 65536, e, t) } } kF.isString(h) || (h = h ? "include" : "omit"); const i = "credentials" in Request.prototype; f = new Request(t, { ...d, signal: p, method: n.toUpperCase(), headers: c.normalize().toJSON(), body: r, duplex: "half", credentials: i ? h : void 0 }); let a = await fetch(f); const o = FD && ("stream" === l || "response" === l); if (FD && (s || o && m)) { const e = {};["status", "statusText", "headers"].forEach((t => { e[t] = a[t] })); const t = kF.toFiniteNumber(a.headers.get("content-length")), [n, r] = s && hD(t, cD(dD(s), !0)) || []; a = new Response(CD(a.body, 65536, n, (() => { r && r(), m && m() })), e) } l = l || "text"; let y = await DD[kF.findKey(DD, l) || "text"](a, e); return !o && m && m(), await new Promise(((t, n) => { sD(t, n, { data: y, headers: nD.from(a.headers), status: a.status, statusText: a.statusText, config: e, request: f }) })) } catch (t) { if (m && m(), t && "TypeError" === t.name && /fetch/i.test(t.message)) throw Object.assign(new AF("Network Error", AF.ERR_NETWORK, e, f), { cause: t.cause || t }); throw AF.from(t, t && t.code, e, f) } }) }; kF.forEach(OD, ((e, t) => { if (e) { try { Object.defineProperty(e, "name", { value: t }) } catch (e) { } Object.defineProperty(e, "adapterName", { value: t }) } })); const zD = e => `- ${e}`, PD = e => kF.isFunction(e) || null === e || !1 === e, BD = e => { e = kF.isArray(e) ? e : [e]; const { length: t } = e; let n, r; const i = {}; for (let a = 0; a < t; a++) { let t; if (n = e[a], r = n, !PD(n) && (r = OD[(t = String(n)).toLowerCase()], void 0 === r)) throw new AF(`Unknown adapter '${t}'`); if (r) break; i[t || "#" + a] = r } if (!r) { const e = Object.entries(i).map((([e, t]) => `adapter ${e} ` + (!1 === t ? "is not supported by the environment" : "is not available in the build"))); let n = t ? e.length > 1 ? "since :\n" + e.map(zD).join("\n") : " " + zD(e[0]) : "as no adapter specified"; throw new AF("There is no suitable adapter to dispatch the request " + n, "ERR_NOT_SUPPORT") } return r }; function LD(e) { if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted) throw new oD(null, e) } function jD(e) { LD(e), e.headers = nD.from(e.headers), e.data = rD.call(e, e.transformRequest), -1 !== ["post", "put", "patch"].indexOf(e.method) && e.headers.setContentType("application/x-www-form-urlencoded", !1); return BD(e.adapter || XF.adapter)(e).then((function (t) { return LD(e), t.data = rD.call(e, e.transformResponse, t), t.headers = nD.from(t.headers), t }), (function (t) { return iD(t) || (LD(e), t && t.response && (t.response.data = rD.call(e, e.transformResponse, t.response), t.response.headers = nD.from(t.response.headers))), Promise.reject(t) })) } const UD = "1.7.8", WD = {};["object", "boolean", "number", "function", "string", "symbol"].forEach(((e, t) => { WD[e] = function (n) { return typeof n === e || "a" + (t < 1 ? "n " : " ") + e } })); const VD = {}; WD.transitional = function (e, t, n) { function r(e, t) { return "[Axios v1.7.8] Transitional option '" + e + "'" + t + (n ? ". " + n : "") } return (n, i, a) => { if (!1 === e) throw new AF(r(i, " has been removed" + (t ? " in " + t : "")), AF.ERR_DEPRECATED); return t && !VD[i] && (VD[i] = !0, console.warn(r(i, " has been deprecated since v" + t + " and will be removed in the near future"))), !e || e(n, i, a) } }, WD.spelling = function (e) { return (t, n) => (console.warn(`${n} is likely a misspelling of ${e}`), !0) }; const GD = { assertOptions: function (e, t, n) { if ("object" != typeof e) throw new AF("options must be an object", AF.ERR_BAD_OPTION_VALUE); const r = Object.keys(e); let i = r.length; for (; i-- > 0;) { const a = r[i], o = t[a]; if (o) { const t = e[a], n = void 0 === t || o(t, a, e); if (!0 !== n) throw new AF("option " + a + " must be " + n, AF.ERR_BAD_OPTION_VALUE) } else if (!0 !== n) throw new AF("Unknown option " + a, AF.ERR_BAD_OPTION) } }, validators: WD }, HD = GD.validators; class qD { constructor(e) { this.defaults = e, this.interceptors = { request: new PF, response: new PF } } async request(e, t) { try { return await this._request(e, t) } catch (e) { if (e instanceof Error) { let t = {}; Error.captureStackTrace ? Error.captureStackTrace(t) : t = new Error; const n = t.stack ? t.stack.replace(/^.+\n/, "") : ""; try { e.stack ? n && !String(e.stack).endsWith(n.replace(/^.+\n.+\n/, "")) && (e.stack += "\n" + n) : e.stack = n } catch (e) { } } throw e } } _request(e, t) { "string" == typeof e ? (t = t || {}).url = e : t = e || {}, t = vD(this.defaults, t); const { transitional: n, paramsSerializer: r, headers: i } = t; void 0 !== n && GD.assertOptions(n, { silentJSONParsing: HD.transitional(HD.boolean), forcedJSONParsing: HD.transitional(HD.boolean), clarifyTimeoutError: HD.transitional(HD.boolean) }, !1), null != r && (kF.isFunction(r) ? t.paramsSerializer = { serialize: r } : GD.assertOptions(r, { encode: HD.function, serialize: HD.function }, !0)), GD.assertOptions(t, { baseUrl: HD.spelling("baseURL"), withXsrfToken: HD.spelling("withXSRFToken") }, !0), t.method = (t.method || this.defaults.method || "get").toLowerCase(); let a = i && kF.merge(i.common, i[t.method]); i && kF.forEach(["delete", "get", "head", "post", "put", "patch", "common"], (e => { delete i[e] })), t.headers = nD.concat(a, i); const o = []; let s = !0; this.interceptors.request.forEach((function (e) { "function" == typeof e.runWhen && !1 === e.runWhen(t) || (s = s && e.synchronous, o.unshift(e.fulfilled, e.rejected)) })); const u = []; let l; this.interceptors.response.forEach((function (e) { u.push(e.fulfilled, e.rejected) })); let c, h = 0; if (!s) { const e = [jD.bind(this), void 0]; for (e.unshift.apply(e, o), e.push.apply(e, u), c = e.length, l = Promise.resolve(t); h < c;)l = l.then(e[h++], e[h++]); return l } c = o.length; let d = t; for (h = 0; h < c;) { const e = o[h++], t = o[h++]; try { d = e(d) } catch (e) { t.call(this, e); break } } try { l = jD.call(this, d) } catch (e) { return Promise.reject(e) } for (h = 0, c = u.length; h < c;)l = l.then(u[h++], u[h++]); return l } getUri(e) { return zF(yD((e = vD(this.defaults, e)).baseURL, e.url), e.params, e.paramsSerializer) } } kF.forEach(["delete", "get", "head", "options"], (function (e) { qD.prototype[e] = function (t, n) { return this.request(vD(n || {}, { method: e, url: t, data: (n || {}).data })) } })), kF.forEach(["post", "put", "patch"], (function (e) { function t(t) { return function (n, r, i) { return this.request(vD(i || {}, { method: e, headers: t ? { "Content-Type": "multipart/form-data" } : {}, url: n, data: r })) } } qD.prototype[e] = t(), qD.prototype[e + "Form"] = t(!0) })); const YD = qD; class XD { constructor(e) { if ("function" != typeof e) throw new TypeError("executor must be a function."); let t; this.promise = new Promise((function (e) { t = e })); const n = this; this.promise.then((e => { if (!n._listeners) return; let t = n._listeners.length; for (; t-- > 0;)n._listeners[t](e); n._listeners = null })), this.promise.then = e => { let t; const r = new Promise((e => { n.subscribe(e), t = e })).then(e); return r.cancel = function () { n.unsubscribe(t) }, r }, e((function (e, r, i) { n.reason || (n.reason = new oD(e, r, i), t(n.reason)) })) } throwIfRequested() { if (this.reason) throw this.reason } subscribe(e) { this.reason ? e(this.reason) : this._listeners ? this._listeners.push(e) : this._listeners = [e] } unsubscribe(e) { if (!this._listeners) return; const t = this._listeners.indexOf(e); -1 !== t && this._listeners.splice(t, 1) } toAbortSignal() { const e = new AbortController, t = t => { e.abort(t) }; return this.subscribe(t), e.signal.unsubscribe = () => this.unsubscribe(t), e.signal } static source() { let e; return { token: new XD((function (t) { e = t })), cancel: e } } } const KD = XD; const ZD = { Continue: 100, SwitchingProtocols: 101, Processing: 102, EarlyHints: 103, Ok: 200, Created: 201, Accepted: 202, NonAuthoritativeInformation: 203, NoContent: 204, ResetContent: 205, PartialContent: 206, MultiStatus: 207, AlreadyReported: 208, ImUsed: 226, MultipleChoices: 300, MovedPermanently: 301, Found: 302, SeeOther: 303, NotModified: 304, UseProxy: 305, Unused: 306, TemporaryRedirect: 307, PermanentRedirect: 308, BadRequest: 400, Unauthorized: 401, PaymentRequired: 402, Forbidden: 403, NotFound: 404, MethodNotAllowed: 405, NotAcceptable: 406, ProxyAuthenticationRequired: 407, RequestTimeout: 408, Conflict: 409, Gone: 410, LengthRequired: 411, PreconditionFailed: 412, PayloadTooLarge: 413, UriTooLong: 414, UnsupportedMediaType: 415, RangeNotSatisfiable: 416, ExpectationFailed: 417, ImATeapot: 418, MisdirectedRequest: 421, UnprocessableEntity: 422, Locked: 423, FailedDependency: 424, TooEarly: 425, UpgradeRequired: 426, PreconditionRequired: 428, TooManyRequests: 429, RequestHeaderFieldsTooLarge: 431, UnavailableForLegalReasons: 451, InternalServerError: 500, NotImplemented: 501, BadGateway: 502, ServiceUnavailable: 503, GatewayTimeout: 504, HttpVersionNotSupported: 505, VariantAlsoNegotiates: 506, InsufficientStorage: 507, LoopDetected: 508, NotExtended: 510, NetworkAuthenticationRequired: 511 }; Object.entries(ZD).forEach((([e, t]) => { ZD[t] = e })); const JD = ZD; const QD = function e(t) { const n = new YD(t), r = FM(YD.prototype.request, n); return kF.extend(r, YD.prototype, n, { allOwnKeys: !0 }), kF.extend(r, n, null, { allOwnKeys: !0 }), r.create = function (n) { return e(vD(t, n)) }, r }(XF); QD.Axios = YD, QD.CanceledError = oD, QD.CancelToken = KD, QD.isCancel = iD, QD.VERSION = UD, QD.toFormData = MF, QD.AxiosError = AF, QD.Cancel = QD.CanceledError, QD.all = function (e) { return Promise.all(e) }, QD.spread = function (e) { return function (t) { return e.apply(null, t) } }, QD.isAxiosError = function (e) { return kF.isObject(e) && !0 === e.isAxiosError }, QD.mergeConfig = vD, QD.AxiosHeaders = nD, QD.formToJSON = e => qF(kF.isHTMLForm(e) ? new FormData(e) : e), QD.getAdapter = BD, QD.HttpStatusCode = JD, QD.default = QD; const e$ = QD; function t$(e) { return new RegExp("^(?:[a-z]+:)?//", "i").test(e) } class n$ { constructor(e, t = "model", n = !0) { const r = n ? function (e) { if (!t$(e) && "undefined" != typeof window) { if (e.startsWith("/")) return window.location.origin + e; let t = window.location.href; return t.endsWith("/") || (t += "/"), t + e } return e }(e) : e, i = {}; if (r.endsWith(".json")) { const e = r.lastIndexOf("/") + 1; this.directory = r.slice(0, e); const n = r.slice(e, -5); n !== t && ["model", "manifest", "metadata"].includes(n) ? console.warn(`Expected a ${t}.json file URL, but received a ${n}.json file instead.`) : i[t] = r } else this.directory = r.endsWith("/") ? r : `${r}/`; this.modelUrl = i.model || this.getPath("model.json"), this.metadataUrl = i.metadata || this.getPath("metadata.json"), this.manifestUrl = i.manifest || this.getPath("manifest.json") } getPath(e) { return t$(e) ? e : this.directory + e } async loadManifestJson() { try { return (await e$.get(this.manifestUrl)).data } catch (e) { throw new Error(`Error loading manifest.json file from URL ${this.manifestUrl}: ${String(e)}`) } } async loadMetadataJson() { try { return (await e$.get(this.metadataUrl)).data } catch (e) { throw new Error(`Error loading metadata.json file from URL ${this.metadataUrl}: ${String(e)}`) } } async loadLayersModel(e) { const t = e ? this.getPath(e) : this.modelUrl; try { return await ts(t) } catch (e) { throw new Error(`Error loading model from URL ${t}: ${String(e)}`) } } } function r$(e, t, n) { return new n$(e, t, n) } class i$ { constructor(e) { this.options = e || {} } normalizeValue(e, t, n) { return t === n ? 0 : (e - t) / (n - t) } unnormalizeValue(e, t, n) { return t === n ? t : e * (n - t) + t } getMin(e) { return e.reduce(((e, t) => Math.min(e, t))) } getMax(e) { return e.reduce(((e, t) => Math.max(e, t))) } isJsonOrString(e) { try { JSON.parse(e) } catch (e) { return !1 } return !0 } zipArrays(e, t) { if (e.length !== t.length) return console.error("arrays do not have the same length"), []; return [...new Array(e.length).fill(null)].map(((n, r) => ({ ...e[r], ...t[r] }))) } createLabelsFromArrayValues(e, t) { let n; return Array.isArray(e) && (n = e.map(((e, n) => `${t}_${n}`))), n } formatDataAsObject(e, t) { let n = {}; if (Array.isArray(e)) return e.forEach(((e, r) => { const i = t[r]; n[i] = e })), n; if ("object" == typeof e) return n = e, n; throw new Error("input provided is not supported or does not match your output label specifications") } getDataType(e) { let t = typeof e; return "object" === t && Array.isArray(e) && (t = "array"), t } } const a$ = new i$; const o$ = class { constructor() { this.meta = { inputUnits: null, outputUnits: null, inputs: {}, outputs: {}, isNormalized: !1 }, this.isMetadataReady = !1, this.isWarmedUp = !1, this.data = { raw: [] } } createMetadata(e = null) { this.getDTypesFromData(), this.getDataStats(), this.getDataOneHot(), this.getDataUnits(e), this.isMetadataReady = !0 } getDataStats() { this.meta.inputs = this.getInputMetaStats(this.meta.inputs, "xs"), this.meta.outputs = this.getInputMetaStats(this.meta.outputs, "ys") } getInputMetaStats(e, t) { const n = Object.assign({}, e); return Object.keys(n).forEach((e => { if ("string" === n[e].dtype) n[e].min = 0, n[e].max = 1; else if ("number" === n[e].dtype) { const r = this.data.raw.map((n => n[t][e])); n[e].min = a$.getMin(r), n[e].max = a$.getMax(r) } else if ("array" === n[e].dtype) { const r = this.data.raw.map((n => n[t][e])).flat(); n[e].min = a$.getMin(r), n[e].max = a$.getMax(r) } })), n } getDataUnits(e = null) { this.meta.inputUnits = e || [this.getInputMetaUnits(this.meta.inputs)].flat(), this.meta.outputUnits = this.getInputMetaUnits(this.meta.outputs) } getInputMetaUnits(e) { let t = 0; return Object.entries(e).forEach((e => { const { dtype: n } = e[1]; if ("number" === n) t += 1; else if ("string" === n) { const { uniqueValues: n } = e[1], r = n.length; t += r } else "array" === n && (t = []) })), t } getDTypesFromData() { const e = { ...this.meta, inputs: {}, outputs: {} }, t = this.data.raw[0], n = Object.keys(t.xs), r = Object.keys(t.ys); n.forEach((n => { e.inputs[n] = { dtype: a$.getDataType(t.xs[n]) } })), r.forEach((n => { e.outputs[n] = { dtype: a$.getDataType(t.ys[n]) } })), this.meta = e } addData(e, t) { this.data.raw.push({ xs: e, ys: t }) } convertRawToTensors(e) { const t = Object.assign({}, this.meta), n = e.length; return P.tidy((() => { const r = [], i = []; e.forEach((e => { const n = Object.keys(t.inputs).map((t => e.xs[t])).flat(); r.push(n); const a = Object.keys(t.outputs).map((t => e.ys[t])).flat(); i.push(a) })); return { inputs: P.tensor(r.flat(), [n, ...t.inputUnits]), outputs: P.tensor(i.flat(), [n, t.outputUnits]) } })) } normalizeDataRaw() { const e = this.normalizeInputData(this.meta.inputs, "xs"), t = this.normalizeInputData(this.meta.outputs, "ys"); return a$.zipArrays(e, t) } normalizeInputData(e, t) { const n = this.data.raw, r = n.length, i = Object.assign({}, e), a = {}; Object.keys(i).forEach((e => { const r = { min: i[e].min, max: i[e].max }, o = n.map((n => n[t][e])); "string" === i[e].dtype ? (r.legend = i[e].legend, a[e] = this.normalizeArray(o, r)) : "number" === i[e].dtype ? a[e] = this.normalizeArray(o, r) : "array" === i[e].dtype && (a[e] = o.map((e => this.normalizeArray(e, r)))) })); return [...new Array(r).fill(null)].map(((e, n) => { const r = { [t]: {} }; return Object.keys(i).forEach((e => { r[t][e] = a[e][n] })), r })) } normalizeArray(e, t) { const { min: n, max: r } = t; if (t.legend) { return e.map((e => t.legend[e] ? t.legend[e] : e)) } if (n === r && console.warn("šŖ ml5.js NeuralNetwork warns: Normalization failed, all data entries for an input parameter are identical (min === max). The data for this input parameter will be set to 0, effectively removing it from the model. Please check your input data."), e.every((e => "number" == typeof e))) { return e.map((e => a$.normalizeValue(e, n, r))) } throw new Error("error in inputArray of normalizeArray() function") } unnormalizeArray(e, t) { const { min: n, max: r } = t; if (t.legend) { const n = e.map((e => { let n; return Object.entries(t.legend).forEach((t => { const r = t[0], i = t[1]; e.map(((e, t) => e === i[t])).every((e => !0 === e)) && (n = r) })), n })); return n } if (e.every((e => "number" == typeof e))) { return e.map((e => a$.unnormalizeValue(e, n, r))) } throw new Error("error in inputArray of normalizeArray() function") } applyOneHotEncodingsToDataRaw() { const e = Object.assign({}, this.meta); return this.data.raw.map((t => { const n = { ...t.xs }, r = { ...t.ys }; return Object.keys(e.inputs).forEach((r => { e.inputs[r].legend && (n[r] = e.inputs[r].legend[t.xs[r]]) })), Object.keys(e.outputs).forEach((n => { e.outputs[n].legend && (r[n] = e.outputs[n].legend[t.ys[n]]) })), { xs: n, ys: r } })) } getDataOneHot() { this.meta.inputs = this.getInputMetaOneHot(this.meta.inputs, "xs"), this.meta.outputs = this.getInputMetaOneHot(this.meta.outputs, "ys") } getInputMetaOneHot(e, t) { const n = Object.assign({}, e); return Object.entries(n).forEach((e => { const r = e[0], { dtype: i } = e[1]; if ("string" === i) { const e = [...new Set(this.data.raw.map((e => e[t][r])))], i = this.createOneHotEncodings(e); n[r] = { ...n[r], ...i } } })), n } createOneHotEncodings(e) { return P.tidy((() => { const t = { uniqueValues: e, legend: {} }, n = e; if (n.length < 2) throw new Error(`šŖ ml5.js classification error: Classification requires at least 2 different classes, but only found ${n.length} class: "${n[0] || "undefined"}". Please add training data with multiple different output values.`); const r = n.map(((e, t) => t)), i = P.oneHot(P.tensor1d(r, "int32"), n.length).arraySync(); return n.forEach(((e, n) => { t.legend[e] = i[n] })), t })) } async loadDataFromUrl(e, t, n) { try { if (e.endsWith(".csv")) await this.loadCSV(e, t, n); else if (e.endsWith(".json")) await this.loadJSON(e, t, n); else { if (!e.includes("blob")) throw new Error("Not a valid data format. Must be csv or json"); await this.loadBlob(e, t, n) } } catch (e) { throw console.error(e), new Error(e) } } async loadJSON(e, t, n) { try { let r; if (e instanceof Object) r = Object.assign({}, e); else { const { data: t } = await e$.get(e); r = t } this.formatRawData(r, t, n) } catch (e) { throw console.error("error loading json"), new Error(e) } } async loadCSV(e, t, n) { try { const r = Jf(e), i = { entries: await r.toArray() }; this.formatRawData(i, t, n) } catch (e) { throw console.error("error loading csv", e), new Error(e) } } async loadBlob(e, t, n) { try { const { data: r } = await e$.get(e), i = r; if (a$.isJsonOrString(i)) { const e = JSON.parse(i); await this.loadJSON(e, t, n) } else { const e = this.csvToJSON(i); await this.loadJSON(e, t, n) } } catch (e) { throw console.log("mmm might be passing in a string or something!", e), new Error(e) } } async loadData(e) { try { let t; if ("string" != typeof e) { const n = e[0]; if ((new FileReader).readAsText(n), n.name.includes(".json")) { const e = await n.text(); t = JSON.parse(e) } else console.log('data must be a json object containing an array called "data" or "entries') } else { let n = await e$.get(e, { responseType: "text" }); a$.isJsonOrString(n.data) ? t = JSON.parse(n.data) : console.error("šŖ ml5.js error: `NeuralNetwork.loadData` only accepts JSON data.") } this.data.raw = this.findEntries(t), !this.data.raw.length > 0 && console.error("šŖ ml5.js error: `NeuralNetwork.loadData` only accepts JSON objects with a 'data' property.") } catch (e) { throw new Error(e) } } async saveData(e) { const t = new Date; let n = `${`${String(t.getFullYear())}-${String(t.getMonth() + 1)}-${String(t.getDate())}`}_${`${String(t.getHours())}-${String(t.getMinutes())}-${String(t.getSeconds())}`}`; e && (n = e); const r = { data: this.data.raw }; await EM(JSON.stringify(r), `${n}.json`, "text/plain") } async saveMeta(e = "model") { await EM(JSON.stringify(this.meta), `${e}_meta.json`, "text/plain") } async loadMeta(e) { if (e instanceof FileList) { const t = Array.from(e).find((e => e.name.includes("_meta.json"))); if (!t) return void console.warn("no model_meta.json file found in FileList"); const n = await t.text(); this.meta = JSON.parse(n) } else if (e instanceof Object) { const t = await e$.get(e.metadata); this.meta = t.data } else { const t = r$(e).getPath("model_meta.json"), n = await e$.get(t); this.meta = n.data } this.isMetadataReady = !0, this.isWarmedUp = !0 } formatRawData(e, t, n) { const r = this.findEntries(e); !r.length > 0 && console.log("your data must be contained in an array in \n\n a property called 'entries' or 'data' of your json object"); const i = r.map(((e, r) => { const i = { xs: {}, ys: {} }; return t.forEach((t => { void 0 !== e[t] ? i.xs[t] = e[t] : console.error(`the input label ${t} does not exist at row ${r}`) })), n.forEach((t => { void 0 !== e[t] ? i.ys[t] = e[t] : console.error(`the output label ${t} does not exist at row ${r}`) })), i })); this.data.raw = i } csvToJSON(e) { const t = e.split("\n"), n = [], r = t[0].split(","); for (let e = 1; e < t.length; e += 1) { const i = {}, a = t[e].split(","); r.forEach(((e, t) => { i[e] = a[t] })), n.push(i) } return { entries: n } } findEntries(e) { const t = Object.assign({}, e); if (t.entries && t.entries instanceof Array) return t.entries; if (t.data && t.data instanceof Array) return t.data; return Object.keys(t).forEach((e => { if ("object" == typeof t[e]) return this.findEntries(t[e]) })), t } getData() { return this.data.raw } }; var s$ = n(9778); const u$ = class { constructor() { this.config = { height: 300 } } modelSummary(e, t) { const n = { ...e }; s$.show.modelSummary(n, t) } scatterplot(e, t, n) { const r = n.map((n => ({ x: n.xs[e], y: n.ys[t] }))), i = { xLabel: "X", yLabel: "Y", height: this.config.height }; s$.render.scatterplot({ name: "debug mode" }, r, i) } scatterplotAll(e, t, n) { let r = []; e.forEach((e => { t.forEach((t => { const i = n.map((n => ({ x: n.xs[e], y: n.ys[t] }))); r = [...r, ...i] })) })); const i = { xLabel: "X", yLabel: "Y", height: this.config.height }; s$.render.scatterplot({ name: "debug mode" }, r, i) } barchart(e, t, n) { const r = n.map((n => ({ value: n.xs[e], index: n.ys[t] }))), i = { xLabel: "label", yLabel: "value", height: this.config.height }; console.log(i); s$.render.barchart({ name: "Bar chart" }, r) } trainingVis() { return s$.show.fitCallbacks({ name: "Training Performance" }, ["loss", "accuracy"], { height: this.config.height, callbacks: ["onEpochEnd"] }) } }, l$ = { inputs: [], outputs: [], dataUrl: null, modelUrl: null, layers: [], task: null, debug: !1, learningRate: .2, hiddenUnits: 16, neuroEvolution: !1 }; class c$ { constructor(e, t) { "imageClassification" === e.task && (l$.learningRate = .02), this.options = { ...l$, ...e } || l$, this.neuralNetwork = new MM, this.neuralNetworkData = new o$, this.neuralNetworkVis = new u$, this.data = { training: [] }, this.init = this.init.bind(this), this.addData = this.addData.bind(this), this.loadDataFromUrl = this.loadDataFromUrl.bind(this), this.createMetaData = this.createMetaData.bind(this), this.prepareForTraining = this.prepareForTraining.bind(this), this.normalizeData = this.normalizeData.bind(this), this.normalizeInput = this.normalizeInput.bind(this), this.searchAndFormat = this.searchAndFormat.bind(this), this.formatInputItem = this.formatInputItem.bind(this), this.convertTrainingDataToTensors = this.convertTrainingDataToTensors.bind(this), this.formatInputsForPrediction = this.formatInputsForPrediction.bind(this), this.formatInputsForPredictionAll = this.formatInputsForPredictionAll.bind(this), this.isOneHotEncodedOrNormalized = this.isOneHotEncodedOrNormalized.bind(this), this.train = this.train.bind(this), this.trainInternal = this.trainInternal.bind(this), this.addLayer = this.addLayer.bind(this), this.createNetworkLayers = this.createNetworkLayers.bind(this), this.addDefaultLayers = this.addDefaultLayers.bind(this), this.compile = this.compile.bind(this), this.predict = this.predict.bind(this), this.predictMultiple = this.predictMultiple.bind(this), this.classify = this.classify.bind(this), this.classifyMultiple = this.classifyMultiple.bind(this), this.predictInternal = this.predictInternal.bind(this), this.classifyInternal = this.classifyInternal.bind(this), this.saveData = this.saveData.bind(this), this.loadData = this.loadData.bind(this), this.save = this.save.bind(this), this.load = this.load.bind(this), this.dispose = this.dispose.bind(this), this.mutate = this.mutate.bind(this), this.crossover = this.crossover.bind(this), this.ready = hM(this.init(), t) } async init() { return !0 === this.options.neuroEvolution && this.createLayersNoTraining(), this.options.dataUrl ? await this.loadDataFromUrl() : this.options.modelUrl && await this.load(this.options.modelUrl), this } createLayersNoTraining() { const { inputs: e, outputs: t, task: n } = this.options; if ("classification" === n) for (let n = 0; n < t.length; n += 1) { const r = new Array(e).fill(0); this.addData(r, [t[n]]) } else { const n = new Array(e).fill(0), r = new Array(t).fill(0); this.addData(n, r) } this.neuralNetworkData.createMetadata(), this.addDefaultLayers() } copy() { const e = new c$(this.options); return P.tidy((() => { const t = this.neuralNetwork.model.getWeights(), n = []; for (let e = 0; e < t.length; e += 1)n[e] = t[e].clone(); return e.neuralNetwork.model.setWeights(n), e })) } addData(e, t, n = null) { const { inputs: r, outputs: i } = this.options; let a, o; if (null !== n ? (a = n.inputLabels, o = n.outputLabels) : r.length > 0 && i.length > 0 ? (r.every((e => "string" == typeof e)) && (a = r), i.every((e => "string" == typeof e)) && (o = i)) : "object" == typeof e && "object" == typeof t ? (a = Object.keys(e), o = Object.keys(t)) : (a = a$.createLabelsFromArrayValues(e, "input"), o = a$.createLabelsFromArrayValues(t, "output")), !(a instanceof Array)) throw new Error("inputLabels must be an array"); if (!(o instanceof Array)) throw new Error("outputLabels must be an array"); const s = this.searchAndFormat(e), u = a$.formatDataAsObject(s, a), l = a$.formatDataAsObject(t, o); this.neuralNetworkData.addData(u, l) } async loadDataFromUrl() { const { dataUrl: e, inputs: t, outputs: n } = this.options; await this.neuralNetworkData.loadDataFromUrl(e, t, n), this.createMetaData(), this.prepareForTraining() } createMetaData() { const { inputs: e } = this.options; let t; Array.isArray(e) && e.length > 0 && (t = e.every((e => "number" == typeof e)) && e.length > 0 ? e : null), this.neuralNetworkData.createMetadata(t) } prepareForTraining() { this.data.training = this.neuralNetworkData.applyOneHotEncodingsToDataRaw(), this.neuralNetworkData.isWarmedUp = !0 } normalizeData() { this.neuralNetworkData.isMetadataReady || this.createMetaData(), this.neuralNetworkData.isWarmedUp || this.prepareForTraining(); const e = this.neuralNetworkData.normalizeDataRaw(); this.data.training = e, this.neuralNetworkData.meta.isNormalized = !0 } normalizeInput(e, t, n) { const r = t, { min: i, max: a } = n[r]; return a$.normalizeValue(e, i, a) } searchAndFormat(e) { let t; if (Array.isArray(e)) t = e.map((e => this.formatInputItem(e))); else if ("object" == typeof e) { const n = Object.assign({}, e); Object.keys(e).forEach((t => { const r = e[t]; n[t] = this.formatInputItem(r) })), t = n } return t } formatInputItem(e) { let t, n; return CM(e) ? t = e : "object" == typeof e && CM(e.elt) ? t = e.elt : "object" == typeof e && CM(e.canvas) && (t = e.canvas), n = t ? function (e) { const t = SM(e), n = t.getContext("2d").getImageData(0, 0, t.width, t.height); return Array.from(n.data) }(t) : e, n } convertTrainingDataToTensors() { return this.neuralNetworkData.convertRawToTensors(this.data.training) } formatInputsForPrediction(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r = []; return e instanceof Array ? r = n.map(((n, r) => this.isOneHotEncodedOrNormalized(e[r], n, t.inputs))) : e instanceof Object && (r = n.map((n => this.isOneHotEncodedOrNormalized(e[n], n, t.inputs)))), r = r.flat(), r } formatInputsForPredictionAll(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; return e instanceof Array && e.every((e => Array.isArray(e))) ? (r = e.map((e => this.formatInputsForPrediction(e))), P.tensor(r, [e.length, n.length])) : (r = this.formatInputsForPrediction(e), P.tensor([r])) } isOneHotEncodedOrNormalized(e, t, n) { const r = e, i = t; let a; return "number" != typeof e ? a = n[i].legend[r] : (a = e, this.neuralNetworkData.meta.isNormalized && (a = this.normalizeInput(e, i, n))), a } async train(e, t, n) { let r, i, a; return "object" == typeof e && "function" == typeof t && "function" == typeof n ? (r = e, i = t, a = n) : "object" == typeof e && "function" == typeof t ? (r = e, i = null, a = t) : "function" == typeof e && "function" == typeof t ? (r = {}, i = e, a = t) : (r = {}, i = null, a = e), hM(this.trainInternal(r, i), a) } async trainInternal(e, t) { const n = { epochs: 10, batchSize: 32, validationSplit: .1, whileTraining: null, ...e }; if (!0 === this.options.debug || "true" === this.options.debug ? n.whileTraining = [this.neuralNetworkVis.trainingVis(), { onEpochEnd: t }] : n.whileTraining = [{ onEpochEnd: t }], this.neuralNetworkData.isMetadataReady || this.createMetaData(), this.neuralNetworkData.isWarmedUp || this.prepareForTraining(), !n.inputs && !n.outputs) { const { inputs: e, outputs: t } = this.convertTrainingDataToTensors(); n.inputs = e, n.outputs = t } this.neuralNetwork.isLayered || (this.options.layers = this.createNetworkLayers(this.options.layers)), this.neuralNetwork.isLayered || (this.options.layers = this.addDefaultLayers()), this.neuralNetwork.isCompiled || this.compile(), await this.neuralNetwork.train(n) } addLayer(e) { this.neuralNetwork.addLayer(e) } createNetworkLayers(e) { const t = [...e], { inputUnits: n, outputUnits: r } = this.neuralNetworkData.meta, a = t.length; if (!(t.length >= 2)) return !1; t[0].inputShape = t[0].inputShape ? t[0].inputShape : n; const o = t[a - 1]; return o.units = o.units ? o.units : r, t.forEach((e => { this.addLayer(i[e.type](e)) })), t } addDefaultLayers() { let e; switch (this.options.task.toLowerCase()) { case "classification": return e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "softmax" }], this.createNetworkLayers(e); case "regression": return e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "sigmoid" }], this.createNetworkLayers(e); case "imageclassification": return e = [{ type: "conv2d", filters: 8, kernelSize: 5, strides: 1, activation: "relu", kernelInitializer: "varianceScaling" }, { type: "maxPooling2d", poolSize: [2, 2], strides: [2, 2] }, { type: "conv2d", filters: 16, kernelSize: 5, strides: 1, activation: "relu", kernelInitializer: "varianceScaling" }, { type: "maxPooling2d", poolSize: [2, 2], strides: [2, 2] }, { type: "flatten" }, { type: "dense", kernelInitializer: "varianceScaling", activation: "softmax" }], this.createNetworkLayers(e); default: return console.log("no imputUnits or outputUnits defined"), e = [{ type: "dense", units: this.options.hiddenUnits, activation: "relu" }, { type: "dense", activation: "sigmoid" }], this.createNetworkLayers(e) } } compile() { const e = this.options.learningRate; let t = {}; "classification" === this.options.task || "imageClassification" === this.options.task ? t = { loss: "categoricalCrossentropy", optimizer: P.train.sgd, metrics: ["accuracy"] } : "regression" === this.options.task && (t = { loss: "meanSquaredError", optimizer: P.train.adam, metrics: ["accuracy"] }), t.optimizer = t.optimizer ? this.neuralNetwork.setOptimizerFunction(e, t.optimizer) : this.neuralNetwork.setOptimizerFunction(e, P.train.sgd), this.neuralNetwork.compile(t), this.options.debug && this.neuralNetworkVis.modelSummary({ name: "Model Summary" }, this.neuralNetwork.model) } predictSync(e) { return this.predictSyncInternal(e) } predict(e, t) { return hM(this.predictInternal(e), t) } predictMultiple(e, t) { return hM(this.predictInternal(e), t) } classifySync(e) { return this.classifySyncInternal(e) } classify(e, t) { return hM(this.classifyInternal(e), t) } classifyMultiple(e, t) { return hM(this.classifyInternal(e), t) } predictSyncInternal(e) { const { meta: t } = this.neuralNetworkData, n = this.formatInputsForPredictionAll(e), r = this.neuralNetwork.predictSync(n); if (n.dispose(), null !== t) { const e = Object.keys(t.outputs), n = r.map((n => e.map(((r, i) => { let a, o; if (t.isNormalized) { const { min: e, max: s } = t.outputs[r]; a = a$.unnormalizeValue(n[i], e, s), o = n[i] } else a = n[i]; const s = { [e[i]]: a, label: r, value: a }; return o && (s.unNormalizedValue = o), s })))); return n.length < 2 ? n[0] : n } return r } async predictInternal(e) { const { meta: t } = this.neuralNetworkData, n = this.formatInputsForPredictionAll(e), r = await this.neuralNetwork.predict(n); if (n.dispose(), null !== t) { const e = Object.keys(t.outputs), n = r.map((n => e.map(((r, i) => { let a, o; if (t.isNormalized) { const { min: e, max: s } = t.outputs[r]; a = a$.unnormalizeValue(n[i], e, s), o = n[i] } else a = n[i]; const s = { [e[i]]: a, label: r, value: a }; return o && (s.unNormalizedValue = o), s })))); return n.length < 2 ? n[0] : n } return r } classifySyncInternal(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; if ("imageClassification" === this.options.task) { if (r = this.searchAndFormat(e), r = Array.isArray(r) ? r.flat() : r[n[0]], t.isNormalized) { const { min: e, max: i } = t.inputs[n[0]]; r = this.neuralNetworkData.normalizeArray(Array.from(r), { min: e, max: i }) } else r = Array.from(r); r = P.tensor([r], [1, ...t.inputUnits]) } else r = this.formatInputsForPredictionAll(e); const i = this.neuralNetwork.classifySync(r); if (r.dispose(), null !== t) { const e = Object.keys(t.outputs)[0], n = Object.entries(t.outputs[e].legend), r = i.map((e => n.map(((t, n) => ({ [t[0]]: e[n], label: t[0], confidence: e[n] }))).sort(((e, t) => t.confidence - e.confidence)))); return r.length < 2 ? r[0] : r } return i } async classifyInternal(e) { const { meta: t } = this.neuralNetworkData, n = Object.keys(t.inputs); let r; if ("imageClassification" === this.options.task) { if (r = this.searchAndFormat(e), r = Array.isArray(r) ? r.flat() : r[n[0]], t.isNormalized) { const { min: e, max: i } = t.inputs[n[0]]; r = this.neuralNetworkData.normalizeArray(Array.from(r), { min: e, max: i }) } else r = Array.from(r); r = P.tensor([r], [1, ...t.inputUnits]) } else r = this.formatInputsForPredictionAll(e); const i = await this.neuralNetwork.classify(r); if (r.dispose(), null !== t) { const e = Object.keys(t.outputs)[0], n = Object.entries(t.outputs[e].legend); n.sort(((e, t) => t[1].reduce(((e, t) => 2 * e + t), 0) - e[1].reduce(((e, t) => 2 * e + t), 0))); const r = i.map((e => n.map(((t, n) => ({ [t[0]]: e[n], label: t[0], confidence: e[n] }))).sort(((e, t) => t.confidence - e.confidence)))); return r.length < 2 ? r[0] : r } return i } saveData(e, t) { const n = xM(e, t); return hM(this.neuralNetworkData.saveData(n.name), n.callback) } async loadData(e, t) { return hM(this.neuralNetworkData.loadData(e), t) } async save(e, t) { const n = xM(e, t), r = n.string || "model"; return hM(Promise.all([this.neuralNetwork.save(r), this.neuralNetworkData.saveMeta(r)]), n.callback) } async load(e, t) { return hM(Promise.all([this.neuralNetwork.load(e), this.neuralNetworkData.loadMeta(e)]), t) } dispose() { this.neuralNetwork.dispose() } mutate(e, t) { this.neuralNetwork.mutate(e, t) } crossover(e) { const t = this.copy(); return t.neuralNetwork.crossover(e.neuralNetwork), t } } const h$ = (e, t, n) => { let r, i; e instanceof Object ? (r = e, i = t) : (r = { inputs: e, outputs: t }, i = n); return new c$(r, i) }; var d$ = n(8554), f$ = function () { return f$ = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, f$.apply(this, arguments) }; function p$(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function m$(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(s) { return function (u) { return function (s) { if (n) throw new TypeError("Generator is already executing."); for (; a && (a = 0, s[0] && (o = 0)), o;)try { if (n = 1, r && (i = 2 & s[0] ? r.return : s[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, s[1])).done) return i; switch (r = 0, i && (s = [2 & s[0], i.value]), s[0]) { case 0: case 1: i = s; break; case 4: return o.label++, { value: s[1], done: !1 }; case 5: o.label++, r = s[1], s = [0]; continue; case 7: s = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== s[0] && 2 !== s[0])) { o = 0; continue } if (3 === s[0] && (!i || s[1] > i[0] && s[1] < i[3])) { o.label = s[1]; break } if (6 === s[0] && o.label < i[1]) { o.label = i[1], i = s; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(s); break } i[2] && o.ops.pop(), o.trys.pop(); continue }s = t.call(e, o) } catch (e) { s = [6, e], r = 0 } finally { n = i = 0 } if (5 & s[0]) throw s[1]; return { value: s[0] ? s[1] : void 0, done: !0 } }([s, u]) } } } "function" == typeof SuppressedError && SuppressedError; var g$ = ["wrist", "thumb_cmc", "thumb_mcp", "thumb_ip", "thumb_tip", "index_finger_mcp", "index_finger_pip", "index_finger_dip", "index_finger_tip", "middle_finger_mcp", "middle_finger_pip", "middle_finger_dip", "middle_finger_tip", "ring_finger_mcp", "ring_finger_pip", "ring_finger_dip", "ring_finger_tip", "pinky_finger_mcp", "pinky_finger_pip", "pinky_finger_dip", "pinky_finger_tip"], y$ = { runtime: "mediapipe", maxHands: 2, modelType: "full" }, b$ = function () { function e(e) { var t, n = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.handsSolution = new d$.Hands({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), t = "lite" === e.modelType ? 0 : 1, this.handsSolution.setOptions({ modelComplexity: t, selfieMode: this.selfieMode, maxNumHands: e.maxHands }), this.handsSolution.onResults((function (e) { if (n.height = e.image.height, n.width = e.image.width, n.hands = [], null !== e.multiHandLandmarks) for (var t = e.multiHandedness, r = e.multiHandLandmarks, i = e.multiHandWorldLandmarks, a = 0; a < t.length; a++)n.hands.push(f$(f$({}, n.translateOutput(r[a], i[a])), { score: t[a].score, handedness: t[a].label })) })) } return e.prototype.translateOutput = function (e, t) { var n = this; return { keypoints: e.map((function (e, t) { return { x: e.x * n.width, y: e.y * n.height, score: e.visibility, name: g$[t] } })), keypoints3D: t.map((function (e, t) { return { x: e.x, y: e.y, z: e.z, score: e.visibility, name: g$[t] } })) } }, e.prototype.estimateHands = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r; return m$(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.handsSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.handsSolution.send({ image: e })]; case 4: return i.sent(), [2, this.hands] } })) })) }, e.prototype.dispose = function () { this.handsSolution.close() }, e.prototype.reset = function () { this.handsSolution.reset(), this.width = 0, this.height = 0, this.hands = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.handsSolution.initialize() }, e }(); function v$(e) { return p$(this, void 0, void 0, (function () { var t, n; return m$(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return f$({}, y$); var t = f$({}, e); return t.runtime = "mediapipe", null == t.maxHands && (t.maxHands = y$.maxHands), null == t.modelType && (t.modelType = y$.modelType), t }(e), [4, (n = new b$(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } function x$(e) { return e.width * e.height } function w$(e) { var t = e.xCenter - e.width / 2, n = t + e.width, r = e.yCenter - e.height / 2; return { xMin: t, xMax: n, yMin: r, yMax: r + e.height, width: e.width, height: e.height } } function k$(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function S$(e) { return e - 2 * Math.PI * Math.floor((e + Math.PI) / (2 * Math.PI)) } function _$(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function C$(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function A$(e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = k$(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; C$(t, "targetSize"), C$(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n, r) { var i = e.width, a = e.height, o = r ? -1 : 1, s = Math.cos(e.rotation), u = Math.sin(e.rotation), l = e.xCenter, c = e.yCenter, h = 1 / t, d = 1 / n, f = new Array(16); return f[0] = i * s * o * h, f[1] = -a * u * h, f[2] = 0, f[3] = (-.5 * i * s * o + .5 * a * u + l) * h, f[4] = i * u * o * d, f[5] = a * s * d, f[6] = 0, f[7] = (-.5 * a * s - .5 * i * u * o + c) * d, f[8] = 0, f[9] = 0, f[10] = i * h, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(f) }(u, s.width, s.height, !1), h = (0, P.tidy)((function () { var t = _$(e), n = (0, P.tensor2d)(function (e, t, n) { return C$(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform((0, P.expandDims)((0, P.cast)(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return (0, P.tidy)((function () { return (0, P.add)((0, P.mul)(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } } function T$(e, t, n, r) { return 1 === r ? .5 * (e + t) : e + (t - e) * n / (r - 1) } function E$(e) { return { xCenter: e.xMin + e.width / 2, yCenter: e.yMin + e.height / 2, width: e.width, height: e.height } } function N$(e) { var t = e.relativeKeypoints; if (t.length <= 1) throw new Error("2 or more keypoints required to calculate a rect."); var n = Number.MAX_VALUE, r = Number.MAX_VALUE, i = Number.MIN_VALUE, a = Number.MIN_VALUE; return t.forEach((function (e) { n = Math.min(n, e.x), i = Math.max(i, e.x), r = Math.min(r, e.y), a = Math.max(a, e.y) })), { xCenter: (n + i) / 2, yCenter: (r + a) / 2, width: i - n, height: a - r } } function I$(e, t, n, r) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s; return m$(this, (function (u) { switch (u.label) { case 0: return e.sort((function (e, t) { return Math.max.apply(Math, t.score) - Math.max.apply(Math, e.score) })), r = (0, P.tensor2d)(e.map((function (e) { return [e.locationData.relativeBoundingBox.yMin, e.locationData.relativeBoundingBox.xMin, e.locationData.relativeBoundingBox.yMax, e.locationData.relativeBoundingBox.xMax] }))), i = (0, P.tensor1d)(e.map((function (e) { return e.score[0] }))), [4, P.image.nonMaxSuppressionAsync(r, i, t, n)]; case 1: return [4, (a = u.sent()).array()]; case 2: return o = u.sent(), s = e.filter((function (e, t) { return o.indexOf(t) > -1 })), (0, P.dispose)([r, i, a]), [2, s] } })) })) } function M$(e, t) { return e.map((function (e) { var n = f$(f$({}, e), { x: e.x * t.width, y: e.y * t.height }); return null != e.z && (n.z = e.z * t.width), n })) } function F$(e, t, n) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s; return m$(this, (function (u) { switch (u.label) { case 0: return r = e[0], i = e[1], a = function (e, t, n) { return (0, P.tidy)((function () { var r, i, a, o; n.reverseOutputOrder ? (i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))) : (r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))), i = (0, P.add)((0, P.mul)((0, P.div)(i, n.xScale), t.w), t.x), r = (0, P.add)((0, P.mul)((0, P.div)(r, n.yScale), t.h), t.y), n.applyExponentialOnBoxSize ? (a = (0, P.mul)((0, P.exp)((0, P.div)(a, n.hScale)), t.h), o = (0, P.mul)((0, P.exp)((0, P.div)(o, n.wScale)), t.w)) : (a = (0, P.mul)((0, P.div)(a, n.hScale), t.h), o = (0, P.mul)((0, P.div)(o, n.wScale), t.h)); var s = (0, P.sub)(r, (0, P.div)(a, 2)), u = (0, P.sub)(i, (0, P.div)(o, 2)), l = (0, P.add)(r, (0, P.div)(a, 2)), c = (0, P.add)(i, (0, P.div)(o, 2)), h = (0, P.concat)([(0, P.reshape)(s, [n.numBoxes, 1]), (0, P.reshape)(u, [n.numBoxes, 1]), (0, P.reshape)(l, [n.numBoxes, 1]), (0, P.reshape)(c, [n.numBoxes, 1])], 1); if (n.numKeypoints) for (var d = 0; d < n.numKeypoints; ++d) { var f = n.keypointCoordOffset + d * n.numValuesPerKeypoint, p = void 0, m = void 0; n.reverseOutputOrder ? (p = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), m = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))) : (m = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), p = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))); var g = (0, P.add)((0, P.mul)((0, P.div)(p, n.xScale), t.w), t.x), y = (0, P.add)((0, P.mul)((0, P.div)(m, n.yScale), t.h), t.y); h = (0, P.concat)([h, (0, P.reshape)(g, [n.numBoxes, 1]), (0, P.reshape)(y, [n.numBoxes, 1])], 1) } return h })) }(i, t, n), o = (0, P.tidy)((function () { var e = r; return n.sigmoidScore ? (null != n.scoreClippingThresh && (e = (0, P.clipByValue)(r, -n.scoreClippingThresh, n.scoreClippingThresh)), e = (0, P.sigmoid)(e)) : e })), [4, D$(a, o, n)]; case 1: return s = u.sent(), (0, P.dispose)([a, o]), [2, s] } })) })) } function D$(e, t, n) { return p$(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p; return m$(this, (function (m) { switch (m.label) { case 0: return r = [], [4, e.data()]; case 1: return i = m.sent(), [4, t.data()]; case 2: for (a = m.sent(), o = 0; o < n.numBoxes; ++o)if (!(null != n.minScoreThresh && a[o] < n.minScoreThresh || (s = o * n.numCoords, u = $$(i[s + 0], i[s + 1], i[s + 2], i[s + 3], a[o], n.flipVertically, o), (l = u.locationData.relativeBoundingBox).width < 0 || l.height < 0))) { if (n.numKeypoints > 0) for ((c = u.locationData).relativeKeypoints = [], h = n.numKeypoints * n.numValuesPerKeypoint, d = 0; d < h; d += n.numValuesPerKeypoint)f = s + n.keypointCoordOffset + d, p = { x: i[f + 0], y: n.flipVertically ? 1 - i[f + 1] : i[f + 1] }, c.relativeKeypoints.push(p); r.push(u) } return [2, r] } })) })) } function $$(e, t, n, r, i, a, o) { return { score: [i], ind: o, locationData: { relativeBoundingBox: { xMin: t, yMin: a ? 1 - n : e, xMax: r, yMax: a ? 1 - e : n, width: r - t, height: n - e } } } } function R$(e, t) { return "none" === e ? t : function (e) { return 1 / (1 + Math.exp(-e)) }(t) } function O$(e, t, n, r) { return p$(this, void 0, void 0, (function () { var i, a, o, s, u, l, c, h; return m$(this, (function (d) { switch (d.label) { case 0: return n = n || t.flipHorizontally || !1, r = r || t.flipVertically || !1, i = e.size, a = i / t.numLandmarks, [4, e.data()]; case 1: for (o = d.sent(), s = [], u = 0; u < t.numLandmarks; ++u)l = u * a, (h = { x: 0, y: 0 }).x = n ? t.inputImageWidth - o[l] : o[l], a > 1 && (h.y = r ? t.inputImageHeight - o[l + 1] : o[l + 1]), a > 2 && (h.z = o[l + 2]), a > 3 && (h.score = R$(t.visibilityActivation, o[l + 3])), s.push(h); for (c = 0; c < s.length; ++c)(h = s[c]).x = h.x / t.inputImageWidth, h.y = h.y / t.inputImageHeight, h.z = h.z / t.inputImageWidth / (t.normalizeZ || 1); return [2, s] } })) })) } function z$(e, t, n) { var r = e.width, i = e.height, a = e.rotation; if (null == n.rotation && null == n.rotationDegree || (a = function (e, t) { return null != t.rotation ? e += t.rotation : null != t.rotationDegree && (e += Math.PI * t.rotationDegree / 180), S$(e) }(a, n)), 0 === a) e.xCenter = e.xCenter + r * n.shiftX, e.yCenter = e.yCenter + i * n.shiftY; else { var o = (t.width * r * n.shiftX * Math.cos(a) - t.height * i * n.shiftY * Math.sin(a)) / t.width, s = (t.width * r * n.shiftX * Math.sin(a) + t.height * i * n.shiftY * Math.cos(a)) / t.height; e.xCenter = e.xCenter + o, e.yCenter = e.yCenter + s } if (n.squareLong) { var u = Math.max(r * t.width, i * t.height); r = u / t.width, i = u / t.height } else if (n.squareShort) { var l = Math.min(r * t.width, i * t.height); r = l / t.width, i = l / t.height } return e.width = r * n.scaleX, e.height = i * n.scaleY, e } var P$, B$ = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 1, featureMapHeight: [], featureMapWidth: [], numLayers: 4, minScale: .1484375, maxScale: .75, inputSizeHeight: 192, inputSizeWidth: 192, anchorOffsetX: .5, anchorOffsetY: .5, strides: [8, 16, 16, 16], aspectRatios: [1], fixedAnchorSize: !0 }, L$ = { runtime: "tfjs", modelType: "full", maxHands: 2, detectorModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1", landmarkModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1" }, j$ = { flipHorizontal: !1, staticImageMode: !1 }, U$ = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 2016, numCoords: 18, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 7, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 192, yScale: 192, hScale: 192, wScale: 192, minScoreThresh: .5 }, W$ = { shiftX: 0, shiftY: -.5, scaleX: 2.6, scaleY: 2.6, squareLong: !0 }, V$ = { shiftX: 0, shiftY: -.1, scaleX: 2, scaleY: 2, squareLong: !0 }, G$ = { outputTensorSize: { width: 192, height: 192 }, keepAspectRatio: !0, outputTensorFloatRange: [0, 1], borderMode: "zero" }, H$ = { outputTensorSize: { width: 224, height: 224 }, keepAspectRatio: !0, outputTensorFloatRange: [0, 1], borderMode: "zero" }, q$ = { numLandmarks: 21, inputImageWidth: 224, inputImageHeight: 224, normalizeZ: .4, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, Y$ = { numLandmarks: 21, inputImageWidth: 1, inputImageHeight: 1, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, X$ = function () { function e(e, t, n) { this.detectorModel = e, this.landmarkModel = t, this.maxHands = n, this.prevHandRectsFromLandmarks = null, this.anchors = function (e) { null == e.reduceBoxesInLowestLayer && (e.reduceBoxesInLowestLayer = !1), null == e.interpolatedScaleAspectRatio && (e.interpolatedScaleAspectRatio = 1), null == e.fixedAnchorSize && (e.fixedAnchorSize = !1); for (var t = [], n = 0; n < e.numLayers;) { for (var r = [], i = [], a = [], o = [], s = n; s < e.strides.length && e.strides[s] === e.strides[n];) { var u = T$(e.minScale, e.maxScale, s, e.strides.length); if (0 === s && e.reduceBoxesInLowestLayer) a.push(1), a.push(2), a.push(.5), o.push(.1), o.push(u), o.push(u); else { for (var l = 0; l < e.aspectRatios.length; ++l)a.push(e.aspectRatios[l]), o.push(u); if (e.interpolatedScaleAspectRatio > 0) { var c = s === e.strides.length - 1 ? 1 : T$(e.minScale, e.maxScale, s + 1, e.strides.length); o.push(Math.sqrt(u * c)), a.push(e.interpolatedScaleAspectRatio) } } s++ } for (var h = 0; h < a.length; ++h) { var d = Math.sqrt(a[h]); r.push(o[h] / d), i.push(o[h] * d) } var f = 0, p = 0; if (e.featureMapHeight.length > 0) f = e.featureMapHeight[n], p = e.featureMapWidth[n]; else { var m = e.strides[n]; f = Math.ceil(e.inputSizeHeight / m), p = Math.ceil(e.inputSizeWidth / m) } for (var g = 0; g < f; ++g)for (var y = 0; y < p; ++y)for (var b = 0; b < r.length; ++b) { var v = { xCenter: (y + e.anchorOffsetX) / p, yCenter: (g + e.anchorOffsetY) / f, width: 0, height: 0 }; e.fixedAnchorSize ? (v.width = 1, v.height = 1) : (v.width = i[b], v.height = r[b]), t.push(v) } n = s } return t }(B$); var r = (0, P.tensor1d)(this.anchors.map((function (e) { return e.width }))), i = (0, P.tensor1d)(this.anchors.map((function (e) { return e.height }))), a = (0, P.tensor1d)(this.anchors.map((function (e) { return e.xCenter }))), o = (0, P.tensor1d)(this.anchors.map((function (e) { return e.yCenter }))); this.anchorTensor = { x: a, y: o, w: r, h: i } } return e.prototype.estimateHands = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m, g, y, b, v, x = this; return m$(this, (function (w) { switch (w.label) { case 0: return n = function (e) { if (null == e) return f$({}, j$); var t = f$({}, e); return null == t.flipHorizontal && (t.flipHorizontal = j$.flipHorizontal), null == t.staticImageMode && (t.staticImageMode = j$.staticImageMode), t }(t), null == e ? (this.reset(), [2, []]) : (r = k$(e), i = (0, P.tidy)((function () { var t = (0, P.cast)(_$(e), "float32"); return n.flipHorizontal && (t = (0, P.squeeze)(P.image.flipLeftRight((0, P.expandDims)(t, 0)), [0])), t })), a = this.prevHandRectsFromLandmarks, n.staticImageMode || null == a || a.length < this.maxHands ? [4, this.detectPalm(i)] : [3, 2]); case 1: return 0 === (s = w.sent()).length ? (this.reset(), i.dispose(), [2, []]) : (u = s.map((function (e) { return x.palmDetectionToRoi(e, r) })), o = u, [3, 3]); case 2: o = a, w.label = 3; case 3: return k = [], [o].forEach((function (e) { return e.forEach((function (e) { (k = k.filter((function (t) { return function (e, t) { var n = w$(e), r = w$(t); if (!function (e, t) { return !(e.xMax < t.xMin || t.xMax < e.xMin || e.yMax < t.yMin || t.yMax < e.yMin) }(n, r)) return 0; var i = x$(function (e, t) { var n = Math.max(e.xMin, t.xMin), r = Math.min(e.xMax, t.xMax), i = Math.max(e.yMin, t.yMin), a = Math.min(e.yMax, t.yMax); return { xMin: n, xMax: r, yMin: i, yMax: a, width: Math.max(r - n, 0), height: Math.max(a - i, 0) } }(n, r)), a = x$(n) + x$(r) - i; return a > 0 ? i / a : 0 }(e, t) <= .5 }))).push(e) })) })), o = k, [4, Promise.all(o.map((function (e) { return x.handLandmarks(e, i) })))]; case 4: for (l = w.sent(), c = [], this.prevHandRectsFromLandmarks = [], h = 0, d = l; h < d.length; h++)null != (f = d[h]) && (p = f.landmarks, m = f.worldLandmarks, g = f.handScore, y = f.handedness, this.prevHandRectsFromLandmarks.push(this.handLandmarksToRoi(p, r)), null != (b = M$(p, r)) && b.forEach((function (e, t) { delete e.z, e.name = g$[t] })), null != (v = m) && v.forEach((function (e, t) { e.name = g$[t] })), c.push({ keypoints: b, keypoints3D: v, handedness: y, score: g })); return i.dispose(), [2, c] }var k })) })) }, e.prototype.dispose = function () { this.detectorModel.dispose(), this.landmarkModel.dispose(), (0, P.dispose)([this.anchorTensor.x, this.anchorTensor.y, this.anchorTensor.w, this.anchorTensor.h]) }, e.prototype.reset = function () { this.prevHandRectsFromLandmarks = null }, e.prototype.detectPalm = function (e) { return p$(this, void 0, void 0, (function () { var t, n, r, i, a, o, s, u, l, c; return m$(this, (function (h) { switch (h.label) { case 0: return t = A$(e, G$), n = t.imageTensor, r = t.padding, i = this.detectorModel.predict(n), a = function (e) { return (0, P.tidy)((function () { var t = function (e) { return (0, P.tidy)((function () { return [(0, P.slice)(e, [0, 0, 0], [1, -1, 1]), (0, P.slice)(e, [0, 0, 1], [1, -1, -1])] })) }(e), n = t[0], r = t[1]; return { boxes: (0, P.squeeze)(r), logits: (0, P.squeeze)(n) } })) }(i), o = a.boxes, [4, F$([s = a.logits, o], this.anchorTensor, U$)]; case 1: return 0 === (u = h.sent()).length ? ((0, P.dispose)([n, i, s, o]), [2, u]) : [4, I$(u, this.maxHands, .3)]; case 2: return l = h.sent(), c = function (e, t) { void 0 === e && (e = []); for (var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom, o = 0; o < e.length; o++) { var s = e[o], u = s.locationData.relativeBoundingBox, l = (u.xMin - n) / (1 - i), c = (u.yMin - r) / (1 - a), h = u.width / (1 - i), d = u.height / (1 - a); u.xMin = l, u.yMin = c, u.width = h, u.height = d, u.xMax = l + h, u.yMax = c + d; var f = s.locationData.relativeKeypoints; f && f.forEach((function (e) { var t = (e.x - n) / (1 - i), o = (e.y - r) / (1 - a); e.x = t, e.y = o })) } return e }(l, r), (0, P.dispose)([n, i, s, o]), [2, c] } })) })) }, e.prototype.palmDetectionToRoi = function (e, t) { return z$(function (e, t, n, r, i) { var a = "rect" === n ? function (e, t, n) { var r, i = e.locationData; if ("boundingbox" === t) r = E$(i.boundingBox); else { r = N$(i); var a = n.width, o = n.height; r.xCenter = Math.round(r.xCenter * a), r.yCenter = Math.round(r.yCenter * o), r.width = Math.round(r.width * a), r.height = Math.round(r.height * o) } return r }(e, t, r) : function (e, t) { var n = e.locationData; return "boundingbox" === t ? E$(n.relativeBoundingBox) : N$(n) }(e, t); return i && (a.rotation = function (e, t, n) { var r, i = e.locationData, a = n.rotationVectorStartKeypointIndex, o = n.rotationVectorEndKeypointIndex; r = n.rotationVectorTargetAngle ? n.rotationVectorTargetAngle : Math.PI * n.rotationVectorTargetAngleDegree / 180; var s = i.relativeKeypoints[a].x * t.width, u = i.relativeKeypoints[a].y * t.height, l = i.relativeKeypoints[o].x * t.width, c = i.relativeKeypoints[o].y * t.height; return S$(r - Math.atan2(-(c - u), l - s)) }(e, r, i)), a }(e, "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 0, rotationVectorEndKeypointIndex: 2, rotationVectorTargetAngleDegree: 90 }), t, W$) }, e.prototype.handLandmarks = function (e, t) { return p$(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m, g, y; return m$(this, (function (b) { switch (b.label) { case 0: return n = A$(t, H$, e), r = n.imageTensor, i = n.padding, a = this.landmarkModel.execute(r, ["Identity_2:0", "Identity_1:0", "Identity:0", "Identity_3:0"]), o = a[0], s = a[1], u = a[2], l = a[3], [4, s.data()]; case 1: return (c = b.sent()[0]) < .5 ? ((0, P.dispose)(a), (0, P.dispose)(r), [2, null]) : [4, u.data()]; case 2: return h = b.sent()[0], d = h >= .5 ? "Left" : "Right", [4, O$(o, q$)]; case 3: return f = b.sent(), [4, O$(l, Y$)]; case 4: return p = b.sent(), m = function (e, t) { var n = t.left, r = t.top, i = t.left + t.right, a = t.top + t.bottom; return e.map((function (e) { return f$(f$({}, e), { x: (e.x - n) / (1 - i), y: (e.y - r) / (1 - a), z: e.z / (1 - i) }) })) }(f, i), g = function (e, t, n) { void 0 === n && (n = { ignoreRotation: !1 }); for (var r = [], i = 0, a = e; i < a.length; i++) { var o = a[i], s = o.x - .5, u = o.y - .5, l = n.ignoreRotation ? 0 : t.rotation, c = Math.cos(l) * s - Math.sin(l) * u, h = Math.sin(l) * s + Math.cos(l) * u; c = c * t.width + t.xCenter, h = h * t.height + t.yCenter; var d = o.z * t.width, f = f$({}, o); f.x = c, f.y = h, f.z = d, r.push(f) } return r }(m, e), y = function (e, t) { for (var n = [], r = 0, i = e; r < i.length; r++) { var a = i[r], o = a.x, s = a.y, u = t.rotation, l = Math.cos(u) * o - Math.sin(u) * s, c = Math.sin(u) * o + Math.cos(u) * s, h = f$({}, a); h.x = l, h.y = c, n.push(h) } return n }(p, e), (0, P.dispose)(a), (0, P.dispose)(r), [2, { landmarks: g, worldLandmarks: y, handScore: c, handedness: d }] } })) })) }, e.prototype.handLandmarksToRoi = function (e, t) { return z$(function (e, t) { for (var n = function (e, t) { var n = e[0].x * t.width, r = e[0].y * t.height, i = (e[4].x + e[8].x) / 2, a = (e[4].y + e[8].y) / 2; return i = (i + e[6].x) / 2 * t.width, a = (a + e[6].y) / 2 * t.height, S$(Math.PI / 2 - Math.atan2(-(a - r), i - n)) }(e, t), r = S$(-n), i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY, u = 0, l = e; u < l.length; u++) { var c = (g = l[u]).x, h = g.y; i = Math.min(i, c), a = Math.max(a, c), o = Math.min(o, h), s = Math.max(s, h) } var d = (a + i) / 2, f = (s + o) / 2; i = Number.POSITIVE_INFINITY, a = Number.NEGATIVE_INFINITY, o = Number.POSITIVE_INFINITY, s = Number.NEGATIVE_INFINITY; for (var p = 0, m = e; p < m.length; p++) { var g, y = ((g = m[p]).x - d) * t.width, b = (g.y - f) * t.height, v = y * Math.cos(r) - b * Math.sin(r), x = y * Math.sin(r) + b * Math.cos(r); i = Math.min(i, v), a = Math.max(a, v), o = Math.min(o, x), s = Math.max(s, x) } var w = (a + i) / 2, k = (s + o) / 2, S = w * Math.cos(n) - k * Math.sin(n) + t.width * d, _ = w * Math.sin(n) + k * Math.cos(n) + t.height * f, C = (a - i) / t.width, A = (s - o) / t.height; return { xCenter: S / t.width, yCenter: _ / t.height, width: C, height: A, rotation: n } }([].concat(e.slice(0, 4), e.slice(5, 7), e.slice(9, 11), e.slice(13, 15), e.slice(17, 19)), t), t, V$) }, e }(); function K$(e) { return p$(this, void 0, void 0, (function () { var t, n, r, i, a, o; return m$(this, (function (s) { switch (s.label) { case 0: return t = function (e) { if (null == e) return f$({}, L$); var t = f$({}, e); if (t.runtime = "tfjs", null == t.maxHands && (t.maxHands = L$.maxHands), null == t.modelType && (t.modelType = L$.modelType), "lite" !== t.modelType && "full" !== t.modelType) throw new Error("Model type must be one of lite or full, but got " + t.modelType); return null == t.detectorModelUrl && ("lite" === t.modelType ? t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/lite/1" : t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/detector/full/1"), null == t.landmarkModelUrl && ("lite" === t.modelType ? t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/lite/1" : t.landmarkModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/handpose_3d/landmark/full/1"), t }(e), n = t.detectorModelUrl.indexOf("https://tfhub.dev") > -1, r = t.landmarkModelUrl.indexOf("https://tfhub.dev") > -1, [4, Promise.all([Ud(t.detectorModelUrl, { fromTFHub: n }), Ud(t.landmarkModelUrl, { fromTFHub: r })])]; case 1: return i = s.sent(), a = i[0], o = i[1], [2, new X$(a, o, t.maxHands)] } })) })) } (P$ || (P$ = {})).MediaPipeHands = "MediaPipeHands"; var Z$ = n(3185); const J$ = (e, t, n, r, i) => `šŖml5.js warns: The '${t}' option for ${e} has to be set to a ${r}, but it is being set to a ${n} instead.\n\nml5.js is using default value of '${i}'.`, Q$ = (e, t, n, r, i) => `šŖml5.js warns: The '${t}' option for ${e} has to be set to ${iR(r)}, but it is being set to '${n}' instead.\n\nml5.js is using default value of '${i}'.`, eR = (e, t, n, r, i, a) => `šŖml5.js warns: The '${t}' option for ${e} has to be set to a number between ${r} and ${i}, but it is being set to '${n}' instead.\n\nml5.js is using default value of '${a}'.`, tR = (e, t, n, r) => `šŖml5.js warns: The '${t}' option for ${e} has to be set to an integer, but it is being set to the float value '${n}' instead.\n\nml5.js is using the default value of '${r}'.`, nR = (e, t, n, r, i) => `šŖml5.js warns: The '${t}' option for ${e} has to be a multiple of ${r}, but it is being set to '${n}' instead.\n\nml5.js is using the default value of '${i}'.`, rR = (e, t, n, r) => `šŖml5.js warns: The modelName parameter for ${e} has to be set to ${iR(n)}, but it is being set to '${t}' instead.\n\nml5.js is using default model '${r}'.`; function iR(e) { if (1 === e.length) return `'${e[0]}'`; if (2 === e.length) return `'${e[0]}' or '${e[1]}'`; { const t = e.pop(); return `'${e.join("', '")}', or '${t}'` } } function aR(e, t) { return "function" == typeof t ? t(e) : t } function oR(e, t, n) { if (n && "string" == typeof e) { return t.find((t => t.toLowerCase() === e.toLowerCase())) } return t.includes(e) ? e : void 0 } function sR(e, t, n) { return e < t || e > n ? void 0 : e } function uR(e, t, n, r) { if (void 0 === e) return n; const i = oR(e, t, !0); return void 0 === i ? (console.warn(rR(r, e, t, n)), n) : i } const lR = function (e, t, n) { const r = {}; for (const i in t) { const a = t[i], o = aR(r, a.type), s = aR(r, a.default); if (aR(r, a.ignore)) continue; const u = t[i].alias; let l, c = !1; if (void 0 !== e[i]) l = e[i]; else { if (void 0 === u || void 0 === e[u]) { r[i] = s; continue } l = e[u], c = !0 } if (typeof l !== o && "enum" !== o) console.warn(J$(n, c ? u : i, typeof l, o, s)), r[i] = s; else if ("enum" === o) { const e = aR(r, a.enums), t = oR(l, e, aR(r, a.caseInsensitive) ?? !0); void 0 === t ? (console.warn(Q$(n, c ? u : i, l, e, s)), r[i] = s) : r[i] = t } else if ("number" === o) { const e = aR(r, a.min) ?? -1 / 0, t = aR(r, a.max) ?? 1 / 0, o = aR(r, a.integer) ?? !1, h = aR(r, a.multipleOf), d = sR(l, e, t); o && !Number.isInteger(l) ? (console.warn(tR(n, c ? u : i, l, s)), r[i] = s) : void 0 !== h && l % h != 0 ? (console.warn(nR(n, c ? u : i, l, h, s)), r[i] = s) : void 0 === d ? (console.warn(eR(n, c ? u : i, l, e, t, s)), r[i] = s) : r[i] = d } else { if ("boolean" !== o && "string" !== o && "object" !== o) throw new Error(`Unknown type "${o}" for ${i} in moldObject.`); r[i] = l } } return r }; function cR(e, t, n) { return Object.assign(e, { [n]: e[t] }), delete e[t], e }
/**
* @license
* Copyright (c) 2020-2024 ml5
* This software is released under the ml5.js License.
* https://github.com/ml5js/ml5-next-gen/blob/main/LICENSE.md
*/
const hR = { maxHands: { type: "number", min: 1, max: 2147483647, integer: !0, default: 2 }, runtime: { type: "enum", enums: ["mediapipe", "tfjs"], default: "tfjs" }, modelType: { type: "enum", enums: ["lite", "full"], default: "full" }, solutionPath: { type: "string", default: "https://cdn.jsdelivr.net/npm/@mediapipe/hands", ignore: e => "mediapipe" !== e.runtime }, detectorModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime }, landmarkModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime } }, dR = { flipHorizontal: { type: "boolean", alias: "flipped", default: !1 } }; class fR { constructor(e, t, n) { this.modelName = this.modelName = uR(e, ["MediaPipeHands"], "MediaPipeHands", "handPose"), this.model = null, this.userOptions = t, this.runtimeConfig = {}, this.detectMedia = null, this.detectCallback = null, this.detecting = !1, this.signalStop = !1, this.prevCall = "", this.ready = hM(this.loadModel(), n) } async loadModel() { const e = P$.MediaPipeHands, t = lR(this.userOptions, hR, "handPose"); return this.runtimeConfig = lR(this.userOptions, dR, "handPose"), await P.ready(), this.model = await function (e, t) { return p$(this, void 0, void 0, (function () { var n, r; return m$(this, (function (i) { if (e === P$.MediaPipeHands) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, K$(n)]; if ("mediapipe" === n.runtime) return [2, v$(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) }(e, t), this } async detect(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detect()."); const { image: n, callback: r } = t; await AM(n, !1); let i = await this.model.estimateHands(n, this.runtimeConfig); return this.renameScoreToConfidence(i), this.addKeypoints(i), "function" == typeof r && r(i), i } detectStart(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detectStart()."), t.require("callback", "A callback function argument is required for detectStart()."), this.detectMedia = t.image, this.detectCallback = t.callback, this.signalStop = !1, this.detecting || (this.detecting = !0, this.detectLoop()), "start" === this.prevCall && console.warn("detectStart() was called more than once without calling detectStop(). Only the latest detectStart() call will take effect."), this.prevCall = "start" } detectStop() { this.detecting && (this.signalStop = !0), this.prevCall = "stop" } async detectLoop() { for (await AM(this.detectMedia, !1); !this.signalStop;) { let e = await this.model.estimateHands(this.detectMedia, this.runtimeConfig); this.renameScoreToConfidence(e), this.addKeypoints(e), this.detectCallback(e), await P.nextFrame() } this.detecting = !1, this.signalStop = !1 } renameScoreToConfidence(e) { e.forEach((e => { cR(e, "score", "confidence") })) } addKeypoints(e) { e = e.map((e => { for (let t = 0; t < e.keypoints.length; t++) { let n = e.keypoints[t], r = e.keypoints3D[t]; e[n.name] = { x: n.x, y: n.y, x3D: r.x, y3D: r.y, z3D: r.z } } return e })) } getConnections() { return Z$.c6 } } const pR = (...e) => { const { string: t, options: n = {}, callback: r } = xM(...e); return new fR(t, n, r) }; class mR { constructor(e, t) { this.modelName = uR(e, ["MovieReviews"], "MovieReviews", "sentiment"), this.ready = hM(this.loadModel(), t) } async loadModel(e) { await P.ready(); const t = r$("moviereviews" === this.modelName.toLowerCase() ? "https://storage.googleapis.com/tfjs-models/tfjs/sentiment_cnn_v1/" : this.modelName, "model"), [n, r] = await Promise.all([t.loadLayersModel(), t.loadMetadataJson()]); return this.model = n, this.indexFrom = r.index_from, this.maxLen = r.max_len, this.wordIndex = r.word_index, this.vocabularySize = r.vocabulary_size, this } async predict(...e) { const t = xM(...e), { string: n, callback: r } = t; t.require("string", "A string argument is required for sentiment.predict function."); const i = function (e, t, n = "pre", r = "pre", i = 0) { return e.map((e => { if (e.length > t && ("pre" === r ? e.splice(0, e.length - t) : e.splice(t, e.length - t)), e.length < t) { const r = []; for (let n = 0; n < t - e.length; n += 1)r.push(i); e = "pre" === n ? r.concat(e) : e.concat(r) } return e })) }([n.trim().toLowerCase().replace(/[.,?!]/g, "").split(" ").map((e => { let t = this.wordIndex[e] + this.indexFrom; return t > this.vocabularySize && (t = 2), t }))], this.maxLen), a = P.tensor2d(i, [1, this.maxLen]), o = this.model.predict(a), s = (await o.data())[0]; return o.dispose(), a.dispose(), r && r({ confidence: s }), { confidence: s } } } const gR = (...e) => { const { string: t, callback: n } = xM(...e); return new mR(t, n) }; var yR = n(2726), bR = function () { return bR = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, bR.apply(this, arguments) }; function vR(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function xR(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== a[0] && 2 !== a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } function wR(e) { var t = e.map((function (e) { return e[0] })); return t.push(e[e.length - 1][1]), t } var kR = { lips: wR([[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]]), leftEye: wR([[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]]), leftEyebrow: wR([[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]]), leftIris: wR([[474, 475], [475, 476], [476, 477], [477, 474]]), rightEye: wR([[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]]), rightEyebrow: wR([[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]]), rightIris: wR([[469, 470], [470, 471], [471, 472], [472, 469]]), faceOval: wR([[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]]) }, SR = [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]], _R = Object.entries(kR).map((function (e) { var t = e[0]; return e[1].map((function (e) { return [e, t] })) })).flat(), CR = new Map(_R); function AR(e) { for (var t = { locationData: { relativeKeypoints: [] } }, n = Number.MAX_SAFE_INTEGER, r = Number.MIN_SAFE_INTEGER, i = Number.MAX_SAFE_INTEGER, a = Number.MIN_SAFE_INTEGER, o = 0; o < e.length; ++o) { var s = e[o]; n = Math.min(n, s.x), r = Math.max(r, s.x), i = Math.min(i, s.y), a = Math.max(a, s.y), t.locationData.relativeKeypoints.push({ x: s.x, y: s.y }) } return t.locationData.relativeBoundingBox = { xMin: n, yMin: i, xMax: r, yMax: a, width: r - n, height: a - i }, t } var TR = { runtime: "mediapipe", maxFaces: 1, refineLandmarks: !1 }, ER = function () { function e(e) { var t = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.faceMeshSolution = new yR.FaceMesh({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), this.faceMeshSolution.setOptions({ refineLandmarks: e.refineLandmarks, selfieMode: this.selfieMode, maxNumFaces: e.maxFaces }), this.faceMeshSolution.onResults((function (e) { if (t.height = e.image.height, t.width = e.image.width, t.faces = [], null !== e.multiFaceLandmarks) for (var n = e.multiFaceLandmarks, r = 0; r < n.length; r++) { var i = t.translateOutput(n[r]); t.faces.push({ keypoints: i, box: AR(i).locationData.relativeBoundingBox }) } })) } return e.prototype.translateOutput = function (e) { var t = this; return e.map((function (e, n) { var r = { x: e.x * t.width, y: e.y * t.height, z: e.z * t.width }, i = CR.get(n); return null != i && (r.name = i), r })) }, e.prototype.estimateFaces = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r; return xR(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.faceMeshSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.faceMeshSolution.send({ image: e })]; case 4: return i.sent(), [2, this.faces] } })) })) }, e.prototype.dispose = function () { this.faceMeshSolution.close() }, e.prototype.reset = function () { this.faceMeshSolution.reset(), this.width = 0, this.height = 0, this.faces = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.faceMeshSolution.initialize() }, e }(); function NR(e) { return vR(this, void 0, void 0, (function () { var t, n; return xR(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return bR({}, TR); var t = bR({}, e); return t.runtime = "mediapipe", null == t.maxFaces && (t.maxFaces = TR.maxFaces), null == t.refineLandmarks && (t.refineLandmarks = TR.refineLandmarks), t }(e), [4, (n = new ER(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } var IR = "undefined" != typeof globalThis ? globalThis : "undefined" != typeof window ? window : void 0 !== n.g ? n.g : "undefined" != typeof self ? self : {}, MR = {}; (function () { var e; function t(e) { var t = 0; return function () { return t < e.length ? { done: !1, value: e[t++] } : { done: !0 } } } var n = "function" == typeof Object.defineProperties ? Object.defineProperty : function (e, t, n) { return e == Array.prototype || e == Object.prototype || (e[t] = n.value), e }, r = function (e) { e = ["object" == typeof globalThis && globalThis, e, "object" == typeof window && window, "object" == typeof self && self, "object" == typeof IR && IR]; for (var t = 0; t < e.length; ++t) { var n = e[t]; if (n && n.Math == Math) return n } throw Error("Cannot find global object") }(this); function i(e, t) { if (t) e: { var i = r; e = e.split("."); for (var a = 0; a < e.length - 1; a++) { var o = e[a]; if (!(o in i)) break e; i = i[o] } (t = t(a = i[e = e[e.length - 1]])) != a && null != t && n(i, e, { configurable: !0, writable: !0, value: t }) } } function a(e) { return (e = { next: e })[Symbol.iterator] = function () { return this }, e } function o(e) { var n = "undefined" != typeof Symbol && Symbol.iterator && e[Symbol.iterator]; return n ? n.call(e) : { next: t(e) } } function s(e) { if (!(e instanceof Array)) { e = o(e); for (var t, n = []; !(t = e.next()).done;)n.push(t.value); e = n } return e } i("Symbol", (function (e) { function t(e, t) { this.g = e, n(this, "description", { configurable: !0, writable: !0, value: t }) } if (e) return e; t.prototype.toString = function () { return this.g }; var r = "jscomp_symbol_" + (1e9 * Math.random() >>> 0) + "_", i = 0; return function e(n) { if (this instanceof e) throw new TypeError("Symbol is not a constructor"); return new t(r + (n || "") + "_" + i++, n) } })), i("Symbol.iterator", (function (e) { if (e) return e; e = Symbol("Symbol.iterator"); for (var i = "Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array".split(" "), o = 0; o < i.length; o++) { var s = r[i[o]]; "function" == typeof s && "function" != typeof s.prototype[e] && n(s.prototype, e, { configurable: !0, writable: !0, value: function () { return a(t(this)) } }) } return e })); var u, l = "function" == typeof Object.create ? Object.create : function (e) { function t() { } return t.prototype = e, new t }; if ("function" == typeof Object.setPrototypeOf) u = Object.setPrototypeOf; else { var c; e: { var h = {}; try { h.__proto__ = { a: !0 }, c = h.a; break e } catch (e) { } c = !1 } u = c ? function (e, t) { if (e.__proto__ = t, e.__proto__ !== t) throw new TypeError(e + " is not extensible"); return e } : null } var d = u; function f(e, t) { if (e.prototype = l(t.prototype), e.prototype.constructor = e, d) d(e, t); else for (var n in t) if ("prototype" != n) if (Object.defineProperties) { var r = Object.getOwnPropertyDescriptor(t, n); r && Object.defineProperty(e, n, r) } else e[n] = t[n]; e.na = t.prototype } function p() { this.l = !1, this.i = null, this.h = void 0, this.g = 1, this.u = this.o = 0, this.j = null } function m(e) { if (e.l) throw new TypeError("Generator is already running"); e.l = !0 } function g(e, t) { e.j = { da: t, ea: !0 }, e.g = e.o || e.u } function y(e, t, n) { return e.g = n, { value: t } } function b(e) { this.g = new p, this.h = e } function v(e, t, n, r) { try { var i = t.call(e.g.i, n); if (!(i instanceof Object)) throw new TypeError("Iterator result " + i + " is not an object"); if (!i.done) return e.g.l = !1, i; var a = i.value } catch (t) { return e.g.i = null, g(e.g, t), x(e) } return e.g.i = null, r.call(e.g, a), x(e) } function x(e) { for (; e.g.g;)try { var t = e.h(e.g); if (t) return e.g.l = !1, { value: t.value, done: !1 } } catch (t) { e.g.h = void 0, g(e.g, t) } if (e.g.l = !1, e.g.j) { if (t = e.g.j, e.g.j = null, t.ea) throw t.da; return { value: t.return, done: !0 } } return { value: void 0, done: !0 } } function w(e) { this.next = function (t) { return m(e.g), e.g.i ? t = v(e, e.g.i.next, t, e.g.s) : (e.g.s(t), t = x(e)), t }, this.throw = function (t) { return m(e.g), e.g.i ? t = v(e, e.g.i.throw, t, e.g.s) : (g(e.g, t), t = x(e)), t }, this.return = function (t) { return function (e, t) { m(e.g); var n = e.g.i; return n ? v(e, "return" in n ? n.return : function (e) { return { value: e, done: !0 } }, t, e.g.return) : (e.g.return(t), x(e)) }(e, t) }, this[Symbol.iterator] = function () { return this } } function k(e) { return function (e) { function t(t) { return e.next(t) } function n(t) { return e.throw(t) } return new Promise((function (r, i) { !function e(a) { a.done ? r(a.value) : Promise.resolve(a.value).then(t, n).then(e, i) }(e.next()) })) }(new w(new b(e))) } p.prototype.s = function (e) { this.h = e }, p.prototype.return = function (e) { this.j = { return: e }, this.g = this.u }, i("Promise", (function (e) { function t(e) { this.h = 0, this.i = void 0, this.g = [], this.s = !1; var t = this.j(); try { e(t.resolve, t.reject) } catch (e) { t.reject(e) } } function n() { this.g = null } function i(e) { return e instanceof t ? e : new t((function (t) { t(e) })) } if (e) return e; n.prototype.h = function (e) { if (null == this.g) { this.g = []; var t = this; this.i((function () { t.l() })) } this.g.push(e) }; var a = r.setTimeout; n.prototype.i = function (e) { a(e, 0) }, n.prototype.l = function () { for (; this.g && this.g.length;) { var e = this.g; this.g = []; for (var t = 0; t < e.length; ++t) { var n = e[t]; e[t] = null; try { n() } catch (e) { this.j(e) } } } this.g = null }, n.prototype.j = function (e) { this.i((function () { throw e })) }, t.prototype.j = function () { function e(e) { return function (r) { n || (n = !0, e.call(t, r)) } } var t = this, n = !1; return { resolve: e(this.D), reject: e(this.l) } }, t.prototype.D = function (e) { if (e === this) this.l(new TypeError("A Promise cannot resolve to itself")); else if (e instanceof t) this.H(e); else { e: switch (typeof e) { case "object": var n = null != e; break e; case "function": n = !0; break e; default: n = !1 }n ? this.A(e) : this.o(e) } }, t.prototype.A = function (e) { var t = void 0; try { t = e.then } catch (e) { return void this.l(e) } "function" == typeof t ? this.I(t, e) : this.o(e) }, t.prototype.l = function (e) { this.u(2, e) }, t.prototype.o = function (e) { this.u(1, e) }, t.prototype.u = function (e, t) { if (0 != this.h) throw Error("Cannot settle(" + e + ", " + t + "): Promise already settled in state" + this.h); this.h = e, this.i = t, 2 === this.h && this.G(), this.B() }, t.prototype.G = function () { var e = this; a((function () { if (e.C()) { var t = r.console; void 0 !== t && t.error(e.i) } }), 1) }, t.prototype.C = function () { if (this.s) return !1; var e = r.CustomEvent, t = r.Event, n = r.dispatchEvent; return void 0 === n || ("function" == typeof e ? e = new e("unhandledrejection", { cancelable: !0 }) : "function" == typeof t ? e = new t("unhandledrejection", { cancelable: !0 }) : (e = r.document.createEvent("CustomEvent")).initCustomEvent("unhandledrejection", !1, !0, e), e.promise = this, e.reason = this.i, n(e)) }, t.prototype.B = function () { if (null != this.g) { for (var e = 0; e < this.g.length; ++e)s.h(this.g[e]); this.g = null } }; var s = new n; return t.prototype.H = function (e) { var t = this.j(); e.M(t.resolve, t.reject) }, t.prototype.I = function (e, t) { var n = this.j(); try { e.call(t, n.resolve, n.reject) } catch (e) { n.reject(e) } }, t.prototype.then = function (e, n) { function r(e, t) { return "function" == typeof e ? function (t) { try { i(e(t)) } catch (e) { a(e) } } : t } var i, a, o = new t((function (e, t) { i = e, a = t })); return this.M(r(e, i), r(n, a)), o }, t.prototype.catch = function (e) { return this.then(void 0, e) }, t.prototype.M = function (e, t) { function n() { switch (r.h) { case 1: e(r.i); break; case 2: t(r.i); break; default: throw Error("Unexpected state: " + r.h) } } var r = this; null == this.g ? s.h(n) : this.g.push(n), this.s = !0 }, t.resolve = i, t.reject = function (e) { return new t((function (t, n) { n(e) })) }, t.race = function (e) { return new t((function (t, n) { for (var r = o(e), a = r.next(); !a.done; a = r.next())i(a.value).M(t, n) })) }, t.all = function (e) { var n = o(e), r = n.next(); return r.done ? i([]) : new t((function (e, t) { function a(t) { return function (n) { o[t] = n, 0 == --s && e(o) } } var o = [], s = 0; do { o.push(void 0), s++, i(r.value).M(a(o.length - 1), t), r = n.next() } while (!r.done) })) }, t })); var S = "function" == typeof Object.assign ? Object.assign : function (e, t) { for (var n = 1; n < arguments.length; n++) { var r = arguments[n]; if (r) for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (e[i] = r[i]) } return e }; i("Object.assign", (function (e) { return e || S })), i("Object.is", (function (e) { return e || function (e, t) { return e === t ? 0 !== e || 1 / e == 1 / t : e != e && t != t } })), i("Array.prototype.includes", (function (e) { return e || function (e, t) { var n = this; n instanceof String && (n = String(n)); var r = n.length; for (0 > (t = t || 0) && (t = Math.max(t + r, 0)); t < r; t++) { var i = n[t]; if (i === e || Object.is(i, e)) return !0 } return !1 } })), i("String.prototype.includes", (function (e) { return e || function (e, t) { if (null == this) throw new TypeError("The 'this' value for String.prototype.includes must not be null or undefined"); if (e instanceof RegExp) throw new TypeError("First argument to String.prototype.includes must not be a regular expression"); return -1 !== this.indexOf(e, t || 0) } })), i("Array.prototype.keys", (function (e) { return e || function () { return function (e, t) { e instanceof String && (e += ""); var n = 0, r = !1, i = { next: function () { if (!r && n < e.length) { var i = n++; return { value: t(i, e[i]), done: !1 } } return r = !0, { done: !0, value: void 0 } } }; return i[Symbol.iterator] = function () { return i }, i }(this, (function (e) { return e })) } })); var _ = this || self; function C(e, t) { e = e.split("."); var n, r = _; e[0] in r || void 0 === r.execScript || r.execScript("var " + e[0]); for (; e.length && (n = e.shift());)e.length || void 0 === t ? r = r[n] && r[n] !== Object.prototype[n] ? r[n] : r[n] = {} : r[n] = t } function A() { throw Error("Invalid UTF8") } function T(e, t) { return t = String.fromCharCode.apply(null, t), null == e ? t : e + t } var E, N, I = "undefined" != typeof TextDecoder, M = "undefined" != typeof TextEncoder, F = {}, D = null; function $(e) { var t; void 0 === t && (t = 0), O(), t = F[t]; for (var n = Array(Math.floor(e.length / 3)), r = t[64] || "", i = 0, a = 0; i < e.length - 2; i += 3) { var o = e[i], s = e[i + 1], u = e[i + 2], l = t[o >> 2]; o = t[(3 & o) << 4 | s >> 4], s = t[(15 & s) << 2 | u >> 6], u = t[63 & u], n[a++] = l + o + s + u } switch (l = 0, u = r, e.length - i) { case 2: u = t[(15 & (l = e[i + 1])) << 2] || r; case 1: e = e[i], n[a] = t[e >> 2] + t[(3 & e) << 4 | l >> 4] + u + r }return n.join("") } function R(e) { var t = e.length, n = 3 * t / 4; n % 3 ? n = Math.floor(n) : -1 != "=.".indexOf(e[t - 1]) && (n = -1 != "=.".indexOf(e[t - 2]) ? n - 2 : n - 1); var r = new Uint8Array(n), i = 0; return function (e, t) { function n(t) { for (; r < e.length;) { var n = e.charAt(r++), i = D[n]; if (null != i) return i; if (!/^[\s\xa0]*$/.test(n)) throw Error("Unknown base64 encoding at char: " + n) } return t } O(); for (var r = 0; ;) { var i = n(-1), a = n(0), o = n(64), s = n(64); if (64 === s && -1 === i) break; t(i << 2 | a >> 4), 64 != o && (t(a << 4 & 240 | o >> 2), 64 != s && t(o << 6 & 192 | s)) } }(e, (function (e) { r[i++] = e })), i !== n ? r.subarray(0, i) : r } function O() { if (!D) { D = {}; for (var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".split(""), t = ["+/=", "+/", "-_=", "-_.", "-_"], n = 0; 5 > n; n++) { var r = e.concat(t[n].split("")); F[n] = r; for (var i = 0; i < r.length; i++) { var a = r[i]; void 0 === D[a] && (D[a] = i) } } } } var z, P = "function" == typeof Uint8Array; function B(e) { return P && null != e && e instanceof Uint8Array } function L(e) { if (this.L = e, null !== e && 0 === e.length) throw Error("ByteString should be constructed with non-empty values") } var j = "function" == typeof Uint8Array.prototype.slice, U = 0; function W(e, t) { return Error("Invalid wire type: " + e + " (at position " + t + ")") } function V() { return Error("Failed to read varint, encoding is invalid.") } function G(e, t) { t = void 0 !== (t = void 0 === t ? {} : t).v && t.v, this.h = null, this.g = this.i = this.j = 0, this.v = t, e && H(this, e) } function H(e, t) { e.h = function (e, t) { if (e.constructor === Uint8Array) return e; if (e.constructor === ArrayBuffer) return new Uint8Array(e); if (e.constructor === Array) return new Uint8Array(e); if (e.constructor === String) return R(e); if (e.constructor === L) return !t && (t = e.L) && t.constructor === Uint8Array ? t : (t = null == (t = e.L) || B(t) ? t : "string" == typeof t ? R(t) : null, (e = e.L = t) ? new Uint8Array(e) : z || (z = new Uint8Array(0))); if (e instanceof Uint8Array) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength); throw Error("Type not convertible to a Uint8Array, expected a Uint8Array, an ArrayBuffer, a base64 encoded string, or Array of numbers") }(t, e.v), e.j = 0, e.i = e.h.length, e.g = e.j } function q(e) { if (e.g > e.i) throw Error("Tried to read past the end of the data " + e.g + " > " + e.i) } function Y(e) { var t = e.h, n = t[e.g], r = 127 & n; if (128 > n) return e.g += 1, q(e), r; if (r |= (127 & (n = t[e.g + 1])) << 7, 128 > n) return e.g += 2, q(e), r; if (r |= (127 & (n = t[e.g + 2])) << 14, 128 > n) return e.g += 3, q(e), r; if (r |= (127 & (n = t[e.g + 3])) << 21, 128 > n) return e.g += 4, q(e), r; if (n = t[e.g + 4], e.g += 5, r |= (15 & n) << 28, 128 > n) return q(e), r; if (128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++] && 128 <= t[e.g++]) throw V(); return q(e), r } G.prototype.reset = function () { this.g = this.j }; var X = []; function K() { this.g = [] } function Z(e, t) { for (; 127 < t;)e.g.push(127 & t | 128), t >>>= 7; e.g.push(t) } function J(e) { var t = {}, n = void 0 !== t.W && t.W; this.l = { v: void 0 !== t.v && t.v }, this.W = n, t = this.l, X.length ? (n = X.pop(), t && (n.v = t.v), e && H(n, e), e = n) : e = new G(e, t), this.g = e, this.j = this.g.g, this.h = this.i = -1 } function Q(e) { var t = e.g; if (t.g == t.i) return !1; e.j = e.g.g; var n = Y(e.g) >>> 0; if (t = n >>> 3, !(0 <= (n &= 7) && 5 >= n)) throw W(n, e.j); if (1 > t) throw Error("Invalid field number: " + t + " (at position " + e.j + ")"); return e.i = t, e.h = n, !0 } function ee(e) { switch (e.h) { case 0: if (0 != e.h) ee(e); else e: { for (var t = (e = e.g).g, n = t + 10; t < n;)if (!(128 & e.h[t++])) { e.g = t, q(e); break e } throw V() } break; case 1: (e = e.g).g += 8, q(e); break; case 2: 2 != e.h ? ee(e) : (t = Y(e.g) >>> 0, (e = e.g).g += t, q(e)); break; case 5: (e = e.g).g += 4, q(e); break; case 3: for (t = e.i; ;) { if (!Q(e)) throw Error("Unmatched start-group tag: stream EOF"); if (4 == e.h) { if (e.i != t) throw Error("Unmatched end-group tag"); break } ee(e) } break; default: throw W(e.h, e.j) } } K.prototype.length = function () { return this.g.length }, K.prototype.end = function () { var e = this.g; return this.g = [], e }, J.prototype.reset = function () { this.g.reset(), this.j = this.g.g, this.h = this.i = -1 }; var te = []; function ne() { this.i = [], this.h = 0, this.g = new K } function re(e, t) { 0 !== t.length && (e.i.push(t), e.h += t.length) } var ie = "function" == typeof Symbol && "symbol" == typeof Symbol() ? Symbol(void 0) : void 0; function ae(e, t) { Object.isFrozen(e) || (ie ? e[ie] |= t : void 0 !== e.N ? e.N |= t : Object.defineProperties(e, { N: { value: t, configurable: !0, writable: !0, enumerable: !1 } })) } function oe(e) { var t; return null == (t = ie ? e[ie] : e.N) ? 0 : t } function se(e) { return ae(e, 1), e } function ue(e) { return !!Array.isArray(e) && !!(2 & oe(e)) } function le(e) { if (!Array.isArray(e)) throw Error("cannot mark non-array as immutable"); ae(e, 2) } function ce(e) { return null !== e && "object" == typeof e && !Array.isArray(e) && e.constructor === Object } var he = Object.freeze(se([])); function de(e) { if (ue(e.m)) throw Error("Cannot mutate an immutable Message") } var fe, pe = "undefined" != typeof Symbol && void 0 !== Symbol.hasInstance; function me(e) { return { value: e, configurable: !1, writable: !1, enumerable: !1 } } function ge(e, t, n) { return -1 === t ? null : t >= e.i ? e.g ? e.g[t] : void 0 : void 0 !== n && n && e.g && null != (n = e.g[t]) ? n : e.m[t + e.h] } function ye(e, t, n, r) { r = void 0 !== r && r, de(e), t < e.i && !r ? e.m[t + e.h] = n : (e.g || (e.g = e.m[e.i + e.h] = {}))[t] = n } function be(e, t, n, r) { n = void 0 === n || n; var i = ge(e, t, r = void 0 !== r && r); return null == i && (i = he), ue(e.m) ? n && (le(i), Object.freeze(i)) : (i === he || ue(i)) && ye(e, t, i = se(i.slice()), r), i } function ve(e, t, n) { return null == (e = null == (e = ge(e, t)) ? e : +e) ? void 0 === n ? 0 : n : e } function xe(e, t, n, r) { e.j || (e.j = {}); var i = ue(e.m), a = e.j[n]; if (!a) { r = be(e, n, !0, void 0 !== r && r), a = [], i = i || ue(r); for (var o = 0; o < r.length; o++)a[o] = new t(r[o]), i && le(a[o].m); i && (le(a), Object.freeze(a)), e.j[n] = a } return a } function we(e, t, n, r, i) { var a = void 0 !== a && a; return de(e), a = xe(e, n, t, a), n = r || new n, e = be(e, t), null != i ? (a.splice(i, 0, n), e.splice(i, 0, n.m)) : (a.push(n), e.push(n.m)), n } function ke(e, t) { return null == (e = ge(e, t)) ? 0 : e } function Se(e, t) { return null == (e = ge(e, t)) ? "" : e } function _e(e) { return Ae(e, void 0 === Te ? Ee : Te) } function Ce(e, t) { if (null != e) { if (Array.isArray(e)) e = Ae(e, t); else if (ce(e)) { var n, r = {}; for (n in e) r[n] = Ce(e[n], t); e = r } else e = t(e); return e } } function Ae(e, t) { for (var n = e.slice(), r = 0; r < n.length; r++)n[r] = Ce(n[r], t); return Array.isArray(e) && 1 & oe(e) && se(n), n } function Te(e) { return e && "object" == typeof e && e.toJSON ? e.toJSON() : (e = function (e) { switch (typeof e) { case "number": return isFinite(e) ? e : String(e); case "object": if (e && !Array.isArray(e)) { if (B(e)) return $(e); if (e instanceof L) { var t = e.L; return t = null == t || "string" == typeof t ? t : P && t instanceof Uint8Array ? $(t) : null, (e.L = t) || "" } } }return e }(e), Array.isArray(e) ? _e(e) : e) } function Ee(e) { return B(e) ? new Uint8Array(e) : e } function Ne(e, t, n) { e || (e = fe), fe = null; var r = this.constructor.h; if (e || (e = r ? [r] : []), this.h = (r ? 0 : -1) - (this.constructor.g || 0), this.j = void 0, this.m = e, e = (r = this.m.length) - 1, r && ce(r = this.m[e]) ? (this.i = e - this.h, this.g = r) : void 0 !== t && -1 < t ? (this.i = Math.max(t, e + 1 - this.h), this.g = void 0) : this.i = Number.MAX_VALUE, n) for (t = 0; t < n.length; t++)if ((e = n[t]) < this.i) e += this.h, (r = this.m[e]) ? Array.isArray(r) && se(r) : this.m[e] = he; else { var i = (r = this.g || (this.g = this.m[this.i + this.h] = {}))[e]; i ? Array.isArray(i) && se(i) : r[e] = he } } function Ie() { Ne.apply(this, arguments) } if (Ne.prototype.toJSON = function () { return _e(this.m) }, Ne.prototype.toString = function () { return this.m.toString() }, f(Ie, Ne), pe) { var Me = {}; Object.defineProperties(Ie, (Me[Symbol.hasInstance] = me((function () { throw Error("Cannot perform instanceof checks for MutableMessage") })), Me)) } function Fe(e, t, n) { if (n) { var r, i = {}; for (r in n) { var a = n[r], o = a.ha; o || (i.F = a.la || a.fa.P, a.aa ? (i.U = Be(a.aa), o = function (e) { return function (t, n, r) { return e.F(t, n, r, e.U) } }(i)) : a.ca ? (i.T = Le(a.X.g, a.ca), o = function (e) { return function (t, n, r) { return e.F(t, n, r, e.T) } }(i)) : o = i.F, a.ha = o), o(t, e, a.X), i = { F: i.F, U: i.U, T: i.T } } } !function (e, t) { if (t = t.ba) { re(e, e.g.end()); for (var n = 0; n < t.length; n++)re(e, t[n]) } }(t, e) } var De = Symbol(); function $e(e, t, n) { return e[De] || (e[De] = function (e, r) { return t(e, r, n) }) } function Re(e) { var t = e[De]; if (!t) { var n = Je(e); t = function (e, t) { return Qe(e, t, n) }, e[De] = t } return t } function Oe(e) { var t = function (e) { var t = e.aa; return t ? Re(t) : (t = e.ka) ? $e(e.X.g, t, e.ca) : void 0 }(e), n = e.X, r = e.fa.O; return t ? function (e, i) { return r(e, i, n, t) } : function (e, t) { return r(e, t, n) } } function ze(e, t, n, r, i, a) { var o = 0; for ((e = e()).length && "number" != typeof e[0] && (n(t, e[0]), o++); o < e.length;) { n = e[o++]; for (var s = o + 1; s < e.length && "number" != typeof e[s];)s++; var u = e[o++]; switch (s -= o) { case 0: r(t, n, u); break; case 1: r(t, n, u, e[o++]); break; case 2: i(t, n, u, e[o++], e[o++]); break; case 3: s = e[o++]; var l = e[o++], c = e[o++]; Array.isArray(c) ? i(t, n, u, s, l, c) : a(t, n, u, s, l, c); break; case 4: a(t, n, u, e[o++], e[o++], e[o++], e[o++]); break; default: throw Error("unexpected number of binary field arguments: " + s) } } return t } var Pe = Symbol(); function Be(e) { var t = e[Pe]; if (!t) { var n = He(e); t = function (e, t) { return tt(e, t, n) }, e[Pe] = t } return t } function Le(e, t) { var n = e[Pe]; return n || (n = function (e, n) { return Fe(e, n, t) }, e[Pe] = n), n } var je = Symbol(); function Ue(e, t) { e.push(t) } function We(e, t, n) { e.push(t, n.P) } function Ve(e, t, n, r, i) { var a = Be(i), o = n.P; e.push(t, (function (e, t, n) { return o(e, t, n, r, a) })) } function Ge(e, t, n, r, i, a) { var o = Le(r, a), s = n.P; e.push(t, (function (e, t, n) { return s(e, t, n, r, o) })) } function He(e) { return e[je] || ze(e, e[je] = [], Ue, We, Ve, Ge) } var qe = Symbol(); function Ye(e, t) { e[0] = t } function Xe(e, t, n, r) { var i = n.O; e[t] = r ? function (e, t, n) { return i(e, t, n, r) } : i } function Ke(e, t, n, r, i, a) { var o = n.O, s = Re(i); e[t] = function (e, t, n) { return o(e, t, n, r, s, a) } } function Ze(e, t, n, r, i, a, o) { var s = n.O, u = $e(r, i, a); e[t] = function (e, t, n) { return s(e, t, n, r, u, o) } } function Je(e) { return e[qe] || ze(e, e[qe] = {}, Ye, Xe, Ke, Ze) } function Qe(e, t, n) { for (; Q(t) && 4 != t.h;) { var r = t.i, i = n[r]; if (!i) { var a = n[0]; a && (a = a[r]) && (i = n[r] = Oe(a)) } if (!(i && i(t, e, r) || (i = t, r = e, a = i.j, ee(i), i.W))) { var o = i.g.h; i = a === (i = i.g.g) ? z || (z = new Uint8Array(0)) : j ? o.slice(a, i) : new Uint8Array(o.subarray(a, i)), (a = r.ba) ? a.push(i) : r.ba = [i] } } return e } function et(e, t, n) { if (te.length) { var r = te.pop(); e && (H(r.g, e), r.i = -1, r.h = -1), e = r } else e = new J(e); try { return Qe(new t, e, Je(n)) } finally { (t = e.g).h = null, t.j = 0, t.i = 0, t.g = 0, t.v = !1, e.i = -1, e.h = -1, 100 > te.length && te.push(e) } } function tt(e, t, n) { for (var r = n.length, i = 1 == r % 2, a = i ? 1 : 0; a < r; a += 2)(0, n[a + 1])(t, e, n[a]); Fe(e, t, i ? n[0] : void 0) } function nt(e, t) { var n = new ne; tt(e, n, He(t)), re(n, n.g.end()), e = new Uint8Array(n.h); for (var r = (t = n.i).length, i = 0, a = 0; a < r; a++) { var o = t[a]; e.set(o, i), i += o.length } return n.i = [e], e } function rt(e, t) { return { O: e, P: t } } var it = rt((function (e, t, n) { if (5 !== e.h) return !1; var r = (e = e.g).h[e.g], i = e.h[e.g + 1], a = e.h[e.g + 2], o = e.h[e.g + 3]; return e.g += 4, q(e), e = 2 * ((i = (r | i << 8 | a << 16 | o << 24) >>> 0) >> 31) + 1, r = i >>> 23 & 255, i &= 8388607, ye(t, n, 255 == r ? i ? NaN : 1 / 0 * e : 0 == r ? e * Math.pow(2, -149) * i : e * Math.pow(2, r - 150) * (i + Math.pow(2, 23))), !0 }), (function (e, t, n) { if (null != (t = ge(t, n))) { Z(e.g, 8 * n + 5), e = e.g; var r = t; 0 === (r = (n = 0 > r ? 1 : 0) ? -r : r) ? U = 0 < 1 / r ? 0 : 2147483648 : isNaN(r) ? U = 2147483647 : 34028234663852886e22 < r ? U = (n << 31 | 2139095040) >>> 0 : 11754943508222875e-54 > r ? (r = Math.round(r / Math.pow(2, -149)), U = (n << 31 | r) >>> 0) : (t = Math.floor(Math.log(r) / Math.LN2), r *= Math.pow(2, -t), 16777216 <= (r = Math.round(8388608 * r)) && ++t, U = (n << 31 | t + 127 << 23 | 8388607 & r) >>> 0), n = U, e.g.push(n >>> 0 & 255), e.g.push(n >>> 8 & 255), e.g.push(n >>> 16 & 255), e.g.push(n >>> 24 & 255) } })), at = rt((function (e, t, n) { if (0 !== e.h) return !1; for (var r = e.g, i = 128, a = 0, o = e = 0; 4 > o && 128 <= i; o++)i = r.h[r.g++], q(r), a |= (127 & i) << 7 * o; if (128 <= i && (i = r.h[r.g++], q(r), a |= (127 & i) << 28, e |= (127 & i) >> 4), 128 <= i) for (o = 0; 5 > o && 128 <= i; o++)i = r.h[r.g++], q(r), e |= (127 & i) << 7 * o + 3; if (!(128 > i)) throw V(); return r = a >>> 0, (e = 2147483648 & (i = e >>> 0)) && (i = ~i >>> 0, 0 == (r = 1 + ~r >>> 0) && (i = i + 1 >>> 0)), r = 4294967296 * i + (r >>> 0), ye(t, n, e ? -r : r), !0 }), (function (e, t, n) { if (null != (t = ge(t, n)) && null != t) { Z(e.g, 8 * n), e = e.g; var r = t; for (n = 0 > r, t = (r = Math.abs(r)) >>> 0, r = Math.floor((r - t) / 4294967296), r >>>= 0, n && (r = ~r >>> 0, 4294967295 < (t = 1 + (~t >>> 0)) && (t = 0, 4294967295 < ++r && (r = 0))), n = U = t, t = r; 0 < t || 127 < n;)e.g.push(127 & n | 128), n = (n >>> 7 | t << 25) >>> 0, t >>>= 7; e.g.push(n) } })), ot = rt((function (e, t, n) { return 0 === e.h && (ye(t, n, Y(e.g)), !0) }), (function (e, t, n) { if (null != (t = ge(t, n)) && null != t) if (Z(e.g, 8 * n), e = e.g, 0 <= (n = t)) Z(e, n); else { for (t = 0; 9 > t; t++)e.g.push(127 & n | 128), n >>= 7; e.g.push(1) } })), st = rt((function (e, t, n) { if (2 !== e.h) return !1; var r, i = Y(e.g) >>> 0, a = (e = e.g).g; if (e.g += i, q(e), e = e.h, I) (r = E) || (r = E = new TextDecoder("utf-8", { fatal: !0 })), r = r.decode(e.subarray(a, a + i)); else { i = a + i; for (var o, s, u, l = [], c = null; a < i;)128 > (o = e[a++]) ? l.push(o) : 224 > o ? a >= i ? A() : (s = e[a++], 194 > o || 128 != (192 & s) ? (a--, A()) : l.push((31 & o) << 6 | 63 & s)) : 240 > o ? a >= i - 1 ? A() : 128 != (192 & (s = e[a++])) || 224 === o && 160 > s || 237 === o && 160 <= s || 128 != (192 & (r = e[a++])) ? (a--, A()) : l.push((15 & o) << 12 | (63 & s) << 6 | 63 & r) : 244 >= o ? a >= i - 2 ? A() : 128 != (192 & (s = e[a++])) || s - 144 + (o << 28) >> 30 || 128 != (192 & (r = e[a++])) || 128 != (192 & (u = e[a++])) ? (a--, A()) : (o = (7 & o) << 18 | (63 & s) << 12 | (63 & r) << 6 | 63 & u, o -= 65536, l.push(55296 + (o >> 10 & 1023), 56320 + (1023 & o))) : A(), 8192 <= l.length && (c = T(c, l), l.length = 0); r = T(c, l) } return ye(t, n, r), !0 }), (function (e, t, n) { if (null != (t = ge(t, n))) { var r = !1; if (r = void 0 !== r && r, M) { if (r && /(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])/.test(t)) throw Error("Found an unpaired surrogate"); t = (N || (N = new TextEncoder)).encode(t) } else { for (var i = 0, a = new Uint8Array(3 * t.length), o = 0; o < t.length; o++) { var s = t.charCodeAt(o); if (128 > s) a[i++] = s; else { if (2048 > s) a[i++] = s >> 6 | 192; else { if (55296 <= s && 57343 >= s) { if (56319 >= s && o < t.length) { var u = t.charCodeAt(++o); if (56320 <= u && 57343 >= u) { s = 1024 * (s - 55296) + u - 56320 + 65536, a[i++] = s >> 18 | 240, a[i++] = s >> 12 & 63 | 128, a[i++] = s >> 6 & 63 | 128, a[i++] = 63 & s | 128; continue } o-- } if (r) throw Error("Found an unpaired surrogate"); s = 65533 } a[i++] = s >> 12 | 224, a[i++] = s >> 6 & 63 | 128 } a[i++] = 63 & s | 128 } } t = a.subarray(0, i) } Z(e.g, 8 * n + 2), Z(e.g, t.length), re(e, e.g.end()), re(e, t) } })), ut = rt((function (e, t, n, r, i) { if (2 !== e.h) return !1; t = we(t, n, r), n = e.g.i, r = Y(e.g) >>> 0; var a = e.g.g + r, o = a - n; if (0 >= o && (e.g.i = a, i(t, e), o = a - e.g.g), o) throw Error("Message parsing ended unexpectedly. Expected to read " + r + " bytes, instead read " + (r - o) + " bytes, either the data ended unexpectedly or the message misreported its own length"); return e.g.g = a, e.g.i = n, !0 }), (function (e, t, n, r, i) { if (null != (t = xe(t, r, n))) for (r = 0; r < t.length; r++) { var a = e; Z(a.g, 8 * n + 2); var o = a.g.end(); re(a, o), o.push(a.h), a = o, i(t[r], e), o = e; var s = a.pop(); for (s = o.h + o.g.length() - s; 127 < s;)a.push(127 & s | 128), s >>>= 7, o.h++; a.push(s), o.h++ } })); function lt() { Ie.apply(this, arguments) } if (f(lt, Ie), pe) { var ct = {}; Object.defineProperties(lt, (ct[Symbol.hasInstance] = me(Object[Symbol.hasInstance]), ct)) } function ht(e) { lt.call(this, e) } function dt() { return [1, ot, 2, it, 3, st, 4, st] } function ft(e) { lt.call(this, e, -1, mt) } function pt() { return [1, ut, ht, dt] } f(ht, lt), f(ft, lt), ft.prototype.addClassification = function (e, t) { return we(this, 1, ht, e, t), this }; var mt = [1]; function gt(e) { lt.call(this, e) } function yt() { return [1, it, 2, it, 3, it, 4, it, 5, it] } function bt(e) { lt.call(this, e, -1, xt) } function vt() { return [1, ut, gt, yt] } f(gt, lt), f(bt, lt); var xt = [1]; function wt(e) { lt.call(this, e) } function kt() { return [1, it, 2, it, 3, it, 4, it, 5, it, 6, at] } f(wt, lt); var St = [[61, 146], [146, 91], [91, 181], [181, 84], [84, 17], [17, 314], [314, 405], [405, 321], [321, 375], [375, 291], [61, 185], [185, 40], [40, 39], [39, 37], [37, 0], [0, 267], [267, 269], [269, 270], [270, 409], [409, 291], [78, 95], [95, 88], [88, 178], [178, 87], [87, 14], [14, 317], [317, 402], [402, 318], [318, 324], [324, 308], [78, 191], [191, 80], [80, 81], [81, 82], [82, 13], [13, 312], [312, 311], [311, 310], [310, 415], [415, 308]], _t = [[263, 249], [249, 390], [390, 373], [373, 374], [374, 380], [380, 381], [381, 382], [382, 362], [263, 466], [466, 388], [388, 387], [387, 386], [386, 385], [385, 384], [384, 398], [398, 362]], Ct = [[276, 283], [283, 282], [282, 295], [295, 285], [300, 293], [293, 334], [334, 296], [296, 336]], At = [[33, 7], [7, 163], [163, 144], [144, 145], [145, 153], [153, 154], [154, 155], [155, 133], [33, 246], [246, 161], [161, 160], [160, 159], [159, 158], [158, 157], [157, 173], [173, 133]], Tt = [[46, 53], [53, 52], [52, 65], [65, 55], [70, 63], [63, 105], [105, 66], [66, 107]], Et = [[10, 338], [338, 297], [297, 332], [332, 284], [284, 251], [251, 389], [389, 356], [356, 454], [454, 323], [323, 361], [361, 288], [288, 397], [397, 365], [365, 379], [379, 378], [378, 400], [400, 377], [377, 152], [152, 148], [148, 176], [176, 149], [149, 150], [150, 136], [136, 172], [172, 58], [58, 132], [132, 93], [93, 234], [234, 127], [127, 162], [162, 21], [21, 54], [54, 103], [103, 67], [67, 109], [109, 10]], Nt = [].concat(s(St), s(_t), s(Ct), s(At), s(Tt), s(Et)); function It(e, t, n) { if (n = e.createShader(0 === n ? e.VERTEX_SHADER : e.FRAGMENT_SHADER), e.shaderSource(n, t), e.compileShader(n), !e.getShaderParameter(n, e.COMPILE_STATUS)) throw Error("Could not compile WebGL shader.\n\n" + e.getShaderInfoLog(n)); return n } function Mt(e) { return xe(e, ht, 1).map((function (e) { return { index: ke(e, 1), ga: ve(e, 2), label: null != ge(e, 3) ? Se(e, 3) : void 0, displayName: null != ge(e, 4) ? Se(e, 4) : void 0 } })) } function Ft(e) { return { x: ve(e, 1), y: ve(e, 2), z: ve(e, 3), visibility: null != ge(e, 4) ? ve(e, 4) : void 0 } } function Dt(e, t) { this.h = e, this.g = t, this.l = 0 } function $t(e, t, n) { return function (e, t) { var n = e.g; if (void 0 === e.o) { var r = It(n, "\n attribute vec2 aVertex;\n attribute vec2 aTex;\n varying vec2 vTex;\n void main(void) {\n gl_Position = vec4(aVertex, 0.0, 1.0);\n vTex = aTex;\n }", 0), i = It(n, "\n precision mediump float;\n varying vec2 vTex;\n uniform sampler2D sampler0;\n void main(){\n gl_FragColor = texture2D(sampler0, vTex);\n }", 1), a = n.createProgram(); if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) throw Error("Could not compile WebGL program.\n\n" + n.getProgramInfoLog(a)); r = e.o = a, n.useProgram(r), i = n.getUniformLocation(r, "sampler0"), e.j = { K: n.getAttribLocation(r, "aVertex"), J: n.getAttribLocation(r, "aTex"), ma: i }, e.u = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.enableVertexAttribArray(e.j.K), n.vertexAttribPointer(e.j.K, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([-1, -1, -1, 1, 1, 1, 1, -1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), e.s = n.createBuffer(), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.enableVertexAttribArray(e.j.J), n.vertexAttribPointer(e.j.J, 2, n.FLOAT, !1, 0, 0), n.bufferData(n.ARRAY_BUFFER, new Float32Array([0, 1, 0, 0, 1, 0, 1, 1]), n.STATIC_DRAW), n.bindBuffer(n.ARRAY_BUFFER, null), n.uniform1i(i, 0) } r = e.j, n.useProgram(e.o), n.canvas.width = t.width, n.canvas.height = t.height, n.viewport(0, 0, t.width, t.height), n.activeTexture(n.TEXTURE0), e.h.bindTexture2d(t.glName), n.enableVertexAttribArray(r.K), n.bindBuffer(n.ARRAY_BUFFER, e.u), n.vertexAttribPointer(r.K, 2, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(r.J), n.bindBuffer(n.ARRAY_BUFFER, e.s), n.vertexAttribPointer(r.J, 2, n.FLOAT, !1, 0, 0), n.bindFramebuffer(n.DRAW_FRAMEBUFFER ? n.DRAW_FRAMEBUFFER : n.FRAMEBUFFER, null), n.clearColor(0, 0, 0, 0), n.clear(n.COLOR_BUFFER_BIT), n.colorMask(!0, !0, !0, !0), n.drawArrays(n.TRIANGLE_FAN, 0, 4), n.disableVertexAttribArray(r.K), n.disableVertexAttribArray(r.J), n.bindBuffer(n.ARRAY_BUFFER, null), e.h.bindTexture2d(0) }(e, t), "function" == typeof e.g.canvas.transferToImageBitmap ? Promise.resolve(e.g.canvas.transferToImageBitmap()) : n ? Promise.resolve(e.g.canvas) : "function" == typeof createImageBitmap ? createImageBitmap(e.g.canvas) : (void 0 === e.i && (e.i = document.createElement("canvas")), new Promise((function (t) { e.i.height = e.g.canvas.height, e.i.width = e.g.canvas.width, e.i.getContext("2d", {}).drawImage(e.g.canvas, 0, 0, e.g.canvas.width, e.g.canvas.height), t(e.i) }))) } function Rt(e) { this.g = e } var Ot = new Uint8Array([0, 97, 115, 109, 1, 0, 0, 0, 1, 4, 1, 96, 0, 0, 3, 2, 1, 0, 10, 9, 1, 7, 0, 65, 0, 253, 15, 26, 11]); function zt(e, t) { return t + e } function Pt(e, t) { window[e] = t } function Bt(e) { if (this.g = e, this.listeners = {}, this.j = {}, this.H = {}, this.o = {}, this.u = {}, this.I = this.s = this.Z = !0, this.D = Promise.resolve(), this.Y = "", this.C = {}, this.locateFile = e && e.locateFile || zt, "object" == typeof window) var t = window.location.pathname.toString().substring(0, window.location.pathname.toString().lastIndexOf("/")) + "/"; else { if ("undefined" == typeof location) throw Error("solutions can only be loaded on a web page or in a web worker"); t = location.pathname.toString().substring(0, location.pathname.toString().lastIndexOf("/")) + "/" } if (this.$ = t, e.options) for (var n = (t = o(Object.keys(e.options))).next(); !n.done; n = t.next()) { n = n.value; var r = e.options[n].default; void 0 !== r && (this.j[n] = "function" == typeof r ? r() : r) } } function Lt(e, t) { var n, r; return k((function (i) { return t in e.H ? i.return(e.H[t]) : (n = e.locateFile(t, ""), r = fetch(n).then((function (e) { return e.arrayBuffer() })), e.H[t] = r, i.return(r)) })) } function jt(e, t, n) { var r, i, a, s, u, l, c, h, d, f, p, m, g, b; return k((function (v) { switch (v.g) { case 1: if (!n) return v.return(t); for (r = {}, i = 0, a = o(Object.keys(n)), s = a.next(); !s.done; s = a.next())u = s.value, "string" != typeof (l = n[u]) && "texture" === l.type && void 0 !== t[l.stream] && ++i; 1 < i && (e.I = !1), c = o(Object.keys(n)), s = c.next(); case 2: if (s.done) { v.g = 4; break } if (h = s.value, "string" == typeof (d = n[h])) return g = r, b = h, y(v, function (e, t, n) { var r; return k((function (i) { return "number" == typeof n || n instanceof Uint8Array || n instanceof e.h.Uint8BlobList ? i.return(n) : n instanceof e.h.Texture2dDataOut ? ((r = e.u[t]) || (r = new Dt(e.h, e.G), e.u[t] = r), i.return($t(r, n, e.I))) : i.return(void 0) })) }(e, h, t[d]), 14); if (f = t[d.stream], "detection_list" === d.type) { if (f) { for (var x = f.getRectList(), w = f.getLandmarksList(), S = f.getClassificationsList(), _ = [], C = 0; C < x.size(); ++C) { var A = et(x.get(C), wt, kt); A = { boundingBox: { xCenter: ve(A, 1), yCenter: ve(A, 2), height: ve(A, 3), width: ve(A, 4), rotation: ve(A, 5, 0), rectId: ke(A, 6) }, landmarks: xe(et(w.get(C), bt, vt), gt, 1).map(Ft), V: Mt(et(S.get(C), ft, pt)) }, _.push(A) } x = _ } else x = []; r[h] = x, v.g = 7; break } if ("proto_list" === d.type) { if (f) { for (x = Array(f.size()), w = 0; w < f.size(); w++)x[w] = f.get(w); f.delete() } else x = []; r[h] = x, v.g = 7; break } if (void 0 === f) { v.g = 3; break } if ("float_list" === d.type) { r[h] = f, v.g = 7; break } if ("proto" === d.type) { r[h] = f, v.g = 7; break } if ("texture" !== d.type) throw Error("Unknown output config type: '" + d.type + "'"); return (p = e.u[h]) || (p = new Dt(e.h, e.G), e.u[h] = p), y(v, $t(p, f, e.I), 13); case 13: m = v.h, r[h] = m; case 7: d.transform && r[h] && (r[h] = d.transform(r[h])), v.g = 3; break; case 14: g[b] = v.h; case 3: s = c.next(), v.g = 2; break; case 4: return v.return(r) } })) } function Ut(e, t) { for (var n = t.name || "$", r = [].concat(s(t.wants)), i = new e.h.StringList, a = o(t.wants), u = a.next(); !u.done; u = a.next())i.push_back(u.value); a = e.h.PacketListener.implement({ onResults: function (i) { for (var a = {}, o = 0; o < t.wants.length; ++o)a[r[o]] = i.get(o); var s = e.listeners[n]; s && (e.D = jt(e, a, t.outs).then((function (n) { n = s(n); for (var i = 0; i < t.wants.length; ++i) { var o = a[r[i]]; "object" == typeof o && o.hasOwnProperty && o.hasOwnProperty("delete") && o.delete() } n && (e.D = n) }))) } }), e.i.attachMultiListener(i, a), i.delete() } function Wt(e) { var t = this; e = e || {}; var n = { url: "face_detection_short.binarypb" }, r = { type: 1, graphOptionXref: { calculatorType: "TensorsToDetectionsCalculator", calculatorName: "facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator", fieldName: "min_score_thresh" } }; this.g = new Bt({ locateFile: e.locateFile, files: [{ data: !0, url: "face_detection_short.binarypb" }, { data: !0, url: "face_detection_short_range.tflite" }, { simd: !0, url: "face_detection_solution_simd_wasm_bin.js" }, { simd: !1, url: "face_detection_solution_wasm_bin.js" }], graph: n, listeners: [{ wants: ["detections", "image_transformed"], outs: { image: "image_transformed", detections: { type: "detection_list", stream: "detections" } } }], inputs: { image: { type: "video", stream: "input_frames_gpu" } }, options: { useCpuInference: { type: 0, graphOptionXref: { calculatorType: "InferenceCalculator", fieldName: "use_cpu_inference" }, default: "object" == typeof window && void 0 !== window.navigator && ("iPad Simulator;iPhone Simulator;iPod Simulator;iPad;iPhone;iPod".split(";").includes(navigator.platform) || navigator.userAgent.includes("Mac") && "ontouchend" in document) }, selfieMode: { type: 0, graphOptionXref: { calculatorType: "GlScalerCalculator", calculatorIndex: 1, fieldName: "flip_horizontal" } }, model: { type: 0, onChange: function (e) { var i, a, s, u, l; return k((function (c) { switch (c.g) { case 1: i = o("short" === e ? ["face_detection_short_range.tflite"] : ["face_detection_full_range_sparse.tflite"]), a = i.next(); case 2: if (a.done) { c.g = 4; break } return s = a.value, u = "third_party/mediapipe/modules/face_detection/" + s, y(c, Lt(t.g, s), 5); case 5: l = c.h, t.g.overrideFile(u, l), a = i.next(), c.g = 2; break; case 4: return n.url = "short" === e ? "face_detection_short.binarypb" : "face_detection_full.binarypb", r.graphOptionXref.calculatorName = "short" === e ? "facedetectionshortrangegpu__facedetectionshortrangecommon__TensorsToDetectionsCalculator" : "facedetectionfullrangegpu__facedetectionfullrangecommon__TensorsToDetectionsCalculator", c.return(!0) } })) } }, minDetectionConfidence: r } }) } (e = Bt.prototype).close = function () { return this.i && this.i.delete(), Promise.resolve() }, e.reset = function () { var e = this; return k((function (t) { e.i && (e.i.reset(), e.o = {}, e.u = {}), t.g = 0 })) }, e.setOptions = function (e, t) { var n = this; if (t = t || this.g.options) { for (var r = [], i = [], a = {}, s = o(Object.keys(e)), u = s.next(); !u.done; a = { R: a.R, S: a.S }, u = s.next()) { var l = u.value; l in this.j && this.j[l] === e[l] || (this.j[l] = e[l], void 0 !== (u = t[l]) && (u.onChange && (a.R = u.onChange, a.S = e[l], r.push(function (e) { return function () { return k((function (t) { if (1 == t.g) return y(t, e.R(e.S), 2); !0 === t.h && (n.s = !0), t.g = 0 })) } }(a))), u.graphOptionXref && (l = { valueNumber: 1 === u.type ? e[l] : 0, valueBoolean: 0 === u.type && e[l], valueString: 2 === u.type ? e[l] : "" }, u = Object.assign(Object.assign(Object.assign({}, { calculatorName: "", calculatorIndex: 0 }), u.graphOptionXref), l), i.push(u)))) } 0 === r.length && 0 === i.length || (this.s = !0, this.B = (void 0 === this.B ? [] : this.B).concat(i), this.A = (void 0 === this.A ? [] : this.A).concat(r)) } }, e.initialize = function () { var e = this; return k((function (t) { return 1 == t.g ? y(t, function (e) { var t, n, r, i, a, o, u, l, c, h, d; return k((function (f) { switch (f.g) { case 1: return e.Z ? (t = void 0 === e.g.files ? [] : "function" == typeof e.g.files ? e.g.files(e.j) : e.g.files, y(f, k((function (e) { switch (e.g) { case 1: return e.o = 2, y(e, WebAssembly.instantiate(Ot), 4); case 4: e.g = 3, e.o = 0; break; case 2: return e.o = 0, e.j = null, e.return(!1); case 3: return e.return(!0) } })), 2)) : f.return(); case 2: if (n = f.h, "object" == typeof window) return Pt("createMediapipeSolutionsWasm", { locateFile: e.locateFile }), Pt("createMediapipeSolutionsPackedAssets", { locateFile: e.locateFile }), o = t.filter((function (e) { return void 0 !== e.data })), u = t.filter((function (e) { return void 0 === e.data })), l = Promise.all(o.map((function (t) { var n = Lt(e, t.url); if (void 0 !== t.path) { var r = t.path; n = n.then((function (t) { return e.overrideFile(r, t), Promise.resolve(t) })) } return n }))), c = Promise.all(u.map((function (t) { return void 0 === t.simd || t.simd && n || !t.simd && !n ? function (e) { var t = document.createElement("script"); return t.setAttribute("src", e), t.setAttribute("crossorigin", "anonymous"), new Promise((function (e) { t.addEventListener("load", (function () { e() }), !1), t.addEventListener("error", (function () { e() }), !1), document.body.appendChild(t) })) }(e.locateFile(t.url, e.$)) : Promise.resolve() }))).then((function () { var t, n, r; return k((function (i) { if (1 == i.g) return t = window.createMediapipeSolutionsWasm, n = window.createMediapipeSolutionsPackedAssets, r = e, y(i, t(n), 2); r.h = i.h, i.g = 0 })) })), h = k((function (t) { return e.g.graph && e.g.graph.url ? t = y(t, Lt(e, e.g.graph.url), 0) : (t.g = 0, t = void 0), t })), y(f, Promise.all([c, l, h]), 7); if ("function" != typeof importScripts) throw Error("solutions can only be loaded on a web page or in a web worker"); return r = t.filter((function (e) { return void 0 === e.simd || e.simd && n || !e.simd && !n })).map((function (t) { return e.locateFile(t.url, e.$) })), importScripts.apply(null, s(r)), i = e, y(f, createMediapipeSolutionsWasm(Module), 6); case 6: i.h = f.h, e.l = new OffscreenCanvas(1, 1), e.h.canvas = e.l, a = e.h.GL.createContext(e.l, { antialias: !1, alpha: !1, ja: "undefined" != typeof WebGL2RenderingContext ? 2 : 1 }), e.h.GL.makeContextCurrent(a), f.g = 4; break; case 7: if (e.l = document.createElement("canvas"), !(d = e.l.getContext("webgl2", {})) && !(d = e.l.getContext("webgl", {}))) return alert("Failed to create WebGL canvas context when passing video frame."), f.return(); e.G = d, e.h.canvas = e.l, e.h.createContext(e.l, !0, !0, {}); case 4: e.i = new e.h.SolutionWasm, e.Z = !1, f.g = 0 } })) }(e), 2) : 3 != t.g ? y(t, function (e) { var t, n, r, i, a, s, u, l; return k((function (c) { if (1 == c.g) return e.g.graph && e.g.graph.url && e.Y === e.g.graph.url ? c.return() : (e.s = !0, e.g.graph && e.g.graph.url ? (e.Y = e.g.graph.url, y(c, Lt(e, e.g.graph.url), 3)) : void (c.g = 2)); for (2 != c.g && (t = c.h, e.i.loadGraph(t)), n = o(Object.keys(e.C)), r = n.next(); !r.done; r = n.next())i = r.value, e.i.overrideFile(i, e.C[i]); if (e.C = {}, e.g.listeners) for (a = o(e.g.listeners), s = a.next(); !s.done; s = a.next())u = s.value, Ut(e, u); l = e.j, e.j = {}, e.setOptions(l), c.g = 0 })) }(e), 3) : y(t, function (e) { var t, n, r, i, a, s; return k((function (u) { switch (u.g) { case 1: if (!e.s) return u.return(); if (!e.A) { u.g = 2; break } t = o(e.A), n = t.next(); case 3: if (n.done) { u.g = 5; break } return y(u, (0, n.value)(), 4); case 4: n = t.next(), u.g = 3; break; case 5: e.A = void 0; case 2: if (e.B) { for (r = new e.h.GraphOptionChangeRequestList, i = o(e.B), a = i.next(); !a.done; a = i.next())s = a.value, r.push_back(s); e.i.changeOptions(r), r.delete(), e.B = void 0 } e.s = !1, u.g = 0 } })) }(e), 0) })) }, e.overrideFile = function (e, t) { this.i ? this.i.overrideFile(e, t) : this.C[e] = t }, e.clearOverriddenFiles = function () { this.C = {}, this.i && this.i.clearOverriddenFiles() }, e.send = function (e, t) { var n, r, i, a, s, u, l, c, h, d = this; return k((function (f) { switch (f.g) { case 1: return d.g.inputs ? (n = 1e3 * (null == t ? performance.now() : t), y(f, d.D, 2)) : f.return(); case 2: return y(f, d.initialize(), 3); case 3: for (r = new d.h.PacketDataList, i = o(Object.keys(e)), a = i.next(); !a.done; a = i.next())if (s = a.value, u = d.g.inputs[s]) { e: { var p = e[s]; switch (u.type) { case "video": var m = d.o[u.stream]; if (m || (m = new Dt(d.h, d.G), d.o[u.stream] = m), 0 === m.l && (m.l = m.h.createTexture()), "undefined" != typeof HTMLVideoElement && p instanceof HTMLVideoElement) var g = p.videoWidth, b = p.videoHeight; else "undefined" != typeof HTMLImageElement && p instanceof HTMLImageElement ? (g = p.naturalWidth, b = p.naturalHeight) : (g = p.width, b = p.height); b = { glName: m.l, width: g, height: b }, (g = m.g).canvas.width = b.width, g.canvas.height = b.height, g.activeTexture(g.TEXTURE0), m.h.bindTexture2d(m.l), g.texImage2D(g.TEXTURE_2D, 0, g.RGBA, g.RGBA, g.UNSIGNED_BYTE, p), m.h.bindTexture2d(0), m = b; break e; case "detections": for ((m = d.o[u.stream]) || (m = new Rt(d.h), d.o[u.stream] = m), m.data || (m.data = new m.g.DetectionListData), m.data.reset(p.length), b = 0; b < p.length; ++b) { g = p[b]; var v = m.data, x = v.setBoundingBox, w = b, k = g.boundingBox, S = new wt; if (ye(S, 1, k.xCenter), ye(S, 2, k.yCenter), ye(S, 3, k.height), ye(S, 4, k.width), ye(S, 5, k.rotation), ye(S, 6, k.rectId), k = nt(S, kt), x.call(v, w, k), g.landmarks) for (v = 0; v < g.landmarks.length; ++v) { var _ = !!(S = g.landmarks[v]).visibility; w = (x = m.data).addNormalizedLandmark, k = b, S = Object.assign(Object.assign({}, S), { visibility: _ ? S.visibility : 0 }), ye(_ = new gt, 1, S.x), ye(_, 2, S.y), ye(_, 3, S.z), S.visibility && ye(_, 4, S.visibility), S = nt(_, yt), w.call(x, k, S) } if (g.V) for (v = 0; v < g.V.length; ++v)w = (x = m.data).addClassification, k = b, S = g.V[v], ye(_ = new ht, 2, S.ga), S.index && ye(_, 1, S.index), S.label && ye(_, 3, S.label), S.displayName && ye(_, 4, S.displayName), S = nt(_, dt), w.call(x, k, S) } m = m.data; break e; default: m = {} } } switch (l = m, c = u.stream, u.type) { case "video": r.pushTexture2d(Object.assign(Object.assign({}, l), { stream: c, timestamp: n })); break; case "detections": (h = l).stream = c, h.timestamp = n, r.pushDetectionList(h); break; default: throw Error("Unknown input config type: '" + u.type + "'") } } return d.i.send(r), y(f, d.D, 4); case 4: r.delete(), f.g = 0 } })) }, e.onResults = function (e, t) { this.listeners[t || "$"] = e }, C("Solution", Bt), C("OptionType", { BOOL: 0, NUMBER: 1, ia: 2, 0: "BOOL", 1: "NUMBER", 2: "STRING" }), (e = Wt.prototype).close = function () { return this.g.close(), Promise.resolve() }, e.onResults = function (e) { this.g.onResults(e) }, e.initialize = function () { var e = this; return k((function (t) { return y(t, e.g.initialize(), 0) })) }, e.reset = function () { this.g.reset() }, e.send = function (e) { var t = this; return k((function (n) { return y(n, t.g.send(e), 0) })) }, e.setOptions = function (e) { this.g.setOptions(e) }, C("FaceDetection", Wt), C("FACEDETECTION_LIPS", St), C("FACEDETECTION_LEFT_EYE", _t), C("FACEDETECTION_LEFT_EYEBROW", Ct), C("FACEDETECTION_RIGHT_EYE", At), C("FACEDETECTION_RIGHT_EYEBROW", Tt), C("FACEDETECTION_FACE_OVAL", Et), C("FACEDETECTION_CONTOURS", Nt), C("FACEDETECTION_TESSELATION", [[127, 34], [34, 139], [139, 127], [11, 0], [0, 37], [37, 11], [232, 231], [231, 120], [120, 232], [72, 37], [37, 39], [39, 72], [128, 121], [121, 47], [47, 128], [232, 121], [121, 128], [128, 232], [104, 69], [69, 67], [67, 104], [175, 171], [171, 148], [148, 175], [118, 50], [50, 101], [101, 118], [73, 39], [39, 40], [40, 73], [9, 151], [151, 108], [108, 9], [48, 115], [115, 131], [131, 48], [194, 204], [204, 211], [211, 194], [74, 40], [40, 185], [185, 74], [80, 42], [42, 183], [183, 80], [40, 92], [92, 186], [186, 40], [230, 229], [229, 118], [118, 230], [202, 212], [212, 214], [214, 202], [83, 18], [18, 17], [17, 83], [76, 61], [61, 146], [146, 76], [160, 29], [29, 30], [30, 160], [56, 157], [157, 173], [173, 56], [106, 204], [204, 194], [194, 106], [135, 214], [214, 192], [192, 135], [203, 165], [165, 98], [98, 203], [21, 71], [71, 68], [68, 21], [51, 45], [45, 4], [4, 51], [144, 24], [24, 23], [23, 144], [77, 146], [146, 91], [91, 77], [205, 50], [50, 187], [187, 205], [201, 200], [200, 18], [18, 201], [91, 106], [106, 182], [182, 91], [90, 91], [91, 181], [181, 90], [85, 84], [84, 17], [17, 85], [206, 203], [203, 36], [36, 206], [148, 171], [171, 140], [140, 148], [92, 40], [40, 39], [39, 92], [193, 189], [189, 244], [244, 193], [159, 158], [158, 28], [28, 159], [247, 246], [246, 161], [161, 247], [236, 3], [3, 196], [196, 236], [54, 68], [68, 104], [104, 54], [193, 168], [168, 8], [8, 193], [117, 228], [228, 31], [31, 117], [189, 193], [193, 55], [55, 189], [98, 97], [97, 99], [99, 98], [126, 47], [47, 100], [100, 126], [166, 79], [79, 218], [218, 166], [155, 154], [154, 26], [26, 155], [209, 49], [49, 131], [131, 209], [135, 136], [136, 150], [150, 135], [47, 126], [126, 217], [217, 47], [223, 52], [52, 53], [53, 223], [45, 51], [51, 134], [134, 45], [211, 170], [170, 140], [140, 211], [67, 69], [69, 108], [108, 67], [43, 106], [106, 91], [91, 43], [230, 119], [119, 120], [120, 230], [226, 130], [130, 247], [247, 226], [63, 53], [53, 52], [52, 63], [238, 20], [20, 242], [242, 238], [46, 70], [70, 156], [156, 46], [78, 62], [62, 96], [96, 78], [46, 53], [53, 63], [63, 46], [143, 34], [34, 227], [227, 143], [123, 117], [117, 111], [111, 123], [44, 125], [125, 19], [19, 44], [236, 134], [134, 51], [51, 236], [216, 206], [206, 205], [205, 216], [154, 153], [153, 22], [22, 154], [39, 37], [37, 167], [167, 39], [200, 201], [201, 208], [208, 200], [36, 142], [142, 100], [100, 36], [57, 212], [212, 202], [202, 57], [20, 60], [60, 99], [99, 20], [28, 158], [158, 157], [157, 28], [35, 226], [226, 113], [113, 35], [160, 159], [159, 27], [27, 160], [204, 202], [202, 210], [210, 204], [113, 225], [225, 46], [46, 113], [43, 202], [202, 204], [204, 43], [62, 76], [76, 77], [77, 62], [137, 123], [123, 116], [116, 137], [41, 38], [38, 72], [72, 41], [203, 129], [129, 142], [142, 203], [64, 98], [98, 240], [240, 64], [49, 102], [102, 64], [64, 49], [41, 73], [73, 74], [74, 41], [212, 216], [216, 207], [207, 212], [42, 74], [74, 184], [184, 42], [169, 170], [170, 211], [211, 169], [170, 149], [149, 176], [176, 170], [105, 66], [66, 69], [69, 105], [122, 6], [6, 168], [168, 122], [123, 147], [147, 187], [187, 123], [96, 77], [77, 90], [90, 96], [65, 55], [55, 107], [107, 65], [89, 90], [90, 180], [180, 89], [101, 100], [100, 120], [120, 101], [63, 105], [105, 104], [104, 63], [93, 137], [137, 227], [227, 93], [15, 86], [86, 85], [85, 15], [129, 102], [102, 49], [49, 129], [14, 87], [87, 86], [86, 14], [55, 8], [8, 9], [9, 55], [100, 47], [47, 121], [121, 100], [145, 23], [23, 22], [22, 145], [88, 89], [89, 179], [179, 88], [6, 122], [122, 196], [196, 6], [88, 95], [95, 96], [96, 88], [138, 172], [172, 136], [136, 138], [215, 58], [58, 172], [172, 215], [115, 48], [48, 219], [219, 115], [42, 80], [80, 81], [81, 42], [195, 3], [3, 51], [51, 195], [43, 146], [146, 61], [61, 43], [171, 175], [175, 199], [199, 171], [81, 82], [82, 38], [38, 81], [53, 46], [46, 225], [225, 53], [144, 163], [163, 110], [110, 144], [52, 65], [65, 66], [66, 52], [229, 228], [228, 117], [117, 229], [34, 127], [127, 234], [234, 34], [107, 108], [108, 69], [69, 107], [109, 108], [108, 151], [151, 109], [48, 64], [64, 235], [235, 48], [62, 78], [78, 191], [191, 62], [129, 209], [209, 126], [126, 129], [111, 35], [35, 143], [143, 111], [117, 123], [123, 50], [50, 117], [222, 65], [65, 52], [52, 222], [19, 125], [125, 141], [141, 19], [221, 55], [55, 65], [65, 221], [3, 195], [195, 197], [197, 3], [25, 7], [7, 33], [33, 25], [220, 237], [237, 44], [44, 220], [70, 71], [71, 139], [139, 70], [122, 193], [193, 245], [245, 122], [247, 130], [130, 33], [33, 247], [71, 21], [21, 162], [162, 71], [170, 169], [169, 150], [150, 170], [188, 174], [174, 196], [196, 188], [216, 186], [186, 92], [92, 216], [2, 97], [97, 167], [167, 2], [141, 125], [125, 241], [241, 141], [164, 167], [167, 37], [37, 164], [72, 38], [38, 12], [12, 72], [38, 82], [82, 13], [13, 38], [63, 68], [68, 71], [71, 63], [226, 35], [35, 111], [111, 226], [101, 50], [50, 205], [205, 101], [206, 92], [92, 165], [165, 206], [209, 198], [198, 217], [217, 209], [165, 167], [167, 97], [97, 165], [220, 115], [115, 218], [218, 220], [133, 112], [112, 243], [243, 133], [239, 238], [238, 241], [241, 239], [214, 135], [135, 169], [169, 214], [190, 173], [173, 133], [133, 190], [171, 208], [208, 32], [32, 171], [125, 44], [44, 237], [237, 125], [86, 87], [87, 178], [178, 86], [85, 86], [86, 179], [179, 85], [84, 85], [85, 180], [180, 84], [83, 84], [84, 181], [181, 83], [201, 83], [83, 182], [182, 201], [137, 93], [93, 132], [132, 137], [76, 62], [62, 183], [183, 76], [61, 76], [76, 184], [184, 61], [57, 61], [61, 185], [185, 57], [212, 57], [57, 186], [186, 212], [214, 207], [207, 187], [187, 214], [34, 143], [143, 156], [156, 34], [79, 239], [239, 237], [237, 79], [123, 137], [137, 177], [177, 123], [44, 1], [1, 4], [4, 44], [201, 194], [194, 32], [32, 201], [64, 102], [102, 129], [129, 64], [213, 215], [215, 138], [138, 213], [59, 166], [166, 219], [219, 59], [242, 99], [99, 97], [97, 242], [2, 94], [94, 141], [141, 2], [75, 59], [59, 235], [235, 75], [24, 110], [110, 228], [228, 24], [25, 130], [130, 226], [226, 25], [23, 24], [24, 229], [229, 23], [22, 23], [23, 230], [230, 22], [26, 22], [22, 231], [231, 26], [112, 26], [26, 232], [232, 112], [189, 190], [190, 243], [243, 189], [221, 56], [56, 190], [190, 221], [28, 56], [56, 221], [221, 28], [27, 28], [28, 222], [222, 27], [29, 27], [27, 223], [223, 29], [30, 29], [29, 224], [224, 30], [247, 30], [30, 225], [225, 247], [238, 79], [79, 20], [20, 238], [166, 59], [59, 75], [75, 166], [60, 75], [75, 240], [240, 60], [147, 177], [177, 215], [215, 147], [20, 79], [79, 166], [166, 20], [187, 147], [147, 213], [213, 187], [112, 233], [233, 244], [244, 112], [233, 128], [128, 245], [245, 233], [128, 114], [114, 188], [188, 128], [114, 217], [217, 174], [174, 114], [131, 115], [115, 220], [220, 131], [217, 198], [198, 236], [236, 217], [198, 131], [131, 134], [134, 198], [177, 132], [132, 58], [58, 177], [143, 35], [35, 124], [124, 143], [110, 163], [163, 7], [7, 110], [228, 110], [110, 25], [25, 228], [356, 389], [389, 368], [368, 356], [11, 302], [302, 267], [267, 11], [452, 350], [350, 349], [349, 452], [302, 303], [303, 269], [269, 302], [357, 343], [343, 277], [277, 357], [452, 453], [453, 357], [357, 452], [333, 332], [332, 297], [297, 333], [175, 152], [152, 377], [377, 175], [347, 348], [348, 330], [330, 347], [303, 304], [304, 270], [270, 303], [9, 336], [336, 337], [337, 9], [278, 279], [279, 360], [360, 278], [418, 262], [262, 431], [431, 418], [304, 408], [408, 409], [409, 304], [310, 415], [415, 407], [407, 310], [270, 409], [409, 410], [410, 270], [450, 348], [348, 347], [347, 450], [422, 430], [430, 434], [434, 422], [313, 314], [314, 17], [17, 313], [306, 307], [307, 375], [375, 306], [387, 388], [388, 260], [260, 387], [286, 414], [414, 398], [398, 286], [335, 406], [406, 418], [418, 335], [364, 367], [367, 416], [416, 364], [423, 358], [358, 327], [327, 423], [251, 284], [284, 298], [298, 251], [281, 5], [5, 4], [4, 281], [373, 374], [374, 253], [253, 373], [307, 320], [320, 321], [321, 307], [425, 427], [427, 411], [411, 425], [421, 313], [313, 18], [18, 421], [321, 405], [405, 406], [406, 321], [320, 404], [404, 405], [405, 320], [315, 16], [16, 17], [17, 315], [426, 425], [425, 266], [266, 426], [377, 400], [400, 369], [369, 377], [322, 391], [391, 269], [269, 322], [417, 465], [465, 464], [464, 417], [386, 257], [257, 258], [258, 386], [466, 260], [260, 388], [388, 466], [456, 399], [399, 419], [419, 456], [284, 332], [332, 333], [333, 284], [417, 285], [285, 8], [8, 417], [346, 340], [340, 261], [261, 346], [413, 441], [441, 285], [285, 413], [327, 460], [460, 328], [328, 327], [355, 371], [371, 329], [329, 355], [392, 439], [439, 438], [438, 392], [382, 341], [341, 256], [256, 382], [429, 420], [420, 360], [360, 429], [364, 394], [394, 379], [379, 364], [277, 343], [343, 437], [437, 277], [443, 444], [444, 283], [283, 443], [275, 440], [440, 363], [363, 275], [431, 262], [262, 369], [369, 431], [297, 338], [338, 337], [337, 297], [273, 375], [375, 321], [321, 273], [450, 451], [451, 349], [349, 450], [446, 342], [342, 467], [467, 446], [293, 334], [334, 282], [282, 293], [458, 461], [461, 462], [462, 458], [276, 353], [353, 383], [383, 276], [308, 324], [324, 325], [325, 308], [276, 300], [300, 293], [293, 276], [372, 345], [345, 447], [447, 372], [352, 345], [345, 340], [340, 352], [274, 1], [1, 19], [19, 274], [456, 248], [248, 281], [281, 456], [436, 427], [427, 425], [425, 436], [381, 256], [256, 252], [252, 381], [269, 391], [391, 393], [393, 269], [200, 199], [199, 428], [428, 200], [266, 330], [330, 329], [329, 266], [287, 273], [273, 422], [422, 287], [250, 462], [462, 328], [328, 250], [258, 286], [286, 384], [384, 258], [265, 353], [353, 342], [342, 265], [387, 259], [259, 257], [257, 387], [424, 431], [431, 430], [430, 424], [342, 353], [353, 276], [276, 342], [273, 335], [335, 424], [424, 273], [292, 325], [325, 307], [307, 292], [366, 447], [447, 345], [345, 366], [271, 303], [303, 302], [302, 271], [423, 266], [266, 371], [371, 423], [294, 455], [455, 460], [460, 294], [279, 278], [278, 294], [294, 279], [271, 272], [272, 304], [304, 271], [432, 434], [434, 427], [427, 432], [272, 407], [407, 408], [408, 272], [394, 430], [430, 431], [431, 394], [395, 369], [369, 400], [400, 395], [334, 333], [333, 299], [299, 334], [351, 417], [417, 168], [168, 351], [352, 280], [280, 411], [411, 352], [325, 319], [319, 320], [320, 325], [295, 296], [296, 336], [336, 295], [319, 403], [403, 404], [404, 319], [330, 348], [348, 349], [349, 330], [293, 298], [298, 333], [333, 293], [323, 454], [454, 447], [447, 323], [15, 16], [16, 315], [315, 15], [358, 429], [429, 279], [279, 358], [14, 15], [15, 316], [316, 14], [285, 336], [336, 9], [9, 285], [329, 349], [349, 350], [350, 329], [374, 380], [380, 252], [252, 374], [318, 402], [402, 403], [403, 318], [6, 197], [197, 419], [419, 6], [318, 319], [319, 325], [325, 318], [367, 364], [364, 365], [365, 367], [435, 367], [367, 397], [397, 435], [344, 438], [438, 439], [439, 344], [272, 271], [271, 311], [311, 272], [195, 5], [5, 281], [281, 195], [273, 287], [287, 291], [291, 273], [396, 428], [428, 199], [199, 396], [311, 271], [271, 268], [268, 311], [283, 444], [444, 445], [445, 283], [373, 254], [254, 339], [339, 373], [282, 334], [334, 296], [296, 282], [449, 347], [347, 346], [346, 449], [264, 447], [447, 454], [454, 264], [336, 296], [296, 299], [299, 336], [338, 10], [10, 151], [151, 338], [278, 439], [439, 455], [455, 278], [292, 407], [407, 415], [415, 292], [358, 371], [371, 355], [355, 358], [340, 345], [345, 372], [372, 340], [346, 347], [347, 280], [280, 346], [442, 443], [443, 282], [282, 442], [19, 94], [94, 370], [370, 19], [441, 442], [442, 295], [295, 441], [248, 419], [419, 197], [197, 248], [263, 255], [255, 359], [359, 263], [440, 275], [275, 274], [274, 440], [300, 383], [383, 368], [368, 300], [351, 412], [412, 465], [465, 351], [263, 467], [467, 466], [466, 263], [301, 368], [368, 389], [389, 301], [395, 378], [378, 379], [379, 395], [412, 351], [351, 419], [419, 412], [436, 426], [426, 322], [322, 436], [2, 164], [164, 393], [393, 2], [370, 462], [462, 461], [461, 370], [164, 0], [0, 267], [267, 164], [302, 11], [11, 12], [12, 302], [268, 12], [12, 13], [13, 268], [293, 300], [300, 301], [301, 293], [446, 261], [261, 340], [340, 446], [330, 266], [266, 425], [425, 330], [426, 423], [423, 391], [391, 426], [429, 355], [355, 437], [437, 429], [391, 327], [327, 326], [326, 391], [440, 457], [457, 438], [438, 440], [341, 382], [382, 362], [362, 341], [459, 457], [457, 461], [461, 459], [434, 430], [430, 394], [394, 434], [414, 463], [463, 362], [362, 414], [396, 369], [369, 262], [262, 396], [354, 461], [461, 457], [457, 354], [316, 403], [403, 402], [402, 316], [315, 404], [404, 403], [403, 315], [314, 405], [405, 404], [404, 314], [313, 406], [406, 405], [405, 313], [421, 418], [418, 406], [406, 421], [366, 401], [401, 361], [361, 366], [306, 408], [408, 407], [407, 306], [291, 409], [409, 408], [408, 291], [287, 410], [410, 409], [409, 287], [432, 436], [436, 410], [410, 432], [434, 416], [416, 411], [411, 434], [264, 368], [368, 383], [383, 264], [309, 438], [438, 457], [457, 309], [352, 376], [376, 401], [401, 352], [274, 275], [275, 4], [4, 274], [421, 428], [428, 262], [262, 421], [294, 327], [327, 358], [358, 294], [433, 416], [416, 367], [367, 433], [289, 455], [455, 439], [439, 289], [462, 370], [370, 326], [326, 462], [2, 326], [326, 370], [370, 2], [305, 460], [460, 455], [455, 305], [254, 449], [449, 448], [448, 254], [255, 261], [261, 446], [446, 255], [253, 450], [450, 449], [449, 253], [252, 451], [451, 450], [450, 252], [256, 452], [452, 451], [451, 256], [341, 453], [453, 452], [452, 341], [413, 464], [464, 463], [463, 413], [441, 413], [413, 414], [414, 441], [258, 442], [442, 441], [441, 258], [257, 443], [443, 442], [442, 257], [259, 444], [444, 443], [443, 259], [260, 445], [445, 444], [444, 260], [467, 342], [342, 445], [445, 467], [459, 458], [458, 250], [250, 459], [289, 392], [392, 290], [290, 289], [290, 328], [328, 460], [460, 290], [376, 433], [433, 435], [435, 376], [250, 290], [290, 392], [392, 250], [411, 416], [416, 433], [433, 411], [341, 463], [463, 464], [464, 341], [453, 464], [464, 465], [465, 453], [357, 465], [465, 412], [412, 357], [343, 412], [412, 399], [399, 343], [360, 363], [363, 440], [440, 360], [437, 399], [399, 456], [456, 437], [420, 456], [456, 363], [363, 420], [401, 435], [435, 288], [288, 401], [372, 383], [383, 353], [353, 372], [339, 255], [255, 249], [249, 339], [448, 261], [261, 255], [255, 448], [133, 243], [243, 190], [190, 133], [133, 155], [155, 112], [112, 133], [33, 246], [246, 247], [247, 33], [33, 130], [130, 25], [25, 33], [398, 384], [384, 286], [286, 398], [362, 398], [398, 414], [414, 362], [362, 463], [463, 341], [341, 362], [263, 359], [359, 467], [467, 263], [263, 249], [249, 255], [255, 263], [466, 467], [467, 260], [260, 466], [75, 60], [60, 166], [166, 75], [238, 239], [239, 79], [79, 238], [162, 127], [127, 139], [139, 162], [72, 11], [11, 37], [37, 72], [121, 232], [232, 120], [120, 121], [73, 72], [72, 39], [39, 73], [114, 128], [128, 47], [47, 114], [233, 232], [232, 128], [128, 233], [103, 104], [104, 67], [67, 103], [152, 175], [175, 148], [148, 152], [119, 118], [118, 101], [101, 119], [74, 73], [73, 40], [40, 74], [107, 9], [9, 108], [108, 107], [49, 48], [48, 131], [131, 49], [32, 194], [194, 211], [211, 32], [184, 74], [74, 185], [185, 184], [191, 80], [80, 183], [183, 191], [185, 40], [40, 186], [186, 185], [119, 230], [230, 118], [118, 119], [210, 202], [202, 214], [214, 210], [84, 83], [83, 17], [17, 84], [77, 76], [76, 146], [146, 77], [161, 160], [160, 30], [30, 161], [190, 56], [56, 173], [173, 190], [182, 106], [106, 194], [194, 182], [138, 135], [135, 192], [192, 138], [129, 203], [203, 98], [98, 129], [54, 21], [21, 68], [68, 54], [5, 51], [51, 4], [4, 5], [145, 144], [144, 23], [23, 145], [90, 77], [77, 91], [91, 90], [207, 205], [205, 187], [187, 207], [83, 201], [201, 18], [18, 83], [181, 91], [91, 182], [182, 181], [180, 90], [90, 181], [181, 180], [16, 85], [85, 17], [17, 16], [205, 206], [206, 36], [36, 205], [176, 148], [148, 140], [140, 176], [165, 92], [92, 39], [39, 165], [245, 193], [193, 244], [244, 245], [27, 159], [159, 28], [28, 27], [30, 247], [247, 161], [161, 30], [174, 236], [236, 196], [196, 174], [103, 54], [54, 104], [104, 103], [55, 193], [193, 8], [8, 55], [111, 117], [117, 31], [31, 111], [221, 189], [189, 55], [55, 221], [240, 98], [98, 99], [99, 240], [142, 126], [126, 100], [100, 142], [219, 166], [166, 218], [218, 219], [112, 155], [155, 26], [26, 112], [198, 209], [209, 131], [131, 198], [169, 135], [135, 150], [150, 169], [114, 47], [47, 217], [217, 114], [224, 223], [223, 53], [53, 224], [220, 45], [45, 134], [134, 220], [32, 211], [211, 140], [140, 32], [109, 67], [67, 108], [108, 109], [146, 43], [43, 91], [91, 146], [231, 230], [230, 120], [120, 231], [113, 226], [226, 247], [247, 113], [105, 63], [63, 52], [52, 105], [241, 238], [238, 242], [242, 241], [124, 46], [46, 156], [156, 124], [95, 78], [78, 96], [96, 95], [70, 46], [46, 63], [63, 70], [116, 143], [143, 227], [227, 116], [116, 123], [123, 111], [111, 116], [1, 44], [44, 19], [19, 1], [3, 236], [236, 51], [51, 3], [207, 216], [216, 205], [205, 207], [26, 154], [154, 22], [22, 26], [165, 39], [39, 167], [167, 165], [199, 200], [200, 208], [208, 199], [101, 36], [36, 100], [100, 101], [43, 57], [57, 202], [202, 43], [242, 20], [20, 99], [99, 242], [56, 28], [28, 157], [157, 56], [124, 35], [35, 113], [113, 124], [29, 160], [160, 27], [27, 29], [211, 204], [204, 210], [210, 211], [124, 113], [113, 46], [46, 124], [106, 43], [43, 204], [204, 106], [96, 62], [62, 77], [77, 96], [227, 137], [137, 116], [116, 227], [73, 41], [41, 72], [72, 73], [36, 203], [203, 142], [142, 36], [235, 64], [64, 240], [240, 235], [48, 49], [49, 64], [64, 48], [42, 41], [41, 74], [74, 42], [214, 212], [212, 207], [207, 214], [183, 42], [42, 184], [184, 183], [210, 169], [169, 211], [211, 210], [140, 170], [170, 176], [176, 140], [104, 105], [105, 69], [69, 104], [193, 122], [122, 168], [168, 193], [50, 123], [123, 187], [187, 50], [89, 96], [96, 90], [90, 89], [66, 65], [65, 107], [107, 66], [179, 89], [89, 180], [180, 179], [119, 101], [101, 120], [120, 119], [68, 63], [63, 104], [104, 68], [234, 93], [93, 227], [227, 234], [16, 15], [15, 85], [85, 16], [209, 129], [129, 49], [49, 209], [15, 14], [14, 86], [86, 15], [107, 55], [55, 9], [9, 107], [120, 100], [100, 121], [121, 120], [153, 145], [145, 22], [22, 153], [178, 88], [88, 179], [179, 178], [197, 6], [6, 196], [196, 197], [89, 88], [88, 96], [96, 89], [135, 138], [138, 136], [136, 135], [138, 215], [215, 172], [172, 138], [218, 115], [115, 219], [219, 218], [41, 42], [42, 81], [81, 41], [5, 195], [195, 51], [51, 5], [57, 43], [43, 61], [61, 57], [208, 171], [171, 199], [199, 208], [41, 81], [81, 38], [38, 41], [224, 53], [53, 225], [225, 224], [24, 144], [144, 110], [110, 24], [105, 52], [52, 66], [66, 105], [118, 229], [229, 117], [117, 118], [227, 34], [34, 234], [234, 227], [66, 107], [107, 69], [69, 66], [10, 109], [109, 151], [151, 10], [219, 48], [48, 235], [235, 219], [183, 62], [62, 191], [191, 183], [142, 129], [129, 126], [126, 142], [116, 111], [111, 143], [143, 116], [118, 117], [117, 50], [50, 118], [223, 222], [222, 52], [52, 223], [94, 19], [19, 141], [141, 94], [222, 221], [221, 65], [65, 222], [196, 3], [3, 197], [197, 196], [45, 220], [220, 44], [44, 45], [156, 70], [70, 139], [139, 156], [188, 122], [122, 245], [245, 188], [139, 71], [71, 162], [162, 139], [149, 170], [170, 150], [150, 149], [122, 188], [188, 196], [196, 122], [206, 216], [216, 92], [92, 206], [164, 2], [2, 167], [167, 164], [242, 141], [141, 241], [241, 242], [0, 164], [164, 37], [37, 0], [11, 72], [72, 12], [12, 11], [12, 38], [38, 13], [13, 12], [70, 63], [63, 71], [71, 70], [31, 226], [226, 111], [111, 31], [36, 101], [101, 205], [205, 36], [203, 206], [206, 165], [165, 203], [126, 209], [209, 217], [217, 126], [98, 165], [165, 97], [97, 98], [237, 220], [220, 218], [218, 237], [237, 239], [239, 241], [241, 237], [210, 214], [214, 169], [169, 210], [140, 171], [171, 32], [32, 140], [241, 125], [125, 237], [237, 241], [179, 86], [86, 178], [178, 179], [180, 85], [85, 179], [179, 180], [181, 84], [84, 180], [180, 181], [182, 83], [83, 181], [181, 182], [194, 201], [201, 182], [182, 194], [177, 137], [137, 132], [132, 177], [184, 76], [76, 183], [183, 184], [185, 61], [61, 184], [184, 185], [186, 57], [57, 185], [185, 186], [216, 212], [212, 186], [186, 216], [192, 214], [214, 187], [187, 192], [139, 34], [34, 156], [156, 139], [218, 79], [79, 237], [237, 218], [147, 123], [123, 177], [177, 147], [45, 44], [44, 4], [4, 45], [208, 201], [201, 32], [32, 208], [98, 64], [64, 129], [129, 98], [192, 213], [213, 138], [138, 192], [235, 59], [59, 219], [219, 235], [141, 242], [242, 97], [97, 141], [97, 2], [2, 141], [141, 97], [240, 75], [75, 235], [235, 240], [229, 24], [24, 228], [228, 229], [31, 25], [25, 226], [226, 31], [230, 23], [23, 229], [229, 230], [231, 22], [22, 230], [230, 231], [232, 26], [26, 231], [231, 232], [233, 112], [112, 232], [232, 233], [244, 189], [189, 243], [243, 244], [189, 221], [221, 190], [190, 189], [222, 28], [28, 221], [221, 222], [223, 27], [27, 222], [222, 223], [224, 29], [29, 223], [223, 224], [225, 30], [30, 224], [224, 225], [113, 247], [247, 225], [225, 113], [99, 60], [60, 240], [240, 99], [213, 147], [147, 215], [215, 213], [60, 20], [20, 166], [166, 60], [192, 187], [187, 213], [213, 192], [243, 112], [112, 244], [244, 243], [244, 233], [233, 245], [245, 244], [245, 128], [128, 188], [188, 245], [188, 114], [114, 174], [174, 188], [134, 131], [131, 220], [220, 134], [174, 217], [217, 236], [236, 174], [236, 198], [198, 134], [134, 236], [215, 177], [177, 58], [58, 215], [156, 143], [143, 124], [124, 156], [25, 110], [110, 7], [7, 25], [31, 228], [228, 25], [25, 31], [264, 356], [356, 368], [368, 264], [0, 11], [11, 267], [267, 0], [451, 452], [452, 349], [349, 451], [267, 302], [302, 269], [269, 267], [350, 357], [357, 277], [277, 350], [350, 452], [452, 357], [357, 350], [299, 333], [333, 297], [297, 299], [396, 175], [175, 377], [377, 396], [280, 347], [347, 330], [330, 280], [269, 303], [303, 270], [270, 269], [151, 9], [9, 337], [337, 151], [344, 278], [278, 360], [360, 344], [424, 418], [418, 431], [431, 424], [270, 304], [304, 409], [409, 270], [272, 310], [310, 407], [407, 272], [322, 270], [270, 410], [410, 322], [449, 450], [450, 347], [347, 449], [432, 422], [422, 434], [434, 432], [18, 313], [313, 17], [17, 18], [291, 306], [306, 375], [375, 291], [259, 387], [387, 260], [260, 259], [424, 335], [335, 418], [418, 424], [434, 364], [364, 416], [416, 434], [391, 423], [423, 327], [327, 391], [301, 251], [251, 298], [298, 301], [275, 281], [281, 4], [4, 275], [254, 373], [373, 253], [253, 254], [375, 307], [307, 321], [321, 375], [280, 425], [425, 411], [411, 280], [200, 421], [421, 18], [18, 200], [335, 321], [321, 406], [406, 335], [321, 320], [320, 405], [405, 321], [314, 315], [315, 17], [17, 314], [423, 426], [426, 266], [266, 423], [396, 377], [377, 369], [369, 396], [270, 322], [322, 269], [269, 270], [413, 417], [417, 464], [464, 413], [385, 386], [386, 258], [258, 385], [248, 456], [456, 419], [419, 248], [298, 284], [284, 333], [333, 298], [168, 417], [417, 8], [8, 168], [448, 346], [346, 261], [261, 448], [417, 413], [413, 285], [285, 417], [326, 327], [327, 328], [328, 326], [277, 355], [355, 329], [329, 277], [309, 392], [392, 438], [438, 309], [381, 382], [382, 256], [256, 381], [279, 429], [429, 360], [360, 279], [365, 364], [364, 379], [379, 365], [355, 277], [277, 437], [437, 355], [282, 443], [443, 283], [283, 282], [281, 275], [275, 363], [363, 281], [395, 431], [431, 369], [369, 395], [299, 297], [297, 337], [337, 299], [335, 273], [273, 321], [321, 335], [348, 450], [450, 349], [349, 348], [359, 446], [446, 467], [467, 359], [283, 293], [293, 282], [282, 283], [250, 458], [458, 462], [462, 250], [300, 276], [276, 383], [383, 300], [292, 308], [308, 325], [325, 292], [283, 276], [276, 293], [293, 283], [264, 372], [372, 447], [447, 264], [346, 352], [352, 340], [340, 346], [354, 274], [274, 19], [19, 354], [363, 456], [456, 281], [281, 363], [426, 436], [436, 425], [425, 426], [380, 381], [381, 252], [252, 380], [267, 269], [269, 393], [393, 267], [421, 200], [200, 428], [428, 421], [371, 266], [266, 329], [329, 371], [432, 287], [287, 422], [422, 432], [290, 250], [250, 328], [328, 290], [385, 258], [258, 384], [384, 385], [446, 265], [265, 342], [342, 446], [386, 387], [387, 257], [257, 386], [422, 424], [424, 430], [430, 422], [445, 342], [342, 276], [276, 445], [422, 273], [273, 424], [424, 422], [306, 292], [292, 307], [307, 306], [352, 366], [366, 345], [345, 352], [268, 271], [271, 302], [302, 268], [358, 423], [423, 371], [371, 358], [327, 294], [294, 460], [460, 327], [331, 279], [279, 294], [294, 331], [303, 271], [271, 304], [304, 303], [436, 432], [432, 427], [427, 436], [304, 272], [272, 408], [408, 304], [395, 394], [394, 431], [431, 395], [378, 395], [395, 400], [400, 378], [296, 334], [334, 299], [299, 296], [6, 351], [351, 168], [168, 6], [376, 352], [352, 411], [411, 376], [307, 325], [325, 320], [320, 307], [285, 295], [295, 336], [336, 285], [320, 319], [319, 404], [404, 320], [329, 330], [330, 349], [349, 329], [334, 293], [293, 333], [333, 334], [366, 323], [323, 447], [447, 366], [316, 15], [15, 315], [315, 316], [331, 358], [358, 279], [279, 331], [317, 14], [14, 316], [316, 317], [8, 285], [285, 9], [9, 8], [277, 329], [329, 350], [350, 277], [253, 374], [374, 252], [252, 253], [319, 318], [318, 403], [403, 319], [351, 6], [6, 419], [419, 351], [324, 318], [318, 325], [325, 324], [397, 367], [367, 365], [365, 397], [288, 435], [435, 397], [397, 288], [278, 344], [344, 439], [439, 278], [310, 272], [272, 311], [311, 310], [248, 195], [195, 281], [281, 248], [375, 273], [273, 291], [291, 375], [175, 396], [396, 199], [199, 175], [312, 311], [311, 268], [268, 312], [276, 283], [283, 445], [445, 276], [390, 373], [373, 339], [339, 390], [295, 282], [282, 296], [296, 295], [448, 449], [449, 346], [346, 448], [356, 264], [264, 454], [454, 356], [337, 336], [336, 299], [299, 337], [337, 338], [338, 151], [151, 337], [294, 278], [278, 455], [455, 294], [308, 292], [292, 415], [415, 308], [429, 358], [358, 355], [355, 429], [265, 340], [340, 372], [372, 265], [352, 346], [346, 280], [280, 352], [295, 442], [442, 282], [282, 295], [354, 19], [19, 370], [370, 354], [285, 441], [441, 295], [295, 285], [195, 248], [248, 197], [197, 195], [457, 440], [440, 274], [274, 457], [301, 300], [300, 368], [368, 301], [417, 351], [351, 465], [465, 417], [251, 301], [301, 389], [389, 251], [394, 395], [395, 379], [379, 394], [399, 412], [412, 419], [419, 399], [410, 436], [436, 322], [322, 410], [326, 2], [2, 393], [393, 326], [354, 370], [370, 461], [461, 354], [393, 164], [164, 267], [267, 393], [268, 302], [302, 12], [12, 268], [312, 268], [268, 13], [13, 312], [298, 293], [293, 301], [301, 298], [265, 446], [446, 340], [340, 265], [280, 330], [330, 425], [425, 280], [322, 426], [426, 391], [391, 322], [420, 429], [429, 437], [437, 420], [393, 391], [391, 326], [326, 393], [344, 440], [440, 438], [438, 344], [458, 459], [459, 461], [461, 458], [364, 434], [434, 394], [394, 364], [428, 396], [396, 262], [262, 428], [274, 354], [354, 457], [457, 274], [317, 316], [316, 402], [402, 317], [316, 315], [315, 403], [403, 316], [315, 314], [314, 404], [404, 315], [314, 313], [313, 405], [405, 314], [313, 421], [421, 406], [406, 313], [323, 366], [366, 361], [361, 323], [292, 306], [306, 407], [407, 292], [306, 291], [291, 408], [408, 306], [291, 287], [287, 409], [409, 291], [287, 432], [432, 410], [410, 287], [427, 434], [434, 411], [411, 427], [372, 264], [264, 383], [383, 372], [459, 309], [309, 457], [457, 459], [366, 352], [352, 401], [401, 366], [1, 274], [274, 4], [4, 1], [418, 421], [421, 262], [262, 418], [331, 294], [294, 358], [358, 331], [435, 433], [433, 367], [367, 435], [392, 289], [289, 439], [439, 392], [328, 462], [462, 326], [326, 328], [94, 2], [2, 370], [370, 94], [289, 305], [305, 455], [455, 289], [339, 254], [254, 448], [448, 339], [359, 255], [255, 446], [446, 359], [254, 253], [253, 449], [449, 254], [253, 252], [252, 450], [450, 253], [252, 256], [256, 451], [451, 252], [256, 341], [341, 452], [452, 256], [414, 413], [413, 463], [463, 414], [286, 441], [441, 414], [414, 286], [286, 258], [258, 441], [441, 286], [258, 257], [257, 442], [442, 258], [257, 259], [259, 443], [443, 257], [259, 260], [260, 444], [444, 259], [260, 467], [467, 445], [445, 260], [309, 459], [459, 250], [250, 309], [305, 289], [289, 290], [290, 305], [305, 290], [290, 460], [460, 305], [401, 376], [376, 435], [435, 401], [309, 250], [250, 392], [392, 309], [376, 411], [411, 433], [433, 376], [453, 341], [341, 464], [464, 453], [357, 453], [453, 465], [465, 357], [343, 357], [357, 412], [412, 343], [437, 343], [343, 399], [399, 437], [344, 360], [360, 440], [440, 344], [420, 437], [437, 456], [456, 420], [360, 420], [420, 363], [363, 360], [361, 401], [401, 288], [288, 361], [265, 372], [372, 353], [353, 265], [390, 339], [339, 249], [249, 390], [339, 448], [448, 255], [255, 339]]) }).call(IR); var FR = function () { return FR = Object.assign || function (e) { for (var t, n = 1, r = arguments.length; n < r; n++)for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]); return e }, FR.apply(this, arguments) }; function DR(e, t, n, r) { return new (n || (n = Promise))((function (i, a) { function o(e) { try { u(r.next(e)) } catch (e) { a(e) } } function s(e) { try { u(r.throw(e)) } catch (e) { a(e) } } function u(e) { var t; e.done ? i(e.value) : (t = e.value, t instanceof n ? t : new n((function (e) { e(t) }))).then(o, s) } u((r = r.apply(e, t || [])).next()) })) } function $R(e, t) { var n, r, i, a, o = { label: 0, sent: function () { if (1 & i[0]) throw i[1]; return i[1] }, trys: [], ops: [] }; return a = { next: s(0), throw: s(1), return: s(2) }, "function" == typeof Symbol && (a[Symbol.iterator] = function () { return this }), a; function s(a) { return function (s) { return function (a) { if (n) throw new TypeError("Generator is already executing."); for (; o;)try { if (n = 1, r && (i = 2 & a[0] ? r.return : a[0] ? r.throw || ((i = r.return) && i.call(r), 0) : r.next) && !(i = i.call(r, a[1])).done) return i; switch (r = 0, i && (a = [2 & a[0], i.value]), a[0]) { case 0: case 1: i = a; break; case 4: return o.label++, { value: a[1], done: !1 }; case 5: o.label++, r = a[1], a = [0]; continue; case 7: a = o.ops.pop(), o.trys.pop(); continue; default: if (!((i = (i = o.trys).length > 0 && i[i.length - 1]) || 6 !== a[0] && 2 !== a[0])) { o = 0; continue } if (3 === a[0] && (!i || a[1] > i[0] && a[1] < i[3])) { o.label = a[1]; break } if (6 === a[0] && o.label < i[1]) { o.label = i[1], i = a; break } if (i && o.label < i[2]) { o.label = i[2], o.ops.push(a); break } i[2] && o.ops.pop(), o.trys.pop(); continue }a = t.call(e, o) } catch (e) { a = [6, e], r = 0 } finally { n = i = 0 } if (5 & a[0]) throw a[1]; return { value: a[0] ? a[1] : void 0, done: !0 } }([a, s]) } } } var RR = ["rightEye", "leftEye", "noseTip", "mouthCenter", "rightEarTragion", "leftEarTragion"], OR = { modelType: "short", runtime: "mediapipe", maxFaces: 1 }, zR = function () { function e(e) { var t = this; this.width = 0, this.height = 0, this.selfieMode = !1, this.faceDetectorSolution = new MR.FaceDetection({ locateFile: function (t, n) { return e.solutionPath ? e.solutionPath.replace(/\/+$/, "") + "/" + t : n + "/" + t } }), this.faceDetectorSolution.setOptions({ selfieMode: this.selfieMode, model: e.modelType }), this.faceDetectorSolution.onResults((function (e) { if (t.height = e.image.height, t.width = e.image.width, t.faces = [], null !== e.detections) for (var n = 0, r = e.detections; n < r.length; n++) { var i = r[n]; t.faces.push(t.normalizedToAbsolute(i.landmarks, { xMin: o = (a = i.boundingBox).xCenter - a.width / 2, xMax: o + a.width, yMin: s = a.yCenter - a.height / 2, yMax: s + a.height, width: a.width, height: a.height })) } var a, o, s })) } return e.prototype.normalizedToAbsolute = function (e, t) { var n = this; return { keypoints: e.map((function (e, t) { return { x: e.x * n.width, y: e.y * n.height, name: RR[t] } })), box: { xMin: t.xMin * this.width, yMin: t.yMin * this.height, xMax: t.xMax * this.width, yMax: t.yMax * this.height, width: t.width * this.width, height: t.height * this.height } } }, e.prototype.estimateFaces = function (e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { switch (i.label) { case 0: return t && t.flipHorizontal && t.flipHorizontal !== this.selfieMode && (this.selfieMode = t.flipHorizontal, this.faceDetectorSolution.setOptions({ selfieMode: this.selfieMode })), e instanceof P.Tensor ? (r = ImageData.bind, [4, P.browser.toPixels(e)]) : [3, 2]; case 1: return n = new (r.apply(ImageData, [void 0, i.sent(), e.shape[1], e.shape[0]])), [3, 3]; case 2: n = e, i.label = 3; case 3: return e = n, [4, this.faceDetectorSolution.send({ image: e })]; case 4: return i.sent(), [2, this.faces] } })) })) }, e.prototype.dispose = function () { this.faceDetectorSolution.close() }, e.prototype.reset = function () { this.faceDetectorSolution.reset(), this.width = 0, this.height = 0, this.faces = null, this.selfieMode = !1 }, e.prototype.initialize = function () { return this.faceDetectorSolution.initialize() }, e }(); function PR(e) { return DR(this, void 0, void 0, (function () { var t, n; return $R(this, (function (r) { switch (r.label) { case 0: return t = function (e) { if (null == e) return FR({}, OR); var t = FR({}, e); return t.runtime = "mediapipe", null == t.modelType && (t.modelType = OR.modelType), null == t.maxFaces && (t.maxFaces = OR.maxFaces), t }(e), [4, (n = new zR(t)).initialize()]; case 1: return r.sent(), [2, n] } })) })) } function BR(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function LR(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function jR(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function UR(e) { null == e.reduceBoxesInLowestLayer && (e.reduceBoxesInLowestLayer = !1), null == e.interpolatedScaleAspectRatio && (e.interpolatedScaleAspectRatio = 1), null == e.fixedAnchorSize && (e.fixedAnchorSize = !1); for (var t = [], n = 0; n < e.numLayers;) { for (var r = [], i = [], a = [], o = [], s = n; s < e.strides.length && e.strides[s] === e.strides[n];) { var u = WR(e.minScale, e.maxScale, s, e.strides.length); if (0 === s && e.reduceBoxesInLowestLayer) a.push(1), a.push(2), a.push(.5), o.push(.1), o.push(u), o.push(u); else { for (var l = 0; l < e.aspectRatios.length; ++l)a.push(e.aspectRatios[l]), o.push(u); if (e.interpolatedScaleAspectRatio > 0) { var c = s === e.strides.length - 1 ? 1 : WR(e.minScale, e.maxScale, s + 1, e.strides.length); o.push(Math.sqrt(u * c)), a.push(e.interpolatedScaleAspectRatio) } } s++ } for (var h = 0; h < a.length; ++h) { var d = Math.sqrt(a[h]); r.push(o[h] / d), i.push(o[h] * d) } var f = 0, p = 0; if (e.featureMapHeight.length > 0) f = e.featureMapHeight[n], p = e.featureMapWidth[n]; else { var m = e.strides[n]; f = Math.ceil(e.inputSizeHeight / m), p = Math.ceil(e.inputSizeWidth / m) } for (var g = 0; g < f; ++g)for (var y = 0; y < p; ++y)for (var b = 0; b < r.length; ++b) { var v = { xCenter: (y + e.anchorOffsetX) / p, yCenter: (g + e.anchorOffsetY) / f, width: 0, height: 0 }; e.fixedAnchorSize ? (v.width = 1, v.height = 1) : (v.width = i[b], v.height = r[b]), t.push(v) } n = s } return t } function WR(e, t, n, r) { return 1 === r ? .5 * (e + t) : e + (t - e) * n / (r - 1) } function VR(e, t) { var n = t[0], r = t[1]; return [n * e[0] + r * e[1] + e[3], n * e[4] + r * e[5] + e[7]] } function GR(e, t, n, r) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s; return $R(this, (function (u) { switch (u.label) { case 0: return e.sort((function (e, t) { return Math.max.apply(Math, t.score) - Math.max.apply(Math, e.score) })), r = (0, P.tensor2d)(e.map((function (e) { return [e.locationData.relativeBoundingBox.yMin, e.locationData.relativeBoundingBox.xMin, e.locationData.relativeBoundingBox.yMax, e.locationData.relativeBoundingBox.xMax] }))), i = (0, P.tensor1d)(e.map((function (e) { return e.score[0] }))), [4, P.image.nonMaxSuppressionAsync(r, i, t, n)]; case 1: return [4, (a = u.sent()).array()]; case 2: return o = u.sent(), s = e.filter((function (e, t) { return o.indexOf(t) > -1 })), (0, P.dispose)([r, i, a]), [2, s] } })) })) } function HR(e, t, n) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s; return $R(this, (function (u) { switch (u.label) { case 0: return r = e[0], i = e[1], a = function (e, t, n) { return (0, P.tidy)((function () { var r, i, a, o; n.reverseOutputOrder ? (i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))) : (r = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 0], [-1, 1])), i = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 1], [-1, 1])), a = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 2], [-1, 1])), o = (0, P.squeeze)((0, P.slice)(e, [0, n.boxCoordOffset + 3], [-1, 1]))), i = (0, P.add)((0, P.mul)((0, P.div)(i, n.xScale), t.w), t.x), r = (0, P.add)((0, P.mul)((0, P.div)(r, n.yScale), t.h), t.y), n.applyExponentialOnBoxSize ? (a = (0, P.mul)((0, P.exp)((0, P.div)(a, n.hScale)), t.h), o = (0, P.mul)((0, P.exp)((0, P.div)(o, n.wScale)), t.w)) : (a = (0, P.mul)((0, P.div)(a, n.hScale), t.h), o = (0, P.mul)((0, P.div)(o, n.wScale), t.h)); var s = (0, P.sub)(r, (0, P.div)(a, 2)), u = (0, P.sub)(i, (0, P.div)(o, 2)), l = (0, P.add)(r, (0, P.div)(a, 2)), c = (0, P.add)(i, (0, P.div)(o, 2)), h = (0, P.concat)([(0, P.reshape)(s, [n.numBoxes, 1]), (0, P.reshape)(u, [n.numBoxes, 1]), (0, P.reshape)(l, [n.numBoxes, 1]), (0, P.reshape)(c, [n.numBoxes, 1])], 1); if (n.numKeypoints) for (var d = 0; d < n.numKeypoints; ++d) { var f = n.keypointCoordOffset + d * n.numValuesPerKeypoint, p = void 0, m = void 0; n.reverseOutputOrder ? (p = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), m = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))) : (m = (0, P.squeeze)((0, P.slice)(e, [0, f], [-1, 1])), p = (0, P.squeeze)((0, P.slice)(e, [0, f + 1], [-1, 1]))); var g = (0, P.add)((0, P.mul)((0, P.div)(p, n.xScale), t.w), t.x), y = (0, P.add)((0, P.mul)((0, P.div)(m, n.yScale), t.h), t.y); h = (0, P.concat)([h, (0, P.reshape)(g, [n.numBoxes, 1]), (0, P.reshape)(y, [n.numBoxes, 1])], 1) } return h })) }(i, t, n), o = (0, P.tidy)((function () { var e = r; return n.sigmoidScore ? (null != n.scoreClippingThresh && (e = (0, P.clipByValue)(r, -n.scoreClippingThresh, n.scoreClippingThresh)), e = (0, P.sigmoid)(e)) : e })), [4, qR(a, o, n)]; case 1: return s = u.sent(), (0, P.dispose)([a, o]), [2, s] } })) })) } function qR(e, t, n) { return DR(this, void 0, void 0, (function () { var r, i, a, o, s, u, l, c, h, d, f, p; return $R(this, (function (m) { switch (m.label) { case 0: return r = [], [4, e.data()]; case 1: return i = m.sent(), [4, t.data()]; case 2: for (a = m.sent(), o = 0; o < n.numBoxes; ++o)if (!(null != n.minScoreThresh && a[o] < n.minScoreThresh || (s = o * n.numCoords, u = YR(i[s + 0], i[s + 1], i[s + 2], i[s + 3], a[o], n.flipVertically, o), (l = u.locationData.relativeBoundingBox).width < 0 || l.height < 0))) { if (n.numKeypoints > 0) for ((c = u.locationData).relativeKeypoints = [], h = n.numKeypoints * n.numValuesPerKeypoint, d = 0; d < h; d += n.numValuesPerKeypoint)f = s + n.keypointCoordOffset + d, p = { x: i[f + 0], y: n.flipVertically ? 1 - i[f + 1] : i[f + 1] }, c.relativeKeypoints.push(p); r.push(u) } return [2, r] } })) })) } function YR(e, t, n, r, i, a, o) { return { score: [i], ind: o, locationData: { relativeBoundingBox: { xMin: t, yMin: a ? 1 - n : e, xMax: r, yMax: a ? 1 - e : n, width: r - t, height: n - e } } } } var XR, KR = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 1, featureMapHeight: [], featureMapWidth: [], numLayers: 4, minScale: .1484375, maxScale: .75, inputSizeHeight: 128, inputSizeWidth: 128, anchorOffsetX: .5, anchorOffsetY: .5, strides: [8, 16, 16, 16], aspectRatios: [1], fixedAnchorSize: !0 }, ZR = { reduceBoxesInLowestLayer: !1, interpolatedScaleAspectRatio: 0, featureMapHeight: [], featureMapWidth: [], numLayers: 1, minScale: .1484375, maxScale: .75, inputSizeHeight: 192, inputSizeWidth: 192, anchorOffsetX: .5, anchorOffsetY: .5, strides: [4], aspectRatios: [1], fixedAnchorSize: !0 }, JR = { runtime: "tfjs", modelType: "short", maxFaces: 1, detectorModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1" }, QR = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 896, numCoords: 16, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 6, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 128, yScale: 128, hScale: 128, wScale: 128, minScoreThresh: .5 }, eO = { applyExponentialOnBoxSize: !1, flipVertically: !1, ignoreClasses: [], numClasses: 1, numBoxes: 2304, numCoords: 16, boxCoordOffset: 0, keypointCoordOffset: 4, numKeypoints: 6, numValuesPerKeypoint: 2, sigmoidScore: !0, scoreClippingThresh: 100, reverseOutputOrder: !0, xScale: 192, yScale: 192, hScale: 192, wScale: 192, minScoreThresh: .6 }, tO = { outputTensorSize: { width: 128, height: 128 }, keepAspectRatio: !0, outputTensorFloatRange: [-1, 1], borderMode: "zero" }, nO = { outputTensorSize: { width: 192, height: 192 }, keepAspectRatio: !0, outputTensorFloatRange: [-1, 1], borderMode: "zero" }, rO = function () { function e(e, t, n) { this.detectorModel = t, this.maxFaces = n, "full" === e ? (this.imageToTensorConfig = nO, this.tensorsToDetectionConfig = eO, this.anchors = UR(ZR)) : (this.imageToTensorConfig = tO, this.tensorsToDetectionConfig = QR, this.anchors = UR(KR)); var r = (0, P.tensor1d)(this.anchors.map((function (e) { return e.width }))), i = (0, P.tensor1d)(this.anchors.map((function (e) { return e.height }))), a = (0, P.tensor1d)(this.anchors.map((function (e) { return e.xCenter }))), o = (0, P.tensor1d)(this.anchors.map((function (e) { return e.yCenter }))); this.anchorTensor = { x: a, y: o, w: r, h: i } } return e.prototype.dispose = function () { this.detectorModel.dispose(), (0, P.dispose)([this.anchorTensor.x, this.anchorTensor.y, this.anchorTensor.w, this.anchorTensor.h]) }, e.prototype.reset = function () { }, e.prototype.detectFaces = function (e, t) { return void 0 === t && (t = !1), DR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d; return $R(this, (function (f) { switch (f.label) { case 0: return null == e ? (this.reset(), [2, []]) : (n = (0, P.tidy)((function () { var n = (0, P.cast)(LR(e), "float32"); return t && (n = (0, P.squeeze)(P.image.flipLeftRight((0, P.expandDims)(n, 0)), [0])), n })), r = function (e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = BR(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; jR(t, "targetSize"), jR(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n) { var r = e.width, i = e.height, a = Math.cos(e.rotation), o = Math.sin(e.rotation), s = e.xCenter, u = e.yCenter, l = 1 / t, c = 1 / n, h = new Array(16); return h[0] = r * a * 1 * l, h[1] = -i * o * l, h[2] = 0, h[3] = (-.5 * r * a * 1 + .5 * i * o + s) * l, h[4] = r * o * 1 * c, h[5] = i * a * c, h[6] = 0, h[7] = (-.5 * i * a - .5 * r * o * 1 + u) * c, h[8] = 0, h[9] = 0, h[10] = r * l, h[11] = 0, h[12] = 0, h[13] = 0, h[14] = 0, h[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(h) }(u, s.width, s.height), h = (0, P.tidy)((function () { var t = LR(e), n = (0, P.tensor2d)(function (e, t, n) { return jR(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform((0, P.expandDims)((0, P.cast)(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return (0, P.tidy)((function () { return (0, P.add)((0, P.mul)(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } }(n, this.imageToTensorConfig), i = r.imageTensor, a = r.transformationMatrix, o = this.detectorModel.execute(i, "Identity:0"), s = function (e) { return (0, P.tidy)((function () { var t = function (e) { return (0, P.tidy)((function () { return [(0, P.slice)(e, [0, 0, 0], [1, -1, 1]), (0, P.slice)(e, [0, 0, 1], [1, -1, -1])] })) }(e), n = t[0], r = t[1]; return { boxes: (0, P.squeeze)(r), logits: (0, P.squeeze)(n) } })) }(o), u = s.boxes, [4, HR([l = s.logits, u], this.anchorTensor, this.tensorsToDetectionConfig)]); case 1: return 0 === (c = f.sent()).length ? ((0, P.dispose)([n, i, o, l, u]), [2, c]) : [4, GR(c, this.maxFaces, .3)]; case 2: return h = f.sent(), d = function (e, t) { void 0 === e && (e = []); var n, r = (n = t, [].concat.apply([], n)); return e.forEach((function (e) { var t = e.locationData; t.relativeKeypoints.forEach((function (e) { var t = VR(r, [e.x, e.y]), n = t[0], i = t[1]; e.x = n, e.y = i })); var n = t.relativeBoundingBox, i = Number.MAX_VALUE, a = Number.MAX_VALUE, o = Number.MIN_VALUE, s = Number.MIN_VALUE;[[n.xMin, n.yMin], [n.xMin + n.width, n.yMin], [n.xMin + n.width, n.yMin + n.height], [n.xMin, n.yMin + n.height]].forEach((function (e) { var t = VR(r, e), n = t[0], u = t[1]; i = Math.min(i, n), o = Math.max(o, n), a = Math.min(a, u), s = Math.max(s, u) })), t.relativeBoundingBox = { xMin: i, xMax: o, yMin: a, yMax: s, width: o - i, height: s - a } })), e }(h, a), (0, P.dispose)([n, i, o, l, u]), [2, d] } })) })) }, e.prototype.estimateFaces = function (e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { return n = BR(e), r = !!t && t.flipHorizontal, [2, this.detectFaces(e, r).then((function (e) { return e.map((function (e) { for (var t = e.locationData.relativeKeypoints.map((function (e, t) { return FR(FR({}, e), { x: e.x * n.width, y: e.y * n.height, name: RR[t] }) })), r = e.locationData.relativeBoundingBox, i = 0, a = ["width", "xMax", "xMin"]; i < a.length; i++)r[a[i]] *= n.width; for (var o = 0, s = ["height", "yMax", "yMin"]; o < s.length; o++)r[s[o]] *= n.height; return { keypoints: t, box: r } })) }))] })) })) }, e }(); function iO(e) { return DR(this, void 0, void 0, (function () { var t, n, r; return $R(this, (function (i) { switch (i.label) { case 0: return t = function (e) { if (null == e) return FR({}, JR); var t = FR({}, e); return null == t.modelType && (t.modelType = JR.modelType), null == t.maxFaces && (t.maxFaces = JR.maxFaces), null == t.detectorModelUrl && ("full" === t.modelType ? t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/face_detection/full/1" : t.detectorModelUrl = "https://tfhub.dev/mediapipe/tfjs-model/face_detection/short/1"), t }(e), n = "string" == typeof t.detectorModelUrl && t.detectorModelUrl.indexOf("https://tfhub.dev") > -1, [4, Ud(t.detectorModelUrl, { fromTFHub: n })]; case 1: return r = i.sent(), [2, new rO(t.modelType, r, t.maxFaces)] } })) })) } function aO(e, t) { return DR(this, void 0, void 0, (function () { var n, r; return $R(this, (function (i) { if (e === XR.MediaPipeFaceDetector) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, iO(n)]; if ("mediapipe" === n.runtime) return [2, PR(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) } function oO(e) { return e.width * e.height } function sO(e) { var t = e.xCenter - e.width / 2, n = t + e.width, r = e.yCenter - e.height / 2; return { xMin: t, xMax: n, yMin: r, yMax: r + e.height, width: e.width, height: e.height } } function uO(e) { return e instanceof P.Tensor ? { height: e.shape[0], width: e.shape[1] } : { height: e.height, width: e.width } } function lO(e) { return e - 2 * Math.PI * Math.floor((e + Math.PI) / (2 * Math.PI)) } function cO(e) { return e instanceof P.Tensor ? e : P.browser.fromPixels(e) } function hO(e, t) { P.util.assert(0 !== e.width, (function () { return t + " width cannot be 0." })), P.util.assert(0 !== e.height, (function () { return t + " height cannot be 0." })) } function dO(e, t, n) { var r = t.outputTensorSize, i = t.keepAspectRatio, a = t.borderMode, o = t.outputTensorFloatRange, s = uO(e), u = function (e, t) { return t ? { xCenter: t.xCenter * e.width, yCenter: t.yCenter * e.height, width: t.width * e.width, height: t.height * e.height, rotation: t.rotation } : { xCenter: .5 * e.width, yCenter: .5 * e.height, width: e.width, height: e.height, rotation: 0 } }(s, n), l = function (e, t, n) { if (void 0 === n && (n = !1), !n) return { top: 0, left: 0, right: 0, bottom: 0 }; var r = t.height, i = t.width; hO(t, "targetSize"), hO(e, "roi"); var a, o, s = r / i, u = e.height / e.width, l = 0, c = 0; return s > u ? (a = e.width, o = e.width * s, c = (1 - u / s) / 2) : (a = e.height / s, o = e.height, l = (1 - s / u) / 2), e.width = a, e.height = o, { top: c, left: l, right: l, bottom: c } }(u, r, i), c = function (e, t, n, r) { var i = e.width, a = e.height, o = r ? -1 : 1, s = Math.cos(e.rotation), u = Math.sin(e.rotation), l = e.xCenter, c = e.yCenter, h = 1 / t, d = 1 / n, f = new Array(16); return f[0] = i * s * o * h, f[1] = -a * u * h, f[2] = 0, f[3] = (-.5 * i * s * o + .5 * a * u + l) * h, f[4] = i * u * o * d, f[5] = a * s * d, f[6] = 0, f[7] = (-.5 * a * s - .5 * i * u * o + c) * d, f[8] = 0, f[9] = 0, f[10] = i * h, f[11] = 0, f[12] = 0, f[13] = 0, f[14] = 0, f[15] = 1, function (e) { if (16 !== e.length) throw new Error("Array length must be 16 but got " + e.length); return [[e[0], e[1], e[2], e[3]], [e[4], e[5], e[6], e[7]], [e[8], e[9], e[10], e[11]], [e[12], e[13], e[14], e[15]]] }(f) }(u, s.width, s.height, !1), h = P.tidy((function () { var t = cO(e), n = P.tensor2d(function (e, t, n) { return hO(n, "inputResolution"), [1 / n.width * e[0][0] * t.width, 1 / n.height * e[0][1] * t.width, e[0][3] * t.width, 1 / n.width * e[1][0] * t.height, 1 / n.height * e[1][1] * t.height, e[1][3] * t.height, 0, 0] }(c, s, r), [1, 8]), i = "zero" === a ? "constant" : "nearest", u = P.image.transform(P.expandDims(P.cast(t, "float32")), n, "bilinear", i, 0, [r.height, r.width]); return null != o ? function (e, t) { var n = function (e, t, n, r) { var i = (r - n) / 255; return { scale: i, offset: n - 0 * i } }(0, 0, t[0], t[1]); return P.tidy((function () { return P.add(P.mul(e, n.scale), n.offset) })) }(u, o) : u })); return { imageTensor: h, padding: l, transformationMatrix: c } } function fO(e) { return { xCenter: e.xMin + e.width / 2, yCenter: e.yMin + e.height / 2, width: e.width, height: e.height } } function pO(e) { var t = e.relativeKeypoints; if (t.length <= 1) throw new Error("2 or more keypoints required to calculate a rect."); var n = Number.MAX_VALUE, r = Number.MAX_VALUE, i = Number.MIN_VALUE, a = Number.MIN_VALUE; return t.forEach((function (e) { n = Math.min(n, e.x), i = Math.max(i, e.x), r = Math.min(r, e.y), a = Math.max(a, e.y) })), { xCenter: (n + i) / 2, yCenter: (r + a) / 2, width: i - n, height: a - r } } function mO(e, t, n, r, i) { var a = "rect" === n ? function (e, t, n) { var r, i = e.locationData; if ("boundingbox" === t) r = fO(i.boundingBox); else { r = pO(i); var a = n.width, o = n.height; r.xCenter = Math.round(r.xCenter * a), r.yCenter = Math.round(r.yCenter * o), r.width = Math.round(r.width * a), r.height = Math.round(r.height * o) } return r }(e, t, r) : function (e, t) { var n = e.locationData; return "boundingbox" === t ? fO(n.relativeBoundingBox) : pO(n) }(e, t); return i && (a.rotation = function (e, t, n) { var r, i = e.locationData, a = n.rotationVectorStartKeypointIndex, o = n.rotationVectorEndKeypointIndex; r = n.rotationVectorTargetAngle ? n.rotationVectorTargetAngle : Math.PI * n.rotationVectorTargetAngleDegree / 180; var s = i.relativeKeypoints[a].x * t.width, u = i.relativeKeypoints[a].y * t.height, l = i.relativeKeypoints[o].x * t.width, c = i.relativeKeypoints[o].y * t.height; return lO(r - Math.atan2(-(c - u), l - s)) }(e, r, i)), a } function gO(e, t, n) { for (var r = 0; r < t.length; ++r) { var i = t[r], a = n[e[r]]; a.x = i.x, a.y = i.y } } function yO(e, t, n, r) { if ("string" == typeof t) { if ("copy" === t) for (var i = 0; i < n.length; ++i)r[e[i]].z = n[i].z } else { var a = function (e, t) { for (var n = 0, r = 0; r < t.length; ++r)n += e[t[r]].z; return n / t.length }(r, t); for (i = 0; i < e.length; ++i)r[e[i]].z = a } } function bO(e, t) { for (var n = function (e) { var t = [].concat.apply([], e.map((function (e) { return e.indexesMapping }))); if (0 === t.length) throw new Error("There should be at least one landmark in indexes mapping"); var n = t[0], r = t[0], i = new Set(t); i.forEach((function (e) { n = Math.min(n, e), r = Math.max(r, e) })); var a = i.size; if (0 !== n) throw new Error("Indexes are expected to start with 0 instead of " + n); if (r + 1 !== a) throw new Error("Indexes should have no gaps but " + (r - a + 1) + " indexes are missing"); return a }(t), r = new Array(n).fill(null).map(Object), i = 0; i < e.length; ++i) { var a = e[i], o = t[i]; if (a.length !== o.indexesMapping.length) throw new Error("There are " + a.length + " refinement landmarks while mapping has " + o.indexesMapping.length); gO(o.indexesMapping, a, r), yO(o.indexesMapping, o.zRefinement, a, r) } return r } function vO(e, t) { return e.map((function (e) { var n = bR(bR({}, e), { x: e.x * t.width, y: e.y * t.height }); return null != e.z && (n.z = e.z * t.width), n })) } function xO(e, t) { return "none" === e ? t : function (e) { return 1 / (1 + Math.exp(-e)) }(t) } function wO(e, t, n, r) { return vR(this, void 0, void 0, (function () { var i, a, o, s, u, l, c, h; return xR(this, (function (d) { switch (d.label) { case 0: return n = n || t.flipHorizontally || !1, r = r || t.flipVertically || !1, i = e.size, a = i / t.numLandmarks, [4, e.data()]; case 1: for (o = d.sent(), s = [], u = 0; u < t.numLandmarks; ++u)l = u * a, (h = { x: 0, y: 0 }).x = n ? t.inputImageWidth - o[l] : o[l], a > 1 && (h.y = r ? t.inputImageHeight - o[l + 1] : o[l + 1]), a > 2 && (h.z = o[l + 2]), a > 3 && (h.score = xO(t.visibilityActivation, o[l + 3])), s.push(h); for (c = 0; c < s.length; ++c)(h = s[c]).x = h.x / t.inputImageWidth, h.y = h.y / t.inputImageHeight, h.z = h.z / t.inputImageWidth / (t.normalizeZ || 1); return [2, s] } })) })) } function kO(e, t, n) { var r = e.width, i = e.height, a = e.rotation; if (null == n.rotation && null == n.rotationDegree || (a = function (e, t) { return null != t.rotation ? e += t.rotation : null != t.rotationDegree && (e += Math.PI * t.rotationDegree / 180), lO(e) }(a, n)), 0 === a) e.xCenter = e.xCenter + r * n.shiftX, e.yCenter = e.yCenter + i * n.shiftY; else { var o = (t.width * r * n.shiftX * Math.cos(a) - t.height * i * n.shiftY * Math.sin(a)) / t.width, s = (t.width * r * n.shiftX * Math.sin(a) + t.height * i * n.shiftY * Math.cos(a)) / t.height; e.xCenter = e.xCenter + o, e.yCenter = e.yCenter + s } if (n.squareLong) { var u = Math.max(r * t.width, i * t.height); r = u / t.width, i = u / t.height } else if (n.squareShort) { var l = Math.min(r * t.width, i * t.height); r = l / t.width, i = l / t.height } return e.width = r * n.scaleX, e.height = i * n.scaleY, e } (XR || (XR = {})).MediaPipeFaceDetector = "MediaPipeFaceDetector"; var SO, _O = { runtime: "tfjs", maxFaces: 1, refineLandmarks: !1, landmarkModelUrl: "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1" }, CO = { flipHorizontal: !1, staticImageMode: !1 }, AO = { shiftX: 0, shiftY: 0, scaleX: 1.5, scaleY: 1.5, squareLong: !0 }, TO = { outputTensorSize: { width: 192, height: 192 }, outputTensorFloatRange: [0, 1], borderMode: "replicate" }, EO = { numLandmarks: 468, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, NO = { numLandmarks: 80, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, IO = { numLandmarks: 71, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, MO = { numLandmarks: 5, inputImageWidth: 192, inputImageHeight: 192, visibilityActivation: "none", flipHorizontally: !1, flipVertically: !1 }, FO = { indexesMapping: Array.from(Array(468).keys()), zRefinement: "copy" }, DO = { indexesMapping: [61, 146, 91, 181, 84, 17, 314, 405, 321, 375, 291, 185, 40, 39, 37, 0, 267, 269, 270, 409, 78, 95, 88, 178, 87, 14, 317, 402, 318, 324, 308, 191, 80, 81, 82, 13, 312, 311, 310, 415, 76, 77, 90, 180, 85, 16, 315, 404, 320, 307, 306, 184, 74, 73, 72, 11, 302, 303, 304, 408, 62, 96, 89, 179, 86, 15, 316, 403, 319, 325, 292, 183, 42, 41, 38, 12, 268, 271, 272, 407], zRefinement: "none" }, $O = { indexesMapping: [33, 7, 163, 144, 145, 153, 154, 155, 133, 246, 161, 160, 159, 158, 157, 173, 130, 25, 110, 24, 23, 22, 26, 112, 243, 247, 30, 29, 27, 28, 56, 190, 226, 31, 228, 229, 230, 231, 232, 233, 244, 113, 225, 224, 223, 222, 221, 189, 35, 124, 46, 53, 52, 65, 143, 111, 117, 118, 119, 120, 121, 128, 245, 156, 70, 63, 105, 66, 107, 55, 193], zRefinement: "none" }, RO = { indexesMapping: [263, 249, 390, 373, 374, 380, 381, 382, 362, 466, 388, 387, 386, 385, 384, 398, 359, 255, 339, 254, 253, 252, 256, 341, 463, 467, 260, 259, 257, 258, 286, 414, 446, 261, 448, 449, 450, 451, 452, 453, 464, 342, 445, 444, 443, 442, 441, 413, 265, 353, 276, 283, 282, 295, 372, 340, 346, 347, 348, 349, 350, 357, 465, 383, 300, 293, 334, 296, 336, 285, 417], zRefinement: "none" }, OO = { indexesMapping: [468, 469, 470, 471, 472], zRefinement: [33, 7, 163, 144, 145, 153, 154, 155, 133, 246, 161, 160, 159, 158, 157, 173] }, zO = { indexesMapping: [473, 474, 475, 476, 477], zRefinement: [263, 249, 390, 373, 374, 380, 381, 382, 362, 466, 388, 387, 386, 385, 384, 398] }, PO = function () { function e(e, t, n, r) { this.detector = e, this.landmarkModel = t, this.maxFaces = n, this.withAttention = r, this.prevFaceRectsFromLandmarks = null } return e.prototype.estimateFaces = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u, l, c, h, d, f, p, m = this; return xR(this, (function (g) { switch (g.label) { case 0: return n = function (e) { if (null == e) return bR({}, CO); var t = bR({}, e); return null == t.flipHorizontal && (t.flipHorizontal = CO.flipHorizontal), null == t.staticImageMode && (t.staticImageMode = CO.staticImageMode), t }(t), null == e ? (this.reset(), [2, []]) : (r = uO(e), i = P.tidy((function () { var t = P.cast(cO(e), "float32"); return n.flipHorizontal && (t = P.squeeze(P.image.flipLeftRight(P.expandDims(t, 0)), [0])), t })), a = this.prevFaceRectsFromLandmarks, n.staticImageMode || null == a || a.length < this.maxFaces ? [4, this.detector.detectFaces(i, !1)] : [3, 2]); case 1: return 0 === (s = g.sent()).length ? (this.reset(), i.dispose(), [2, []]) : (o = s.map((function (e) { return m.faceDetectionFrontDetectionToRoi(e, r) })), [3, 3]); case 2: o = [], g.label = 3; case 3: return y = [], [o, a || []].forEach((function (e) { return e.forEach((function (e) { (y = y.filter((function (t) { return function (e, t) { var n = sO(e), r = sO(t); if (!function (e, t) { return !(e.xMax < t.xMin || t.xMax < e.xMin || e.yMax < t.yMin || t.yMax < e.yMin) }(n, r)) return 0; var i = oO(function (e, t) { var n = Math.max(e.xMin, t.xMin), r = Math.min(e.xMax, t.xMax), i = Math.max(e.yMin, t.yMin), a = Math.min(e.yMax, t.yMax); return { xMin: n, xMax: r, yMin: i, yMax: a, width: Math.max(r - n, 0), height: Math.max(a - i, 0) } }(n, r)), a = oO(n) + oO(r) - i; return a > 0 ? i / a : 0 }(e, t) <= .5 }))).push(e) })) })), u = y, [4, Promise.all(u.map((function (e) { return m.faceLandmark(e, i) })))]; case 4: for (l = g.sent(), c = [], this.prevFaceRectsFromLandmarks = [], h = 0; h < l.length; ++h)null != (d = l[h]) && (this.prevFaceRectsFromLandmarks.push(this.faceLandmarksToRoi(d, r)), null != (f = vO(d, r)) && f.forEach((function (e, t) { var n = CR.get(t); null != n && (e.name = n) })), p = AR(f), c.push({ keypoints: f, box: p.locationData.relativeBoundingBox })); return i.dispose(), [2, c] }var y })) })) }, e.prototype.dispose = function () { this.detector.dispose(), this.landmarkModel.dispose() }, e.prototype.reset = function () { this.detector.reset(), this.prevFaceRectsFromLandmarks = null }, e.prototype.faceDetectionFrontDetectionToRoi = function (e, t) { return kO(mO(e, "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 0, rotationVectorEndKeypointIndex: 1, rotationVectorTargetAngleDegree: 0 }), t, AO) }, e.prototype.faceLandmark = function (e, t) { return vR(this, void 0, void 0, (function () { var n, r, i, a, o, s, u; return xR(this, (function (l) { switch (l.label) { case 0: return n = dO(t, TO, e).imageTensor, r = ["output_faceflag"].concat(this.withAttention ? ["output_mesh_identity", "output_lips", "Identity_6:0", "Identity_1:0", "Identity_2:0", "Identity_5:0"] : ["output_mesh"]), i = this.landmarkModel.execute(n, r), a = i[0], o = i.slice(1), [4, a.data()]; case 1: return l.sent()[0] < .5 ? (P.dispose(i), P.dispose(n), [2, null]) : this.withAttention ? [4, this.tensorsToFaceLandmarksWithAttention(o)] : [3, 3]; case 2: return s = l.sent(), [3, 5]; case 3: return [4, this.tensorsToFaceLandmarks(o)]; case 4: s = l.sent(), l.label = 5; case 5: return u = function (e, t, n) { void 0 === n && (n = { ignoreRotation: !1 }); for (var r = [], i = 0, a = e; i < a.length; i++) { var o = a[i], s = o.x - .5, u = o.y - .5, l = n.ignoreRotation ? 0 : t.rotation, c = Math.cos(l) * s - Math.sin(l) * u, h = Math.sin(l) * s + Math.cos(l) * u; c = c * t.width + t.xCenter, h = h * t.height + t.yCenter; var d = o.z * t.width, f = bR({}, o); f.x = c, f.y = h, f.z = d, r.push(f) } return r }(s, e), P.dispose(i), P.dispose(n), [2, u] } })) })) }, e.prototype.tensorsToFaceLandmarks = function (e) { return vR(this, void 0, void 0, (function () { return xR(this, (function (t) { return [2, wO(e[0], EO)] })) })) }, e.prototype.tensorsToFaceLandmarksWithAttention = function (e) { return vR(this, void 0, void 0, (function () { var t, n, r, i, a, o; return xR(this, (function (s) { switch (s.label) { case 0: return [4, wO(e[0], EO)]; case 1: return t = s.sent(), [4, wO(e[1], NO)]; case 2: return n = s.sent(), [4, wO(e[3], IO)]; case 3: return r = s.sent(), [4, wO(e[5], IO)]; case 4: return i = s.sent(), [4, wO(e[4], MO)]; case 5: return a = s.sent(), [4, wO(e[2], MO)]; case 6: return o = s.sent(), [2, bO([t, n, r, i, a, o], [FO, DO, $O, RO, OO, zO])] } })) })) }, e.prototype.faceLandmarksToRoi = function (e, t) { return kO(mO(AR(e), "boundingbox", "normRect", t, { rotationVectorStartKeypointIndex: 33, rotationVectorEndKeypointIndex: 263, rotationVectorTargetAngleDegree: 0 }), t, AO) }, e }(); function BO(e) { return vR(this, void 0, void 0, (function () { var t, n, r, i; return xR(this, (function (a) { switch (a.label) { case 0: return t = function (e) { if (null == e) return bR({}, _O); var t = bR({}, e); return t.runtime = "tfjs", null == t.maxFaces && (t.maxFaces = _O.maxFaces), null == t.refineLandmarks && (t.refineLandmarks = _O.refineLandmarks), null == t.landmarkModelUrl && (t.landmarkModelUrl = t.refineLandmarks ? "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/attention_mesh/1" : "https://tfhub.dev/mediapipe/tfjs-model/face_landmarks_detection/face_mesh/1"), t }(e), n = "string" == typeof t.landmarkModelUrl && t.landmarkModelUrl.indexOf("https://tfhub.dev") > -1, [4, Ud(t.landmarkModelUrl, { fromTFHub: n })]; case 1: return r = a.sent(), [4, aO(XR.MediaPipeFaceDetector, { modelType: "short", maxFaces: t.maxFaces, detectorModelUrl: t.detectorModelUrl, runtime: t.runtime })]; case 2: return i = a.sent(), [2, new PO(i, r, t.maxFaces, t.refineLandmarks)] } })) })) } !function (e) { e.MediaPipeFaceMesh = "MediaPipeFaceMesh" }(SO || (SO = {})); var LO = Object.freeze({ __proto__: null, getKeypointIndexByContour: function (e) { if (e === SO.MediaPipeFaceMesh) return kR; throw new Error("Model " + e + " is not supported.") }, getAdjacentPairs: function (e) { if (e === SO.MediaPipeFaceMesh) return SR; throw new Error("Model " + e + " is not supported.") } });
/**
* @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
*
* https://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 jO = [[.499976992607117, .652534008026123], [.500025987625122, .547487020492554], [.499974012374878, .602371990680695], [.482113003730774, .471979022026062], [.500150978565216, .527155995368958], [.499909996986389, .498252987861633], [.499523013830185, .40106201171875], [.289712011814117, .380764007568359], [.499954998493195, .312398016452789], [.499987006187439, .269918978214264], [.500023007392883, .107050001621246], [.500023007392883, .666234016418457], [.5000159740448, .679224014282227], [.500023007392883, .692348003387451], [.499976992607117, .695277988910675], [.499976992607117, .70593398809433], [.499976992607117, .719385027885437], [.499976992607117, .737019002437592], [.499967992305756, .781370997428894], [.499816000461578, .562981009483337], [.473773002624512, .573909997940063], [.104906998574734, .254140973091125], [.365929991006851, .409575998783112], [.338757991790771, .41302502155304], [.311120003461838, .409460008144379], [.274657994508743, .389131009578705], [.393361985683441, .403706014156342], [.345234006643295, .344011008739471], [.370094001293182, .346076011657715], [.319321990013123, .347265005111694], [.297903001308441, .353591024875641], [.24779200553894, .410809993743896], [.396889001131058, .842755019664764], [.280097991228104, .375599980354309], [.106310002505779, .399955987930298], [.2099249958992, .391353011131287], [.355807989835739, .534406006336212], [.471751004457474, .65040397644043], [.474155008792877, .680191993713379], [.439785003662109, .657229006290436], [.414617002010345, .66654098033905], [.450374007225037, .680860996246338], [.428770989179611, .682690978050232], [.374971002340317, .727805018424988], [.486716985702515, .547628998756409], [.485300987958908, .527395009994507], [.257764995098114, .314490020275116], [.401223003864288, .455172002315521], [.429818987846375, .548614978790283], [.421351999044418, .533740997314453], [.276895999908447, .532056987285614], [.483370006084442, .499586999416351], [.33721199631691, .282882988452911], [.296391993761063, .293242990970612], [.169294998049736, .193813979625702], [.447580009698868, .302609980106354], [.392390012741089, .353887975215912], [.354490011930466, .696784019470215], [.067304998636246, .730105042457581], [.442739009857178, .572826027870178], [.457098007202148, .584792017936707], [.381974011659622, .694710969924927], [.392388999462128, .694203019142151], [.277076005935669, .271932005882263], [.422551989555359, .563233017921448], [.385919004678726, .281364023685455], [.383103013038635, .255840003490448], [.331431001424789, .119714021682739], [.229923993349075, .232002973556519], [.364500999450684, .189113974571228], [.229622006416321, .299540996551514], [.173287004232407, .278747975826263], [.472878992557526, .666198015213013], [.446828007698059, .668527007102966], [.422762006521225, .673889994621277], [.445307999849319, .580065965652466], [.388103008270264, .693961024284363], [.403039008378983, .706539988517761], [.403629004955292, .693953037261963], [.460041999816895, .557139039039612], [.431158006191254, .692366003990173], [.452181994915009, .692366003990173], [.475387006998062, .692366003990173], [.465828001499176, .779190003871918], [.472328990697861, .736225962638855], [.473087012767792, .717857003211975], [.473122000694275, .704625964164734], [.473033010959625, .695277988910675], [.427942007780075, .695277988910675], [.426479011774063, .703539967536926], [.423162013292313, .711845993995667], [.4183090031147, .720062971115112], [.390094995498657, .639572978019714], [.013953999616206, .560034036636353], [.499913990497589, .58014702796936], [.413199990987778, .69539999961853], [.409626007080078, .701822996139526], [.468080013990402, .601534962654114], [.422728985548019, .585985004901886], [.463079988956451, .593783974647522], [.37211999297142, .47341400384903], [.334562003612518, .496073007583618], [.411671012639999, .546965003013611], [.242175996303558, .14767599105835], [.290776997804642, .201445996761322], [.327338010072708, .256527006626129], [.399509996175766, .748921036720276], [.441727995872498, .261676013469696], [.429764986038208, .187834024429321], [.412198007106781, .108901023864746], [.288955003023148, .398952007293701], [.218936994671822, .435410976409912], [.41278201341629, .398970007896423], [.257135003805161, .355440020561218], [.427684992551804, .437960982322693], [.448339998722076, .536936044692993], [.178560003638268, .45755398273468], [.247308000922203, .457193970680237], [.286267012357712, .467674970626831], [.332827985286713, .460712015628815], [.368755996227264, .447206974029541], [.398963987827301, .432654976844788], [.476410001516342, .405806005001068], [.189241006970406, .523923993110657], [.228962004184723, .348950982093811], [.490725994110107, .562400996685028], [.404670000076294, .485132992267609], [.019469000399113, .401564002037048], [.426243007183075, .420431017875671], [.396993011236191, .548797011375427], [.266469985246658, .376977026462555], [.439121007919312, .51895797252655], [.032313998788595, .644356966018677], [.419054001569748, .387154996395111], [.462783008813858, .505746960639954], [.238978996872902, .779744982719421], [.198220998048782, .831938028335571], [.107550002634525, .540755033493042], [.183610007166862, .740257024765015], [.134409993886948, .333683013916016], [.385764002799988, .883153975009918], [.490967005491257, .579378008842468], [.382384985685349, .508572995662689], [.174399003386497, .397670984268188], [.318785011768341, .39623498916626], [.343364000320435, .400596976280212], [.396100014448166, .710216999053955], [.187885001301765, .588537991046906], [.430987000465393, .944064974784851], [.318993002176285, .898285031318665], [.266247987747192, .869701027870178], [.500023007392883, .190576016902924], [.499976992607117, .954452991485596], [.366169989109039, .398822009563446], [.393207013607025, .39553701877594], [.410373002290726, .391080021858215], [.194993004202843, .342101991176605], [.388664990663528, .362284004688263], [.365961998701096, .355970978736877], [.343364000320435, .355356991291046], [.318785011768341, .35834002494812], [.301414996385574, .363156020641327], [.058132998645306, .319076001644135], [.301414996385574, .387449026107788], [.499987989664078, .618434011936188], [.415838003158569, .624195992946625], [.445681989192963, .566076993942261], [.465844005346298, .620640993118286], [.49992299079895, .351523995399475], [.288718998432159, .819945991039276], [.335278987884521, .852819979190826], [.440512001514435, .902418971061707], [.128294005990028, .791940987110138], [.408771991729736, .373893976211548], [.455606997013092, .451801002025604], [.499877005815506, .908990025520325], [.375436991453171, .924192011356354], [.11421000212431, .615022003650665], [.448662012815475, .695277988910675], [.4480200111866, .704632043838501], [.447111994028091, .715808033943176], [.444831997156143, .730794012546539], [.430011987686157, .766808986663818], [.406787008047104, .685672998428345], [.400738000869751, .681069016456604], [.392399996519089, .677703022956848], [.367855995893478, .663918972015381], [.247923001646996, .601333022117615], [.452769994735718, .420849978923798], [.43639200925827, .359887003898621], [.416164010763168, .368713974952698], [.413385987281799, .692366003990173], [.228018000721931, .683571994304657], [.468268007040024, .352671027183533], [.411361992359161, .804327011108398], [.499989002943039, .469825029373169], [.479153990745544, .442654013633728], [.499974012374878, .439637005329132], [.432112008333206, .493588984012604], [.499886006116867, .866917014122009], [.49991300702095, .821729004383087], [.456548988819122, .819200992584229], [.344549000263214, .745438992977142], [.37890899181366, .574010014533997], [.374292999505997, .780184984207153], [.319687992334366, .570737957954407], [.357154995203018, .604269981384277], [.295284003019333, .621580958366394], [.447750002145767, .862477004528046], [.410986006259918, .508723020553589], [.31395098567009, .775308012962341], [.354128003120422, .812552988529205], [.324548006057739, .703992962837219], [.189096003770828, .646299958229065], [.279776990413666, .71465802192688], [.1338230073452, .682700991630554], [.336768001317978, .644733011722565], [.429883986711502, .466521978378296], [.455527991056442, .548622965812683], [.437114000320435, .558896005153656], [.467287987470627, .529924988746643], [.414712011814117, .335219979286194], [.37704598903656, .322777986526489], [.344107985496521, .320150971412659], [.312875986099243, .32233202457428], [.283526003360748, .333190023899078], [.241245999932289, .382785975933075], [.102986000478268, .468762993812561], [.267612010240555, .424560010433197], [.297879010438919, .433175981044769], [.333433985710144, .433878004550934], [.366427004337311, .426115989685059], [.396012008190155, .416696012020111], [.420121014118195, .41022801399231], [.007561000064015, .480777025222778], [.432949006557465, .569517970085144], [.458638995885849, .479089021682739], [.473466008901596, .545744001865387], [.476087987422943, .563830018043518], [.468472003936768, .555056989192963], [.433990985155106, .582361996173859], [.483518004417419, .562983989715576], [.482482999563217, .57784903049469], [.42645001411438, .389798998832703], [.438998997211456, .39649498462677], [.450067013502121, .400434017181396], [.289712011814117, .368252992630005], [.276670008897781, .363372981548309], [.517862021923065, .471948027610779], [.710287988185883, .380764007568359], [.526226997375488, .573909997940063], [.895093023777008, .254140973091125], [.634069979190826, .409575998783112], [.661242008209229, .41302502155304], [.688880026340485, .409460008144379], [.725341975688934, .389131009578705], [.606630027294159, .40370500087738], [.654766023159027, .344011008739471], [.629905998706818, .346076011657715], [.680678009986877, .347265005111694], [.702096998691559, .353591024875641], [.75221198797226, .410804986953735], [.602918028831482, .842862963676453], [.719901978969574, .375599980354309], [.893692970275879, .399959981441498], [.790081977844238, .391354024410248], [.643998026847839, .534487962722778], [.528249025344849, .65040397644043], [.525849997997284, .680191040039062], [.560214996337891, .657229006290436], [.585384011268616, .66654098033905], [.549625992774963, .680860996246338], [.57122802734375, .682691991329193], [.624852001667023, .72809898853302], [.513050019741058, .547281980514526], [.51509702205658, .527251958847046], [.742246985435486, .314507007598877], [.598631024360657, .454979002475739], [.570338010787964, .548575043678284], [.578631997108459, .533622980117798], [.723087012767792, .532054007053375], [.516445994377136, .499638974666595], [.662801027297974, .282917976379395], [.70362401008606, .293271005153656], [.830704987049103, .193813979625702], [.552385985851288, .302568018436432], [.607609987258911, .353887975215912], [.645429015159607, .696707010269165], [.932694971561432, .730105042457581], [.557260990142822, .572826027870178], [.542901992797852, .584792017936707], [.6180260181427, .694710969924927], [.607590973377228, .694203019142151], [.722943007946014, .271963000297546], [.577413976192474, .563166975975037], [.614082992076874, .281386971473694], [.616907000541687, .255886018276215], [.668509006500244, .119913995265961], [.770092010498047, .232020974159241], [.635536015033722, .189248979091644], [.77039098739624, .299556016921997], [.826722025871277, .278755009174347], [.527121007442474, .666198015213013], [.553171992301941, .668527007102966], [.577238023281097, .673889994621277], [.554691970348358, .580065965652466], [.611896991729736, .693961024284363], [.59696102142334, .706539988517761], [.596370995044708, .693953037261963], [.539958000183105, .557139039039612], [.568841993808746, .692366003990173], [.547818005084991, .692366003990173], [.52461302280426, .692366003990173], [.534089982509613, .779141008853912], [.527670979499817, .736225962638855], [.526912987232208, .717857003211975], [.526877999305725, .704625964164734], [.526966989040375, .695277988910675], [.572058022022247, .695277988910675], [.573521018028259, .703539967536926], [.57683801651001, .711845993995667], [.581691026687622, .720062971115112], [.609944999217987, .639909982681274], [.986046016216278, .560034036636353], [.5867999792099, .69539999961853], [.590372025966644, .701822996139526], [.531915009021759, .601536989212036], [.577268004417419, .585934996604919], [.536915004253387, .593786001205444], [.627542972564697, .473352015018463], [.665585994720459, .495950996875763], [.588353991508484, .546862006187439], [.757824003696442, .14767599105835], [.709249973297119, .201507985591888], [.672684013843536, .256581008434296], [.600408971309662, .74900496006012], [.55826598405838, .261672019958496], [.570303976535797, .187870979309082], [.588165998458862, .109044015407562], [.711045026779175, .398952007293701], [.781069993972778, .435405015945435], [.587247014045715, .398931980133057], [.742869973182678, .355445981025696], [.572156012058258, .437651991844177], [.55186802148819, .536570012569427], [.821442008018494, .457556009292603], [.752701997756958, .457181990146637], [.71375697851181, .467626988887787], [.66711300611496, .460672974586487], [.631101012229919, .447153985500336], [.6008620262146, .432473003864288], [.523481011390686, .405627012252808], [.810747981071472, .523926019668579], [.771045982837677, .348959028720856], [.509127020835876, .562718033790588], [.595292985439301, .485023975372314], [.980530977249146, .401564002037048], [.573499977588654, .420000016689301], [.602994978427887, .548687994480133], [.733529984951019, .376977026462555], [.560611009597778, .519016981124878], [.967685997486115, .644356966018677], [.580985009670258, .387160003185272], [.537728011608124, .505385041236877], [.760966002941132, .779752969741821], [.801778972148895, .831938028335571], [.892440974712372, .54076099395752], [.816350996494293, .740260004997253], [.865594983100891, .333687007427216], [.614073991775513, .883246004581451], [.508952975273132, .579437971115112], [.617941975593567, .508316040039062], [.825608015060425, .397674977779388], [.681214988231659, .39623498916626], [.656635999679565, .400596976280212], [.603900015354156, .710216999053955], [.81208598613739, .588539004325867], [.56801301240921, .944564998149872], [.681007981300354, .898285031318665], [.733752012252808, .869701027870178], [.633830010890961, .398822009563446], [.606792986392975, .39553701877594], [.589659988880157, .391062021255493], [.805015981197357, .342108011245728], [.611334979534149, .362284004688263], [.634037971496582, .355970978736877], [.656635999679565, .355356991291046], [.681214988231659, .35834002494812], [.698584973812103, .363156020641327], [.941866993904114, .319076001644135], [.698584973812103, .387449026107788], [.584177017211914, .624107003211975], [.554318010807037, .566076993942261], [.534153997898102, .62064003944397], [.711217999458313, .819975018501282], [.664629995822906, .852871000766754], [.559099972248077, .902631998062134], [.871706008911133, .791940987110138], [.591234028339386, .373893976211548], [.544341027736664, .451583981513977], [.624562978744507, .924192011356354], [.88577002286911, .615028977394104], [.551338016986847, .695277988910675], [.551980018615723, .704632043838501], [.552887976169586, .715808033943176], [.555167973041534, .730794012546539], [.569944024085999, .767035007476807], [.593203008174896, .685675978660583], [.599261999130249, .681069016456604], [.607599973678589, .677703022956848], [.631937980651855, .663500010967255], [.752032995223999, .601315021514893], [.547226011753082, .420395016670227], [.563543975353241, .359827995300293], [.583841025829315, .368713974952698], [.586614012718201, .692366003990173], [.771915018558502, .683578014373779], [.531597018241882, .352482974529266], [.588370978832245, .804440975189209], [.52079701423645, .442565023899078], [.567984998226166, .493479013442993], [.543282985687256, .819254994392395], [.655317008495331, .745514988899231], [.621008992195129, .574018001556396], [.625559985637665, .78031200170517], [.680198013782501, .570719003677368], [.64276397228241, .604337990283966], [.704662978649139, .621529996395111], [.552012026309967, .862591981887817], [.589071989059448, .508637011051178], [.685944974422455, .775357007980347], [.645735025405884, .812640011310577], [.675342977046967, .703978002071381], [.810858011245728, .646304965019226], [.72012197971344, .714666962623596], [.866151988506317, .682704985141754], [.663187026977539, .644596993923187], [.570082008838654, .466325998306274], [.544561982154846, .548375964164734], [.562758982181549, .558784961700439], [.531987011432648, .530140042304993], [.585271000862122, .335177004337311], [.622952997684479, .32277899980545], [.655896008014679, .320163011550903], [.687132000923157, .322345972061157], [.716481983661652, .333200991153717], [.758756995201111, .382786989212036], [.897013008594513, .468769013881683], [.732392013072968, .424547016620636], [.70211398601532, .433162987232208], [.66652500629425, .433866024017334], [.633504986763, .426087975502014], [.603875994682312, .416586995124817], [.579657971858978, .409945011138916], [.992439985275269, .480777025222778], [.567192018032074, .569419980049133], [.54136598110199, .478899002075195], [.526564002037048, .546118021011353], [.523913025856018, .563830018043518], [.531529009342194, .555056989192963], [.566035985946655, .582329034805298], [.51631098985672, .563053965568542], [.5174720287323, .577877044677734], [.573594987392426, .389806985855103], [.560697972774506, .395331978797913], [.549755990505219, .399751007556915], [.710287988185883, .368252992630005], [.723330020904541, .363372981548309]], UO = { runtime: { type: "enum", enums: ["mediapipe", "tfjs"], default: "tfjs" }, maxFaces: { type: "number", min: 1, default: 1 }, refineLandmarks: { type: "boolean", default: !1 }, solutionPath: { type: "string", default: "https://cdn.jsdelivr.net/npm/@mediapipe/face_mesh", ignore: e => "mediapipe" !== e.runtime }, detectorModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime }, landmarkModelUrl: { type: "string", default: void 0, ignore: e => "tfjs" !== e.runtime } }, WO = { flipHorizontal: { type: "boolean", alias: "flipped", default: !1 } }; class VO { constructor(e, t, n) { this.modelName = uR(e, ["FaceMesh"], "FaceMesh", "faceMesh"), this.model = null, this.userOptions = t, this.runtimeConfig = {}, this.detectMedia = null, this.detectCallback = null, this.detecting = !1, this.signalStop = !1, this.prevCall = "", this.ready = hM(this.loadModel(), n) } async loadModel() { const e = SO.MediaPipeFaceMesh, t = lR(this.userOptions, UO, "faceMesh"); return this.runtimeConfig = lR(this.userOptions, WO, "faceMesh"), await P.ready(), this.model = await function (e, t) { return vR(this, void 0, void 0, (function () { var n, r; return xR(this, (function (i) { if (e === SO.MediaPipeFaceMesh) { if (r = void 0, null != (n = t)) { if ("tfjs" === n.runtime) return [2, BO(n)]; if ("mediapipe" === n.runtime) return [2, NR(n)]; r = n.runtime } throw new Error("Expect modelConfig.runtime to be either 'tfjs' or 'mediapipe', but got " + r) } throw new Error(e + " is not a supported model name.") })) })) }(e, t), this } async detect(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detect()."); const { image: n, callback: r } = t; await AM(n, !1); let i = await this.model.estimateFaces(n, this.runtimeConfig); return i = this.addKeypoints(i), "function" == typeof r && r(i), i } detectStart(...e) { const t = xM(...e); t.require("image", "An html or p5.js image, video, or canvas element argument is required for detectStart()."), t.require("callback", "A callback function argument is required for detectStart()."), this.detectMedia = t.image, this.detectCallback = t.callback, this.signalStop = !1, this.detecting || (this.detecting = !0, this.detectLoop()), "start" === this.prevCall && console.warn("detectStart() was called more than once without calling detectStop(). The lastest detectStart() call will be used and the previous calls will be ignored."), this.prevCall = "start" } detectStop() { this.detecting && (this.signalStop = !0), this.prevCall = "stop" } async detectLoop() { for (await AM(this.detectMedia, !1); !this.signalStop;) { let e = await this.model.estimateFaces(this.detectMedia, this.runtimeConfig); e = this.addKeypoints(e), this.detectCallback(e), await P.nextFrame() } this.detecting = !1, this.signalStop = !1 } addKeypoints(e) { const t = LO.getKeypointIndexByContour(SO.MediaPipeFaceMesh); 291 !== t.lips[20] && t.lips.splice(20, 0, 291); for (let n of e) { n.keypoints[291].name = "lips"; for (let e in t) { for (let r of t[e]) { if (r >= n.keypoints.length) continue; void 0 === n[e] && (n[e] = { keypoints: [] }); let t = n.keypoints[r]; n[e].keypoints.push({ x: t.x, y: t.y, z: t.z }), n[e].xMin = void 0 === n[e].xMin || t.x < n[e].xMin ? t.x : n[e].xMin, n[e].xMax = void 0 === n[e].xMax || t.x > n[e].xMax ? t.x : n[e].xMax, n[e].yMin = void 0 === n[e].yMin || t.y < n[e].yMin ? t.y : n[e].yMin, n[e].yMax = void 0 === n[e].yMax || t.y > n[e].yMax ? t.y : n[e].yMax } n[e] && (n[e].x = n[e].xMin, n[e].y = n[e].yMin, n[e].width = n[e].xMax - n[e].xMin, n[e].height = n[e].yMax - n[e].yMin, n[e].centerX = n[e].x + n[e].width / 2, n[e].centerY = n[e].y + n[e].height / 2, delete n[e].xMin, delete n[e].xMax, delete n[e].yMin, delete n[e].yMax) } } return e } getTriangles() { const e = LO.getAdjacentPairs(SO.MediaPipeFaceMesh), t = []; for (let n = 0; n < e.length; n += 3) { const r = [e[n][0], e[n + 1][0], e[n + 2][0]]; t.push(r) } return t } getConnections() { return LO.getAdjacentPairs(SO.MediaPipeFaceMesh) } getUVCoords() { return jO } } const GO = (...e) => { const { string: t, options: n = {}, callback: r } = xM(...e); return new VO(t, n, r) }; var HO = n(3242);
/**
* @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 qO = (0, P.env)(); qO.registerFlag("WEBGPU_DEFERRED_SUBMIT_BATCH_SIZE", (() => 15)), qO.registerFlag("WEBGPU_CPU_FORWARD", (() => !0)), qO.registerFlag("WEBGPU_MATMUL_PROGRAM_TYPE", (() => -1)), qO.registerFlag("WEBGPU_USE_NAIVE_CONV2D_TRANSPOSE", (() => !0)), qO.registerFlag("WEBGPU_USE_LOW_POWER_GPU", (() => !1)), qO.registerFlag("WEBGPU_CPU_HANDOFF_SIZE_THRESHOLD", (() => 1e3)), qO.registerFlag("WEBGPU_USE_PROFILE_TOOL", (() => !1)), qO.registerFlag("WEBGPU_IMPORT_EXTERNAL_TEXTURE", (() => !0)), qO.registerFlag("WEBGPU_USE_NAIVE_CONV2D_DEBUG", (() => !1)), qO.registerFlag("WEBGPU_THRESHOLD_TO_INCREASE_WORKGROUPS_FOR_MATMUL", (() => -1)), qO.registerFlag("WEBGPU_CONV_SEPARATE_IM2COL_SHADER", (() => !1)), qO.registerFlag("WEBGPU_PRINT_SHADER", (() => "")), qO.registerFlag("WEBGPU_ENGINE_COMPILE_ONLY", (() => !1));
/**
* @license
* Copyright 2022 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.
* =============================================================================
*/
class YO { constructor(e) { e && (this.vendor = e.vendor, this.architecture = e.architecture, this.intelGPUGeneration = this.getIntelGPUGeneration()) } getIntelGPUGeneration() { if (this.isIntel()) { if (this.architecture.startsWith("gen")) return Number(this.architecture.match(/\d+/)); if (this.architecture.startsWith("xe")) return 12 } return 0 } isIntel() { return "intel" === this.vendor } }
/**
* @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.
* =============================================================================
*/
class XO { constructor(e) { this.device = e, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.freeBuffers = new Map, this.usedBuffers = new Map, this.numBytesUsed = 0, this.numBytesAllocated = 0 } acquireBuffer(e, t, n = !1, r = !0) { let i; const a = KO(e, t); return r ? (this.freeBuffers.has(a) || this.freeBuffers.set(a, []), this.freeBuffers.get(a).length > 0 ? (i = this.freeBuffers.get(a).pop(), this.numFreeBuffers--) : (i = this.device.createBuffer({ size: e, usage: t, mappedAtCreation: n }), this.numBytesAllocated += e)) : (i = this.device.createBuffer({ size: e, usage: t, mappedAtCreation: n }), this.numBytesAllocated += e), this.usedBuffers.has(a) || this.usedBuffers.set(a, []), this.usedBuffers.get(a).push(i), this.numUsedBuffers++, this.numBytesUsed += e, i } releaseBuffer(e, t = !0) { if (0 === this.freeBuffers.size) return; const n = e.size, r = KO(n, e.usage), i = this.usedBuffers.get(r), a = i.indexOf(e); if (a < 0) throw new Error("Cannot find the buffer in buffer manager"); i[a] = i[i.length - 1], i.pop(), this.numUsedBuffers--, this.numBytesUsed -= n, t ? (this.freeBuffers.get(r).push(e), this.numFreeBuffers++) : (e.destroy(), this.numBytesAllocated -= n) } getNumUsedBuffers() { return this.numUsedBuffers } getNumFreeBuffers() { return this.numFreeBuffers } dispose() { this.freeBuffers.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.usedBuffers.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.freeBuffers = new Map, this.usedBuffers = new Map, this.numUsedBuffers = 0, this.numFreeBuffers = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0 } } function KO(e, t) { return `${e}_${t}` }
/**
* @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.
* =============================================================================
*/
class ZO { constructor(e) { this.device = e, this.numUsedTextures = 0, this.numFreeTextures = 0, this.freeTextures = new Map, this.usedTextures = new Map, this.numBytesUsed = 0, this.numBytesAllocated = 0 } acquireTexture(e, t, n, r) { const i = e * t * QO(n), a = JO(e, t, n, r); if (this.freeTextures.has(a) || this.freeTextures.set(a, []), this.usedTextures.has(a) || this.usedTextures.set(a, []), this.numBytesUsed += i, this.numUsedTextures++, this.freeTextures.get(a).length > 0) { this.numFreeTextures--; const e = this.freeTextures.get(a).shift(); return this.usedTextures.get(a).push(e), e } this.numBytesAllocated += i; const o = this.device.createTexture({ size: [e, t], format: n, usage: r }); return this.usedTextures.get(a).push(o), o } releaseTexture(e) { if (0 === this.freeTextures.size) return; const t = e.width, n = e.height, r = e.format, i = JO(t, n, r, e.usage); this.freeTextures.has(i) || this.freeTextures.set(i, []), this.freeTextures.get(i).push(e), this.numFreeTextures++, this.numUsedTextures--; const a = this.usedTextures.get(i), o = a.indexOf(e); if (o < 0) throw new Error("Cannot release a texture that was never provided by this texture manager"); a.splice(o, 1); const s = t * n * QO(r); this.numBytesUsed -= s } getNumUsedTextures() { return this.numUsedTextures } getNumFreeTextures() { return this.numFreeTextures } dispose() { this.freeTextures.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.usedTextures.forEach(((e, t) => { e.forEach((e => { e.destroy() })) })), this.freeTextures = new Map, this.usedTextures = new Map, this.numUsedTextures = 0, this.numFreeTextures = 0, this.numBytesUsed = 0, this.numBytesAllocated = 0 } } function JO(e, t, n, r) { return `${e}_${t}_${n}_${r}` } function QO(e) { if ("rgba8unorm" === e) return 16; throw new Error(`${e} is not supported!`) }
/**
* @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 ez(e, t) { if (Math.max(...e) > 5) throw new Error("Cannot symbolically compute strides for rank > 6 tensor."); const n = e.length, r = e.map((e => `${t}.${"xyzwuv"[e]}`)), i = new Array(n - 1); i[n - 2] = r[n - 1]; for (let e = n - 3; e >= 0; --e)i[e] = `(${i[e + 1]} * ${r[e + 1]})`; return i } const tz = (e, t, n) => "int32" === n ? `atomicAdd(${e}, bitcast